/* Generated by Cython 0.28.5 */

#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 < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_28_5"
#define CYTHON_FUTURE_DIVISION 1
#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
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if 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_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #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
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 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_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #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
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 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_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 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
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #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
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#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)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#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 CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#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 | METH_KEYWORDS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#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
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0; // PyThread_create_key reports success always
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif // TSS (Thread Specific Storage) API
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#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
#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
  #define PyObject_Unicode             PyObject_Str
#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
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#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) : (Py_INCREF(func), 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
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#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; \
}

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

#define __PYX_HAVE__pysam__libcbcf
#define __PYX_HAVE_API__pysam__libcbcf
/* Early includes */
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.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 <errno.h>
#include "pythread.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_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)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_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 const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const 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_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const 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)
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);
}
#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)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
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 CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
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[] = {
  "pysam/libcbcf.pyx",
  "pysam/libcbcf.pxd",
  "stringsource",
  "array.pxd",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
};
/* NoFastGil.proto */
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
#define __Pyx_PyGILState_Release PyGILState_Release
#define __Pyx_FastGIL_Remember()
#define __Pyx_FastGIL_Forget()
#define __Pyx_FastGilFuncInit()

/* ForceInitThreads.proto */
#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif


/*--- Type declarations ---*/
#ifndef _ARRAYARRAY_H
struct arrayobject;
typedef struct arrayobject arrayobject;
#endif
struct __pyx_obj_5pysam_10libchtslib_HTSFile;
struct __pyx_obj_5pysam_7libcbcf_VariantHeader;
struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord;
struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords;
struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs;
struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples;
struct __pyx_obj_5pysam_7libcbcf_VariantContig;
struct __pyx_obj_5pysam_7libcbcf_VariantMetadata;
struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata;
struct __pyx_obj_5pysam_7libcbcf_VariantRecord;
struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter;
struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat;
struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo;
struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples;
struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample;
struct __pyx_obj_5pysam_7libcbcf_BaseIndex;
struct __pyx_obj_5pysam_7libcbcf_BCFIndex;
struct __pyx_obj_5pysam_7libcbcf_TabixIndex;
struct __pyx_obj_5pysam_7libcbcf_BaseIterator;
struct __pyx_obj_5pysam_7libcbcf_BCFIterator;
struct __pyx_obj_5pysam_7libcbcf_TabixIterator;
struct __pyx_obj_5pysam_7libcbcf_VariantFile;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues;
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems;
struct __pyx_opt_args_5pysam_9libcutils_parse_region;
struct __pyx_opt_args_5pysam_9libcutils_qualitystring_to_array;
struct __pyx_opt_args_5pysam_9libcutils_array_to_qualitystring;
struct __pyx_opt_args_5pysam_9libcutils_qualities_to_qualitystring;
struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str;
struct __pyx_opt_args_5pysam_9libcutils_charptr_to_bytes;
struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str_w_len;
struct __pyx_opt_args_5pysam_9libcutils_force_str;
struct __pyx_opt_args_5pysam_9libcutils_force_bytes;

/* "pysam/libcutils.pxd":7
 * from cpython cimport array as c_array
 * 
 * cpdef parse_region(contig=*, start=*, stop=*, region=*, reference=*, end=*)             # <<<<<<<<<<<<<<
 * 
 * #########################################################################
 */
struct __pyx_opt_args_5pysam_9libcutils_parse_region {
  int __pyx_n;
  PyObject *contig;
  PyObject *start;
  PyObject *stop;
  PyObject *region;
  PyObject *reference;
  PyObject *end;
};

/* "pysam/libcutils.pxd":12
 * # Utility functions for quality string conversions
 * 
 * cpdef c_array.array qualitystring_to_array(input_str, int offset=*)             # <<<<<<<<<<<<<<
 * cpdef array_to_qualitystring(c_array.array arr, int offset=*)
 * cpdef qualities_to_qualitystring(qualities, int offset=*)
 */
struct __pyx_opt_args_5pysam_9libcutils_qualitystring_to_array {
  int __pyx_n;
  int offset;
};

/* "pysam/libcutils.pxd":13
 * 
 * cpdef c_array.array qualitystring_to_array(input_str, int offset=*)
 * cpdef array_to_qualitystring(c_array.array arr, int offset=*)             # <<<<<<<<<<<<<<
 * cpdef qualities_to_qualitystring(qualities, int offset=*)
 * 
 */
struct __pyx_opt_args_5pysam_9libcutils_array_to_qualitystring {
  int __pyx_n;
  int offset;
};

/* "pysam/libcutils.pxd":14
 * cpdef c_array.array qualitystring_to_array(input_str, int offset=*)
 * cpdef array_to_qualitystring(c_array.array arr, int offset=*)
 * cpdef qualities_to_qualitystring(qualities, int offset=*)             # <<<<<<<<<<<<<<
 * 
 * ########################################################################
 */
struct __pyx_opt_args_5pysam_9libcutils_qualities_to_qualitystring {
  int __pyx_n;
  int offset;
};

/* "pysam/libcutils.pxd":21
 * ## Python 3 compatibility functions
 * ########################################################################
 * cdef charptr_to_str(const char *s, encoding=*)             # <<<<<<<<<<<<<<
 * cdef bytes charptr_to_bytes(const char *s, encoding=*)
 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=*)
 */
struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str {
  int __pyx_n;
  PyObject *encoding;
};

/* "pysam/libcutils.pxd":22
 * ########################################################################
 * cdef charptr_to_str(const char *s, encoding=*)
 * cdef bytes charptr_to_bytes(const char *s, encoding=*)             # <<<<<<<<<<<<<<
 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=*)
 * cdef force_str(object s, encoding=*)
 */
struct __pyx_opt_args_5pysam_9libcutils_charptr_to_bytes {
  int __pyx_n;
  PyObject *encoding;
};

/* "pysam/libcutils.pxd":23
 * cdef charptr_to_str(const char *s, encoding=*)
 * cdef bytes charptr_to_bytes(const char *s, encoding=*)
 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=*)             # <<<<<<<<<<<<<<
 * cdef force_str(object s, encoding=*)
 * cdef bytes force_bytes(object s, encoding=*)
 */
struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str_w_len {
  int __pyx_n;
  PyObject *encoding;
};

/* "pysam/libcutils.pxd":24
 * cdef bytes charptr_to_bytes(const char *s, encoding=*)
 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=*)
 * cdef force_str(object s, encoding=*)             # <<<<<<<<<<<<<<
 * cdef bytes force_bytes(object s, encoding=*)
 * cdef bytes encode_filename(object filename)
 */
struct __pyx_opt_args_5pysam_9libcutils_force_str {
  int __pyx_n;
  PyObject *encoding;
};

/* "pysam/libcutils.pxd":25
 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=*)
 * cdef force_str(object s, encoding=*)
 * cdef bytes force_bytes(object s, encoding=*)             # <<<<<<<<<<<<<<
 * cdef bytes encode_filename(object filename)
 * cdef from_string_and_size(const char *s, size_t length)
 */
struct __pyx_opt_args_5pysam_9libcutils_force_bytes {
  int __pyx_n;
  PyObject *encoding;
};
struct __pyx_opt_args_5pysam_7libcbcf_char_array_to_tuple;

/* "pysam/libcbcf.pyx":250
 * 
 * 
 * cdef tuple char_array_to_tuple(const char **a, ssize_t n, int free_after=0):             # <<<<<<<<<<<<<<
 *     if not a:
 *         return None
 */
struct __pyx_opt_args_5pysam_7libcbcf_char_array_to_tuple {
  int __pyx_n;
  int free_after;
};

/* "pysam/libchtslib.pxd":2590
 * 
 * 
 * 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 *threads;
  PyObject *index_filename;
  int is_stream;
  int is_remote;
  int duplicate_filehandle;
};


/* "pysam/libcbcf.pxd":38
 * 
 * 
 * cdef class VariantHeader(object):             # <<<<<<<<<<<<<<
 *     cdef bcf_hdr_t *ptr
 * 
 */
struct __pyx_obj_5pysam_7libcbcf_VariantHeader {
  PyObject_HEAD
  struct __pyx_vtabstruct_5pysam_7libcbcf_VariantHeader *__pyx_vtab;
  bcf_hdr_t *ptr;
};


/* "pysam/libcbcf.pxd":44
 * 
 * 
 * cdef class VariantHeaderRecord(object):             # <<<<<<<<<<<<<<
 *     cdef readonly VariantHeader header
 *     cdef bcf_hrec_t *ptr
 */
struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *header;
  bcf_hrec_t *ptr;
};


/* "pysam/libcbcf.pxd":49
 * 
 * 
 * cdef class VariantHeaderRecords(object):             # <<<<<<<<<<<<<<
 *     cdef readonly VariantHeader header
 * 
 */
struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *header;
};


/* "pysam/libcbcf.pxd":53
 * 
 * 
 * cdef class VariantHeaderContigs(object):             # <<<<<<<<<<<<<<
 *     cdef readonly VariantHeader header
 * 
 */
struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *header;
};


/* "pysam/libcbcf.pxd":57
 * 
 * 
 * cdef class VariantHeaderSamples(object):             # <<<<<<<<<<<<<<
 *     cdef readonly VariantHeader header
 * 
 */
struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *header;
};


/* "pysam/libcbcf.pxd":61
 * 
 * 
 * cdef class VariantContig(object):             # <<<<<<<<<<<<<<
 *     cdef readonly VariantHeader header
 *     cdef int id
 */
struct __pyx_obj_5pysam_7libcbcf_VariantContig {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *header;
  int id;
};


/* "pysam/libcbcf.pxd":66
 * 
 * 
 * cdef class VariantMetadata(object):             # <<<<<<<<<<<<<<
 *     cdef readonly VariantHeader header
 *     cdef int type
 */
struct __pyx_obj_5pysam_7libcbcf_VariantMetadata {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *header;
  int type;
  int id;
};


/* "pysam/libcbcf.pxd":72
 * 
 * 
 * cdef class VariantHeaderMetadata(object):             # <<<<<<<<<<<<<<
 *     cdef readonly VariantHeader header
 *     cdef int32_t type
 */
struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *header;
  int32_t type;
};


/* "pysam/libcbcf.pxd":77
 * 
 * 
 * cdef class VariantRecord(object):             # <<<<<<<<<<<<<<
 *     cdef readonly VariantHeader header
 *     cdef bcf1_t *ptr
 */
struct __pyx_obj_5pysam_7libcbcf_VariantRecord {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *header;
  bcf1_t *ptr;
};


/* "pysam/libcbcf.pxd":82
 * 
 * 
 * cdef class VariantRecordFilter(object):             # <<<<<<<<<<<<<<
 *     cdef VariantRecord record
 * 
 */
struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantRecord *record;
};


/* "pysam/libcbcf.pxd":86
 * 
 * 
 * cdef class VariantRecordFormat(object):             # <<<<<<<<<<<<<<
 *     cdef VariantRecord record
 * 
 */
struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantRecord *record;
};


/* "pysam/libcbcf.pxd":90
 * 
 * 
 * cdef class VariantRecordInfo(object):             # <<<<<<<<<<<<<<
 *     cdef VariantRecord record
 * 
 */
struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantRecord *record;
};


/* "pysam/libcbcf.pxd":94
 * 
 * 
 * cdef class VariantRecordSamples(object):             # <<<<<<<<<<<<<<
 *     cdef VariantRecord record
 * 
 */
struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantRecord *record;
};


/* "pysam/libcbcf.pxd":98
 * 
 * 
 * cdef class VariantRecordSample(object):             # <<<<<<<<<<<<<<
 *     cdef VariantRecord record
 *     cdef readonly int32_t index
 */
struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantRecord *record;
  int32_t index;
};


/* "pysam/libcbcf.pxd":103
 * 
 * 
 * cdef class BaseIndex(object):             # <<<<<<<<<<<<<<
 *     cdef tuple refs
 *     cdef dict refmap
 */
struct __pyx_obj_5pysam_7libcbcf_BaseIndex {
  PyObject_HEAD
  PyObject *refs;
  PyObject *refmap;
};


/* "pysam/libcbcf.pxd":108
 * 
 * 
 * cdef class BCFIndex(BaseIndex):             # <<<<<<<<<<<<<<
 *     cdef readonly VariantHeader header
 *     cdef hts_idx_t *ptr
 */
struct __pyx_obj_5pysam_7libcbcf_BCFIndex {
  struct __pyx_obj_5pysam_7libcbcf_BaseIndex __pyx_base;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *header;
  hts_idx_t *ptr;
};


/* "pysam/libcbcf.pxd":113
 * 
 * 
 * cdef class TabixIndex(BaseIndex):             # <<<<<<<<<<<<<<
 *     cdef tbx_t *ptr
 * 
 */
struct __pyx_obj_5pysam_7libcbcf_TabixIndex {
  struct __pyx_obj_5pysam_7libcbcf_BaseIndex __pyx_base;
  tbx_t *ptr;
};


/* "pysam/libcbcf.pxd":117
 * 
 * 
 * cdef class BaseIterator(object):             # <<<<<<<<<<<<<<
 *     cdef VariantFile bcf
 *     cdef hts_itr_t  *iter
 */
struct __pyx_obj_5pysam_7libcbcf_BaseIterator {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf_VariantFile *bcf;
  hts_itr_t *iter;
};


/* "pysam/libcbcf.pxd":122
 * 
 * 
 * cdef class BCFIterator(BaseIterator):             # <<<<<<<<<<<<<<
 *     cdef BCFIndex index
 * 
 */
struct __pyx_obj_5pysam_7libcbcf_BCFIterator {
  struct __pyx_obj_5pysam_7libcbcf_BaseIterator __pyx_base;
  struct __pyx_obj_5pysam_7libcbcf_BCFIndex *index;
};


/* "pysam/libcbcf.pxd":126
 * 
 * 
 * cdef class TabixIterator(BaseIterator):             # <<<<<<<<<<<<<<
 *     cdef TabixIndex index
 *     cdef kstring_t line_buffer
 */
struct __pyx_obj_5pysam_7libcbcf_TabixIterator {
  struct __pyx_obj_5pysam_7libcbcf_BaseIterator __pyx_base;
  struct __pyx_obj_5pysam_7libcbcf_TabixIndex *index;
  kstring_t line_buffer;
};


/* "pysam/libcbcf.pxd":131
 * 
 * 
 * cdef class VariantFile(HTSFile):             # <<<<<<<<<<<<<<
 *     cdef readonly VariantHeader  header
 *     cdef readonly BaseIndex      index
 */
struct __pyx_obj_5pysam_7libcbcf_VariantFile {
  struct __pyx_obj_5pysam_10libchtslib_HTSFile __pyx_base;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *header;
  struct __pyx_obj_5pysam_7libcbcf_BaseIndex *index;
  int drop_samples;
  int is_reading;
  int header_written;
};


/* "pysam/libcbcf.pyx":250
 * 
 * 
 * cdef tuple char_array_to_tuple(const char **a, ssize_t n, int free_after=0):             # <<<<<<<<<<<<<<
 *     if not a:
 *         return None
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple {
  PyObject_HEAD
  char const **__pyx_v_a;
  Py_ssize_t __pyx_v_n;
};


/* "pysam/libcbcf.pyx":254
 *         return None
 *     try:
 *          return tuple(charptr_to_str(a[i]) for i in range(n))             # <<<<<<<<<<<<<<
 *     finally:
 *         if free_after and a:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple *__pyx_outer_scope;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_t_0;
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
};


/* "pysam/libcbcf.pyx":260
 * 
 * 
 * cdef bcf_array_to_object(void *data, int type, ssize_t n, ssize_t count, int scalar):             # <<<<<<<<<<<<<<
 *     cdef char    *datac
 *     cdef int8_t  *data8
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object {
  PyObject_HEAD
  PyObject *__pyx_v_b;
};


/* "pysam/libcbcf.pyx":285
 *                 # Otherwise, copy the entire block
 *                 b = datac[:n]
 *             value = tuple(v.decode('ascii') if v and v != bcf_str_missing else None for v in b.split(b','))             # <<<<<<<<<<<<<<
 *     else:
 *         value = []
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object *__pyx_outer_scope;
  PyObject *__pyx_v_v;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":331
 * 
 * 
 * cdef bcf_object_to_array(values, void *data, int bt_type, ssize_t n, int vlen):             # <<<<<<<<<<<<<<
 *     cdef char    *datac
 *     cdef int8_t  *data8
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array {
  PyObject_HEAD
  PyObject *__pyx_v_values;
};


/* "pysam/libcbcf.pyx":343
 *     if bt_type == BCF_BT_CHAR:
 *         if not isinstance(values, (str, bytes)):
 *             values = b','.join(force_bytes(v) if v else bcf_str_missing for v in values)             # <<<<<<<<<<<<<<
 *             value_count = len(values)
 *         assert value_count <= n
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *__pyx_outer_scope;
  PyObject *__pyx_v_v;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":554
 * 
 * 
 * cdef object bcf_check_values(VariantRecord record, value, int sample,             # <<<<<<<<<<<<<<
 *                              int hl_type, int ht_type,
 *                              int id, int bt_type, ssize_t bt_len,
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values {
  PyObject_HEAD
  PyObject *__pyx_v_values;
};


/* "pysam/libcbcf.pyx":593
 *                 raise ValueError('Integer value too small/large to store in VCF/BCF')
 *     elif ht_type == BCF_HT_STR:
 *         values = b','.join(force_bytes(v) if v is not None else b'' for v in values)             # <<<<<<<<<<<<<<
 *     elif ht_type == BCF_HT_FLAG:
 *         if values[0] not in (True, False, None, 1, 0):
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *__pyx_outer_scope;
  PyObject *__pyx_v_v;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":1255
 * 
 *     @property
 *     def attrs(self):             # <<<<<<<<<<<<<<
 *         """sequence of additional header attributes"""
 *         cdef bcf_hrec_t *r = self.ptr
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__ {
  PyObject_HEAD
  bcf_hrec_t *__pyx_v_r;
};


/* "pysam/libcbcf.pyx":1261
 *             return ()
 *         cdef int i
 *         return tuple((bcf_str_cache_get_charptr(r.keys[i]) if r.keys[i] else None,             # <<<<<<<<<<<<<<
 *                       charptr_to_str(r.vals[i]) if r.vals[i] else None)
 *                      for i in range(r.nkeys))
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr {
  PyObject_HEAD
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__ *__pyx_outer_scope;
  int __pyx_v_i;
  int __pyx_t_0;
  int __pyx_t_1;
  int __pyx_t_2;
};


/* "pysam/libcbcf.pyx":1284
 *         raise KeyError('cannot find metadata key')
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__ {
  PyObject_HEAD
  int __pyx_v_i;
  bcf_hrec_t *__pyx_v_r;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self;
  int __pyx_t_0;
  int __pyx_t_1;
  int __pyx_t_2;
};


/* "pysam/libcbcf.pyx":1312
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hrec_t *r = self.ptr
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues {
  PyObject_HEAD
  int __pyx_v_i;
  bcf_hrec_t *__pyx_v_r;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self;
  int __pyx_t_0;
  int __pyx_t_1;
  int __pyx_t_2;
};


/* "pysam/libcbcf.pyx":1322
 *                 yield charptr_to_str(r.vals[i]) if r.vals[i] else None
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hrec_t *r = self.ptr
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems {
  PyObject_HEAD
  int __pyx_v_i;
  bcf_hrec_t *__pyx_v_r;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self;
  int __pyx_t_0;
  int __pyx_t_1;
  int __pyx_t_2;
};


/* "pysam/libcbcf.pyx":1433
 *         return makeVariantHeaderRecord(self.header, self.header.ptr.hrec[i])
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef int32_t i
 *         for i in range(self.header.ptr.nhrec):
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__ {
  PyObject_HEAD
  int32_t __pyx_v_i;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self;
  int __pyx_t_0;
  int __pyx_t_1;
  int32_t __pyx_t_2;
};


/* "pysam/libcbcf.pyx":1623
 *         #bcf_hdr_sync(hdr)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_idpair_t *idpair
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__ {
  PyObject_HEAD
  bcf_hdr_t *__pyx_v_hdr;
  int32_t __pyx_v_i;
  bcf_idpair_t *__pyx_v_idpair;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self;
  int32_t __pyx_t_0;
  int32_t __pyx_t_1;
  int32_t __pyx_t_2;
};


/* "pysam/libcbcf.pyx":1652
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues {
  PyObject_HEAD
  PyObject *__pyx_v_key;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":1657
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems {
  PyObject_HEAD
  PyObject *__pyx_v_key;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":1803
 *         #bcf_hdr_sync(hdr)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_CTG]
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__ {
  PyObject_HEAD
  vdict_t *__pyx_v_d;
  bcf_hdr_t *__pyx_v_hdr;
  uint32_t __pyx_v_i;
  uint32_t __pyx_v_n;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self;
  uint32_t __pyx_t_0;
  uint32_t __pyx_t_1;
  uint32_t __pyx_t_2;
};


/* "pysam/libcbcf.pyx":1832
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues {
  PyObject_HEAD
  PyObject *__pyx_v_key;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":1837
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems {
  PyObject_HEAD
  PyObject *__pyx_v_key;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":1900
 *         return charptr_to_str(hdr.samples[i])
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int32_t i, n = bcf_hdr_nsamples(hdr)
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__ {
  PyObject_HEAD
  bcf_hdr_t *__pyx_v_hdr;
  int32_t __pyx_v_i;
  int32_t __pyx_v_n;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self;
  int32_t __pyx_t_0;
  int32_t __pyx_t_1;
  int32_t __pyx_t_2;
};


/* "pysam/libcbcf.pyx":2273
 *         r.d.n_flt = 0
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__ {
  PyObject_HEAD
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_i;
  bcf1_t *__pyx_v_r;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self;
  int __pyx_t_0;
  int __pyx_t_1;
  int __pyx_t_2;
};


/* "pysam/libcbcf.pyx":2298
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues {
  PyObject_HEAD
  PyObject *__pyx_v_key;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":2303
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems {
  PyObject_HEAD
  PyObject *__pyx_v_key;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":2417
 *                     raise ValueError('Unable to delete FORMAT')
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__ {
  PyObject_HEAD
  bcf_fmt_t *__pyx_v_fmt;
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_i;
  bcf1_t *__pyx_v_r;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self;
  uint32_t __pyx_t_0;
  uint32_t __pyx_t_1;
  int __pyx_t_2;
};


/* "pysam/libcbcf.pyx":2446
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues {
  PyObject_HEAD
  PyObject *__pyx_v_key;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":2451
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems {
  PyObject_HEAD
  PyObject *__pyx_v_key;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":2623
 *                     raise ValueError('Unable to delete INFO')
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__ {
  PyObject_HEAD
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_i;
  bcf_info_t *__pyx_v_info;
  char const *__pyx_v_key;
  bcf1_t *__pyx_v_r;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self;
  uint32_t __pyx_t_0;
  uint32_t __pyx_t_1;
  int __pyx_t_2;
};


/* "pysam/libcbcf.pyx":2690
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues {
  PyObject_HEAD
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_i;
  bcf_info_t *__pyx_v_info;
  char const *__pyx_v_key;
  bcf1_t *__pyx_v_r;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self;
  uint32_t __pyx_t_0;
  uint32_t __pyx_t_1;
  int __pyx_t_2;
};


/* "pysam/libcbcf.pyx":2708
 *                     yield bcf_info_get_value(self.record, info)
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems {
  PyObject_HEAD
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_i;
  bcf_info_t *__pyx_v_info;
  char const *__pyx_v_key;
  bcf1_t *__pyx_v_r;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self;
  PyObject *__pyx_v_value;
  uint32_t __pyx_t_0;
  uint32_t __pyx_t_1;
  int __pyx_t_2;
};


/* "pysam/libcbcf.pyx":2851
 *         return makeVariantRecordSample(self.record, sample_index)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__ {
  PyObject_HEAD
  bcf_hdr_t *__pyx_v_hdr;
  int32_t __pyx_v_i;
  int32_t __pyx_v_n;
  bcf1_t *__pyx_v_r;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self;
  int32_t __pyx_t_0;
  int32_t __pyx_t_1;
  int32_t __pyx_t_2;
};


/* "pysam/libcbcf.pyx":2888
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues {
  PyObject_HEAD
  bcf_hdr_t *__pyx_v_hdr;
  int32_t __pyx_v_i;
  int32_t __pyx_v_n;
  bcf1_t *__pyx_v_r;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self;
  int32_t __pyx_t_0;
  int32_t __pyx_t_1;
  int32_t __pyx_t_2;
};


/* "pysam/libcbcf.pyx":2897
 *             yield makeVariantRecordSample(self.record, i)
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems {
  PyObject_HEAD
  bcf_hdr_t *__pyx_v_hdr;
  int32_t __pyx_v_i;
  int32_t __pyx_v_n;
  bcf1_t *__pyx_v_r;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self;
  int32_t __pyx_t_0;
  int32_t __pyx_t_1;
  int32_t __pyx_t_2;
};


/* "pysam/libcbcf.pyx":3459
 *                 bcf_format_del_value(self, bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__ {
  PyObject_HEAD
  bcf_fmt_t *__pyx_v_fmt;
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_i;
  bcf1_t *__pyx_v_r;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self;
  uint32_t __pyx_t_0;
  uint32_t __pyx_t_1;
  int __pyx_t_2;
};


/* "pysam/libcbcf.pyx":3488
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues {
  PyObject_HEAD
  PyObject *__pyx_v_key;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":3493
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems {
  PyObject_HEAD
  PyObject *__pyx_v_key;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":3603
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues {
  PyObject_HEAD
  PyObject *__pyx_v_key;
  struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysam/libcbcf.pyx":3608
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */
struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems {
  PyObject_HEAD
  PyObject *__pyx_v_key;
  struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};



/* "pysam/libchtslib.pxd":2590
 * 
 * 
 * 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/libcbcf.pyx":1935
 * 
 * 
 * cdef class VariantHeader(object):             # <<<<<<<<<<<<<<
 *     """header information for a :class:`VariantFile` object"""
 *     #FIXME: Add structured proxy
 */

struct __pyx_vtabstruct_5pysam_7libcbcf_VariantHeader {
  PyObject *(*_subset_samples)(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *, PyObject *);
};
static struct __pyx_vtabstruct_5pysam_7libcbcf_VariantHeader *__pyx_vtabptr_5pysam_7libcbcf_VariantHeader;


/* "pysam/libcbcf.pyx":3935
 * 
 * 
 * cdef class VariantFile(HTSFile):             # <<<<<<<<<<<<<<
 *     """*(filename, mode=None, index_filename=None, header=None, drop_samples=False,
 *     duplicate_filehandle=True, ignore_truncation=False, threads=1)*
 */

struct __pyx_vtabstruct_5pysam_7libcbcf_VariantFile {
  struct __pyx_vtabstruct_5pysam_10libchtslib_HTSFile __pyx_base;
  int (*write)(struct __pyx_obj_5pysam_7libcbcf_VariantFile *, struct __pyx_obj_5pysam_7libcbcf_VariantRecord *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5pysam_7libcbcf_VariantFile *__pyx_vtabptr_5pysam_7libcbcf_VariantFile;

/* --- 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);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

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

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#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);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, 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

/* Profile.proto */
#ifndef CYTHON_PROFILE
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
  #define CYTHON_PROFILE 0
#else
  #define CYTHON_PROFILE 1
#endif
#endif
#ifndef CYTHON_TRACE_NOGIL
  #define CYTHON_TRACE_NOGIL 0
#else
  #if CYTHON_TRACE_NOGIL && !defined(CYTHON_TRACE)
    #define CYTHON_TRACE 1
  #endif
#endif
#ifndef CYTHON_TRACE
  #define CYTHON_TRACE 0
#endif
#if CYTHON_TRACE
  #undef CYTHON_PROFILE_REUSE_FRAME
#endif
#ifndef CYTHON_PROFILE_REUSE_FRAME
  #define CYTHON_PROFILE_REUSE_FRAME 0
#endif
#if CYTHON_PROFILE || CYTHON_TRACE
  #include "compile.h"
  #include "frameobject.h"
  #include "traceback.h"
  #if CYTHON_PROFILE_REUSE_FRAME
    #define CYTHON_FRAME_MODIFIER static
    #define CYTHON_FRAME_DEL(frame)
  #else
    #define CYTHON_FRAME_MODIFIER
    #define CYTHON_FRAME_DEL(frame) Py_CLEAR(frame)
  #endif
  #define __Pyx_TraceDeclarations\
  static PyCodeObject *__pyx_frame_code = NULL;\
  CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL;\
  int __Pyx_use_tracing = 0;
  #define __Pyx_TraceFrameInit(codeobj)\
  if (codeobj) __pyx_frame_code = (PyCodeObject*) codeobj;
  #ifdef WITH_THREAD
  #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
  if (nogil) {\
      if (CYTHON_TRACE_NOGIL) {\
          PyThreadState *tstate;\
          PyGILState_STATE state = PyGILState_Ensure();\
          tstate = __Pyx_PyThreadState_Current;\
          if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
                  (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
              __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
          }\
          PyGILState_Release(state);\
          if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
      }\
  } else {\
      PyThreadState* tstate = PyThreadState_GET();\
      if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
              (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
          __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
          if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
      }\
  }
  #else
  #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
  {   PyThreadState* tstate = PyThreadState_GET();\
      if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
              (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
          __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
          if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
      }\
  }
  #endif
  #define __Pyx_TraceException()\
  if (likely(!__Pyx_use_tracing)); else {\
      PyThreadState* tstate = __Pyx_PyThreadState_Current;\
      if (tstate->use_tracing &&\
              (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
          tstate->tracing++;\
          tstate->use_tracing = 0;\
          PyObject *exc_info = __Pyx_GetExceptionTuple(tstate);\
          if (exc_info) {\
              if (CYTHON_TRACE && tstate->c_tracefunc)\
                  tstate->c_tracefunc(\
                      tstate->c_traceobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
              tstate->c_profilefunc(\
                  tstate->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
              Py_DECREF(exc_info);\
          }\
          tstate->use_tracing = 1;\
          tstate->tracing--;\
      }\
  }
  static void __Pyx_call_return_trace_func(PyThreadState *tstate, PyFrameObject *frame, PyObject *result) {
      PyObject *type, *value, *traceback;
      __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
      tstate->tracing++;
      tstate->use_tracing = 0;
      if (CYTHON_TRACE && tstate->c_tracefunc)
          tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_RETURN, result);
      if (tstate->c_profilefunc)
          tstate->c_profilefunc(tstate->c_profileobj, frame, PyTrace_RETURN, result);
      CYTHON_FRAME_DEL(frame);
      tstate->use_tracing = 1;
      tstate->tracing--;
      __Pyx_ErrRestoreInState(tstate, type, value, traceback);
  }
  #ifdef WITH_THREAD
  #define __Pyx_TraceReturn(result, nogil)\
  if (likely(!__Pyx_use_tracing)); else {\
      if (nogil) {\
          if (CYTHON_TRACE_NOGIL) {\
              PyThreadState *tstate;\
              PyGILState_STATE state = PyGILState_Ensure();\
              tstate = __Pyx_PyThreadState_Current;\
              if (tstate->use_tracing) {\
                  __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
              }\
              PyGILState_Release(state);\
          }\
      } else {\
          PyThreadState* tstate = __Pyx_PyThreadState_Current;\
          if (tstate->use_tracing) {\
              __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
          }\
      }\
  }
  #else
  #define __Pyx_TraceReturn(result, nogil)\
  if (likely(!__Pyx_use_tracing)); else {\
      PyThreadState* tstate = __Pyx_PyThreadState_Current;\
      if (tstate->use_tracing) {\
          __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
      }\
  }
  #endif
  static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno);
  static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, PyThreadState* tstate, const char *funcname, const char *srcfile, int firstlineno);
#else
  #define __Pyx_TraceDeclarations
  #define __Pyx_TraceFrameInit(codeobj)
  #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)   if ((1)); else goto_error;
  #define __Pyx_TraceException()
  #define __Pyx_TraceReturn(result, nogil)
#endif
#if CYTHON_TRACE
  static int __Pyx_call_line_trace_func(PyThreadState *tstate, PyFrameObject *frame, int lineno) {
      int ret;
      PyObject *type, *value, *traceback;
      __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
      __Pyx_PyFrame_SetLineNumber(frame, lineno);
      tstate->tracing++;
      tstate->use_tracing = 0;
      ret = tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_LINE, NULL);
      tstate->use_tracing = 1;
      tstate->tracing--;
      if (likely(!ret)) {
          __Pyx_ErrRestoreInState(tstate, type, value, traceback);
      } else {
          Py_XDECREF(type);
          Py_XDECREF(value);
          Py_XDECREF(traceback);
      }
      return ret;
  }
  #ifdef WITH_THREAD
  #define __Pyx_TraceLine(lineno, nogil, goto_error)\
  if (likely(!__Pyx_use_tracing)); else {\
      if (nogil) {\
          if (CYTHON_TRACE_NOGIL) {\
              int ret = 0;\
              PyThreadState *tstate;\
              PyGILState_STATE state = PyGILState_Ensure();\
              tstate = __Pyx_PyThreadState_Current;\
              if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
                  ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
              }\
              PyGILState_Release(state);\
              if (unlikely(ret)) goto_error;\
          }\
      } else {\
          PyThreadState* tstate = __Pyx_PyThreadState_Current;\
          if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
              int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
              if (unlikely(ret)) goto_error;\
          }\
      }\
  }
  #else
  #define __Pyx_TraceLine(lineno, nogil, goto_error)\
  if (likely(!__Pyx_use_tracing)); else {\
      PyThreadState* tstate = __Pyx_PyThreadState_Current;\
      if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
          int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
          if (unlikely(ret)) goto_error;\
      }\
  }
  #endif
#else
  #define __Pyx_TraceLine(lineno, nogil, goto_error)   if ((1)); else goto_error;
#endif

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

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

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

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

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

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

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

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

/* UnpackUnboundCMethod.proto */
typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

/* CallUnboundCMethod1.proto */
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg)  __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#endif

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

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

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

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

/* append.proto */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

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

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

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

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

/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

/* StrEquals.proto */
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

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

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

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

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

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

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

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

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

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

/* py_dict_items.proto */
static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);

/* CallUnboundCMethod0.proto */
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CallUnboundCMethod0(cfunc, self)\
    (likely((cfunc)->func) ?\
        (likely((cfunc)->flag == METH_NOARGS) ?  (*((cfunc)->func))(self, NULL) :\
         (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
            (PY_VERSION_HEX >= 0x030700A0 ?\
                (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
                (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
          (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
            (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
            (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ?  ((*(PyCFunctionWithKeywords)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
               ((cfunc)->flag == METH_VARARGS ?  (*((cfunc)->func))(self, __pyx_empty_tuple) :\
               __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
        __Pyx__CallUnboundCMethod0(cfunc, self))
#else
#define __Pyx_CallUnboundCMethod0(cfunc, self)  __Pyx__CallUnboundCMethod0(cfunc, self)
#endif

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

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

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

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
    (likely(PyDict_CheckExact(obj)) ?\
     __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
#endif

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

/* py_dict_pop.proto */
static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value);

/* CallUnboundCMethod2.proto */
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
#else
#define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2)  __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
#endif

/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

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

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

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

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

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

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);

/* CallNextTpDealloc.proto */
static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);

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

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif

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

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

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

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* 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_int(int value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value);

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

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int8_t(int8_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int16_t(int16_t value);

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

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_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;
#if PY_MAJOR_VERSION >= 3
        unsigned long long *as_ulonglongs;
        long long *as_longlongs;
#endif
        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 int32_t __Pyx_PyInt_As_int32_t(PyObject *);

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

/* CIntFromPy.proto */
static CYTHON_INLINE int8_t __Pyx_PyInt_As_int8_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE int16_t __Pyx_PyInt_As_int16_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *);

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

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

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

/* CoroutineBase.proto */
typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, 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;
    PyObject *gi_code;
    int resume_label;
    char is_running;
} __pyx_CoroutineObject;
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
    PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
    PyObject *name, PyObject *qualname, PyObject *module_name);
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name);
static int __Pyx_Coroutine_clear(PyObject *self);
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_SwapException(self) {\
    __Pyx_ExceptionSwap(&(self)->exc_type, &(self)->exc_value, &(self)->exc_traceback);\
    __Pyx_Coroutine_ResetFrameBackpointer(self);\
    }
#define __Pyx_Coroutine_ResetAndClearException(self) {\
    __Pyx_ExceptionReset((self)->exc_type, (self)->exc_value, (self)->exc_traceback);\
    (self)->exc_type = (self)->exc_value = (self)->exc_traceback = NULL;\
    }
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
#endif
static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self);

/* 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, code, closure, name, qualname, module_name)\
    __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, 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);

/* FunctionImport.proto */
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);

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

static PyObject *__pyx_f_5pysam_7libcbcf_13VariantHeader__subset_samples(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, PyObject *__pyx_v_include_samples); /* proto*/
static int __pyx_f_5pysam_7libcbcf_11VariantFile_write(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record, int __pyx_skip_dispatch); /* proto*/

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

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

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

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

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

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

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

/* Module declarations from 'cython' */

/* Module declarations from '__builtin__' */

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

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

/* 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 'cpython.object' */

/* 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.libcutils' */
static PyObject *(*__pyx_f_5pysam_9libcutils_charptr_to_str)(char const *, struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_5pysam_9libcutils_charptr_to_str_w_len)(char const *, size_t, struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str_w_len *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_5pysam_9libcutils_force_str)(PyObject *, struct __pyx_opt_args_5pysam_9libcutils_force_str *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_5pysam_9libcutils_force_bytes)(PyObject *, struct __pyx_opt_args_5pysam_9libcutils_force_bytes *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_5pysam_9libcutils_encode_filename)(PyObject *); /*proto*/
static PyObject *(*__pyx_f_5pysam_9libcutils_from_string_and_size)(char const *, size_t); /*proto*/

/* Module declarations from 'pysam.libcbcf' */
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantHeader = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantHeaderRecord = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantHeaderRecords = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantHeaderContigs = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantHeaderSamples = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantContig = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantMetadata = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantHeaderMetadata = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantRecord = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantRecordFilter = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantRecordFormat = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantRecordInfo = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantRecordSamples = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantRecordSample = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_BaseIndex = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_BCFIndex = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_TabixIndex = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_BaseIterator = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_BCFIterator = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_TabixIterator = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf_VariantFile = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_1_genexpr = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_3_genexpr = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_5_genexpr = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_7_genexpr = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_8___get__ = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_9_genexpr = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_10___iter__ = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_11_itervalues = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_12_iteritems = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_13___iter__ = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_14___iter__ = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_15_itervalues = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_16_iteritems = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_17___iter__ = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_18_itervalues = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_19_iteritems = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_20___iter__ = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_21___iter__ = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_22_itervalues = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_23_iteritems = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_24___iter__ = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_25_itervalues = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_26_iteritems = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_27___iter__ = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_28_itervalues = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_29_iteritems = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_30___iter__ = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_31_itervalues = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_32_iteritems = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_33___iter__ = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_34_itervalues = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_35_iteritems = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_36_itervalues = 0;
static PyTypeObject *__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_37_iteritems = 0;
static int __pyx_v_5pysam_7libcbcf_MAX_POS;
static PyObject *__pyx_v_5pysam_7libcbcf_VALUE_TYPES = 0;
static PyObject *__pyx_v_5pysam_7libcbcf_METADATA_TYPES = 0;
static PyObject *__pyx_v_5pysam_7libcbcf_METADATA_LENGTHS = 0;
static PyObject *__pyx_v_5pysam_7libcbcf__nothing = 0;
static PyObject *__pyx_v_5pysam_7libcbcf_bcf_str_cache = 0;
static CYTHON_INLINE PyObject *__pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(char const *); /*proto*/
static int __pyx_f_5pysam_7libcbcf_comb(int, int); /*proto*/
static CYTHON_INLINE int __pyx_f_5pysam_7libcbcf_bcf_geno_combinations(int, int); /*proto*/
static CYTHON_INLINE int __pyx_f_5pysam_7libcbcf_check_header_id(bcf_hdr_t *, int, int); /*proto*/
static CYTHON_INLINE int __pyx_f_5pysam_7libcbcf_is_gt_fmt(bcf_hdr_t *, int); /*proto*/
static CYTHON_INLINE int __pyx_f_5pysam_7libcbcf_bcf_genotype_count(bcf_hdr_t *, bcf1_t *, int); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_char_array_to_tuple(char const **, Py_ssize_t, struct __pyx_opt_args_5pysam_7libcbcf_char_array_to_tuple *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_array_to_object(void *, int, Py_ssize_t, Py_ssize_t, int); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_object_to_array(PyObject *, void *, int, Py_ssize_t, int); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_empty_array(int, Py_ssize_t, int); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_copy_expand_array(void *, int, Py_ssize_t, void *, int, Py_ssize_t, int); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_get_value_count(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *, int, int, Py_ssize_t *, int *, int); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_info_get_value(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *, bcf_info_t const *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_check_values(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *, PyObject *, int, int, int, int, int, Py_ssize_t, Py_ssize_t *, int *, int *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_encode_alleles(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_info_set_value(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *, PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_format_get_value(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_format_set_value(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *, PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_format_del_value(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_format_get_allele_indices(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_format_get_alleles(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *); /*proto*/
static int __pyx_f_5pysam_7libcbcf_bcf_sample_get_phased(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf_bcf_sample_set_phased(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *, int); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_5pysam_7libcbcf_bcf_sync_end(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *); /*proto*/
static CYTHON_INLINE int __pyx_f_5pysam_7libcbcf_has_symbolic_allele(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_f_5pysam_7libcbcf_makeVariantHeaderRecord(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *, bcf_hrec_t *); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_f_5pysam_7libcbcf_makeVariantHeaderRecords(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_f_5pysam_7libcbcf_makeVariantMetadata(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *, int, int); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_f_5pysam_7libcbcf_makeVariantHeaderMetadata(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *, int32_t); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_f_5pysam_7libcbcf_makeVariantContig(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *, int); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_f_5pysam_7libcbcf_makeVariantHeaderContigs(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_f_5pysam_7libcbcf_makeVariantHeaderSamples(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_f_5pysam_7libcbcf_makeVariantHeader(bcf_hdr_t *); /*proto*/
static CYTHON_INLINE int __pyx_f_5pysam_7libcbcf_bcf_header_get_info_id(bcf_hdr_t *, PyObject *); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_f_5pysam_7libcbcf_makeVariantRecordFilter(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_f_5pysam_7libcbcf_makeVariantRecordFormat(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_f_5pysam_7libcbcf_makeVariantRecordInfo(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_f_5pysam_7libcbcf_makeVariantRecordSamples(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_f_5pysam_7libcbcf_makeVariantRecord(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *, bcf1_t *); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_f_5pysam_7libcbcf_makeVariantRecordSample(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *, int32_t); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_f_5pysam_7libcbcf_makeBCFIndex(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *, hts_idx_t *); /*proto*/
static struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_f_5pysam_7libcbcf_makeTabixIndex(tbx_t *); /*proto*/
static void __pyx_f_5pysam_7libcbcf__stop_BCFIterator(struct __pyx_obj_5pysam_7libcbcf_BCFIterator *, bcf1_t *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderRecords__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantMetadata__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderMetadata__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantContig__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantContig *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderContigs__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderSamples__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordFilter__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordFormat__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordInfo__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordSamples__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordSample__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *, PyObject *); /*proto*/
static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_BaseIndex__set_state(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *, PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "pysam.libcbcf"
extern int __pyx_module_is_main_pysam__libcbcf;
int __pyx_module_is_main_pysam__libcbcf = 0;

/* Implementation of 'pysam.libcbcf' */
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_chr;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_MemoryError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_NotImplemented;
static PyObject *__pyx_builtin_reversed;
static PyObject *__pyx_builtin_IOError;
static PyObject *__pyx_builtin_StopIteration;
static const char __pyx_k_A[] = "A";
static const char __pyx_k_G[] = "G";
static const char __pyx_k_R[] = "R";
static const char __pyx_k_r[] = "r";
static const char __pyx_k_w[] = "w";
static const char __pyx_k_GT[] = "GT";
static const char __pyx_k_ID[] = "ID";
static const char __pyx_k__2[] = ",";
static const char __pyx_k_gz[] = ".gz";
static const char __pyx_k_id[] = "id";
static const char __pyx_k_os[] = "os";
static const char __pyx_k_wb[] = "wb";
static const char __pyx_k_wz[] = "wz";
static const char __pyx_k_ALT[] = "ALT";
static const char __pyx_k_END[] = "END";
static const char __pyx_k__15[] = "";
static const char __pyx_k__71[] = ".";
static const char __pyx_k__74[] = "\"";
static const char __pyx_k_add[] = "add";
static const char __pyx_k_all[] = "__all__";
static const char __pyx_k_bcf[] = "bcf";
static const char __pyx_k_chr[] = "chr";
static const char __pyx_k_end[] = "end";
static const char __pyx_k_get[] = "get";
static const char __pyx_k_key[] = "key";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_pop[] = "pop";
static const char __pyx_k_ref[] = "ref";
static const char __pyx_k_rwa[] = "rwa";
static const char __pyx_k_sys[] = "sys";
static const char __pyx_k_wb0[] = "wb0";
static const char __pyx_k_wbu[] = "wbu";
static const char __pyx_k_Flag[] = "Flag";
static const char __pyx_k_INFO[] = "INFO";
static const char __pyx_k_PASS[] = "PASS";
static const char __pyx_k_Type[] = "Type";
static const char __pyx_k__175[] = ", ";
static const char __pyx_k__221[] = "-";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_copy[] = "copy";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_hash[] = "__hash__";
static const char __pyx_k_info[] = "info";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_iter[] = "__iter__";
static const char __pyx_k_join[] = "join";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_mode[] = "mode";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_open[] = "open";
static const char __pyx_k_qual[] = "qual";
static const char __pyx_k_seek[] = "seek";
static const char __pyx_k_send[] = "send";
static const char __pyx_k_stop[] = "stop";
static const char __pyx_k_tell[] = "tell";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_type[] = "type";
static const char __pyx_k_FIXED[] = "FIXED";
static const char __pyx_k_Float[] = "Float";
static const char __pyx_k_ascii[] = "ascii";
static const char __pyx_k_bcf_2[] = ".bcf";
static const char __pyx_k_bcguz[] = "bcguz";
static const char __pyx_k_close[] = "close";
static const char __pyx_k_fetch[] = "fetch";
static const char __pyx_k_items[] = "items";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_remap[] = "remap";
static const char __pyx_k_split[] = "split";
static const char __pyx_k_start[] = "start";
static const char __pyx_k_strip[] = "strip";
static const char __pyx_k_throw[] = "throw";
static const char __pyx_k_upper[] = "upper";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_write[] = "write";
static const char __pyx_k_CONTIG[] = "CONTIG";
static const char __pyx_k_FILTER[] = "FILTER";
static const char __pyx_k_FORMAT[] = "FORMAT";
static const char __pyx_k_Number[] = "Number";
static const char __pyx_k_String[] = "String";
static const char __pyx_k_append[] = "append";
static const char __pyx_k_contig[] = "contig";
static const char __pyx_k_decode[] = "decode";
static const char __pyx_k_filter[] = "filter";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_header[] = "header";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_number[] = "number";
static const char __pyx_k_object[] = "object";
static const char __pyx_k_phased[] = "phased";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_record[] = "record";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_region[] = "region";
static const char __pyx_k_reopen[] = "reopen";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_values[] = "values";
static const char __pyx_k_GENERIC[] = "GENERIC";
static const char __pyx_k_IOError[] = "IOError";
static const char __pyx_k_Integer[] = "Integer";
static const char __pyx_k_NON_REF[] = "<NON_REF>";
static const char __pyx_k_alleles[] = "alleles";
static const char __pyx_k_default[] = "default";
static const char __pyx_k_genexpr[] = "genexpr";
static const char __pyx_k_is_open[] = "is_open";
static const char __pyx_k_records[] = "records";
static const char __pyx_k_samples[] = "samples";
static const char __pyx_k_threads[] = "threads";
static const char __pyx_k_KeyError[] = "KeyError";
static const char __pyx_k_VARIABLE[] = "VARIABLE";
static const char __pyx_k_add_meta[] = "add_meta";
static const char __pyx_k_endswith[] = "endswith";
static const char __pyx_k_filename[] = "filename";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_reversed[] = "reversed";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_iteritems[] = "iteritems";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_reference[] = "reference";
static const char __pyx_k_IndexError[] = "IndexError";
static const char __pyx_k_STRUCTURED[] = "STRUCTURED";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_add_sample[] = "add_sample";
static const char __pyx_k_itervalues[] = "itervalues";
static const char __pyx_k_new_record[] = "new_record";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_startswith[] = "startswith";
static const char __pyx_k_Description[] = "Description";
static const char __pyx_k_Invalid_tid[] = "Invalid tid";
static const char __pyx_k_MemoryError[] = "MemoryError";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_VariantFile[] = "VariantFile";
static const char __pyx_k_description[] = "description";
static const char __pyx_k_invalid_key[] = "invalid key: {}";
static const char __pyx_k_invalid_tag[] = "invalid tag";
static const char __pyx_k_drop_samples[] = "drop_samples";
static const char __pyx_k_parse_region[] = "parse_region";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_unknown_INFO[] = "unknown INFO: {}";
static const char __pyx_k_unknown_mode[] = "unknown mode {}";
static const char __pyx_k_StopIteration[] = "StopIteration";
static const char __pyx_k_VariantHeader[] = "VariantHeader";
static const char __pyx_k_VariantRecord[] = "VariantRecord";
static const char __pyx_k_pysam_libcbcf[] = "pysam.libcbcf";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_Invalid_filter[] = "Invalid filter: {}";
static const char __pyx_k_Invalid_header[] = "Invalid header";
static const char __pyx_k_NotImplemented[] = "NotImplemented";
static const char __pyx_k_Unknown_allele[] = "Unknown allele";
static const char __pyx_k_index_filename[] = "index_filename";
static const char __pyx_k_invalid_FORMAT[] = "invalid FORMAT: {}";
static const char __pyx_k_invalid_contig[] = "invalid contig: {}";
static const char __pyx_k_truncated_file[] = "truncated file";
static const char __pyx_k_unknown_format[] = "unknown format: {}";
static const char __pyx_k_limits_violated[] = "limits violated";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_unable_to_fetch[] = "unable to fetch {}:{}-{}";
static const char __pyx_k_check_truncation[] = "check_truncation";
static const char __pyx_k_invalid_contig_2[] = "invalid contig";
static const char __pyx_k_unsupported_type[] = "unsupported type";
static const char __pyx_k_Error_updating_id[] = "Error updating id";
static const char __pyx_k_Invalid_header_id[] = "Invalid header id";
static const char __pyx_k_bcguz0123456789ex[] = "bcguz0123456789ex";
static const char __pyx_k_ignore_truncation[] = "ignore_truncation";
static const char __pyx_k_invalid_contig_id[] = "invalid contig id";
static const char __pyx_k_unsupported_types[] = "unsupported types";
static const char __pyx_k_vcf_format_failed[] = "vcf_format failed";
static const char __pyx_k_Invalid_INFO_field[] = "Invalid INFO field: {}";
static const char __pyx_k_Unknown_INFO_field[] = "Unknown INFO field: {}";
static const char __pyx_k_bcf_index_required[] = "bcf index required";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_error_in_vcf_parse[] = "error in vcf_parse";
static const char __pyx_k_get_reference_name[] = "get_reference_name";
static const char __pyx_k_BaseIndex_iteritems[] = "BaseIndex.iteritems";
static const char __pyx_k_VariantHeaderRecord[] = "VariantHeaderRecord";
static const char __pyx_k_invalid_header_line[] = "invalid header line";
static const char __pyx_k_invalid_metadata_id[] = "invalid metadata id";
static const char __pyx_k_invalid_sample_name[] = "invalid sample name: {}";
static const char __pyx_k_BaseIndex_itervalues[] = "BaseIndex.itervalues";
static const char __pyx_k_Invalid_allele_index[] = "Invalid allele index";
static const char __pyx_k_Invalid_index_object[] = "Invalid index object";
static const char __pyx_k_Unable_to_delete_END[] = "Unable to delete END";
static const char __pyx_k_bcf_must_not_be_None[] = "bcf must not be None";
static const char __pyx_k_duplicate_filehandle[] = "duplicate_filehandle";
static const char __pyx_k_invalid_contig_index[] = "invalid contig index";
static const char __pyx_k_invalid_filter_index[] = "invalid filter index";
static const char __pyx_k_invalid_mode_options[] = "invalid mode options: {}";
static const char __pyx_k_invalid_reference_id[] = "invalid reference id";
static const char __pyx_k_invalid_sample_index[] = "invalid sample index";
static const char __pyx_k_tabix_index_required[] = "tabix index required";
static const char __pyx_k_Unable_to_delete_INFO[] = "Unable to delete INFO";
static const char __pyx_k_Unknown_format_length[] = "Unknown format length";
static const char __pyx_k_Unsupported_INFO_type[] = "Unsupported INFO type";
static const char __pyx_k_invalid_VariantHeader[] = "invalid VariantHeader";
static const char __pyx_k_invalid_VariantRecord[] = "invalid VariantRecord";
static const char __pyx_k_invalid_metadata_type[] = "invalid metadata type";
static const char __pyx_k_Cannot_re_open_htsfile[] = "Cannot re-open htsfile";
static const char __pyx_k_Duplicated_sample_name[] = "Duplicated sample name: {}";
static const char __pyx_k_Error_s_reading_record[] = "Error(s) reading record: {}";
static const char __pyx_k_Error_updating_alleles[] = "Error updating alleles";
static const char __pyx_k_cannot_set_null_allele[] = "cannot set null allele";
static const char __pyx_k_pyx_unpickle_BaseIndex[] = "__pyx_unpickle_BaseIndex";
static const char __pyx_k_unknown_type_specified[] = "unknown type specified: {}";
static const char __pyx_k_Unable_to_delete_FORMAT[] = "Unable to delete FORMAT";
static const char __pyx_k_Unsupported_FORMAT_type[] = "Unsupported FORMAT type";
static const char __pyx_k_fetch_requires_an_index[] = "fetch requires an index";
static const char __pyx_k_header_must_not_be_None[] = "header must not be None";
static const char __pyx_k_invalid_character_found[] = "invalid character found";
static const char __pyx_k_record_must_not_be_None[] = "record must not be None";
static const char __pyx_k_sample_must_not_be_None[] = "sample must not be None";
static const char __pyx_k_VariantRecordInfo___iter[] = "VariantRecordInfo.__iter__";
static const char __pyx_k_cannot_find_metadata_key[] = "cannot find metadata key";
static const char __pyx_k_contig_must_be_specified[] = "contig must be specified";
static const char __pyx_k_could_not_open_file_mode[] = "could not open file `{}` (mode='{}')";
static const char __pyx_k_Cannot_create_empty_array[] = "Cannot create empty array";
static const char __pyx_k_Invalid_chromosome_contig[] = "Invalid chromosome/contig";
static const char __pyx_k_Position_must_be_positive[] = "Position must be positive";
static const char __pyx_k_invalid_number_of_columns[] = "invalid number of columns";
static const char __pyx_k_VariantHeaderRecord___iter[] = "VariantHeaderRecord.__iter__";
static const char __pyx_k_VariantRecordFilter___iter[] = "VariantRecordFilter.__iter__";
static const char __pyx_k_VariantRecordFormat___iter[] = "VariantRecordFormat.__iter__";
static const char __pyx_k_VariantRecordSample___iter[] = "VariantRecordSample.__iter__";
static const char __pyx_k_cannot_set_null_alt_allele[] = "cannot set null alt allele";
static const char __pyx_k_error_in_bcf_subset_format[] = "error in bcf_subset_format";
static const char __pyx_k_pyx_unpickle_VariantContig[] = "__pyx_unpickle_VariantContig";
static const char __pyx_k_unsupported_info_type_code[] = "unsupported info type code";
static const char __pyx_k_Invalid_header_record_index[] = "Invalid header record index";
static const char __pyx_k_VariantHeaderContigs___iter[] = "VariantHeaderContigs.__iter__";
static const char __pyx_k_VariantHeaderRecords___iter[] = "VariantHeaderRecords.__iter__";
static const char __pyx_k_VariantHeaderSamples___iter[] = "VariantHeaderSamples.__iter__";
static const char __pyx_k_VariantRecordInfo_iteritems[] = "VariantRecordInfo.iteritems";
static const char __pyx_k_VariantRecordSamples___iter[] = "VariantRecordSamples.__iter__";
static const char __pyx_k_cannot_create_VariantHeader[] = "cannot create VariantHeader";
static const char __pyx_k_cannot_create_VariantRecord[] = "cannot create VariantRecord";
static const char __pyx_k_could_not_open_variant_file[] = "could not open variant file `{}`: {}";
static const char __pyx_k_dst_header_must_not_be_None[] = "dst_header must not be None";
static const char __pyx_k_invalid_header_record_index[] = "invalid header record index";
static const char __pyx_k_missing_d_requested_samples[] = "missing {:d} requested samples";
static const char __pyx_k_must_set_at_least_2_alleles[] = "must set at least 2 alleles";
static const char __pyx_k_ref_allele_must_not_be_null[] = "ref allele must not be null";
static const char __pyx_k_unable_to_fetch_next_record[] = "unable to fetch next record";
static const char __pyx_k_Header_already_exists_for_id[] = "Header already exists for id={}";
static const char __pyx_k_I_O_operation_on_closed_file[] = "I/O operation on closed file";
static const char __pyx_k_Unable_to_update_INFO_values[] = "Unable to update INFO values";
static const char __pyx_k_VariantHeaderMetadata___iter[] = "VariantHeaderMetadata.__iter__";
static const char __pyx_k_VariantRecordInfo_itervalues[] = "VariantRecordInfo.itervalues";
static const char __pyx_k_pyx_unpickle_VariantMetadata[] = "__pyx_unpickle_VariantMetadata";
static const char __pyx_k_unsupported_header_type_code[] = "unsupported header type code";
static const char __pyx_k_Error_unpacking_VariantRecord[] = "Error unpacking VariantRecord";
static const char __pyx_k_Stop_position_of_the_interval[] = "Stop position of the interval";
static const char __pyx_k_VariantHeaderRecord_iteritems[] = "VariantHeaderRecord.iteritems";
static const char __pyx_k_VariantRecordFilter_iteritems[] = "VariantRecordFilter.iteritems";
static const char __pyx_k_VariantRecordFormat_iteritems[] = "VariantRecordFormat.iteritems";
static const char __pyx_k_VariantRecordSample_iteritems[] = "VariantRecordSample.iteritems";
static const char __pyx_k_could_not_open_variant_file_2[] = "could not open variant file `{}`";
static const char __pyx_k_mode_must_begin_with_r_w_or_a[] = "mode must begin with r, w or a";
static const char __pyx_k_unable_to_allocate_BCF_record[] = "unable to allocate BCF record";
static const char __pyx_k_Unable_to_update_format_values[] = "Unable to update format values";
static const char __pyx_k_VariantHeaderContigs_iteritems[] = "VariantHeaderContigs.iteritems";
static const char __pyx_k_VariantHeaderRecord_itervalues[] = "VariantHeaderRecord.itervalues";
static const char __pyx_k_VariantRecordFilter_itervalues[] = "VariantRecordFilter.itervalues";
static const char __pyx_k_VariantRecordFormat_itervalues[] = "VariantRecordFormat.itervalues";
static const char __pyx_k_VariantRecordSample_itervalues[] = "VariantRecordSample.itervalues";
static const char __pyx_k_VariantRecordSamples_iteritems[] = "VariantRecordSamples.iteritems";
static const char __pyx_k_bcf_hdr_set_samples_failed_ret[] = "bcf_hdr_set_samples failed: ret = {}";
static const char __pyx_k_invalid_value_for_Float_format[] = "invalid value for Float format";
static const char __pyx_k_pyx_unpickle_VariantHeaderCont[] = "__pyx_unpickle_VariantHeaderContigs";
static const char __pyx_k_pyx_unpickle_VariantHeaderMeta[] = "__pyx_unpickle_VariantHeaderMetadata";
static const char __pyx_k_pyx_unpickle_VariantHeaderReco[] = "__pyx_unpickle_VariantHeaderRecords";
static const char __pyx_k_pyx_unpickle_VariantHeaderSamp[] = "__pyx_unpickle_VariantHeaderSamples";
static const char __pyx_k_pyx_unpickle_VariantRecordFilt[] = "__pyx_unpickle_VariantRecordFilter";
static const char __pyx_k_pyx_unpickle_VariantRecordForm[] = "__pyx_unpickle_VariantRecordFormat";
static const char __pyx_k_pyx_unpickle_VariantRecordInfo[] = "__pyx_unpickle_VariantRecordInfo";
static const char __pyx_k_pyx_unpickle_VariantRecordSamp[] = "__pyx_unpickle_VariantRecordSamples";
static const char __pyx_k_Invalid_VariantRecord_Number_of[] = "Invalid VariantRecord.  Number of samples does not match header ({} vs {})";
static const char __pyx_k_Number_must_be_None_when_adding[] = "Number must be None when adding a filter";
static const char __pyx_k_Type_must_be_None_when_adding_a[] = "Type must be None when adding a filter";
static const char __pyx_k_VariantHeaderContigs_itervalues[] = "VariantHeaderContigs.itervalues";
static const char __pyx_k_VariantHeaderMetadata_iteritems[] = "VariantHeaderMetadata.iteritems";
static const char __pyx_k_VariantRecordSamples_itervalues[] = "VariantRecordSamples.itervalues";
static const char __pyx_k_bcf_check_values_locals_genexpr[] = "bcf_check_values.<locals>.genexpr";
static const char __pyx_k_cannot_iterate_over_Variantfile[] = "cannot iterate over Variantfile opened for writing";
static const char __pyx_k_file_does_not_have_valid_header[] = "file `{}` does not have valid header (mode=`{}`) - is it VCF/BCF format?";
static const char __pyx_k_invalid_file_mode_is_it_VCF_BCF[] = "invalid file `{}` (mode=`{}`) - is it VCF/BCF format?";
static const char __pyx_k_self_ptr_cannot_be_converted_to[] = "self.ptr cannot be converted to a Python object for pickling";
static const char __pyx_k_Cannot_add_extra_threads_when_ig[] = "Cannot add extra threads when \"ignore_truncation\" is True";
static const char __pyx_k_Cannot_copy_arrays_with_src_valu[] = "Cannot copy arrays with src_values={} > dst_values={}";
static const char __pyx_k_Cannot_set_phased_before_genotyp[] = "Cannot set phased before genotype is set";
static const char __pyx_k_Cannot_specify_an_index_filename[] = "Cannot specify an index filename when writing a VCF/BCF file";
static const char __pyx_k_Cannot_translate_record_Number_o[] = "Cannot translate record.  Number of samples does not match header ({} vs {})";
static const char __pyx_k_END_is_a_reserved_attribute_acce[] = "END is a reserved attribute; access is via record.stop";
static const char __pyx_k_Flag_types_are_not_allowed_on_FO[] = "Flag types are not allowed on FORMATs";
static const char __pyx_k_Flag_values_must_be_True_False_N[] = "Flag values must be: True, False, None, 1, 0";
static const char __pyx_k_Header_already_exists_for_contig[] = "Header already exists for contig {}";
static const char __pyx_k_Incompatible_checksums_s_vs_0x09[] = "Incompatible checksums (%s vs 0x099fb99 = (header))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x5d[] = "Incompatible checksums (%s vs 0x5d6ff7b = (index, record))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x9d[] = "Incompatible checksums (%s vs 0x9d0a56c = (header, id, type))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xbe[] = "Incompatible checksums (%s vs 0xbe66ecb = (header, id))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xd9[] = "Incompatible checksums (%s vs 0xd936de3 = (refmap, refs))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xde[] = "Incompatible checksums (%s vs 0xde17f0f = (record))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xed[] = "Incompatible checksums (%s vs 0xed5e66b = (header, type))";
static const char __pyx_k_Integer_value_too_small_large_to[] = "Integer value too small/large to store in VCF/BCF";
static const char __pyx_k_Start_coordinate_must_be_non_neg[] = "Start coordinate must be non-negative";
static const char __pyx_k_Stop_coordinate_must_be_non_nega[] = "Stop coordinate must be non-negative";
static const char __pyx_k_VariantHeaderMetadata_itervalues[] = "VariantHeaderMetadata.itervalues";
static const char __pyx_k_VariantHeaderRecord___get___loca[] = "VariantHeaderRecord.__get__.<locals>.genexpr";
static const char __pyx_k_bcf_array_to_object_locals_genex[] = "bcf_array_to_object.<locals>.genexpr";
static const char __pyx_k_bcf_object_to_array_locals_genex[] = "bcf_object_to_array.<locals>.genexpr";
static const char __pyx_k_cannot_convert_deleted_record_to[] = "cannot convert deleted record to str";
static const char __pyx_k_cannot_create_VariantRecordSampl[] = "cannot create VariantRecordSample";
static const char __pyx_k_cannot_fetch_from_Variantfile_op[] = "cannot fetch from Variantfile opened for writing";
static const char __pyx_k_cannot_subset_samples_after_fetc[] = "cannot subset samples after fetching records";
static const char __pyx_k_cannot_subset_samples_from_Varia[] = "cannot subset samples from Variantfile opened for writing";
static const char __pyx_k_cannot_write_to_a_Variantfile_op[] = "cannot write to a Variantfile opened for reading";
static const char __pyx_k_char_array_to_tuple_locals_genex[] = "char_array_to_tuple.<locals>.genexpr";
static const char __pyx_k_either_value_or_items_must_be_sp[] = "either value or items must be specified";
static const char __pyx_k_genotype_is_only_valid_as_a_form[] = "genotype is only valid as a format field";
static const char __pyx_k_invalid_value_for_Integer_format[] = "invalid value for Integer format";
static const char __pyx_k_mode_contains_conflicting_format[] = "mode contains conflicting format specifiers: {}";
static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
static const char __pyx_k_pyx_unpickle_VariantRecordSamp_2[] = "__pyx_unpickle_VariantRecordSample";
static const char __pyx_k_self_iter_cannot_be_converted_to[] = "self.iter cannot be converted to a Python object for pickling";
static const char __pyx_k_this_class_cannot_be_instantiate[] = "this class cannot be instantiated from Python";
static const char __pyx_k_value_expected_to_be_scalar_give[] = "value expected to be scalar, given len={}";
static const char __pyx_k_values_expected_to_be_tuple_give[] = "values expected to be {}-tuple, given len={}";
static PyObject *__pyx_n_s_A;
static PyObject *__pyx_n_s_ALT;
static PyObject *__pyx_n_s_BaseIndex_iteritems;
static PyObject *__pyx_n_s_BaseIndex_itervalues;
static PyObject *__pyx_n_s_CONTIG;
static PyObject *__pyx_kp_s_Cannot_add_extra_threads_when_ig;
static PyObject *__pyx_kp_s_Cannot_copy_arrays_with_src_valu;
static PyObject *__pyx_kp_s_Cannot_create_empty_array;
static PyObject *__pyx_kp_s_Cannot_re_open_htsfile;
static PyObject *__pyx_kp_s_Cannot_set_phased_before_genotyp;
static PyObject *__pyx_kp_s_Cannot_specify_an_index_filename;
static PyObject *__pyx_kp_s_Cannot_translate_record_Number_o;
static PyObject *__pyx_n_s_Description;
static PyObject *__pyx_kp_s_Duplicated_sample_name;
static PyObject *__pyx_n_b_END;
static PyObject *__pyx_n_s_END;
static PyObject *__pyx_kp_s_END_is_a_reserved_attribute_acce;
static PyObject *__pyx_kp_s_Error_s_reading_record;
static PyObject *__pyx_kp_s_Error_unpacking_VariantRecord;
static PyObject *__pyx_kp_s_Error_updating_alleles;
static PyObject *__pyx_kp_s_Error_updating_id;
static PyObject *__pyx_n_s_FILTER;
static PyObject *__pyx_n_s_FIXED;
static PyObject *__pyx_n_s_FORMAT;
static PyObject *__pyx_n_s_Flag;
static PyObject *__pyx_kp_s_Flag_types_are_not_allowed_on_FO;
static PyObject *__pyx_kp_s_Flag_values_must_be_True_False_N;
static PyObject *__pyx_n_s_Float;
static PyObject *__pyx_n_s_G;
static PyObject *__pyx_n_s_GENERIC;
static PyObject *__pyx_n_s_GT;
static PyObject *__pyx_kp_s_Header_already_exists_for_contig;
static PyObject *__pyx_kp_s_Header_already_exists_for_id;
static PyObject *__pyx_n_s_ID;
static PyObject *__pyx_n_s_INFO;
static PyObject *__pyx_n_s_IOError;
static PyObject *__pyx_kp_s_I_O_operation_on_closed_file;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x09;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x5d;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x9d;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xbe;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xd9;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xde;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xed;
static PyObject *__pyx_n_s_IndexError;
static PyObject *__pyx_n_s_Integer;
static PyObject *__pyx_kp_s_Integer_value_too_small_large_to;
static PyObject *__pyx_kp_s_Invalid_INFO_field;
static PyObject *__pyx_kp_s_Invalid_VariantRecord_Number_of;
static PyObject *__pyx_kp_s_Invalid_allele_index;
static PyObject *__pyx_kp_s_Invalid_chromosome_contig;
static PyObject *__pyx_kp_s_Invalid_filter;
static PyObject *__pyx_kp_s_Invalid_header;
static PyObject *__pyx_kp_s_Invalid_header_id;
static PyObject *__pyx_kp_s_Invalid_header_record_index;
static PyObject *__pyx_kp_s_Invalid_index_object;
static PyObject *__pyx_kp_s_Invalid_tid;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_n_s_MemoryError;
static PyObject *__pyx_kp_s_NON_REF;
static PyObject *__pyx_n_s_NotImplemented;
static PyObject *__pyx_n_s_Number;
static PyObject *__pyx_kp_s_Number_must_be_None_when_adding;
static PyObject *__pyx_n_s_PASS;
static PyObject *__pyx_n_s_PickleError;
static PyObject *__pyx_kp_s_Position_must_be_positive;
static PyObject *__pyx_n_s_R;
static PyObject *__pyx_n_s_STRUCTURED;
static PyObject *__pyx_kp_s_Start_coordinate_must_be_non_neg;
static PyObject *__pyx_n_s_StopIteration;
static PyObject *__pyx_kp_s_Stop_coordinate_must_be_non_nega;
static PyObject *__pyx_kp_s_Stop_position_of_the_interval;
static PyObject *__pyx_n_s_String;
static PyObject *__pyx_n_s_Type;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_kp_s_Type_must_be_None_when_adding_a;
static PyObject *__pyx_kp_s_Unable_to_delete_END;
static PyObject *__pyx_kp_s_Unable_to_delete_FORMAT;
static PyObject *__pyx_kp_s_Unable_to_delete_INFO;
static PyObject *__pyx_kp_s_Unable_to_update_INFO_values;
static PyObject *__pyx_kp_s_Unable_to_update_format_values;
static PyObject *__pyx_kp_s_Unknown_INFO_field;
static PyObject *__pyx_kp_s_Unknown_allele;
static PyObject *__pyx_kp_s_Unknown_format_length;
static PyObject *__pyx_kp_s_Unsupported_FORMAT_type;
static PyObject *__pyx_kp_s_Unsupported_INFO_type;
static PyObject *__pyx_n_s_VARIABLE;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_s_VariantFile;
static PyObject *__pyx_n_s_VariantHeader;
static PyObject *__pyx_n_s_VariantHeaderContigs___iter;
static PyObject *__pyx_n_s_VariantHeaderContigs_iteritems;
static PyObject *__pyx_n_s_VariantHeaderContigs_itervalues;
static PyObject *__pyx_n_s_VariantHeaderMetadata___iter;
static PyObject *__pyx_n_s_VariantHeaderMetadata_iteritems;
static PyObject *__pyx_n_s_VariantHeaderMetadata_itervalues;
static PyObject *__pyx_n_s_VariantHeaderRecord;
static PyObject *__pyx_n_s_VariantHeaderRecord___get___loca;
static PyObject *__pyx_n_s_VariantHeaderRecord___iter;
static PyObject *__pyx_n_s_VariantHeaderRecord_iteritems;
static PyObject *__pyx_n_s_VariantHeaderRecord_itervalues;
static PyObject *__pyx_n_s_VariantHeaderRecords___iter;
static PyObject *__pyx_n_s_VariantHeaderSamples___iter;
static PyObject *__pyx_n_s_VariantRecord;
static PyObject *__pyx_n_s_VariantRecordFilter___iter;
static PyObject *__pyx_n_s_VariantRecordFilter_iteritems;
static PyObject *__pyx_n_s_VariantRecordFilter_itervalues;
static PyObject *__pyx_n_s_VariantRecordFormat___iter;
static PyObject *__pyx_n_s_VariantRecordFormat_iteritems;
static PyObject *__pyx_n_s_VariantRecordFormat_itervalues;
static PyObject *__pyx_n_s_VariantRecordInfo___iter;
static PyObject *__pyx_n_s_VariantRecordInfo_iteritems;
static PyObject *__pyx_n_s_VariantRecordInfo_itervalues;
static PyObject *__pyx_n_s_VariantRecordSample___iter;
static PyObject *__pyx_n_s_VariantRecordSample_iteritems;
static PyObject *__pyx_n_s_VariantRecordSample_itervalues;
static PyObject *__pyx_n_s_VariantRecordSamples___iter;
static PyObject *__pyx_n_s_VariantRecordSamples_iteritems;
static PyObject *__pyx_n_s_VariantRecordSamples_itervalues;
static PyObject *__pyx_kp_b__15;
static PyObject *__pyx_kp_s__15;
static PyObject *__pyx_kp_s__175;
static PyObject *__pyx_kp_b__2;
static PyObject *__pyx_kp_s__2;
static PyObject *__pyx_kp_b__221;
static PyObject *__pyx_kp_b__71;
static PyObject *__pyx_kp_s__71;
static PyObject *__pyx_kp_s__74;
static PyObject *__pyx_n_s_add;
static PyObject *__pyx_n_s_add_meta;
static PyObject *__pyx_n_s_add_sample;
static PyObject *__pyx_n_s_all;
static PyObject *__pyx_n_s_alleles;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_ascii;
static PyObject *__pyx_n_s_bcf;
static PyObject *__pyx_kp_s_bcf_2;
static PyObject *__pyx_n_s_bcf_array_to_object_locals_genex;
static PyObject *__pyx_n_s_bcf_check_values_locals_genexpr;
static PyObject *__pyx_kp_s_bcf_hdr_set_samples_failed_ret;
static PyObject *__pyx_kp_s_bcf_index_required;
static PyObject *__pyx_kp_s_bcf_must_not_be_None;
static PyObject *__pyx_n_s_bcf_object_to_array_locals_genex;
static PyObject *__pyx_n_s_bcguz;
static PyObject *__pyx_n_s_bcguz0123456789ex;
static PyObject *__pyx_kp_s_cannot_convert_deleted_record_to;
static PyObject *__pyx_kp_s_cannot_create_VariantHeader;
static PyObject *__pyx_kp_s_cannot_create_VariantRecord;
static PyObject *__pyx_kp_s_cannot_create_VariantRecordSampl;
static PyObject *__pyx_kp_s_cannot_fetch_from_Variantfile_op;
static PyObject *__pyx_kp_s_cannot_find_metadata_key;
static PyObject *__pyx_kp_s_cannot_iterate_over_Variantfile;
static PyObject *__pyx_kp_s_cannot_set_null_allele;
static PyObject *__pyx_kp_s_cannot_set_null_alt_allele;
static PyObject *__pyx_kp_s_cannot_subset_samples_after_fetc;
static PyObject *__pyx_kp_s_cannot_subset_samples_from_Varia;
static PyObject *__pyx_kp_s_cannot_write_to_a_Variantfile_op;
static PyObject *__pyx_n_s_char_array_to_tuple_locals_genex;
static PyObject *__pyx_n_s_check_truncation;
static PyObject *__pyx_n_s_chr;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_n_s_contig;
static PyObject *__pyx_kp_s_contig_must_be_specified;
static PyObject *__pyx_n_s_copy;
static PyObject *__pyx_kp_s_could_not_open_file_mode;
static PyObject *__pyx_kp_s_could_not_open_variant_file;
static PyObject *__pyx_kp_s_could_not_open_variant_file_2;
static PyObject *__pyx_n_s_decode;
static PyObject *__pyx_n_s_default;
static PyObject *__pyx_n_s_description;
static PyObject *__pyx_n_s_dict;
static PyObject *__pyx_n_s_drop_samples;
static PyObject *__pyx_kp_s_dst_header_must_not_be_None;
static PyObject *__pyx_n_s_duplicate_filehandle;
static PyObject *__pyx_kp_s_either_value_or_items_must_be_sp;
static PyObject *__pyx_n_s_end;
static PyObject *__pyx_n_s_endswith;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_kp_s_error_in_bcf_subset_format;
static PyObject *__pyx_kp_s_error_in_vcf_parse;
static PyObject *__pyx_n_s_fetch;
static PyObject *__pyx_kp_s_fetch_requires_an_index;
static PyObject *__pyx_kp_s_file_does_not_have_valid_header;
static PyObject *__pyx_n_s_filename;
static PyObject *__pyx_n_s_filter;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_genexpr;
static PyObject *__pyx_kp_s_genotype_is_only_valid_as_a_form;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_get_reference_name;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_kp_s_gz;
static PyObject *__pyx_n_s_hash;
static PyObject *__pyx_n_s_header;
static PyObject *__pyx_kp_s_header_must_not_be_None;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_s_ignore_truncation;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_index_filename;
static PyObject *__pyx_n_s_info;
static PyObject *__pyx_n_s_init;
static PyObject *__pyx_kp_s_invalid_FORMAT;
static PyObject *__pyx_kp_s_invalid_VariantHeader;
static PyObject *__pyx_kp_s_invalid_VariantRecord;
static PyObject *__pyx_kp_s_invalid_character_found;
static PyObject *__pyx_kp_s_invalid_contig;
static PyObject *__pyx_kp_s_invalid_contig_2;
static PyObject *__pyx_kp_s_invalid_contig_id;
static PyObject *__pyx_kp_s_invalid_contig_index;
static PyObject *__pyx_kp_s_invalid_file_mode_is_it_VCF_BCF;
static PyObject *__pyx_kp_s_invalid_filter_index;
static PyObject *__pyx_kp_s_invalid_header_line;
static PyObject *__pyx_kp_s_invalid_header_record_index;
static PyObject *__pyx_kp_s_invalid_key;
static PyObject *__pyx_kp_s_invalid_metadata_id;
static PyObject *__pyx_kp_s_invalid_metadata_type;
static PyObject *__pyx_kp_s_invalid_mode_options;
static PyObject *__pyx_kp_s_invalid_number_of_columns;
static PyObject *__pyx_kp_s_invalid_reference_id;
static PyObject *__pyx_kp_s_invalid_sample_index;
static PyObject *__pyx_kp_s_invalid_sample_name;
static PyObject *__pyx_kp_s_invalid_tag;
static PyObject *__pyx_kp_s_invalid_value_for_Float_format;
static PyObject *__pyx_kp_s_invalid_value_for_Integer_format;
static PyObject *__pyx_n_s_is_open;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_n_s_iter;
static PyObject *__pyx_n_s_iteritems;
static PyObject *__pyx_n_s_itervalues;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_key;
static PyObject *__pyx_kp_s_limits_violated;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_kp_s_missing_d_requested_samples;
static PyObject *__pyx_n_s_mode;
static PyObject *__pyx_kp_s_mode_contains_conflicting_format;
static PyObject *__pyx_kp_s_mode_must_begin_with_r_w_or_a;
static PyObject *__pyx_kp_s_must_set_at_least_2_alleles;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_new;
static PyObject *__pyx_n_s_new_record;
static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
static PyObject *__pyx_n_s_number;
static PyObject *__pyx_n_s_object;
static PyObject *__pyx_n_s_open;
static PyObject *__pyx_n_s_os;
static PyObject *__pyx_n_s_parse_region;
static PyObject *__pyx_n_s_phased;
static PyObject *__pyx_n_s_pickle;
static PyObject *__pyx_n_s_pop;
static PyObject *__pyx_n_s_pysam_libcbcf;
static PyObject *__pyx_n_s_pyx_PickleError;
static PyObject *__pyx_n_s_pyx_checksum;
static PyObject *__pyx_n_s_pyx_result;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_type;
static PyObject *__pyx_n_s_pyx_unpickle_BaseIndex;
static PyObject *__pyx_n_s_pyx_unpickle_VariantContig;
static PyObject *__pyx_n_s_pyx_unpickle_VariantHeaderCont;
static PyObject *__pyx_n_s_pyx_unpickle_VariantHeaderMeta;
static PyObject *__pyx_n_s_pyx_unpickle_VariantHeaderReco;
static PyObject *__pyx_n_s_pyx_unpickle_VariantHeaderSamp;
static PyObject *__pyx_n_s_pyx_unpickle_VariantMetadata;
static PyObject *__pyx_n_s_pyx_unpickle_VariantRecordFilt;
static PyObject *__pyx_n_s_pyx_unpickle_VariantRecordForm;
static PyObject *__pyx_n_s_pyx_unpickle_VariantRecordInfo;
static PyObject *__pyx_n_s_pyx_unpickle_VariantRecordSamp;
static PyObject *__pyx_n_s_pyx_unpickle_VariantRecordSamp_2;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_qual;
static PyObject *__pyx_n_b_r;
static PyObject *__pyx_n_s_r;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_record;
static PyObject *__pyx_kp_s_record_must_not_be_None;
static PyObject *__pyx_n_s_records;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_ref;
static PyObject *__pyx_kp_s_ref_allele_must_not_be_null;
static PyObject *__pyx_n_s_reference;
static PyObject *__pyx_n_s_region;
static PyObject *__pyx_n_s_remap;
static PyObject *__pyx_n_s_reopen;
static PyObject *__pyx_n_s_reversed;
static PyObject *__pyx_n_s_rwa;
static PyObject *__pyx_kp_s_sample_must_not_be_None;
static PyObject *__pyx_n_s_samples;
static PyObject *__pyx_n_s_seek;
static PyObject *__pyx_kp_s_self_iter_cannot_be_converted_to;
static PyObject *__pyx_kp_s_self_ptr_cannot_be_converted_to;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_split;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_startswith;
static PyObject *__pyx_n_s_stop;
static PyObject *__pyx_kp_s_stringsource;
static PyObject *__pyx_n_s_strip;
static PyObject *__pyx_n_s_sys;
static PyObject *__pyx_kp_s_tabix_index_required;
static PyObject *__pyx_n_s_tell;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_kp_s_this_class_cannot_be_instantiate;
static PyObject *__pyx_n_s_threads;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_kp_s_truncated_file;
static PyObject *__pyx_n_s_type;
static PyObject *__pyx_kp_s_unable_to_allocate_BCF_record;
static PyObject *__pyx_kp_s_unable_to_fetch;
static PyObject *__pyx_kp_s_unable_to_fetch_next_record;
static PyObject *__pyx_kp_s_unknown_INFO;
static PyObject *__pyx_kp_s_unknown_format;
static PyObject *__pyx_kp_s_unknown_mode;
static PyObject *__pyx_kp_s_unknown_type_specified;
static PyObject *__pyx_kp_s_unsupported_header_type_code;
static PyObject *__pyx_kp_s_unsupported_info_type_code;
static PyObject *__pyx_kp_s_unsupported_type;
static PyObject *__pyx_kp_s_unsupported_types;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_n_s_upper;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_kp_s_value_expected_to_be_scalar_give;
static PyObject *__pyx_n_s_values;
static PyObject *__pyx_kp_s_values_expected_to_be_tuple_give;
static PyObject *__pyx_kp_s_vcf_format_failed;
static PyObject *__pyx_n_b_w;
static PyObject *__pyx_n_s_w;
static PyObject *__pyx_n_s_wb;
static PyObject *__pyx_n_s_wb0;
static PyObject *__pyx_n_s_wbu;
static PyObject *__pyx_n_s_write;
static PyObject *__pyx_n_s_wz;
static PyObject *__pyx_pf_5pysam_7libcbcf_19char_array_to_tuple_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19bcf_array_to_object_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19bcf_object_to_array_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_16bcf_check_values_genexpr(PyObject *__pyx_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_4type___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_3key___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_5value___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_5attrs_7__get___genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_5attrs___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_8__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_11get(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_13__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_15iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_17itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_20iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_23keys(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_25items(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_27values(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_29update(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_31pop(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_33__str__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_35remove(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_37__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_39__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static Py_ssize_t __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_8__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_11__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_13__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_15VariantMetadata___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_4name___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_2id___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_6number___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_4type___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_11description___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_6record___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_2remove_header(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_4__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_6__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_2add(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, PyObject *__pyx_v_id, PyObject *__pyx_v_number, PyObject *__pyx_v_type, PyObject *__pyx_v_description, PyObject *__pyx_v_kwargs); /* proto */
static Py_ssize_t __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_4__len__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_6__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_8__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_10remove_header(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_12clear_header(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_14__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_17get(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static int __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_19__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_21iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_23itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_26iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_29keys(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_31items(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_33values(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_35__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_37__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantContig___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_4name___get__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_2id___get__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_6length___get__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_13header_record___get__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_2remove_header(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_4__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_6__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static Py_ssize_t __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_8remove_header(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_10clear_header(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_12__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_15get(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_17__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_19iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_21itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_24iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_27keys(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_29items(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_31values(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_33add(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, PyObject *__pyx_v_id, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_35__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_37__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static Py_ssize_t __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_8__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_11__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_13add(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_15__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_17__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantHeader___cinit__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantHeader_2__init__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static void __pyx_pf_5pysam_7libcbcf_13VariantHeader_4__dealloc__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantHeader_6__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_8copy(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_10merge(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_7version___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_7samples___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_7records___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_7contigs___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_7filters___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_4info___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_7formats___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_4alts___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_12__str__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_14new_record(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_alleles, PyObject *__pyx_v_id, PyObject *__pyx_v_qual, PyObject *__pyx_v_filter, PyObject *__pyx_v_info, PyObject *__pyx_v_samples, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_16add_record(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_record); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_18add_line(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, PyObject *__pyx_v_line); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_20add_meta(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value, PyObject *__pyx_v_items); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_22add_sample(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_24__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_26__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static Py_ssize_t __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_8add(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_10__delitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_12clear(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_14__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_17get(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_19__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_21iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_23itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_26iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_29keys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_31items(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_33values(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_35__richcmp__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_other, int __pyx_v_op); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_37__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_39__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static Py_ssize_t __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_8__delitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_10clear(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_12__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_15get(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_17__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_19iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_21itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_24iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_27keys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_29items(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_31values(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_33__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_35__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static Py_ssize_t __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static int __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_8__setitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_10__delitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_12clear(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_14__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_17get(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static int __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_19__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_21iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_23itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_26iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_29keys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_31items(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_33values(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_35update(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_37pop(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_39__richcmp__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_other, int __pyx_v_op); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_41__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_43__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static Py_ssize_t __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_8__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_11get(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static int __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_13__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_15iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_17itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_20iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_23keys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_25items(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_27values(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_29update(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_31pop(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_33__richcmp__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_other, int __pyx_v_op); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_35__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_37__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static void __pyx_pf_5pysam_7libcbcf_13VariantRecord_2__dealloc__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_4copy(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_6translate(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_dst_header); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_3rid___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_3rid_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_5chrom___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_5chrom_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_6contig___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_6contig_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_3pos___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_3pos_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_5start___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_5start_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_4stop___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_4stop_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_4rlen___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_4rlen_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_4qual___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_4qual_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_2id___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_2id_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_3ref___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_3ref_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_7alleles___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_7alleles_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_values); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_4alts___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_4alts_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_6filter___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_4info___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_6format___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_7samples___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_8__richcmp__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_other, int __pyx_v_op); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_10__str__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_12__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_14__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_4name___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_14allele_indices___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_4__del__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_7alleles___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_7alleles_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_7alleles_4__del__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_6phased___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_6phased_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static Py_ssize_t __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_8__setitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_10__delitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_12clear(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_14__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_17get(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_19__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_21iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_23itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_26iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_29keys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_31items(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_33values(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_35update(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_37pop(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_39__richcmp__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_other, int __pyx_v_op); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_5index___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_41__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_43__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_9BaseIndex___init__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_5pysam_7libcbcf_9BaseIndex_2__len__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self); /* proto */
static int __pyx_pf_5pysam_7libcbcf_9BaseIndex_4__bool__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_8__iter__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_10get(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static int __pyx_pf_5pysam_7libcbcf_9BaseIndex_12__contains__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_14iterkeys(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_16itervalues(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_19iteritems(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_22keys(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_24items(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_26values(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_28update(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_30pop(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_32__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_34__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_8BCFIndex___init__(struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_self); /* proto */
static void __pyx_pf_5pysam_7libcbcf_8BCFIndex_2__dealloc__(struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_8BCFIndex_4fetch(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_self, PyObject *__pyx_v_bcf, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_reopen); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_8BCFIndex_6header___get__(struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_8BCFIndex_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_8BCFIndex_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_10TabixIndex___init__(struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_v_self); /* proto */
static void __pyx_pf_5pysam_7libcbcf_10TabixIndex_2__dealloc__(struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_10TabixIndex_4fetch(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_v_self, PyObject *__pyx_v_bcf, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_reopen); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_10TabixIndex_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_10TabixIndex_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_12BaseIterator___reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BaseIterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_12BaseIterator_2__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BaseIterator *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_11BCFIterator___init__(struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_bcf, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_reopen); /* proto */
static void __pyx_pf_5pysam_7libcbcf_11BCFIterator_2__dealloc__(struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11BCFIterator_4__iter__(struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11BCFIterator_6__next__(struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11BCFIterator_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11BCFIterator_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13TabixIterator___cinit__(struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static int __pyx_pf_5pysam_7libcbcf_13TabixIterator_2__init__(struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_bcf, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_reopen); /* proto */
static void __pyx_pf_5pysam_7libcbcf_13TabixIterator_4__dealloc__(struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13TabixIterator_6__iter__(struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13TabixIterator_8__next__(struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13TabixIterator_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_13TabixIterator_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5pysam_7libcbcf_11VariantFile___cinit__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static int __pyx_pf_5pysam_7libcbcf_11VariantFile_2__init__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static void __pyx_pf_5pysam_7libcbcf_11VariantFile_4__dealloc__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_6close(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_8__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_10__next__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_12copy(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_14open(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_filename, PyObject *__pyx_v_mode, PyObject *__pyx_v_index_filename, struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header, PyObject *__pyx_v_drop_samples, PyObject *__pyx_v_duplicate_filehandle, PyObject *__pyx_v_ignore_truncation, PyObject *__pyx_v_threads); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_16reset(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_18is_valid_tid(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_tid); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_20get_tid(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_reference); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_22get_reference_name(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_tid); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_24fetch(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_region, PyObject *__pyx_v_reopen, PyObject *__pyx_v_end, PyObject *__pyx_v_reference); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_26new_record(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_28write(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_30subset_samples(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_include_samples); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_5index___get__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_12drop_samples___get__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_10is_reading___get__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_14header_written___get__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_32__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_34__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf___pyx_unpickle_VariantHeaderRecords(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_2__pyx_unpickle_VariantMetadata(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_4__pyx_unpickle_VariantHeaderMetadata(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_6__pyx_unpickle_VariantContig(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_8__pyx_unpickle_VariantHeaderContigs(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_10__pyx_unpickle_VariantHeaderSamples(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_12__pyx_unpickle_VariantRecordFilter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_14__pyx_unpickle_VariantRecordFormat(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_16__pyx_unpickle_VariantRecordInfo(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_18__pyx_unpickle_VariantRecordSamples(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_20__pyx_unpickle_VariantRecordSample(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_5pysam_7libcbcf_22__pyx_unpickle_BaseIndex(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* 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_5pysam_7libcbcf_VariantHeader(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantHeaderRecord(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantHeaderRecords(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantHeaderContigs(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantHeaderSamples(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantContig(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantMetadata(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantHeaderMetadata(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantRecord(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantRecordFilter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantRecordFormat(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantRecordInfo(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantRecordSamples(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantRecordSample(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_BaseIndex(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_BCFIndex(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_TabixIndex(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_BaseIterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_BCFIterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_TabixIterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantFile(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_3_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_5_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_7_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_8___get__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_9_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_10___iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_11_itervalues(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_12_iteritems(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_13___iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_14___iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_15_itervalues(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_16_iteritems(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_17___iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_18_itervalues(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_19_iteritems(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_20___iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_21___iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_22_itervalues(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_23_iteritems(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_24___iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_25_itervalues(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_26_iteritems(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_27___iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_28_itervalues(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_29_iteritems(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_30___iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_31_itervalues(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_32_iteritems(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_33___iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_34_itervalues(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_35_iteritems(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_36_itervalues(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_37_iteritems(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PyBytes_Type_split = {0, &__pyx_n_s_split, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items = {0, &__pyx_n_s_items, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_10091417;
static PyObject *__pyx_int_97976187;
static PyObject *__pyx_int_164668780;
static PyObject *__pyx_int_199651019;
static PyObject *__pyx_int_227765731;
static PyObject *__pyx_int_232881935;
static PyObject *__pyx_int_248899179;
static PyObject *__pyx_int_4294967294;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_k__61;
static PyObject *__pyx_k__133;
static PyObject *__pyx_k__140;
static PyObject *__pyx_k__180;
static PyObject *__pyx_k__182;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__30;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__46;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__50;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__52;
static PyObject *__pyx_tuple__53;
static PyObject *__pyx_tuple__54;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__56;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__58;
static PyObject *__pyx_tuple__59;
static PyObject *__pyx_tuple__60;
static PyObject *__pyx_tuple__62;
static PyObject *__pyx_tuple__63;
static PyObject *__pyx_tuple__64;
static PyObject *__pyx_tuple__65;
static PyObject *__pyx_tuple__66;
static PyObject *__pyx_tuple__67;
static PyObject *__pyx_tuple__68;
static PyObject *__pyx_tuple__69;
static PyObject *__pyx_tuple__70;
static PyObject *__pyx_tuple__72;
static PyObject *__pyx_tuple__73;
static PyObject *__pyx_tuple__75;
static PyObject *__pyx_tuple__76;
static PyObject *__pyx_tuple__77;
static PyObject *__pyx_tuple__78;
static PyObject *__pyx_tuple__79;
static PyObject *__pyx_tuple__80;
static PyObject *__pyx_tuple__81;
static PyObject *__pyx_tuple__82;
static PyObject *__pyx_tuple__83;
static PyObject *__pyx_tuple__84;
static PyObject *__pyx_tuple__85;
static PyObject *__pyx_tuple__86;
static PyObject *__pyx_tuple__87;
static PyObject *__pyx_tuple__88;
static PyObject *__pyx_tuple__89;
static PyObject *__pyx_tuple__90;
static PyObject *__pyx_tuple__91;
static PyObject *__pyx_tuple__92;
static PyObject *__pyx_tuple__93;
static PyObject *__pyx_tuple__94;
static PyObject *__pyx_tuple__95;
static PyObject *__pyx_tuple__96;
static PyObject *__pyx_tuple__97;
static PyObject *__pyx_tuple__98;
static PyObject *__pyx_tuple__99;
static PyObject *__pyx_slice__217;
static PyObject *__pyx_slice__218;
static PyObject *__pyx_tuple__100;
static PyObject *__pyx_tuple__101;
static PyObject *__pyx_tuple__102;
static PyObject *__pyx_tuple__103;
static PyObject *__pyx_tuple__104;
static PyObject *__pyx_tuple__105;
static PyObject *__pyx_tuple__106;
static PyObject *__pyx_tuple__107;
static PyObject *__pyx_tuple__108;
static PyObject *__pyx_tuple__109;
static PyObject *__pyx_tuple__110;
static PyObject *__pyx_tuple__111;
static PyObject *__pyx_tuple__112;
static PyObject *__pyx_tuple__113;
static PyObject *__pyx_tuple__114;
static PyObject *__pyx_tuple__115;
static PyObject *__pyx_tuple__116;
static PyObject *__pyx_tuple__117;
static PyObject *__pyx_tuple__118;
static PyObject *__pyx_tuple__119;
static PyObject *__pyx_tuple__120;
static PyObject *__pyx_tuple__121;
static PyObject *__pyx_tuple__122;
static PyObject *__pyx_tuple__123;
static PyObject *__pyx_tuple__124;
static PyObject *__pyx_tuple__125;
static PyObject *__pyx_tuple__126;
static PyObject *__pyx_tuple__127;
static PyObject *__pyx_tuple__128;
static PyObject *__pyx_tuple__129;
static PyObject *__pyx_tuple__130;
static PyObject *__pyx_tuple__131;
static PyObject *__pyx_tuple__132;
static PyObject *__pyx_tuple__134;
static PyObject *__pyx_tuple__135;
static PyObject *__pyx_tuple__136;
static PyObject *__pyx_tuple__137;
static PyObject *__pyx_tuple__138;
static PyObject *__pyx_tuple__139;
static PyObject *__pyx_tuple__141;
static PyObject *__pyx_tuple__142;
static PyObject *__pyx_tuple__143;
static PyObject *__pyx_tuple__144;
static PyObject *__pyx_tuple__145;
static PyObject *__pyx_tuple__146;
static PyObject *__pyx_tuple__147;
static PyObject *__pyx_tuple__148;
static PyObject *__pyx_tuple__149;
static PyObject *__pyx_tuple__150;
static PyObject *__pyx_tuple__151;
static PyObject *__pyx_tuple__152;
static PyObject *__pyx_tuple__153;
static PyObject *__pyx_tuple__154;
static PyObject *__pyx_tuple__155;
static PyObject *__pyx_tuple__156;
static PyObject *__pyx_tuple__157;
static PyObject *__pyx_tuple__158;
static PyObject *__pyx_tuple__159;
static PyObject *__pyx_tuple__160;
static PyObject *__pyx_tuple__161;
static PyObject *__pyx_tuple__162;
static PyObject *__pyx_tuple__163;
static PyObject *__pyx_tuple__164;
static PyObject *__pyx_tuple__165;
static PyObject *__pyx_tuple__166;
static PyObject *__pyx_tuple__167;
static PyObject *__pyx_tuple__168;
static PyObject *__pyx_tuple__169;
static PyObject *__pyx_tuple__170;
static PyObject *__pyx_tuple__171;
static PyObject *__pyx_tuple__172;
static PyObject *__pyx_tuple__173;
static PyObject *__pyx_tuple__174;
static PyObject *__pyx_tuple__176;
static PyObject *__pyx_tuple__177;
static PyObject *__pyx_tuple__178;
static PyObject *__pyx_tuple__179;
static PyObject *__pyx_tuple__181;
static PyObject *__pyx_tuple__183;
static PyObject *__pyx_tuple__184;
static PyObject *__pyx_tuple__185;
static PyObject *__pyx_tuple__186;
static PyObject *__pyx_tuple__187;
static PyObject *__pyx_tuple__188;
static PyObject *__pyx_tuple__189;
static PyObject *__pyx_tuple__190;
static PyObject *__pyx_tuple__191;
static PyObject *__pyx_tuple__192;
static PyObject *__pyx_tuple__193;
static PyObject *__pyx_tuple__194;
static PyObject *__pyx_tuple__195;
static PyObject *__pyx_tuple__196;
static PyObject *__pyx_tuple__197;
static PyObject *__pyx_tuple__198;
static PyObject *__pyx_tuple__199;
static PyObject *__pyx_tuple__200;
static PyObject *__pyx_tuple__201;
static PyObject *__pyx_tuple__202;
static PyObject *__pyx_tuple__203;
static PyObject *__pyx_tuple__204;
static PyObject *__pyx_tuple__205;
static PyObject *__pyx_tuple__206;
static PyObject *__pyx_tuple__207;
static PyObject *__pyx_tuple__208;
static PyObject *__pyx_tuple__209;
static PyObject *__pyx_tuple__210;
static PyObject *__pyx_tuple__211;
static PyObject *__pyx_tuple__212;
static PyObject *__pyx_tuple__213;
static PyObject *__pyx_tuple__214;
static PyObject *__pyx_tuple__215;
static PyObject *__pyx_tuple__216;
static PyObject *__pyx_tuple__219;
static PyObject *__pyx_tuple__220;
static PyObject *__pyx_tuple__222;
static PyObject *__pyx_tuple__223;
static PyObject *__pyx_tuple__224;
static PyObject *__pyx_tuple__225;
static PyObject *__pyx_tuple__226;
static PyObject *__pyx_tuple__227;
static PyObject *__pyx_tuple__228;
static PyObject *__pyx_tuple__229;
static PyObject *__pyx_tuple__230;
static PyObject *__pyx_tuple__231;
static PyObject *__pyx_tuple__232;
static PyObject *__pyx_tuple__233;
static PyObject *__pyx_tuple__234;
static PyObject *__pyx_tuple__235;
static PyObject *__pyx_tuple__236;
static PyObject *__pyx_tuple__237;
static PyObject *__pyx_tuple__238;
static PyObject *__pyx_tuple__239;
static PyObject *__pyx_tuple__252;
static PyObject *__pyx_tuple__253;
static PyObject *__pyx_tuple__254;
static PyObject *__pyx_tuple__255;
static PyObject *__pyx_tuple__256;
static PyObject *__pyx_tuple__257;
static PyObject *__pyx_tuple__258;
static PyObject *__pyx_tuple__259;
static PyObject *__pyx_tuple__260;
static PyObject *__pyx_tuple__261;
static PyObject *__pyx_tuple__262;
static PyObject *__pyx_tuple__263;
static PyObject *__pyx_tuple__264;
static PyObject *__pyx_tuple__265;
static PyObject *__pyx_tuple__266;
static PyObject *__pyx_codeobj__240;
static PyObject *__pyx_codeobj__241;
static PyObject *__pyx_codeobj__242;
static PyObject *__pyx_codeobj__243;
static PyObject *__pyx_codeobj__244;
static PyObject *__pyx_codeobj__245;
static PyObject *__pyx_codeobj__246;
static PyObject *__pyx_codeobj__247;
static PyObject *__pyx_codeobj__248;
static PyObject *__pyx_codeobj__249;
static PyObject *__pyx_codeobj__250;
static PyObject *__pyx_codeobj__251;
/* Late includes */

/* "pysam/libcbcf.pyx":143
 * cdef dict bcf_str_cache = {}
 * 
 * cdef inline bcf_str_cache_get_charptr(const char* s):             # <<<<<<<<<<<<<<
 *     if s == NULL:
 *         return None
 */

static CYTHON_INLINE PyObject *__pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(char const *__pyx_v_s) {
  PyObject *__pyx_v_pystr;
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("bcf_str_cache_get_charptr", 0);
  __Pyx_TraceCall("bcf_str_cache_get_charptr", __pyx_f[0], 143, 0, __PYX_ERR(0, 143, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":144
 * 
 * cdef inline bcf_str_cache_get_charptr(const char* s):
 *     if s == NULL:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_1 = ((__pyx_v_s == NULL) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":145
 * cdef inline bcf_str_cache_get_charptr(const char* s):
 *     if s == NULL:
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     cdef PyObject *pystr = PyDict_GetItemString(bcf_str_cache, s)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":144
 * 
 * cdef inline bcf_str_cache_get_charptr(const char* s):
 *     if s == NULL:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  }

  /* "pysam/libcbcf.pyx":147
 *         return None
 * 
 *     cdef PyObject *pystr = PyDict_GetItemString(bcf_str_cache, s)             # <<<<<<<<<<<<<<
 *     if pystr:
 *         return <object>pystr
 */
  __pyx_t_2 = __pyx_v_5pysam_7libcbcf_bcf_str_cache;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_pystr = PyDict_GetItemString(__pyx_t_2, __pyx_v_s);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":148
 * 
 *     cdef PyObject *pystr = PyDict_GetItemString(bcf_str_cache, s)
 *     if pystr:             # <<<<<<<<<<<<<<
 *         return <object>pystr
 * 
 */
  __pyx_t_1 = (__pyx_v_pystr != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":149
 *     cdef PyObject *pystr = PyDict_GetItemString(bcf_str_cache, s)
 *     if pystr:
 *         return <object>pystr             # <<<<<<<<<<<<<<
 * 
 *     if PY_MAJOR_VERSION < 3:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_pystr));
    __pyx_r = ((PyObject *)__pyx_v_pystr);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":148
 * 
 *     cdef PyObject *pystr = PyDict_GetItemString(bcf_str_cache, s)
 *     if pystr:             # <<<<<<<<<<<<<<
 *         return <object>pystr
 * 
 */
  }

  /* "pysam/libcbcf.pyx":151
 *         return <object>pystr
 * 
 *     if PY_MAJOR_VERSION < 3:             # <<<<<<<<<<<<<<
 *         val = s
 *     else:
 */
  __pyx_t_1 = ((PY_MAJOR_VERSION < 3) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":152
 * 
 *     if PY_MAJOR_VERSION < 3:
 *         val = s             # <<<<<<<<<<<<<<
 *     else:
 *         val = PyUnicode_DecodeASCII(s, strlen(s), NULL)
 */
    __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_val = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "pysam/libcbcf.pyx":151
 *         return <object>pystr
 * 
 *     if PY_MAJOR_VERSION < 3:             # <<<<<<<<<<<<<<
 *         val = s
 *     else:
 */
    goto __pyx_L5;
  }

  /* "pysam/libcbcf.pyx":154
 *         val = s
 *     else:
 *         val = PyUnicode_DecodeASCII(s, strlen(s), NULL)             # <<<<<<<<<<<<<<
 * 
 *     PyDict_SetItemString(bcf_str_cache, s, val)
 */
  /*else*/ {
    __pyx_t_2 = PyUnicode_DecodeASCII(__pyx_v_s, strlen(__pyx_v_s), NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_val = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L5:;

  /* "pysam/libcbcf.pyx":156
 *         val = PyUnicode_DecodeASCII(s, strlen(s), NULL)
 * 
 *     PyDict_SetItemString(bcf_str_cache, s, val)             # <<<<<<<<<<<<<<
 * 
 *     return val
 */
  __pyx_t_2 = __pyx_v_5pysam_7libcbcf_bcf_str_cache;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = PyDict_SetItemString(__pyx_t_2, __pyx_v_s, __pyx_v_val); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":158
 *     PyDict_SetItemString(bcf_str_cache, s, val)
 * 
 *     return val             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_val);
  __pyx_r = __pyx_v_val;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":143
 * cdef dict bcf_str_cache = {}
 * 
 * cdef inline bcf_str_cache_get_charptr(const char* s):             # <<<<<<<<<<<<<<
 *     if s == NULL:
 *         return None
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_str_cache_get_charptr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":166
 * ########################################################################
 * 
 * cdef int comb(int n, int k) except -1:             # <<<<<<<<<<<<<<
 *     """Return binomial coeffient: n choose k
 * 
 */

static int __pyx_f_5pysam_7libcbcf_comb(int __pyx_v_n, int __pyx_v_k) {
  PyObject *__pyx_v_d = 0;
  PyObject *__pyx_v_result = 0;
  PyObject *__pyx_v_i = NULL;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("comb", 0);
  __Pyx_TraceCall("comb", __pyx_f[0], 166, 0, __PYX_ERR(0, 166, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":178
 *     4950
 *     """
 *     if k > n:             # <<<<<<<<<<<<<<
 *         return 0
 *     elif k == n:
 */
  __pyx_t_1 = ((__pyx_v_k > __pyx_v_n) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":179
 *     """
 *     if k > n:
 *         return 0             # <<<<<<<<<<<<<<
 *     elif k == n:
 *         return 1
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":178
 *     4950
 *     """
 *     if k > n:             # <<<<<<<<<<<<<<
 *         return 0
 *     elif k == n:
 */
  }

  /* "pysam/libcbcf.pyx":180
 *     if k > n:
 *         return 0
 *     elif k == n:             # <<<<<<<<<<<<<<
 *         return 1
 *     elif k > n // 2:
 */
  __pyx_t_1 = ((__pyx_v_k == __pyx_v_n) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":181
 *         return 0
 *     elif k == n:
 *         return 1             # <<<<<<<<<<<<<<
 *     elif k > n // 2:
 *         k = n - k
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":180
 *     if k > n:
 *         return 0
 *     elif k == n:             # <<<<<<<<<<<<<<
 *         return 1
 *     elif k > n // 2:
 */
  }

  /* "pysam/libcbcf.pyx":182
 *     elif k == n:
 *         return 1
 *     elif k > n // 2:             # <<<<<<<<<<<<<<
 *         k = n - k
 * 
 */
  __pyx_t_1 = ((__pyx_v_k > __Pyx_div_long(__pyx_v_n, 2)) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":183
 *         return 1
 *     elif k > n // 2:
 *         k = n - k             # <<<<<<<<<<<<<<
 * 
 *     cdef d, result
 */
    __pyx_v_k = (__pyx_v_n - __pyx_v_k);

    /* "pysam/libcbcf.pyx":182
 *     elif k == n:
 *         return 1
 *     elif k > n // 2:             # <<<<<<<<<<<<<<
 *         k = n - k
 * 
 */
  }

  /* "pysam/libcbcf.pyx":187
 *     cdef d, result
 * 
 *     d = result = n - k + 1             # <<<<<<<<<<<<<<
 *     for i in range(2, k + 1):
 *         d += 1
 */
  __pyx_t_2 = __Pyx_PyInt_From_long(((__pyx_v_n - __pyx_v_k) + 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_d = __pyx_t_2;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_result = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":188
 * 
 *     d = result = n - k + 1
 *     for i in range(2, k + 1):             # <<<<<<<<<<<<<<
 *         d += 1
 *         result  *= d
 */
  __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_k + 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 188, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 188, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 188, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 188, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 188, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pysam/libcbcf.pyx":189
 *     d = result = n - k + 1
 *     for i in range(2, k + 1):
 *         d += 1             # <<<<<<<<<<<<<<
 *         result  *= d
 *         result //= i
 */
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_d, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pysam/libcbcf.pyx":190
 *     for i in range(2, k + 1):
 *         d += 1
 *         result  *= d             # <<<<<<<<<<<<<<
 *         result //= i
 *     return result
 */
    __pyx_t_2 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_d); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pysam/libcbcf.pyx":191
 *         d += 1
 *         result  *= d
 *         result //= i             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_t_2 = PyNumber_InPlaceFloorDivide(__pyx_v_result, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pysam/libcbcf.pyx":188
 * 
 *     d = result = n - k + 1
 *     for i in range(2, k + 1):             # <<<<<<<<<<<<<<
 *         d += 1
 *         result  *= d
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":192
 *         result  *= d
 *         result //= i
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_result); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 192, __pyx_L1_error)
  __pyx_r = __pyx_t_6;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":166
 * ########################################################################
 * 
 * cdef int comb(int n, int k) except -1:             # <<<<<<<<<<<<<<
 *     """Return binomial coeffient: n choose k
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.comb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":195
 * 
 * 
 * cdef inline int bcf_geno_combinations(int ploidy, int alleles) except -1:             # <<<<<<<<<<<<<<
 *     """Return the count of genotypes expected for the given ploidy and number of alleles.
 * 
 */

static CYTHON_INLINE int __pyx_f_5pysam_7libcbcf_bcf_geno_combinations(int __pyx_v_ploidy, int __pyx_v_alleles) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("bcf_geno_combinations", 0);
  __Pyx_TraceCall("bcf_geno_combinations", __pyx_f[0], 195, 0, __PYX_ERR(0, 195, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":207
 *     4
 *     """
 *     return comb(alleles + ploidy - 1, ploidy)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf_comb(((__pyx_v_alleles + __pyx_v_ploidy) - 1), __pyx_v_ploidy); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 207, __pyx_L1_error)
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":195
 * 
 * 
 * cdef inline int bcf_geno_combinations(int ploidy, int alleles) except -1:             # <<<<<<<<<<<<<<
 *     """Return the count of genotypes expected for the given ploidy and number of alleles.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.bcf_geno_combinations", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":216
 * 
 * 
 * cdef inline bint check_header_id(bcf_hdr_t *hdr, int hl_type, int id):             # <<<<<<<<<<<<<<
 *     return id >= 0 and id < hdr.n[BCF_DT_ID] and bcf_hdr_idinfo_exists(hdr, hl_type, id)
 * 
 */

static CYTHON_INLINE int __pyx_f_5pysam_7libcbcf_check_header_id(bcf_hdr_t *__pyx_v_hdr, int __pyx_v_hl_type, int __pyx_v_id) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("check_header_id", 0);
  __Pyx_TraceCall("check_header_id", __pyx_f[0], 216, 0, __PYX_ERR(0, 216, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":217
 * 
 * cdef inline bint check_header_id(bcf_hdr_t *hdr, int hl_type, int id):
 *     return id >= 0 and id < hdr.n[BCF_DT_ID] and bcf_hdr_idinfo_exists(hdr, hl_type, id)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = ((__pyx_v_id >= 0) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_id < (__pyx_v_hdr->n[BCF_DT_ID])) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_2 = (bcf_hdr_idinfo_exists(__pyx_v_hdr, __pyx_v_hl_type, __pyx_v_id) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":216
 * 
 * 
 * cdef inline bint check_header_id(bcf_hdr_t *hdr, int hl_type, int id):             # <<<<<<<<<<<<<<
 *     return id >= 0 and id < hdr.n[BCF_DT_ID] and bcf_hdr_idinfo_exists(hdr, hl_type, id)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pysam.libcbcf.check_header_id", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":220
 * 
 * 
 * cdef inline int is_gt_fmt(bcf_hdr_t *hdr, int fmt_id):             # <<<<<<<<<<<<<<
 *     return strcmp(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt_id), 'GT') == 0
 * 
 */

static CYTHON_INLINE int __pyx_f_5pysam_7libcbcf_is_gt_fmt(bcf_hdr_t *__pyx_v_hdr, int __pyx_v_fmt_id) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_gt_fmt", 0);
  __Pyx_TraceCall("is_gt_fmt", __pyx_f[0], 220, 0, __PYX_ERR(0, 220, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":221
 * 
 * cdef inline int is_gt_fmt(bcf_hdr_t *hdr, int fmt_id):
 *     return strcmp(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt_id), 'GT') == 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = (strcmp(bcf_hdr_int2id(__pyx_v_hdr, BCF_DT_ID, __pyx_v_fmt_id), ((char const *)"GT")) == 0);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":220
 * 
 * 
 * cdef inline int is_gt_fmt(bcf_hdr_t *hdr, int fmt_id):             # <<<<<<<<<<<<<<
 *     return strcmp(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt_id), 'GT') == 0
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pysam.libcbcf.is_gt_fmt", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":224
 * 
 * 
 * cdef inline int bcf_genotype_count(bcf_hdr_t *hdr, bcf1_t *rec, int sample) except -1:             # <<<<<<<<<<<<<<
 * 
 *     if sample < 0:
 */

static CYTHON_INLINE int __pyx_f_5pysam_7libcbcf_bcf_genotype_count(bcf_hdr_t *__pyx_v_hdr, bcf1_t *__pyx_v_rec, int __pyx_v_sample) {
  int32_t *__pyx_v_gt_arr;
  int __pyx_v_ngt;
  int __pyx_v_max_ploidy;
  int32_t *__pyx_v_gt;
  int __pyx_v_ploidy;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("bcf_genotype_count", 0);
  __Pyx_TraceCall("bcf_genotype_count", __pyx_f[0], 224, 0, __PYX_ERR(0, 224, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":226
 * cdef inline int bcf_genotype_count(bcf_hdr_t *hdr, bcf1_t *rec, int sample) except -1:
 * 
 *     if sample < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('genotype is only valid as a format field')
 * 
 */
  __pyx_t_1 = ((__pyx_v_sample < 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":227
 * 
 *     if sample < 0:
 *         raise ValueError('genotype is only valid as a format field')             # <<<<<<<<<<<<<<
 * 
 *     cdef int32_t *gt_arr = NULL
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 227, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 227, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":226
 * cdef inline int bcf_genotype_count(bcf_hdr_t *hdr, bcf1_t *rec, int sample) except -1:
 * 
 *     if sample < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('genotype is only valid as a format field')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":229
 *         raise ValueError('genotype is only valid as a format field')
 * 
 *     cdef int32_t *gt_arr = NULL             # <<<<<<<<<<<<<<
 *     cdef int ngt = 0
 *     ngt = bcf_get_genotypes(hdr, rec, &gt_arr, &ngt)
 */
  __pyx_v_gt_arr = NULL;

  /* "pysam/libcbcf.pyx":230
 * 
 *     cdef int32_t *gt_arr = NULL
 *     cdef int ngt = 0             # <<<<<<<<<<<<<<
 *     ngt = bcf_get_genotypes(hdr, rec, &gt_arr, &ngt)
 * 
 */
  __pyx_v_ngt = 0;

  /* "pysam/libcbcf.pyx":231
 *     cdef int32_t *gt_arr = NULL
 *     cdef int ngt = 0
 *     ngt = bcf_get_genotypes(hdr, rec, &gt_arr, &ngt)             # <<<<<<<<<<<<<<
 * 
 *     if ngt <= 0 or not gt_arr:
 */
  __pyx_v_ngt = bcf_get_genotypes(__pyx_v_hdr, __pyx_v_rec, (&__pyx_v_gt_arr), (&__pyx_v_ngt));

  /* "pysam/libcbcf.pyx":233
 *     ngt = bcf_get_genotypes(hdr, rec, &gt_arr, &ngt)
 * 
 *     if ngt <= 0 or not gt_arr:             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  __pyx_t_3 = ((__pyx_v_ngt <= 0) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_3 = ((!(__pyx_v_gt_arr != 0)) != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":234
 * 
 *     if ngt <= 0 or not gt_arr:
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     assert ngt % rec.n_sample == 0
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":233
 *     ngt = bcf_get_genotypes(hdr, rec, &gt_arr, &ngt)
 * 
 *     if ngt <= 0 or not gt_arr:             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  }

  /* "pysam/libcbcf.pyx":236
 *         return 0
 * 
 *     assert ngt % rec.n_sample == 0             # <<<<<<<<<<<<<<
 *     cdef int max_ploidy = ngt // rec.n_sample
 *     cdef int32_t *gt = gt_arr + sample * max_ploidy
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(__pyx_v_rec->n_sample == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 236, __pyx_L1_error)
    }
    if (unlikely(!(((__pyx_v_ngt % __pyx_v_rec->n_sample) == 0) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 236, __pyx_L1_error)
    }
  }
  #endif

  /* "pysam/libcbcf.pyx":237
 * 
 *     assert ngt % rec.n_sample == 0
 *     cdef int max_ploidy = ngt // rec.n_sample             # <<<<<<<<<<<<<<
 *     cdef int32_t *gt = gt_arr + sample * max_ploidy
 *     cdef int ploidy = 0
 */
  if (unlikely(__pyx_v_rec->n_sample == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 237, __pyx_L1_error)
  }
  __pyx_v_max_ploidy = (__pyx_v_ngt / __pyx_v_rec->n_sample);

  /* "pysam/libcbcf.pyx":238
 *     assert ngt % rec.n_sample == 0
 *     cdef int max_ploidy = ngt // rec.n_sample
 *     cdef int32_t *gt = gt_arr + sample * max_ploidy             # <<<<<<<<<<<<<<
 *     cdef int ploidy = 0
 * 
 */
  __pyx_v_gt = (__pyx_v_gt_arr + (__pyx_v_sample * __pyx_v_max_ploidy));

  /* "pysam/libcbcf.pyx":239
 *     cdef int max_ploidy = ngt // rec.n_sample
 *     cdef int32_t *gt = gt_arr + sample * max_ploidy
 *     cdef int ploidy = 0             # <<<<<<<<<<<<<<
 * 
 *     while ploidy < max_ploidy and gt[0] != bcf_int32_vector_end:
 */
  __pyx_v_ploidy = 0;

  /* "pysam/libcbcf.pyx":241
 *     cdef int ploidy = 0
 * 
 *     while ploidy < max_ploidy and gt[0] != bcf_int32_vector_end:             # <<<<<<<<<<<<<<
 *         gt += 1
 *         ploidy += 1
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_ploidy < __pyx_v_max_ploidy) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_1 = __pyx_t_3;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_3 = (((__pyx_v_gt[0]) != bcf_int32_vector_end) != 0);
    __pyx_t_1 = __pyx_t_3;
    __pyx_L9_bool_binop_done:;
    if (!__pyx_t_1) break;

    /* "pysam/libcbcf.pyx":242
 * 
 *     while ploidy < max_ploidy and gt[0] != bcf_int32_vector_end:
 *         gt += 1             # <<<<<<<<<<<<<<
 *         ploidy += 1
 * 
 */
    __pyx_v_gt = (__pyx_v_gt + 1);

    /* "pysam/libcbcf.pyx":243
 *     while ploidy < max_ploidy and gt[0] != bcf_int32_vector_end:
 *         gt += 1
 *         ploidy += 1             # <<<<<<<<<<<<<<
 * 
 *     free(<void*>gt_arr)
 */
    __pyx_v_ploidy = (__pyx_v_ploidy + 1);
  }

  /* "pysam/libcbcf.pyx":245
 *         ploidy += 1
 * 
 *     free(<void*>gt_arr)             # <<<<<<<<<<<<<<
 * 
 *     return bcf_geno_combinations(ploidy, rec.n_allele)
 */
  free(((void *)__pyx_v_gt_arr));

  /* "pysam/libcbcf.pyx":247
 *     free(<void*>gt_arr)
 * 
 *     return bcf_geno_combinations(ploidy, rec.n_allele)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __pyx_f_5pysam_7libcbcf_bcf_geno_combinations(__pyx_v_ploidy, __pyx_v_rec->n_allele); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 247, __pyx_L1_error)
  __pyx_r = __pyx_t_4;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":224
 * 
 * 
 * cdef inline int bcf_genotype_count(bcf_hdr_t *hdr, bcf1_t *rec, int sample) except -1:             # <<<<<<<<<<<<<<
 * 
 *     if sample < 0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_genotype_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19char_array_to_tuple_2generator28(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":254
 *         return None
 *     try:
 *          return tuple(charptr_to_str(a[i]) for i in range(n))             # <<<<<<<<<<<<<<
 *     finally:
 *         if free_after and a:
 */

static PyObject *__pyx_pf_5pysam_7libcbcf_19char_array_to_tuple_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_1_genexpr(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 254, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19char_array_to_tuple_2generator28, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_char_array_to_tuple_locals_genex, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 254, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.char_array_to_tuple.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_5pysam_7libcbcf_19char_array_to_tuple_2generator28(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __Pyx_TraceCall("genexpr", __pyx_f[0], 254, 0, __PYX_ERR(0, 254, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 254, __pyx_L1_error)
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_n;
  __pyx_t_2 = __pyx_t_1;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_3;
    __pyx_t_4 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_cur_scope->__pyx_outer_scope->__pyx_v_a[__pyx_cur_scope->__pyx_v_i]), NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 254, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 254, __pyx_L1_error)
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":250
 * 
 * 
 * cdef tuple char_array_to_tuple(const char **a, ssize_t n, int free_after=0):             # <<<<<<<<<<<<<<
 *     if not a:
 *         return None
 */

static PyObject *__pyx_f_5pysam_7libcbcf_char_array_to_tuple(char const **__pyx_v_a, Py_ssize_t __pyx_v_n, struct __pyx_opt_args_5pysam_7libcbcf_char_array_to_tuple *__pyx_optional_args) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple *__pyx_cur_scope;
  int __pyx_v_free_after = ((int)0);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  char const *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("char_array_to_tuple", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 250, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __Pyx_TraceCall("char_array_to_tuple", __pyx_f[0], 250, 0, __PYX_ERR(0, 250, __pyx_L1_error));
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_free_after = __pyx_optional_args->free_after;
    }
  }
  __pyx_cur_scope->__pyx_v_a = __pyx_v_a;
  __pyx_cur_scope->__pyx_v_n = __pyx_v_n;

  /* "pysam/libcbcf.pyx":251
 * 
 * cdef tuple char_array_to_tuple(const char **a, ssize_t n, int free_after=0):
 *     if not a:             # <<<<<<<<<<<<<<
 *         return None
 *     try:
 */
  __pyx_t_1 = ((!(__pyx_cur_scope->__pyx_v_a != 0)) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":252
 * cdef tuple char_array_to_tuple(const char **a, ssize_t n, int free_after=0):
 *     if not a:
 *         return None             # <<<<<<<<<<<<<<
 *     try:
 *          return tuple(charptr_to_str(a[i]) for i in range(n))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":251
 * 
 * cdef tuple char_array_to_tuple(const char **a, ssize_t n, int free_after=0):
 *     if not a:             # <<<<<<<<<<<<<<
 *         return None
 *     try:
 */
  }

  /* "pysam/libcbcf.pyx":253
 *     if not a:
 *         return None
 *     try:             # <<<<<<<<<<<<<<
 *          return tuple(charptr_to_str(a[i]) for i in range(n))
 *     finally:
 */
  /*try:*/ {

    /* "pysam/libcbcf.pyx":254
 *         return None
 *     try:
 *          return tuple(charptr_to_str(a[i]) for i in range(n))             # <<<<<<<<<<<<<<
 *     finally:
 *         if free_after and a:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_pf_5pysam_7libcbcf_19char_array_to_tuple_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 254, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 254, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L4_return;
  }

  /* "pysam/libcbcf.pyx":256
 *          return tuple(charptr_to_str(a[i]) for i in range(n))
 *     finally:
 *         if free_after and a:             # <<<<<<<<<<<<<<
 *             free(a)
 * 
 */
  /*finally:*/ {
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
      {
        __pyx_t_13 = (__pyx_v_free_after != 0);
        if (__pyx_t_13) {
        } else {
          __pyx_t_1 = __pyx_t_13;
          goto __pyx_L10_bool_binop_done;
        }
        __pyx_t_13 = (__pyx_cur_scope->__pyx_v_a != 0);
        __pyx_t_1 = __pyx_t_13;
        __pyx_L10_bool_binop_done:;
        if (__pyx_t_1) {

          /* "pysam/libcbcf.pyx":257
 *     finally:
 *         if free_after and a:
 *             free(a)             # <<<<<<<<<<<<<<
 * 
 * 
 */
          free(__pyx_cur_scope->__pyx_v_a);

          /* "pysam/libcbcf.pyx":256
 *          return tuple(charptr_to_str(a[i]) for i in range(n))
 *     finally:
 *         if free_after and a:             # <<<<<<<<<<<<<<
 *             free(a)
 * 
 */
        }
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
      goto __pyx_L1_error;
    }
    __pyx_L4_return: {
      __pyx_t_14 = __pyx_r;
      __pyx_r = 0;
      __pyx_t_13 = (__pyx_v_free_after != 0);
      if (__pyx_t_13) {
      } else {
        __pyx_t_1 = __pyx_t_13;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_13 = (__pyx_cur_scope->__pyx_v_a != 0);
      __pyx_t_1 = __pyx_t_13;
      __pyx_L13_bool_binop_done:;
      if (__pyx_t_1) {

        /* "pysam/libcbcf.pyx":257
 *     finally:
 *         if free_after and a:
 *             free(a)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        free(__pyx_cur_scope->__pyx_v_a);

        /* "pysam/libcbcf.pyx":256
 *          return tuple(charptr_to_str(a[i]) for i in range(n))
 *     finally:
 *         if free_after and a:             # <<<<<<<<<<<<<<
 *             free(a)
 * 
 */
      }
      __pyx_r = __pyx_t_14;
      __pyx_t_14 = 0;
      goto __pyx_L0;
    }
  }

  /* "pysam/libcbcf.pyx":250
 * 
 * 
 * cdef tuple char_array_to_tuple(const char **a, ssize_t n, int free_after=0):             # <<<<<<<<<<<<<<
 *     if not a:
 *         return None
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.char_array_to_tuple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19bcf_array_to_object_2generator29(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":285
 *                 # Otherwise, copy the entire block
 *                 b = datac[:n]
 *             value = tuple(v.decode('ascii') if v and v != bcf_str_missing else None for v in b.split(b','))             # <<<<<<<<<<<<<<
 *     else:
 *         value = []
 */

static PyObject *__pyx_pf_5pysam_7libcbcf_19bcf_array_to_object_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_3_genexpr(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_3_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 285, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19bcf_array_to_object_2generator29, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_bcf_array_to_object_locals_genex, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 285, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.bcf_array_to_object.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_5pysam_7libcbcf_19bcf_array_to_object_2generator29(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __Pyx_TraceCall("genexpr", __pyx_f[0], 285, 0, __PYX_ERR(0, 285, __pyx_L1_error));
  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_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 285, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_b)) { __Pyx_RaiseClosureNameError("b"); __PYX_ERR(0, 285, __pyx_L1_error) }
  __pyx_t_1 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyBytes_Type_split, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_b, __pyx_kp_b__2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 285, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 285, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 285, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 285, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_v); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 285, __pyx_L1_error)
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_7 = __Pyx_PyInt_From_int32_t(bcf_str_missing); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 285, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_v, __pyx_t_7, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 285, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 285, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_5 = __pyx_t_6;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_5) {
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_v, __pyx_n_s_decode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 285, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 285, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_1 = __pyx_t_7;
      __pyx_t_7 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_1 = Py_None;
    }
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_XGIVEREF(__pyx_t_2);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_4;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* 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_3 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 285, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":260
 * 
 * 
 * cdef bcf_array_to_object(void *data, int type, ssize_t n, ssize_t count, int scalar):             # <<<<<<<<<<<<<<
 *     cdef char    *datac
 *     cdef int8_t  *data8
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_array_to_object(void *__pyx_v_data, int __pyx_v_type, Py_ssize_t __pyx_v_n, Py_ssize_t __pyx_v_count, int __pyx_v_scalar) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object *__pyx_cur_scope;
  char *__pyx_v_datac;
  int8_t *__pyx_v_data8;
  int16_t *__pyx_v_data16;
  int32_t *__pyx_v_data32;
  float *__pyx_v_dataf;
  int __pyx_v_i;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  __Pyx_RefNannySetupContext("bcf_array_to_object", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 260, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __Pyx_TraceCall("bcf_array_to_object", __pyx_f[0], 260, 0, __PYX_ERR(0, 260, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":269
 *     cdef bytes    b
 * 
 *     if not data or n <= 0:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_data != 0)) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_n <= 0) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":270
 * 
 *     if not data or n <= 0:
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     if type == BCF_BT_CHAR:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":269
 *     cdef bytes    b
 * 
 *     if not data or n <= 0:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  }

  /* "pysam/libcbcf.pyx":272
 *         return None
 * 
 *     if type == BCF_BT_CHAR:             # <<<<<<<<<<<<<<
 *         datac = <char *>data
 * 
 */
  __pyx_t_1 = ((__pyx_v_type == BCF_BT_CHAR) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":273
 * 
 *     if type == BCF_BT_CHAR:
 *         datac = <char *>data             # <<<<<<<<<<<<<<
 * 
 *         if not n:
 */
    __pyx_v_datac = ((char *)__pyx_v_data);

    /* "pysam/libcbcf.pyx":275
 *         datac = <char *>data
 * 
 *         if not n:             # <<<<<<<<<<<<<<
 *             value = ()
 *         else:
 */
    __pyx_t_1 = ((!(__pyx_v_n != 0)) != 0);
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":276
 * 
 *         if not n:
 *             value = ()             # <<<<<<<<<<<<<<
 *         else:
 *             # Check if at least one null terminator is present
 */
      __Pyx_INCREF(__pyx_empty_tuple);
      __pyx_v_value = __pyx_empty_tuple;

      /* "pysam/libcbcf.pyx":275
 *         datac = <char *>data
 * 
 *         if not n:             # <<<<<<<<<<<<<<
 *             value = ()
 *         else:
 */
      goto __pyx_L7;
    }

    /* "pysam/libcbcf.pyx":279
 *         else:
 *             # Check if at least one null terminator is present
 *             if datac[n-1] == bcf_str_vector_end:             # <<<<<<<<<<<<<<
 *                 # If so, create a string up to the first null terminator
 *                 b = datac
 */
    /*else*/ {
      __pyx_t_1 = (((__pyx_v_datac[(__pyx_v_n - 1)]) == bcf_str_vector_end) != 0);
      if (__pyx_t_1) {

        /* "pysam/libcbcf.pyx":281
 *             if datac[n-1] == bcf_str_vector_end:
 *                 # If so, create a string up to the first null terminator
 *                 b = datac             # <<<<<<<<<<<<<<
 *             else:
 *                 # Otherwise, copy the entire block
 */
        __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_datac); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_v_b = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;

        /* "pysam/libcbcf.pyx":279
 *         else:
 *             # Check if at least one null terminator is present
 *             if datac[n-1] == bcf_str_vector_end:             # <<<<<<<<<<<<<<
 *                 # If so, create a string up to the first null terminator
 *                 b = datac
 */
        goto __pyx_L8;
      }

      /* "pysam/libcbcf.pyx":284
 *             else:
 *                 # Otherwise, copy the entire block
 *                 b = datac[:n]             # <<<<<<<<<<<<<<
 *             value = tuple(v.decode('ascii') if v and v != bcf_str_missing else None for v in b.split(b','))
 *     else:
 */
      /*else*/ {
        __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_datac + 0, __pyx_v_n - 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_v_b = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;
      }
      __pyx_L8:;

      /* "pysam/libcbcf.pyx":285
 *                 # Otherwise, copy the entire block
 *                 b = datac[:n]
 *             value = tuple(v.decode('ascii') if v and v != bcf_str_missing else None for v in b.split(b','))             # <<<<<<<<<<<<<<
 *     else:
 *         value = []
 */
      __pyx_t_3 = __pyx_pf_5pysam_7libcbcf_19bcf_array_to_object_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 285, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_value = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __pyx_L7:;

    /* "pysam/libcbcf.pyx":272
 *         return None
 * 
 *     if type == BCF_BT_CHAR:             # <<<<<<<<<<<<<<
 *         datac = <char *>data
 * 
 */
    goto __pyx_L6;
  }

  /* "pysam/libcbcf.pyx":287
 *             value = tuple(v.decode('ascii') if v and v != bcf_str_missing else None for v in b.split(b','))
 *     else:
 *         value = []             # <<<<<<<<<<<<<<
 *         if type == BCF_BT_INT8:
 *             data8 = <int8_t *>data
 */
  /*else*/ {
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_value = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":288
 *     else:
 *         value = []
 *         if type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *             data8 = <int8_t *>data
 *             for i in range(n):
 */
    __pyx_t_1 = ((__pyx_v_type == BCF_BT_INT8) != 0);
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":289
 *         value = []
 *         if type == BCF_BT_INT8:
 *             data8 = <int8_t *>data             # <<<<<<<<<<<<<<
 *             for i in range(n):
 *                 if data8[i] == bcf_int8_vector_end:
 */
      __pyx_v_data8 = ((int8_t *)__pyx_v_data);

      /* "pysam/libcbcf.pyx":290
 *         if type == BCF_BT_INT8:
 *             data8 = <int8_t *>data
 *             for i in range(n):             # <<<<<<<<<<<<<<
 *                 if data8[i] == bcf_int8_vector_end:
 *                     break
 */
      __pyx_t_5 = __pyx_v_n;
      __pyx_t_6 = __pyx_t_5;
      for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
        __pyx_v_i = __pyx_t_7;

        /* "pysam/libcbcf.pyx":291
 *             data8 = <int8_t *>data
 *             for i in range(n):
 *                 if data8[i] == bcf_int8_vector_end:             # <<<<<<<<<<<<<<
 *                     break
 *                 value.append(data8[i] if data8[i] != bcf_int8_missing else None)
 */
        __pyx_t_1 = (((__pyx_v_data8[__pyx_v_i]) == bcf_int8_vector_end) != 0);
        if (__pyx_t_1) {

          /* "pysam/libcbcf.pyx":292
 *             for i in range(n):
 *                 if data8[i] == bcf_int8_vector_end:
 *                     break             # <<<<<<<<<<<<<<
 *                 value.append(data8[i] if data8[i] != bcf_int8_missing else None)
 *         elif type == BCF_BT_INT16:
 */
          goto __pyx_L11_break;

          /* "pysam/libcbcf.pyx":291
 *             data8 = <int8_t *>data
 *             for i in range(n):
 *                 if data8[i] == bcf_int8_vector_end:             # <<<<<<<<<<<<<<
 *                     break
 *                 value.append(data8[i] if data8[i] != bcf_int8_missing else None)
 */
        }

        /* "pysam/libcbcf.pyx":293
 *                 if data8[i] == bcf_int8_vector_end:
 *                     break
 *                 value.append(data8[i] if data8[i] != bcf_int8_missing else None)             # <<<<<<<<<<<<<<
 *         elif type == BCF_BT_INT16:
 *             data16 = <int16_t *>data
 */
        if ((((__pyx_v_data8[__pyx_v_i]) != bcf_int8_missing) != 0)) {
          __pyx_t_3 = __Pyx_PyInt_From_int8_t((__pyx_v_data8[__pyx_v_i])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 293, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __pyx_t_3;
          __pyx_t_3 = 0;
        } else {
          __Pyx_INCREF(Py_None);
          __pyx_t_4 = Py_None;
        }
        __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_value, __pyx_t_4); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 293, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_L11_break:;

      /* "pysam/libcbcf.pyx":288
 *     else:
 *         value = []
 *         if type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *             data8 = <int8_t *>data
 *             for i in range(n):
 */
      goto __pyx_L9;
    }

    /* "pysam/libcbcf.pyx":294
 *                     break
 *                 value.append(data8[i] if data8[i] != bcf_int8_missing else None)
 *         elif type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *             data16 = <int16_t *>data
 *             for i in range(n):
 */
    __pyx_t_1 = ((__pyx_v_type == BCF_BT_INT16) != 0);
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":295
 *                 value.append(data8[i] if data8[i] != bcf_int8_missing else None)
 *         elif type == BCF_BT_INT16:
 *             data16 = <int16_t *>data             # <<<<<<<<<<<<<<
 *             for i in range(n):
 *                 if data16[i] == bcf_int16_vector_end:
 */
      __pyx_v_data16 = ((int16_t *)__pyx_v_data);

      /* "pysam/libcbcf.pyx":296
 *         elif type == BCF_BT_INT16:
 *             data16 = <int16_t *>data
 *             for i in range(n):             # <<<<<<<<<<<<<<
 *                 if data16[i] == bcf_int16_vector_end:
 *                     break
 */
      __pyx_t_5 = __pyx_v_n;
      __pyx_t_6 = __pyx_t_5;
      for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
        __pyx_v_i = __pyx_t_7;

        /* "pysam/libcbcf.pyx":297
 *             data16 = <int16_t *>data
 *             for i in range(n):
 *                 if data16[i] == bcf_int16_vector_end:             # <<<<<<<<<<<<<<
 *                     break
 *                 value.append(data16[i] if data16[i] != bcf_int16_missing else None)
 */
        __pyx_t_1 = (((__pyx_v_data16[__pyx_v_i]) == bcf_int16_vector_end) != 0);
        if (__pyx_t_1) {

          /* "pysam/libcbcf.pyx":298
 *             for i in range(n):
 *                 if data16[i] == bcf_int16_vector_end:
 *                     break             # <<<<<<<<<<<<<<
 *                 value.append(data16[i] if data16[i] != bcf_int16_missing else None)
 *         elif type == BCF_BT_INT32:
 */
          goto __pyx_L14_break;

          /* "pysam/libcbcf.pyx":297
 *             data16 = <int16_t *>data
 *             for i in range(n):
 *                 if data16[i] == bcf_int16_vector_end:             # <<<<<<<<<<<<<<
 *                     break
 *                 value.append(data16[i] if data16[i] != bcf_int16_missing else None)
 */
        }

        /* "pysam/libcbcf.pyx":299
 *                 if data16[i] == bcf_int16_vector_end:
 *                     break
 *                 value.append(data16[i] if data16[i] != bcf_int16_missing else None)             # <<<<<<<<<<<<<<
 *         elif type == BCF_BT_INT32:
 *             data32 = <int32_t *>data
 */
        if ((((__pyx_v_data16[__pyx_v_i]) != bcf_int16_missing) != 0)) {
          __pyx_t_3 = __Pyx_PyInt_From_int16_t((__pyx_v_data16[__pyx_v_i])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 299, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __pyx_t_3;
          __pyx_t_3 = 0;
        } else {
          __Pyx_INCREF(Py_None);
          __pyx_t_4 = Py_None;
        }
        __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_value, __pyx_t_4); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 299, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_L14_break:;

      /* "pysam/libcbcf.pyx":294
 *                     break
 *                 value.append(data8[i] if data8[i] != bcf_int8_missing else None)
 *         elif type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *             data16 = <int16_t *>data
 *             for i in range(n):
 */
      goto __pyx_L9;
    }

    /* "pysam/libcbcf.pyx":300
 *                     break
 *                 value.append(data16[i] if data16[i] != bcf_int16_missing else None)
 *         elif type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *             data32 = <int32_t *>data
 *             for i in range(n):
 */
    __pyx_t_1 = ((__pyx_v_type == BCF_BT_INT32) != 0);
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":301
 *                 value.append(data16[i] if data16[i] != bcf_int16_missing else None)
 *         elif type == BCF_BT_INT32:
 *             data32 = <int32_t *>data             # <<<<<<<<<<<<<<
 *             for i in range(n):
 *                 if data32[i] == bcf_int32_vector_end:
 */
      __pyx_v_data32 = ((int32_t *)__pyx_v_data);

      /* "pysam/libcbcf.pyx":302
 *         elif type == BCF_BT_INT32:
 *             data32 = <int32_t *>data
 *             for i in range(n):             # <<<<<<<<<<<<<<
 *                 if data32[i] == bcf_int32_vector_end:
 *                     break
 */
      __pyx_t_5 = __pyx_v_n;
      __pyx_t_6 = __pyx_t_5;
      for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
        __pyx_v_i = __pyx_t_7;

        /* "pysam/libcbcf.pyx":303
 *             data32 = <int32_t *>data
 *             for i in range(n):
 *                 if data32[i] == bcf_int32_vector_end:             # <<<<<<<<<<<<<<
 *                     break
 *                 value.append(data32[i] if data32[i] != bcf_int32_missing else None)
 */
        __pyx_t_1 = (((__pyx_v_data32[__pyx_v_i]) == bcf_int32_vector_end) != 0);
        if (__pyx_t_1) {

          /* "pysam/libcbcf.pyx":304
 *             for i in range(n):
 *                 if data32[i] == bcf_int32_vector_end:
 *                     break             # <<<<<<<<<<<<<<
 *                 value.append(data32[i] if data32[i] != bcf_int32_missing else None)
 *         elif type == BCF_BT_FLOAT:
 */
          goto __pyx_L17_break;

          /* "pysam/libcbcf.pyx":303
 *             data32 = <int32_t *>data
 *             for i in range(n):
 *                 if data32[i] == bcf_int32_vector_end:             # <<<<<<<<<<<<<<
 *                     break
 *                 value.append(data32[i] if data32[i] != bcf_int32_missing else None)
 */
        }

        /* "pysam/libcbcf.pyx":305
 *                 if data32[i] == bcf_int32_vector_end:
 *                     break
 *                 value.append(data32[i] if data32[i] != bcf_int32_missing else None)             # <<<<<<<<<<<<<<
 *         elif type == BCF_BT_FLOAT:
 *             dataf = <float *>data
 */
        if ((((__pyx_v_data32[__pyx_v_i]) != bcf_int32_missing) != 0)) {
          __pyx_t_3 = __Pyx_PyInt_From_int32_t((__pyx_v_data32[__pyx_v_i])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __pyx_t_3;
          __pyx_t_3 = 0;
        } else {
          __Pyx_INCREF(Py_None);
          __pyx_t_4 = Py_None;
        }
        __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_value, __pyx_t_4); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 305, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_L17_break:;

      /* "pysam/libcbcf.pyx":300
 *                     break
 *                 value.append(data16[i] if data16[i] != bcf_int16_missing else None)
 *         elif type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *             data32 = <int32_t *>data
 *             for i in range(n):
 */
      goto __pyx_L9;
    }

    /* "pysam/libcbcf.pyx":306
 *                     break
 *                 value.append(data32[i] if data32[i] != bcf_int32_missing else None)
 *         elif type == BCF_BT_FLOAT:             # <<<<<<<<<<<<<<
 *             dataf = <float *>data
 *             for i in range(n):
 */
    __pyx_t_1 = ((__pyx_v_type == BCF_BT_FLOAT) != 0);
    if (likely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":307
 *                 value.append(data32[i] if data32[i] != bcf_int32_missing else None)
 *         elif type == BCF_BT_FLOAT:
 *             dataf = <float *>data             # <<<<<<<<<<<<<<
 *             for i in range(n):
 *                 if bcf_float_is_vector_end(dataf[i]):
 */
      __pyx_v_dataf = ((float *)__pyx_v_data);

      /* "pysam/libcbcf.pyx":308
 *         elif type == BCF_BT_FLOAT:
 *             dataf = <float *>data
 *             for i in range(n):             # <<<<<<<<<<<<<<
 *                 if bcf_float_is_vector_end(dataf[i]):
 *                     break
 */
      __pyx_t_5 = __pyx_v_n;
      __pyx_t_6 = __pyx_t_5;
      for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
        __pyx_v_i = __pyx_t_7;

        /* "pysam/libcbcf.pyx":309
 *             dataf = <float *>data
 *             for i in range(n):
 *                 if bcf_float_is_vector_end(dataf[i]):             # <<<<<<<<<<<<<<
 *                     break
 *                 value.append(dataf[i] if not bcf_float_is_missing(dataf[i]) else None)
 */
        __pyx_t_1 = (bcf_float_is_vector_end((__pyx_v_dataf[__pyx_v_i])) != 0);
        if (__pyx_t_1) {

          /* "pysam/libcbcf.pyx":310
 *             for i in range(n):
 *                 if bcf_float_is_vector_end(dataf[i]):
 *                     break             # <<<<<<<<<<<<<<
 *                 value.append(dataf[i] if not bcf_float_is_missing(dataf[i]) else None)
 *         else:
 */
          goto __pyx_L20_break;

          /* "pysam/libcbcf.pyx":309
 *             dataf = <float *>data
 *             for i in range(n):
 *                 if bcf_float_is_vector_end(dataf[i]):             # <<<<<<<<<<<<<<
 *                     break
 *                 value.append(dataf[i] if not bcf_float_is_missing(dataf[i]) else None)
 */
        }

        /* "pysam/libcbcf.pyx":311
 *                 if bcf_float_is_vector_end(dataf[i]):
 *                     break
 *                 value.append(dataf[i] if not bcf_float_is_missing(dataf[i]) else None)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('unsupported info type code')
 */
        if (((!(bcf_float_is_missing((__pyx_v_dataf[__pyx_v_i])) != 0)) != 0)) {
          __pyx_t_3 = PyFloat_FromDouble((__pyx_v_dataf[__pyx_v_i])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 311, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __pyx_t_3;
          __pyx_t_3 = 0;
        } else {
          __Pyx_INCREF(Py_None);
          __pyx_t_4 = Py_None;
        }
        __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_value, __pyx_t_4); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 311, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_L20_break:;

      /* "pysam/libcbcf.pyx":306
 *                     break
 *                 value.append(data32[i] if data32[i] != bcf_int32_missing else None)
 *         elif type == BCF_BT_FLOAT:             # <<<<<<<<<<<<<<
 *             dataf = <float *>data
 *             for i in range(n):
 */
      goto __pyx_L9;
    }

    /* "pysam/libcbcf.pyx":313
 *                 value.append(dataf[i] if not bcf_float_is_missing(dataf[i]) else None)
 *         else:
 *             raise TypeError('unsupported info type code')             # <<<<<<<<<<<<<<
 * 
 *     # FIXME: Need to know length?  Report errors?  Pad with missing values?  Not clear what to do.
 */
    /*else*/ {
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 313, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 313, __pyx_L1_error)
    }
    __pyx_L9:;
  }
  __pyx_L6:;

  /* "pysam/libcbcf.pyx":316
 * 
 *     # FIXME: Need to know length?  Report errors?  Pad with missing values?  Not clear what to do.
 *     if not value:             # <<<<<<<<<<<<<<
 *         if scalar:
 *             value = None
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 316, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":317
 *     # FIXME: Need to know length?  Report errors?  Pad with missing values?  Not clear what to do.
 *     if not value:
 *         if scalar:             # <<<<<<<<<<<<<<
 *             value = None
 *         elif count <= 0:
 */
    __pyx_t_2 = (__pyx_v_scalar != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":318
 *     if not value:
 *         if scalar:
 *             value = None             # <<<<<<<<<<<<<<
 *         elif count <= 0:
 *             value = ()
 */
      __Pyx_INCREF(Py_None);
      __Pyx_DECREF_SET(__pyx_v_value, Py_None);

      /* "pysam/libcbcf.pyx":317
 *     # FIXME: Need to know length?  Report errors?  Pad with missing values?  Not clear what to do.
 *     if not value:
 *         if scalar:             # <<<<<<<<<<<<<<
 *             value = None
 *         elif count <= 0:
 */
      goto __pyx_L23;
    }

    /* "pysam/libcbcf.pyx":319
 *         if scalar:
 *             value = None
 *         elif count <= 0:             # <<<<<<<<<<<<<<
 *             value = ()
 *         else:
 */
    __pyx_t_2 = ((__pyx_v_count <= 0) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":320
 *             value = None
 *         elif count <= 0:
 *             value = ()             # <<<<<<<<<<<<<<
 *         else:
 *             value = (None,)*count
 */
      __Pyx_INCREF(__pyx_empty_tuple);
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_empty_tuple);

      /* "pysam/libcbcf.pyx":319
 *         if scalar:
 *             value = None
 *         elif count <= 0:             # <<<<<<<<<<<<<<
 *             value = ()
 *         else:
 */
      goto __pyx_L23;
    }

    /* "pysam/libcbcf.pyx":322
 *             value = ()
 *         else:
 *             value = (None,)*count             # <<<<<<<<<<<<<<
 *     elif scalar and len(value) == 1:
 *         value = value[0]
 */
    /*else*/ {
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 322, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 322, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3);
      __pyx_t_3 = 0;
    }
    __pyx_L23:;

    /* "pysam/libcbcf.pyx":316
 * 
 *     # FIXME: Need to know length?  Report errors?  Pad with missing values?  Not clear what to do.
 *     if not value:             # <<<<<<<<<<<<<<
 *         if scalar:
 *             value = None
 */
    goto __pyx_L22;
  }

  /* "pysam/libcbcf.pyx":323
 *         else:
 *             value = (None,)*count
 *     elif scalar and len(value) == 1:             # <<<<<<<<<<<<<<
 *         value = value[0]
 *     else:
 */
  __pyx_t_1 = (__pyx_v_scalar != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L24_bool_binop_done;
  }
  __pyx_t_9 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 323, __pyx_L1_error)
  __pyx_t_1 = ((__pyx_t_9 == 1) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L24_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":324
 *             value = (None,)*count
 *     elif scalar and len(value) == 1:
 *         value = value[0]             # <<<<<<<<<<<<<<
 *     else:
 *         value = tuple(value)
 */
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_value, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 324, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":323
 *         else:
 *             value = (None,)*count
 *     elif scalar and len(value) == 1:             # <<<<<<<<<<<<<<
 *         value = value[0]
 *     else:
 */
    goto __pyx_L22;
  }

  /* "pysam/libcbcf.pyx":326
 *         value = value[0]
 *     else:
 *         value = tuple(value)             # <<<<<<<<<<<<<<
 * 
 *     return value
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L22:;

  /* "pysam/libcbcf.pyx":328
 *         value = tuple(value)
 * 
 *     return value             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_value);
  __pyx_r = __pyx_v_value;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":260
 * 
 * 
 * cdef bcf_array_to_object(void *data, int type, ssize_t n, ssize_t count, int scalar):             # <<<<<<<<<<<<<<
 *     cdef char    *datac
 *     cdef int8_t  *data8
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_array_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19bcf_object_to_array_2generator30(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":343
 *     if bt_type == BCF_BT_CHAR:
 *         if not isinstance(values, (str, bytes)):
 *             values = b','.join(force_bytes(v) if v else bcf_str_missing for v in values)             # <<<<<<<<<<<<<<
 *             value_count = len(values)
 *         assert value_count <= n
 */

static PyObject *__pyx_pf_5pysam_7libcbcf_19bcf_object_to_array_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_5_genexpr(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_5_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 343, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19bcf_object_to_array_2generator30, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_bcf_object_to_array_locals_genex, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 343, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.bcf_object_to_array.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_5pysam_7libcbcf_19bcf_object_to_array_2generator30(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __Pyx_TraceCall("genexpr", __pyx_f[0], 343, 0, __PYX_ERR(0, 343, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 343, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_values)) { __Pyx_RaiseClosureNameError("values"); __PYX_ERR(0, 343, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_values)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_values)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 343, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 343, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 343, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 343, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 343, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 343, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_v); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 343, __pyx_L1_error)
    if (__pyx_t_5) {
      __pyx_t_6 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_cur_scope->__pyx_v_v, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 343, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __pyx_t_6;
      __pyx_t_6 = 0;
    } else {
      __pyx_t_6 = __Pyx_PyInt_From_int32_t(bcf_str_missing); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 343, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __pyx_t_6;
      __pyx_t_6 = 0;
    }
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 343, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":331
 * 
 * 
 * cdef bcf_object_to_array(values, void *data, int bt_type, ssize_t n, int vlen):             # <<<<<<<<<<<<<<
 *     cdef char    *datac
 *     cdef int8_t  *data8
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_object_to_array(PyObject *__pyx_v_values, void *__pyx_v_data, int __pyx_v_bt_type, Py_ssize_t __pyx_v_n, CYTHON_UNUSED int __pyx_v_vlen) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *__pyx_cur_scope;
  char *__pyx_v_datac;
  float *__pyx_v_dataf;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_value_count;
  int8_t *__pyx_v_datai8;
  PyObject *__pyx_v_val = NULL;
  int16_t *__pyx_v_datai16;
  int32_t *__pyx_v_datai32;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  char *__pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  int8_t __pyx_t_11;
  int8_t __pyx_t_12;
  int16_t __pyx_t_13;
  int16_t __pyx_t_14;
  int32_t __pyx_t_15;
  int32_t __pyx_t_16;
  float __pyx_t_17;
  __Pyx_RefNannySetupContext("bcf_object_to_array", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 331, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __Pyx_TraceCall("bcf_object_to_array", __pyx_f[0], 331, 0, __PYX_ERR(0, 331, __pyx_L1_error));
  __pyx_cur_scope->__pyx_v_values = __pyx_v_values;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_values);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_values);

  /* "pysam/libcbcf.pyx":337
 *     cdef int32_t *data32
 *     cdef float   *dataf
 *     cdef ssize_t  i, value_count = len(values)             # <<<<<<<<<<<<<<
 * 
 *     assert value_count <= n
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_values;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 337, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_value_count = __pyx_t_2;

  /* "pysam/libcbcf.pyx":339
 *     cdef ssize_t  i, value_count = len(values)
 * 
 *     assert value_count <= n             # <<<<<<<<<<<<<<
 * 
 *     if bt_type == BCF_BT_CHAR:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_value_count <= __pyx_v_n) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 339, __pyx_L1_error)
    }
  }
  #endif

  /* "pysam/libcbcf.pyx":341
 *     assert value_count <= n
 * 
 *     if bt_type == BCF_BT_CHAR:             # <<<<<<<<<<<<<<
 *         if not isinstance(values, (str, bytes)):
 *             values = b','.join(force_bytes(v) if v else bcf_str_missing for v in values)
 */
  __pyx_t_3 = ((__pyx_v_bt_type == BCF_BT_CHAR) != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":342
 * 
 *     if bt_type == BCF_BT_CHAR:
 *         if not isinstance(values, (str, bytes)):             # <<<<<<<<<<<<<<
 *             values = b','.join(force_bytes(v) if v else bcf_str_missing for v in values)
 *             value_count = len(values)
 */
    __pyx_t_1 = __pyx_cur_scope->__pyx_v_values;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_4 = PyString_Check(__pyx_t_1); 
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = (__pyx_t_4 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_1 = __pyx_cur_scope->__pyx_v_values;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_5 = PyBytes_Check(__pyx_t_1); 
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = (__pyx_t_5 != 0);
    __pyx_t_3 = __pyx_t_4;
    __pyx_L5_bool_binop_done:;
    __pyx_t_4 = ((!(__pyx_t_3 != 0)) != 0);
    if (__pyx_t_4) {

      /* "pysam/libcbcf.pyx":343
 *     if bt_type == BCF_BT_CHAR:
 *         if not isinstance(values, (str, bytes)):
 *             values = b','.join(force_bytes(v) if v else bcf_str_missing for v in values)             # <<<<<<<<<<<<<<
 *             value_count = len(values)
 *         assert value_count <= n
 */
      __pyx_t_1 = __pyx_pf_5pysam_7libcbcf_19bcf_object_to_array_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyBytes_Join(__pyx_kp_b__2, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 343, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_values);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_values, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_6 = 0;

      /* "pysam/libcbcf.pyx":344
 *         if not isinstance(values, (str, bytes)):
 *             values = b','.join(force_bytes(v) if v else bcf_str_missing for v in values)
 *             value_count = len(values)             # <<<<<<<<<<<<<<
 *         assert value_count <= n
 *         datac = <char *>data
 */
      __pyx_t_6 = __pyx_cur_scope->__pyx_v_values;
      __Pyx_INCREF(__pyx_t_6);
      __pyx_t_2 = PyObject_Length(__pyx_t_6); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 344, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_value_count = __pyx_t_2;

      /* "pysam/libcbcf.pyx":342
 * 
 *     if bt_type == BCF_BT_CHAR:
 *         if not isinstance(values, (str, bytes)):             # <<<<<<<<<<<<<<
 *             values = b','.join(force_bytes(v) if v else bcf_str_missing for v in values)
 *             value_count = len(values)
 */
    }

    /* "pysam/libcbcf.pyx":345
 *             values = b','.join(force_bytes(v) if v else bcf_str_missing for v in values)
 *             value_count = len(values)
 *         assert value_count <= n             # <<<<<<<<<<<<<<
 *         datac = <char *>data
 *         memcpy(datac, <char *>values, value_count)
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      if (unlikely(!((__pyx_v_value_count <= __pyx_v_n) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(0, 345, __pyx_L1_error)
      }
    }
    #endif

    /* "pysam/libcbcf.pyx":346
 *             value_count = len(values)
 *         assert value_count <= n
 *         datac = <char *>data             # <<<<<<<<<<<<<<
 *         memcpy(datac, <char *>values, value_count)
 *         for i in range(value_count, n):
 */
    __pyx_v_datac = ((char *)__pyx_v_data);

    /* "pysam/libcbcf.pyx":347
 *         assert value_count <= n
 *         datac = <char *>data
 *         memcpy(datac, <char *>values, value_count)             # <<<<<<<<<<<<<<
 *         for i in range(value_count, n):
 *             datac[i] = 0
 */
    __pyx_t_7 = __Pyx_PyObject_AsWritableString(__pyx_cur_scope->__pyx_v_values); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 347, __pyx_L1_error)
    (void)(memcpy(__pyx_v_datac, ((char *)__pyx_t_7), __pyx_v_value_count));

    /* "pysam/libcbcf.pyx":348
 *         datac = <char *>data
 *         memcpy(datac, <char *>values, value_count)
 *         for i in range(value_count, n):             # <<<<<<<<<<<<<<
 *             datac[i] = 0
 *     elif bt_type == BCF_BT_INT8:
 */
    __pyx_t_8 = __pyx_v_n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = __pyx_v_value_count; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":349
 *         memcpy(datac, <char *>values, value_count)
 *         for i in range(value_count, n):
 *             datac[i] = 0             # <<<<<<<<<<<<<<
 *     elif bt_type == BCF_BT_INT8:
 *         datai8 = <int8_t *>data
 */
      (__pyx_v_datac[__pyx_v_i]) = 0;
    }

    /* "pysam/libcbcf.pyx":341
 *     assert value_count <= n
 * 
 *     if bt_type == BCF_BT_CHAR:             # <<<<<<<<<<<<<<
 *         if not isinstance(values, (str, bytes)):
 *             values = b','.join(force_bytes(v) if v else bcf_str_missing for v in values)
 */
    goto __pyx_L3;
  }

  /* "pysam/libcbcf.pyx":350
 *         for i in range(value_count, n):
 *             datac[i] = 0
 *     elif bt_type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *         datai8 = <int8_t *>data
 *         for i in range(value_count):
 */
  __pyx_t_4 = ((__pyx_v_bt_type == BCF_BT_INT8) != 0);
  if (__pyx_t_4) {

    /* "pysam/libcbcf.pyx":351
 *             datac[i] = 0
 *     elif bt_type == BCF_BT_INT8:
 *         datai8 = <int8_t *>data             # <<<<<<<<<<<<<<
 *         for i in range(value_count):
 *             val = values[i]
 */
    __pyx_v_datai8 = ((int8_t *)__pyx_v_data);

    /* "pysam/libcbcf.pyx":352
 *     elif bt_type == BCF_BT_INT8:
 *         datai8 = <int8_t *>data
 *         for i in range(value_count):             # <<<<<<<<<<<<<<
 *             val = values[i]
 *             datai8[i] = val if val is not None else bcf_int8_missing
 */
    __pyx_t_8 = __pyx_v_value_count;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":353
 *         datai8 = <int8_t *>data
 *         for i in range(value_count):
 *             val = values[i]             # <<<<<<<<<<<<<<
 *             datai8[i] = val if val is not None else bcf_int8_missing
 *         for i in range(value_count, n):
 */
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_values, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 353, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pysam/libcbcf.pyx":354
 *         for i in range(value_count):
 *             val = values[i]
 *             datai8[i] = val if val is not None else bcf_int8_missing             # <<<<<<<<<<<<<<
 *         for i in range(value_count, n):
 *             datai8[i] = bcf_int8_vector_end
 */
      __pyx_t_4 = (__pyx_v_val != Py_None);
      if ((__pyx_t_4 != 0)) {
        __pyx_t_12 = __Pyx_PyInt_As_int8_t(__pyx_v_val); if (unlikely((__pyx_t_12 == ((int8_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 354, __pyx_L1_error)
        __pyx_t_11 = __pyx_t_12;
      } else {
        __pyx_t_11 = bcf_int8_missing;
      }
      (__pyx_v_datai8[__pyx_v_i]) = __pyx_t_11;
    }

    /* "pysam/libcbcf.pyx":355
 *             val = values[i]
 *             datai8[i] = val if val is not None else bcf_int8_missing
 *         for i in range(value_count, n):             # <<<<<<<<<<<<<<
 *             datai8[i] = bcf_int8_vector_end
 *     elif bt_type == BCF_BT_INT16:
 */
    __pyx_t_8 = __pyx_v_n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = __pyx_v_value_count; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":356
 *             datai8[i] = val if val is not None else bcf_int8_missing
 *         for i in range(value_count, n):
 *             datai8[i] = bcf_int8_vector_end             # <<<<<<<<<<<<<<
 *     elif bt_type == BCF_BT_INT16:
 *         datai16 = <int16_t *>data
 */
      (__pyx_v_datai8[__pyx_v_i]) = bcf_int8_vector_end;
    }

    /* "pysam/libcbcf.pyx":350
 *         for i in range(value_count, n):
 *             datac[i] = 0
 *     elif bt_type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *         datai8 = <int8_t *>data
 *         for i in range(value_count):
 */
    goto __pyx_L3;
  }

  /* "pysam/libcbcf.pyx":357
 *         for i in range(value_count, n):
 *             datai8[i] = bcf_int8_vector_end
 *     elif bt_type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *         datai16 = <int16_t *>data
 *         for i in range(value_count):
 */
  __pyx_t_4 = ((__pyx_v_bt_type == BCF_BT_INT16) != 0);
  if (__pyx_t_4) {

    /* "pysam/libcbcf.pyx":358
 *             datai8[i] = bcf_int8_vector_end
 *     elif bt_type == BCF_BT_INT16:
 *         datai16 = <int16_t *>data             # <<<<<<<<<<<<<<
 *         for i in range(value_count):
 *             val = values[i]
 */
    __pyx_v_datai16 = ((int16_t *)__pyx_v_data);

    /* "pysam/libcbcf.pyx":359
 *     elif bt_type == BCF_BT_INT16:
 *         datai16 = <int16_t *>data
 *         for i in range(value_count):             # <<<<<<<<<<<<<<
 *             val = values[i]
 *             datai16[i] = val if val is not None else bcf_int16_missing
 */
    __pyx_t_8 = __pyx_v_value_count;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":360
 *         datai16 = <int16_t *>data
 *         for i in range(value_count):
 *             val = values[i]             # <<<<<<<<<<<<<<
 *             datai16[i] = val if val is not None else bcf_int16_missing
 *         for i in range(value_count, n):
 */
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_values, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 360, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pysam/libcbcf.pyx":361
 *         for i in range(value_count):
 *             val = values[i]
 *             datai16[i] = val if val is not None else bcf_int16_missing             # <<<<<<<<<<<<<<
 *         for i in range(value_count, n):
 *             datai16[i] = bcf_int16_vector_end
 */
      __pyx_t_4 = (__pyx_v_val != Py_None);
      if ((__pyx_t_4 != 0)) {
        __pyx_t_14 = __Pyx_PyInt_As_int16_t(__pyx_v_val); if (unlikely((__pyx_t_14 == ((int16_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 361, __pyx_L1_error)
        __pyx_t_13 = __pyx_t_14;
      } else {
        __pyx_t_13 = bcf_int16_missing;
      }
      (__pyx_v_datai16[__pyx_v_i]) = __pyx_t_13;
    }

    /* "pysam/libcbcf.pyx":362
 *             val = values[i]
 *             datai16[i] = val if val is not None else bcf_int16_missing
 *         for i in range(value_count, n):             # <<<<<<<<<<<<<<
 *             datai16[i] = bcf_int16_vector_end
 *     elif bt_type == BCF_BT_INT32:
 */
    __pyx_t_8 = __pyx_v_n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = __pyx_v_value_count; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":363
 *             datai16[i] = val if val is not None else bcf_int16_missing
 *         for i in range(value_count, n):
 *             datai16[i] = bcf_int16_vector_end             # <<<<<<<<<<<<<<
 *     elif bt_type == BCF_BT_INT32:
 *         datai32 = <int32_t *>data
 */
      (__pyx_v_datai16[__pyx_v_i]) = bcf_int16_vector_end;
    }

    /* "pysam/libcbcf.pyx":357
 *         for i in range(value_count, n):
 *             datai8[i] = bcf_int8_vector_end
 *     elif bt_type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *         datai16 = <int16_t *>data
 *         for i in range(value_count):
 */
    goto __pyx_L3;
  }

  /* "pysam/libcbcf.pyx":364
 *         for i in range(value_count, n):
 *             datai16[i] = bcf_int16_vector_end
 *     elif bt_type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         datai32 = <int32_t *>data
 *         for i in range(value_count):
 */
  __pyx_t_4 = ((__pyx_v_bt_type == BCF_BT_INT32) != 0);
  if (__pyx_t_4) {

    /* "pysam/libcbcf.pyx":365
 *             datai16[i] = bcf_int16_vector_end
 *     elif bt_type == BCF_BT_INT32:
 *         datai32 = <int32_t *>data             # <<<<<<<<<<<<<<
 *         for i in range(value_count):
 *             val = values[i]
 */
    __pyx_v_datai32 = ((int32_t *)__pyx_v_data);

    /* "pysam/libcbcf.pyx":366
 *     elif bt_type == BCF_BT_INT32:
 *         datai32 = <int32_t *>data
 *         for i in range(value_count):             # <<<<<<<<<<<<<<
 *             val = values[i]
 *             datai32[i] = val if val is not None else bcf_int32_missing
 */
    __pyx_t_8 = __pyx_v_value_count;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":367
 *         datai32 = <int32_t *>data
 *         for i in range(value_count):
 *             val = values[i]             # <<<<<<<<<<<<<<
 *             datai32[i] = val if val is not None else bcf_int32_missing
 *         for i in range(value_count, n):
 */
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_values, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 367, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pysam/libcbcf.pyx":368
 *         for i in range(value_count):
 *             val = values[i]
 *             datai32[i] = val if val is not None else bcf_int32_missing             # <<<<<<<<<<<<<<
 *         for i in range(value_count, n):
 *             datai32[i] = bcf_int32_vector_end
 */
      __pyx_t_4 = (__pyx_v_val != Py_None);
      if ((__pyx_t_4 != 0)) {
        __pyx_t_16 = __Pyx_PyInt_As_int32_t(__pyx_v_val); if (unlikely((__pyx_t_16 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 368, __pyx_L1_error)
        __pyx_t_15 = __pyx_t_16;
      } else {
        __pyx_t_15 = bcf_int32_missing;
      }
      (__pyx_v_datai32[__pyx_v_i]) = __pyx_t_15;
    }

    /* "pysam/libcbcf.pyx":369
 *             val = values[i]
 *             datai32[i] = val if val is not None else bcf_int32_missing
 *         for i in range(value_count, n):             # <<<<<<<<<<<<<<
 *             datai32[i] = bcf_int32_vector_end
 *     elif bt_type == BCF_BT_FLOAT:
 */
    __pyx_t_8 = __pyx_v_n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = __pyx_v_value_count; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":370
 *             datai32[i] = val if val is not None else bcf_int32_missing
 *         for i in range(value_count, n):
 *             datai32[i] = bcf_int32_vector_end             # <<<<<<<<<<<<<<
 *     elif bt_type == BCF_BT_FLOAT:
 *         dataf = <float *>data
 */
      (__pyx_v_datai32[__pyx_v_i]) = bcf_int32_vector_end;
    }

    /* "pysam/libcbcf.pyx":364
 *         for i in range(value_count, n):
 *             datai16[i] = bcf_int16_vector_end
 *     elif bt_type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         datai32 = <int32_t *>data
 *         for i in range(value_count):
 */
    goto __pyx_L3;
  }

  /* "pysam/libcbcf.pyx":371
 *         for i in range(value_count, n):
 *             datai32[i] = bcf_int32_vector_end
 *     elif bt_type == BCF_BT_FLOAT:             # <<<<<<<<<<<<<<
 *         dataf = <float *>data
 *         for i in range(value_count):
 */
  __pyx_t_4 = ((__pyx_v_bt_type == BCF_BT_FLOAT) != 0);
  if (likely(__pyx_t_4)) {

    /* "pysam/libcbcf.pyx":372
 *             datai32[i] = bcf_int32_vector_end
 *     elif bt_type == BCF_BT_FLOAT:
 *         dataf = <float *>data             # <<<<<<<<<<<<<<
 *         for i in range(value_count):
 *             val = values[i]
 */
    __pyx_v_dataf = ((float *)__pyx_v_data);

    /* "pysam/libcbcf.pyx":373
 *     elif bt_type == BCF_BT_FLOAT:
 *         dataf = <float *>data
 *         for i in range(value_count):             # <<<<<<<<<<<<<<
 *             val = values[i]
 *             if val is None:
 */
    __pyx_t_8 = __pyx_v_value_count;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":374
 *         dataf = <float *>data
 *         for i in range(value_count):
 *             val = values[i]             # <<<<<<<<<<<<<<
 *             if val is None:
 *                 bcf_float_set(dataf + i, bcf_float_missing)
 */
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_values, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 374, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pysam/libcbcf.pyx":375
 *         for i in range(value_count):
 *             val = values[i]
 *             if val is None:             # <<<<<<<<<<<<<<
 *                 bcf_float_set(dataf + i, bcf_float_missing)
 *             else:
 */
      __pyx_t_4 = (__pyx_v_val == Py_None);
      __pyx_t_3 = (__pyx_t_4 != 0);
      if (__pyx_t_3) {

        /* "pysam/libcbcf.pyx":376
 *             val = values[i]
 *             if val is None:
 *                 bcf_float_set(dataf + i, bcf_float_missing)             # <<<<<<<<<<<<<<
 *             else:
 *                 dataf[i] = val
 */
        bcf_float_set((__pyx_v_dataf + __pyx_v_i), bcf_float_missing);

        /* "pysam/libcbcf.pyx":375
 *         for i in range(value_count):
 *             val = values[i]
 *             if val is None:             # <<<<<<<<<<<<<<
 *                 bcf_float_set(dataf + i, bcf_float_missing)
 *             else:
 */
        goto __pyx_L23;
      }

      /* "pysam/libcbcf.pyx":378
 *                 bcf_float_set(dataf + i, bcf_float_missing)
 *             else:
 *                 dataf[i] = val             # <<<<<<<<<<<<<<
 *         for i in range(value_count, n):
 *             bcf_float_set(dataf + i, bcf_float_vector_end)
 */
      /*else*/ {
        __pyx_t_17 = __pyx_PyFloat_AsFloat(__pyx_v_val); if (unlikely((__pyx_t_17 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
        (__pyx_v_dataf[__pyx_v_i]) = __pyx_t_17;
      }
      __pyx_L23:;
    }

    /* "pysam/libcbcf.pyx":379
 *             else:
 *                 dataf[i] = val
 *         for i in range(value_count, n):             # <<<<<<<<<<<<<<
 *             bcf_float_set(dataf + i, bcf_float_vector_end)
 *     else:
 */
    __pyx_t_8 = __pyx_v_n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = __pyx_v_value_count; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":380
 *                 dataf[i] = val
 *         for i in range(value_count, n):
 *             bcf_float_set(dataf + i, bcf_float_vector_end)             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError('unsupported type')
 */
      bcf_float_set((__pyx_v_dataf + __pyx_v_i), bcf_float_vector_end);
    }

    /* "pysam/libcbcf.pyx":371
 *         for i in range(value_count, n):
 *             datai32[i] = bcf_int32_vector_end
 *     elif bt_type == BCF_BT_FLOAT:             # <<<<<<<<<<<<<<
 *         dataf = <float *>data
 *         for i in range(value_count):
 */
    goto __pyx_L3;
  }

  /* "pysam/libcbcf.pyx":382
 *             bcf_float_set(dataf + i, bcf_float_vector_end)
 *     else:
 *         raise TypeError('unsupported type')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 382, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(0, 382, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "pysam/libcbcf.pyx":331
 * 
 * 
 * cdef bcf_object_to_array(values, void *data, int bt_type, ssize_t n, int vlen):             # <<<<<<<<<<<<<<
 *     cdef char    *datac
 *     cdef int8_t  *data8
 */

  /* 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_6);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_object_to_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":385
 * 
 * 
 * cdef bcf_empty_array(int type, ssize_t n, int vlen):             # <<<<<<<<<<<<<<
 *     cdef char    *datac
 *     cdef int32_t *data32
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_empty_array(int __pyx_v_type, Py_ssize_t __pyx_v_n, int __pyx_v_vlen) {
  char *__pyx_v_datac;
  int32_t *__pyx_v_data32;
  float *__pyx_v_dataf;
  int __pyx_v_i;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  char *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int32_t __pyx_t_7;
  uint32_t __pyx_t_8;
  __Pyx_RefNannySetupContext("bcf_empty_array", 0);
  __Pyx_TraceCall("bcf_empty_array", __pyx_f[0], 385, 0, __PYX_ERR(0, 385, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":391
 *     cdef int      i
 * 
 *     if n <= 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Cannot create empty array')
 * 
 */
  __pyx_t_1 = ((__pyx_v_n <= 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":392
 * 
 *     if n <= 0:
 *         raise ValueError('Cannot create empty array')             # <<<<<<<<<<<<<<
 * 
 *     if type == BCF_HT_STR:
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 392, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 392, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":391
 *     cdef int      i
 * 
 *     if n <= 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Cannot create empty array')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":394
 *         raise ValueError('Cannot create empty array')
 * 
 *     if type == BCF_HT_STR:             # <<<<<<<<<<<<<<
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(char)*n)
 *         datac = <char *>value
 */
  __pyx_t_1 = ((__pyx_v_type == BCF_HT_STR) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":395
 * 
 *     if type == BCF_HT_STR:
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(char)*n)             # <<<<<<<<<<<<<<
 *         datac = <char *>value
 *         for i in range(n):
 */
    __pyx_t_2 = PyBytes_FromStringAndSize(NULL, ((sizeof(char)) * __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_value = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "pysam/libcbcf.pyx":396
 *     if type == BCF_HT_STR:
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(char)*n)
 *         datac = <char *>value             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             datac[i] = bcf_str_missing if not vlen else bcf_str_vector_end
 */
    if (unlikely(__pyx_v_value == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 396, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_value); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 396, __pyx_L1_error)
    __pyx_v_datac = ((char *)__pyx_t_3);

    /* "pysam/libcbcf.pyx":397
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(char)*n)
 *         datac = <char *>value
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             datac[i] = bcf_str_missing if not vlen else bcf_str_vector_end
 *     elif type == BCF_HT_INT:
 */
    __pyx_t_4 = __pyx_v_n;
    __pyx_t_5 = __pyx_t_4;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_v_i = __pyx_t_6;

      /* "pysam/libcbcf.pyx":398
 *         datac = <char *>value
 *         for i in range(n):
 *             datac[i] = bcf_str_missing if not vlen else bcf_str_vector_end             # <<<<<<<<<<<<<<
 *     elif type == BCF_HT_INT:
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(int32_t)*n)
 */
      if (((!(__pyx_v_vlen != 0)) != 0)) {
        __pyx_t_7 = bcf_str_missing;
      } else {
        __pyx_t_7 = bcf_str_vector_end;
      }
      (__pyx_v_datac[__pyx_v_i]) = __pyx_t_7;
    }

    /* "pysam/libcbcf.pyx":394
 *         raise ValueError('Cannot create empty array')
 * 
 *     if type == BCF_HT_STR:             # <<<<<<<<<<<<<<
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(char)*n)
 *         datac = <char *>value
 */
    goto __pyx_L4;
  }

  /* "pysam/libcbcf.pyx":399
 *         for i in range(n):
 *             datac[i] = bcf_str_missing if not vlen else bcf_str_vector_end
 *     elif type == BCF_HT_INT:             # <<<<<<<<<<<<<<
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(int32_t)*n)
 *         data32 = <int32_t *><char *>value
 */
  __pyx_t_1 = ((__pyx_v_type == BCF_HT_INT) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":400
 *             datac[i] = bcf_str_missing if not vlen else bcf_str_vector_end
 *     elif type == BCF_HT_INT:
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(int32_t)*n)             # <<<<<<<<<<<<<<
 *         data32 = <int32_t *><char *>value
 *         for i in range(n):
 */
    __pyx_t_2 = PyBytes_FromStringAndSize(NULL, ((sizeof(int32_t)) * __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 400, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_value = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "pysam/libcbcf.pyx":401
 *     elif type == BCF_HT_INT:
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(int32_t)*n)
 *         data32 = <int32_t *><char *>value             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             data32[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 */
    if (unlikely(__pyx_v_value == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 401, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_value); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L1_error)
    __pyx_v_data32 = ((int32_t *)((char *)__pyx_t_3));

    /* "pysam/libcbcf.pyx":402
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(int32_t)*n)
 *         data32 = <int32_t *><char *>value
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             data32[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif type == BCF_HT_REAL:
 */
    __pyx_t_4 = __pyx_v_n;
    __pyx_t_5 = __pyx_t_4;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_v_i = __pyx_t_6;

      /* "pysam/libcbcf.pyx":403
 *         data32 = <int32_t *><char *>value
 *         for i in range(n):
 *             data32[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end             # <<<<<<<<<<<<<<
 *     elif type == BCF_HT_REAL:
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(float)*n)
 */
      if (((!(__pyx_v_vlen != 0)) != 0)) {
        __pyx_t_7 = bcf_int32_missing;
      } else {
        __pyx_t_7 = bcf_int32_vector_end;
      }
      (__pyx_v_data32[__pyx_v_i]) = __pyx_t_7;
    }

    /* "pysam/libcbcf.pyx":399
 *         for i in range(n):
 *             datac[i] = bcf_str_missing if not vlen else bcf_str_vector_end
 *     elif type == BCF_HT_INT:             # <<<<<<<<<<<<<<
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(int32_t)*n)
 *         data32 = <int32_t *><char *>value
 */
    goto __pyx_L4;
  }

  /* "pysam/libcbcf.pyx":404
 *         for i in range(n):
 *             data32[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif type == BCF_HT_REAL:             # <<<<<<<<<<<<<<
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(float)*n)
 *         dataf = <float *><char *>value
 */
  __pyx_t_1 = ((__pyx_v_type == BCF_HT_REAL) != 0);
  if (likely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":405
 *             data32[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif type == BCF_HT_REAL:
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(float)*n)             # <<<<<<<<<<<<<<
 *         dataf = <float *><char *>value
 *         for i in range(n):
 */
    __pyx_t_2 = PyBytes_FromStringAndSize(NULL, ((sizeof(float)) * __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 405, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_value = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "pysam/libcbcf.pyx":406
 *     elif type == BCF_HT_REAL:
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(float)*n)
 *         dataf = <float *><char *>value             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             bcf_float_set(dataf + i, bcf_float_missing if not vlen else bcf_float_vector_end)
 */
    if (unlikely(__pyx_v_value == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 406, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_value); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 406, __pyx_L1_error)
    __pyx_v_dataf = ((float *)((char *)__pyx_t_3));

    /* "pysam/libcbcf.pyx":407
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(float)*n)
 *         dataf = <float *><char *>value
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             bcf_float_set(dataf + i, bcf_float_missing if not vlen else bcf_float_vector_end)
 *     else:
 */
    __pyx_t_4 = __pyx_v_n;
    __pyx_t_5 = __pyx_t_4;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_v_i = __pyx_t_6;

      /* "pysam/libcbcf.pyx":408
 *         dataf = <float *><char *>value
 *         for i in range(n):
 *             bcf_float_set(dataf + i, bcf_float_missing if not vlen else bcf_float_vector_end)             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError('unsupported header type code')
 */
      if (((!(__pyx_v_vlen != 0)) != 0)) {
        __pyx_t_8 = bcf_float_missing;
      } else {
        __pyx_t_8 = bcf_float_vector_end;
      }
      bcf_float_set((__pyx_v_dataf + __pyx_v_i), __pyx_t_8);
    }

    /* "pysam/libcbcf.pyx":404
 *         for i in range(n):
 *             data32[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif type == BCF_HT_REAL:             # <<<<<<<<<<<<<<
 *         value = PyBytes_FromStringAndSize(NULL, sizeof(float)*n)
 *         dataf = <float *><char *>value
 */
    goto __pyx_L4;
  }

  /* "pysam/libcbcf.pyx":410
 *             bcf_float_set(dataf + i, bcf_float_missing if not vlen else bcf_float_vector_end)
 *     else:
 *         raise TypeError('unsupported header type code')             # <<<<<<<<<<<<<<
 * 
 *     return value
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 410, __pyx_L1_error)
  }
  __pyx_L4:;

  /* "pysam/libcbcf.pyx":412
 *         raise TypeError('unsupported header type code')
 * 
 *     return value             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_value);
  __pyx_r = __pyx_v_value;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":385
 * 
 * 
 * cdef bcf_empty_array(int type, ssize_t n, int vlen):             # <<<<<<<<<<<<<<
 *     cdef char    *datac
 *     cdef int32_t *data32
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_empty_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":415
 * 
 * 
 * cdef bcf_copy_expand_array(void *src_data, int src_type, ssize_t src_values,             # <<<<<<<<<<<<<<
 *                            void *dst_data, int dst_type, ssize_t dst_values,
 *                            int vlen):
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_copy_expand_array(void *__pyx_v_src_data, int __pyx_v_src_type, Py_ssize_t __pyx_v_src_values, void *__pyx_v_dst_data, int __pyx_v_dst_type, Py_ssize_t __pyx_v_dst_values, int __pyx_v_vlen) {
  char *__pyx_v_src_datac;
  char *__pyx_v_dst_datac;
  int8_t *__pyx_v_src_datai8;
  int16_t *__pyx_v_src_datai16;
  int32_t *__pyx_v_src_datai32;
  int32_t *__pyx_v_dst_datai;
  float *__pyx_v_src_dataf;
  float *__pyx_v_dst_dataf;
  Py_ssize_t __pyx_v_i;
  int __pyx_v_val;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  int32_t __pyx_t_13;
  uint32_t __pyx_t_14;
  __Pyx_RefNannySetupContext("bcf_copy_expand_array", 0);
  __Pyx_TraceCall("bcf_copy_expand_array", __pyx_f[0], 415, 0, __PYX_ERR(0, 415, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":429
 *     cdef int val
 * 
 *     if src_values > dst_values:             # <<<<<<<<<<<<<<
 *         raise ValueError('Cannot copy arrays with src_values={} > dst_values={}'.format(src_values, dst_values))
 * 
 */
  __pyx_t_1 = ((__pyx_v_src_values > __pyx_v_dst_values) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":430
 * 
 *     if src_values > dst_values:
 *         raise ValueError('Cannot copy arrays with src_values={} > dst_values={}'.format(src_values, dst_values))             # <<<<<<<<<<<<<<
 * 
 *     if src_type == dst_type == BCF_BT_CHAR:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Cannot_copy_arrays_with_src_valu, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_src_values); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 430, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_dst_values); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 430, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(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, 430, __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, 430, __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, 430, __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, 430, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 430, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":429
 *     cdef int val
 * 
 *     if src_values > dst_values:             # <<<<<<<<<<<<<<
 *         raise ValueError('Cannot copy arrays with src_values={} > dst_values={}'.format(src_values, dst_values))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":432
 *         raise ValueError('Cannot copy arrays with src_values={} > dst_values={}'.format(src_values, dst_values))
 * 
 *     if src_type == dst_type == BCF_BT_CHAR:             # <<<<<<<<<<<<<<
 *         src_datac = <char *>src_data
 *         dst_datac = <char *>dst_data
 */
  __pyx_t_1 = (__pyx_v_src_type == __pyx_v_dst_type);
  if (__pyx_t_1) {
    __pyx_t_1 = (__pyx_v_dst_type == BCF_BT_CHAR);
  }
  __pyx_t_9 = (__pyx_t_1 != 0);
  if (__pyx_t_9) {

    /* "pysam/libcbcf.pyx":433
 * 
 *     if src_type == dst_type == BCF_BT_CHAR:
 *         src_datac = <char *>src_data             # <<<<<<<<<<<<<<
 *         dst_datac = <char *>dst_data
 *         memcpy(src_datac, dst_datac, src_values)
 */
    __pyx_v_src_datac = ((char *)__pyx_v_src_data);

    /* "pysam/libcbcf.pyx":434
 *     if src_type == dst_type == BCF_BT_CHAR:
 *         src_datac = <char *>src_data
 *         dst_datac = <char *>dst_data             # <<<<<<<<<<<<<<
 *         memcpy(src_datac, dst_datac, src_values)
 *         for i in range(src_values, dst_values):
 */
    __pyx_v_dst_datac = ((char *)__pyx_v_dst_data);

    /* "pysam/libcbcf.pyx":435
 *         src_datac = <char *>src_data
 *         dst_datac = <char *>dst_data
 *         memcpy(src_datac, dst_datac, src_values)             # <<<<<<<<<<<<<<
 *         for i in range(src_values, dst_values):
 *             dst_datac[i] = 0
 */
    (void)(memcpy(__pyx_v_src_datac, __pyx_v_dst_datac, __pyx_v_src_values));

    /* "pysam/libcbcf.pyx":436
 *         dst_datac = <char *>dst_data
 *         memcpy(src_datac, dst_datac, src_values)
 *         for i in range(src_values, dst_values):             # <<<<<<<<<<<<<<
 *             dst_datac[i] = 0
 *     elif src_type == BCF_BT_INT8 and dst_type == BCF_BT_INT32:
 */
    __pyx_t_10 = __pyx_v_dst_values;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = __pyx_v_src_values; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_i = __pyx_t_12;

      /* "pysam/libcbcf.pyx":437
 *         memcpy(src_datac, dst_datac, src_values)
 *         for i in range(src_values, dst_values):
 *             dst_datac[i] = 0             # <<<<<<<<<<<<<<
 *     elif src_type == BCF_BT_INT8 and dst_type == BCF_BT_INT32:
 *         src_datai8 = <int8_t *>src_data
 */
      (__pyx_v_dst_datac[__pyx_v_i]) = 0;
    }

    /* "pysam/libcbcf.pyx":432
 *         raise ValueError('Cannot copy arrays with src_values={} > dst_values={}'.format(src_values, dst_values))
 * 
 *     if src_type == dst_type == BCF_BT_CHAR:             # <<<<<<<<<<<<<<
 *         src_datac = <char *>src_data
 *         dst_datac = <char *>dst_data
 */
    goto __pyx_L4;
  }

  /* "pysam/libcbcf.pyx":438
 *         for i in range(src_values, dst_values):
 *             dst_datac[i] = 0
 *     elif src_type == BCF_BT_INT8 and dst_type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         src_datai8 = <int8_t *>src_data
 *         dst_datai  = <int32_t *>dst_data
 */
  __pyx_t_1 = ((__pyx_v_src_type == BCF_BT_INT8) != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_9 = __pyx_t_1;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_dst_type == BCF_BT_INT32) != 0);
  __pyx_t_9 = __pyx_t_1;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_9) {

    /* "pysam/libcbcf.pyx":439
 *             dst_datac[i] = 0
 *     elif src_type == BCF_BT_INT8 and dst_type == BCF_BT_INT32:
 *         src_datai8 = <int8_t *>src_data             # <<<<<<<<<<<<<<
 *         dst_datai  = <int32_t *>dst_data
 *         for i in range(src_values):
 */
    __pyx_v_src_datai8 = ((int8_t *)__pyx_v_src_data);

    /* "pysam/libcbcf.pyx":440
 *     elif src_type == BCF_BT_INT8 and dst_type == BCF_BT_INT32:
 *         src_datai8 = <int8_t *>src_data
 *         dst_datai  = <int32_t *>dst_data             # <<<<<<<<<<<<<<
 *         for i in range(src_values):
 *             val = src_datai8[i]
 */
    __pyx_v_dst_datai = ((int32_t *)__pyx_v_dst_data);

    /* "pysam/libcbcf.pyx":441
 *         src_datai8 = <int8_t *>src_data
 *         dst_datai  = <int32_t *>dst_data
 *         for i in range(src_values):             # <<<<<<<<<<<<<<
 *             val = src_datai8[i]
 *             if val == bcf_int8_missing:
 */
    __pyx_t_10 = __pyx_v_src_values;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_i = __pyx_t_12;

      /* "pysam/libcbcf.pyx":442
 *         dst_datai  = <int32_t *>dst_data
 *         for i in range(src_values):
 *             val = src_datai8[i]             # <<<<<<<<<<<<<<
 *             if val == bcf_int8_missing:
 *                 val = bcf_int32_missing
 */
      __pyx_v_val = (__pyx_v_src_datai8[__pyx_v_i]);

      /* "pysam/libcbcf.pyx":443
 *         for i in range(src_values):
 *             val = src_datai8[i]
 *             if val == bcf_int8_missing:             # <<<<<<<<<<<<<<
 *                 val = bcf_int32_missing
 *             elif val == bcf_int8_vector_end:
 */
      __pyx_t_9 = ((__pyx_v_val == bcf_int8_missing) != 0);
      if (__pyx_t_9) {

        /* "pysam/libcbcf.pyx":444
 *             val = src_datai8[i]
 *             if val == bcf_int8_missing:
 *                 val = bcf_int32_missing             # <<<<<<<<<<<<<<
 *             elif val == bcf_int8_vector_end:
 *                 val = bcf_int32_vector_end
 */
        __pyx_v_val = bcf_int32_missing;

        /* "pysam/libcbcf.pyx":443
 *         for i in range(src_values):
 *             val = src_datai8[i]
 *             if val == bcf_int8_missing:             # <<<<<<<<<<<<<<
 *                 val = bcf_int32_missing
 *             elif val == bcf_int8_vector_end:
 */
        goto __pyx_L11;
      }

      /* "pysam/libcbcf.pyx":445
 *             if val == bcf_int8_missing:
 *                 val = bcf_int32_missing
 *             elif val == bcf_int8_vector_end:             # <<<<<<<<<<<<<<
 *                 val = bcf_int32_vector_end
 *             dst_datai[i] = val
 */
      __pyx_t_9 = ((__pyx_v_val == bcf_int8_vector_end) != 0);
      if (__pyx_t_9) {

        /* "pysam/libcbcf.pyx":446
 *                 val = bcf_int32_missing
 *             elif val == bcf_int8_vector_end:
 *                 val = bcf_int32_vector_end             # <<<<<<<<<<<<<<
 *             dst_datai[i] = val
 *         for i in range(src_values, dst_values):
 */
        __pyx_v_val = bcf_int32_vector_end;

        /* "pysam/libcbcf.pyx":445
 *             if val == bcf_int8_missing:
 *                 val = bcf_int32_missing
 *             elif val == bcf_int8_vector_end:             # <<<<<<<<<<<<<<
 *                 val = bcf_int32_vector_end
 *             dst_datai[i] = val
 */
      }
      __pyx_L11:;

      /* "pysam/libcbcf.pyx":447
 *             elif val == bcf_int8_vector_end:
 *                 val = bcf_int32_vector_end
 *             dst_datai[i] = val             # <<<<<<<<<<<<<<
 *         for i in range(src_values, dst_values):
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 */
      (__pyx_v_dst_datai[__pyx_v_i]) = __pyx_v_val;
    }

    /* "pysam/libcbcf.pyx":448
 *                 val = bcf_int32_vector_end
 *             dst_datai[i] = val
 *         for i in range(src_values, dst_values):             # <<<<<<<<<<<<<<
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif src_type == BCF_BT_INT16 and dst_type == BCF_BT_INT32:
 */
    __pyx_t_10 = __pyx_v_dst_values;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = __pyx_v_src_values; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_i = __pyx_t_12;

      /* "pysam/libcbcf.pyx":449
 *             dst_datai[i] = val
 *         for i in range(src_values, dst_values):
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end             # <<<<<<<<<<<<<<
 *     elif src_type == BCF_BT_INT16 and dst_type == BCF_BT_INT32:
 *         src_datai16 = <int16_t *>src_data
 */
      if (((!(__pyx_v_vlen != 0)) != 0)) {
        __pyx_t_13 = bcf_int32_missing;
      } else {
        __pyx_t_13 = bcf_int32_vector_end;
      }
      (__pyx_v_dst_datai[__pyx_v_i]) = __pyx_t_13;
    }

    /* "pysam/libcbcf.pyx":438
 *         for i in range(src_values, dst_values):
 *             dst_datac[i] = 0
 *     elif src_type == BCF_BT_INT8 and dst_type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         src_datai8 = <int8_t *>src_data
 *         dst_datai  = <int32_t *>dst_data
 */
    goto __pyx_L4;
  }

  /* "pysam/libcbcf.pyx":450
 *         for i in range(src_values, dst_values):
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif src_type == BCF_BT_INT16 and dst_type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         src_datai16 = <int16_t *>src_data
 *         dst_datai   = <int32_t *>dst_data
 */
  __pyx_t_1 = ((__pyx_v_src_type == BCF_BT_INT16) != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_9 = __pyx_t_1;
    goto __pyx_L14_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_dst_type == BCF_BT_INT32) != 0);
  __pyx_t_9 = __pyx_t_1;
  __pyx_L14_bool_binop_done:;
  if (__pyx_t_9) {

    /* "pysam/libcbcf.pyx":451
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif src_type == BCF_BT_INT16 and dst_type == BCF_BT_INT32:
 *         src_datai16 = <int16_t *>src_data             # <<<<<<<<<<<<<<
 *         dst_datai   = <int32_t *>dst_data
 *         for i in range(src_values):
 */
    __pyx_v_src_datai16 = ((int16_t *)__pyx_v_src_data);

    /* "pysam/libcbcf.pyx":452
 *     elif src_type == BCF_BT_INT16 and dst_type == BCF_BT_INT32:
 *         src_datai16 = <int16_t *>src_data
 *         dst_datai   = <int32_t *>dst_data             # <<<<<<<<<<<<<<
 *         for i in range(src_values):
 *             val = src_datai16[i]
 */
    __pyx_v_dst_datai = ((int32_t *)__pyx_v_dst_data);

    /* "pysam/libcbcf.pyx":453
 *         src_datai16 = <int16_t *>src_data
 *         dst_datai   = <int32_t *>dst_data
 *         for i in range(src_values):             # <<<<<<<<<<<<<<
 *             val = src_datai16[i]
 *             if val == bcf_int16_missing:
 */
    __pyx_t_10 = __pyx_v_src_values;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_i = __pyx_t_12;

      /* "pysam/libcbcf.pyx":454
 *         dst_datai   = <int32_t *>dst_data
 *         for i in range(src_values):
 *             val = src_datai16[i]             # <<<<<<<<<<<<<<
 *             if val == bcf_int16_missing:
 *                 val = bcf_int32_missing
 */
      __pyx_v_val = (__pyx_v_src_datai16[__pyx_v_i]);

      /* "pysam/libcbcf.pyx":455
 *         for i in range(src_values):
 *             val = src_datai16[i]
 *             if val == bcf_int16_missing:             # <<<<<<<<<<<<<<
 *                 val = bcf_int32_missing
 *             elif val == bcf_int16_vector_end:
 */
      __pyx_t_9 = ((__pyx_v_val == bcf_int16_missing) != 0);
      if (__pyx_t_9) {

        /* "pysam/libcbcf.pyx":456
 *             val = src_datai16[i]
 *             if val == bcf_int16_missing:
 *                 val = bcf_int32_missing             # <<<<<<<<<<<<<<
 *             elif val == bcf_int16_vector_end:
 *                 val = bcf_int32_vector_end
 */
        __pyx_v_val = bcf_int32_missing;

        /* "pysam/libcbcf.pyx":455
 *         for i in range(src_values):
 *             val = src_datai16[i]
 *             if val == bcf_int16_missing:             # <<<<<<<<<<<<<<
 *                 val = bcf_int32_missing
 *             elif val == bcf_int16_vector_end:
 */
        goto __pyx_L18;
      }

      /* "pysam/libcbcf.pyx":457
 *             if val == bcf_int16_missing:
 *                 val = bcf_int32_missing
 *             elif val == bcf_int16_vector_end:             # <<<<<<<<<<<<<<
 *                 val = bcf_int32_vector_end
 *             dst_datai[i] = val
 */
      __pyx_t_9 = ((__pyx_v_val == bcf_int16_vector_end) != 0);
      if (__pyx_t_9) {

        /* "pysam/libcbcf.pyx":458
 *                 val = bcf_int32_missing
 *             elif val == bcf_int16_vector_end:
 *                 val = bcf_int32_vector_end             # <<<<<<<<<<<<<<
 *             dst_datai[i] = val
 *         for i in range(src_values, dst_values):
 */
        __pyx_v_val = bcf_int32_vector_end;

        /* "pysam/libcbcf.pyx":457
 *             if val == bcf_int16_missing:
 *                 val = bcf_int32_missing
 *             elif val == bcf_int16_vector_end:             # <<<<<<<<<<<<<<
 *                 val = bcf_int32_vector_end
 *             dst_datai[i] = val
 */
      }
      __pyx_L18:;

      /* "pysam/libcbcf.pyx":459
 *             elif val == bcf_int16_vector_end:
 *                 val = bcf_int32_vector_end
 *             dst_datai[i] = val             # <<<<<<<<<<<<<<
 *         for i in range(src_values, dst_values):
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 */
      (__pyx_v_dst_datai[__pyx_v_i]) = __pyx_v_val;
    }

    /* "pysam/libcbcf.pyx":460
 *                 val = bcf_int32_vector_end
 *             dst_datai[i] = val
 *         for i in range(src_values, dst_values):             # <<<<<<<<<<<<<<
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif src_type == BCF_BT_INT32 and dst_type == BCF_BT_INT32:
 */
    __pyx_t_10 = __pyx_v_dst_values;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = __pyx_v_src_values; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_i = __pyx_t_12;

      /* "pysam/libcbcf.pyx":461
 *             dst_datai[i] = val
 *         for i in range(src_values, dst_values):
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end             # <<<<<<<<<<<<<<
 *     elif src_type == BCF_BT_INT32 and dst_type == BCF_BT_INT32:
 *         src_datai32 = <int32_t *>src_data
 */
      if (((!(__pyx_v_vlen != 0)) != 0)) {
        __pyx_t_13 = bcf_int32_missing;
      } else {
        __pyx_t_13 = bcf_int32_vector_end;
      }
      (__pyx_v_dst_datai[__pyx_v_i]) = __pyx_t_13;
    }

    /* "pysam/libcbcf.pyx":450
 *         for i in range(src_values, dst_values):
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif src_type == BCF_BT_INT16 and dst_type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         src_datai16 = <int16_t *>src_data
 *         dst_datai   = <int32_t *>dst_data
 */
    goto __pyx_L4;
  }

  /* "pysam/libcbcf.pyx":462
 *         for i in range(src_values, dst_values):
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif src_type == BCF_BT_INT32 and dst_type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         src_datai32 = <int32_t *>src_data
 *         dst_datai   = <int32_t *>dst_data
 */
  __pyx_t_1 = ((__pyx_v_src_type == BCF_BT_INT32) != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_9 = __pyx_t_1;
    goto __pyx_L21_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_dst_type == BCF_BT_INT32) != 0);
  __pyx_t_9 = __pyx_t_1;
  __pyx_L21_bool_binop_done:;
  if (__pyx_t_9) {

    /* "pysam/libcbcf.pyx":463
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif src_type == BCF_BT_INT32 and dst_type == BCF_BT_INT32:
 *         src_datai32 = <int32_t *>src_data             # <<<<<<<<<<<<<<
 *         dst_datai   = <int32_t *>dst_data
 *         for i in range(src_values):
 */
    __pyx_v_src_datai32 = ((int32_t *)__pyx_v_src_data);

    /* "pysam/libcbcf.pyx":464
 *     elif src_type == BCF_BT_INT32 and dst_type == BCF_BT_INT32:
 *         src_datai32 = <int32_t *>src_data
 *         dst_datai   = <int32_t *>dst_data             # <<<<<<<<<<<<<<
 *         for i in range(src_values):
 *             dst_datai[i] = src_datai32[i]
 */
    __pyx_v_dst_datai = ((int32_t *)__pyx_v_dst_data);

    /* "pysam/libcbcf.pyx":465
 *         src_datai32 = <int32_t *>src_data
 *         dst_datai   = <int32_t *>dst_data
 *         for i in range(src_values):             # <<<<<<<<<<<<<<
 *             dst_datai[i] = src_datai32[i]
 *         for i in range(src_values, dst_values):
 */
    __pyx_t_10 = __pyx_v_src_values;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_i = __pyx_t_12;

      /* "pysam/libcbcf.pyx":466
 *         dst_datai   = <int32_t *>dst_data
 *         for i in range(src_values):
 *             dst_datai[i] = src_datai32[i]             # <<<<<<<<<<<<<<
 *         for i in range(src_values, dst_values):
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 */
      (__pyx_v_dst_datai[__pyx_v_i]) = (__pyx_v_src_datai32[__pyx_v_i]);
    }

    /* "pysam/libcbcf.pyx":467
 *         for i in range(src_values):
 *             dst_datai[i] = src_datai32[i]
 *         for i in range(src_values, dst_values):             # <<<<<<<<<<<<<<
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif src_type == BCF_BT_FLOAT and dst_type == BCF_BT_FLOAT:
 */
    __pyx_t_10 = __pyx_v_dst_values;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = __pyx_v_src_values; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_i = __pyx_t_12;

      /* "pysam/libcbcf.pyx":468
 *             dst_datai[i] = src_datai32[i]
 *         for i in range(src_values, dst_values):
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end             # <<<<<<<<<<<<<<
 *     elif src_type == BCF_BT_FLOAT and dst_type == BCF_BT_FLOAT:
 *         src_dataf = <float *>src_data
 */
      if (((!(__pyx_v_vlen != 0)) != 0)) {
        __pyx_t_13 = bcf_int32_missing;
      } else {
        __pyx_t_13 = bcf_int32_vector_end;
      }
      (__pyx_v_dst_datai[__pyx_v_i]) = __pyx_t_13;
    }

    /* "pysam/libcbcf.pyx":462
 *         for i in range(src_values, dst_values):
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif src_type == BCF_BT_INT32 and dst_type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         src_datai32 = <int32_t *>src_data
 *         dst_datai   = <int32_t *>dst_data
 */
    goto __pyx_L4;
  }

  /* "pysam/libcbcf.pyx":469
 *         for i in range(src_values, dst_values):
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif src_type == BCF_BT_FLOAT and dst_type == BCF_BT_FLOAT:             # <<<<<<<<<<<<<<
 *         src_dataf = <float *>src_data
 *         dst_dataf = <float *>dst_data
 */
  __pyx_t_1 = ((__pyx_v_src_type == BCF_BT_FLOAT) != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_9 = __pyx_t_1;
    goto __pyx_L27_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_dst_type == BCF_BT_FLOAT) != 0);
  __pyx_t_9 = __pyx_t_1;
  __pyx_L27_bool_binop_done:;
  if (likely(__pyx_t_9)) {

    /* "pysam/libcbcf.pyx":470
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif src_type == BCF_BT_FLOAT and dst_type == BCF_BT_FLOAT:
 *         src_dataf = <float *>src_data             # <<<<<<<<<<<<<<
 *         dst_dataf = <float *>dst_data
 *         for i in range(src_values):
 */
    __pyx_v_src_dataf = ((float *)__pyx_v_src_data);

    /* "pysam/libcbcf.pyx":471
 *     elif src_type == BCF_BT_FLOAT and dst_type == BCF_BT_FLOAT:
 *         src_dataf = <float *>src_data
 *         dst_dataf = <float *>dst_data             # <<<<<<<<<<<<<<
 *         for i in range(src_values):
 *             dst_dataf[i] = src_dataf[i]
 */
    __pyx_v_dst_dataf = ((float *)__pyx_v_dst_data);

    /* "pysam/libcbcf.pyx":472
 *         src_dataf = <float *>src_data
 *         dst_dataf = <float *>dst_data
 *         for i in range(src_values):             # <<<<<<<<<<<<<<
 *             dst_dataf[i] = src_dataf[i]
 *         for i in range(src_values, dst_values):
 */
    __pyx_t_10 = __pyx_v_src_values;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_i = __pyx_t_12;

      /* "pysam/libcbcf.pyx":473
 *         dst_dataf = <float *>dst_data
 *         for i in range(src_values):
 *             dst_dataf[i] = src_dataf[i]             # <<<<<<<<<<<<<<
 *         for i in range(src_values, dst_values):
 *             bcf_float_set(dst_dataf + i, bcf_float_missing if not vlen else bcf_float_vector_end)
 */
      (__pyx_v_dst_dataf[__pyx_v_i]) = (__pyx_v_src_dataf[__pyx_v_i]);
    }

    /* "pysam/libcbcf.pyx":474
 *         for i in range(src_values):
 *             dst_dataf[i] = src_dataf[i]
 *         for i in range(src_values, dst_values):             # <<<<<<<<<<<<<<
 *             bcf_float_set(dst_dataf + i, bcf_float_missing if not vlen else bcf_float_vector_end)
 *     else:
 */
    __pyx_t_10 = __pyx_v_dst_values;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = __pyx_v_src_values; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_i = __pyx_t_12;

      /* "pysam/libcbcf.pyx":475
 *             dst_dataf[i] = src_dataf[i]
 *         for i in range(src_values, dst_values):
 *             bcf_float_set(dst_dataf + i, bcf_float_missing if not vlen else bcf_float_vector_end)             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError('unsupported types')
 */
      if (((!(__pyx_v_vlen != 0)) != 0)) {
        __pyx_t_14 = bcf_float_missing;
      } else {
        __pyx_t_14 = bcf_float_vector_end;
      }
      bcf_float_set((__pyx_v_dst_dataf + __pyx_v_i), __pyx_t_14);
    }

    /* "pysam/libcbcf.pyx":469
 *         for i in range(src_values, dst_values):
 *             dst_datai[i] = bcf_int32_missing if not vlen else bcf_int32_vector_end
 *     elif src_type == BCF_BT_FLOAT and dst_type == BCF_BT_FLOAT:             # <<<<<<<<<<<<<<
 *         src_dataf = <float *>src_data
 *         dst_dataf = <float *>dst_data
 */
    goto __pyx_L4;
  }

  /* "pysam/libcbcf.pyx":477
 *             bcf_float_set(dst_dataf + i, bcf_float_missing if not vlen else bcf_float_vector_end)
 *     else:
 *         raise TypeError('unsupported types')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 477, __pyx_L1_error)
  }
  __pyx_L4:;

  /* "pysam/libcbcf.pyx":415
 * 
 * 
 * cdef bcf_copy_expand_array(void *src_data, int src_type, ssize_t src_values,             # <<<<<<<<<<<<<<
 *                            void *dst_data, int dst_type, ssize_t dst_values,
 *                            int vlen):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_copy_expand_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":480
 * 
 * 
 * cdef bcf_get_value_count(VariantRecord record, int hl_type, int id, ssize_t *count, int *scalar, int sample):             # <<<<<<<<<<<<<<
 *     if record is None:
 *         raise ValueError('record must not be None')
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_get_value_count(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record, int __pyx_v_hl_type, int __pyx_v_id, Py_ssize_t *__pyx_v_count, int *__pyx_v_scalar, int __pyx_v_sample) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int __pyx_v_length;
  int __pyx_v_number;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  bcf1_t *__pyx_t_5;
  uint32_t __pyx_t_6;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("bcf_get_value_count", 0);
  __Pyx_TraceCall("bcf_get_value_count", __pyx_f[0], 480, 0, __PYX_ERR(0, 480, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":481
 * 
 * cdef bcf_get_value_count(VariantRecord record, int hl_type, int id, ssize_t *count, int *scalar, int sample):
 *     if record is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('record must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_record) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":482
 * cdef bcf_get_value_count(VariantRecord record, int hl_type, int id, ssize_t *count, int *scalar, int sample):
 *     if record is None:
 *         raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 482, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":481
 * 
 * cdef bcf_get_value_count(VariantRecord record, int hl_type, int id, ssize_t *count, int *scalar, int sample):
 *     if record is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('record must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":484
 *         raise ValueError('record must not be None')
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr             # <<<<<<<<<<<<<<
 *     cdef bcf1_t *r = record.ptr
 * 
 */
  __pyx_t_4 = __pyx_v_record->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":485
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 *     cdef bcf1_t *r = record.ptr             # <<<<<<<<<<<<<<
 * 
 *     if not check_header_id(hdr, hl_type, id):
 */
  __pyx_t_5 = __pyx_v_record->ptr;
  __pyx_v_r = __pyx_t_5;

  /* "pysam/libcbcf.pyx":487
 *     cdef bcf1_t *r = record.ptr
 * 
 *     if not check_header_id(hdr, hl_type, id):             # <<<<<<<<<<<<<<
 *         raise ValueError('Invalid header')
 * 
 */
  __pyx_t_2 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, __pyx_v_hl_type, __pyx_v_id) != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":488
 * 
 *     if not check_header_id(hdr, hl_type, id):
 *         raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *     cdef int length = bcf_hdr_id2length(hdr, hl_type, id)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 488, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 488, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":487
 *     cdef bcf1_t *r = record.ptr
 * 
 *     if not check_header_id(hdr, hl_type, id):             # <<<<<<<<<<<<<<
 *         raise ValueError('Invalid header')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":490
 *         raise ValueError('Invalid header')
 * 
 *     cdef int length = bcf_hdr_id2length(hdr, hl_type, id)             # <<<<<<<<<<<<<<
 *     cdef int number = bcf_hdr_id2number(hdr, hl_type, id)
 * 
 */
  __pyx_v_length = bcf_hdr_id2length(__pyx_v_hdr, __pyx_v_hl_type, __pyx_v_id);

  /* "pysam/libcbcf.pyx":491
 * 
 *     cdef int length = bcf_hdr_id2length(hdr, hl_type, id)
 *     cdef int number = bcf_hdr_id2number(hdr, hl_type, id)             # <<<<<<<<<<<<<<
 * 
 *     scalar[0] = 0
 */
  __pyx_v_number = bcf_hdr_id2number(__pyx_v_hdr, __pyx_v_hl_type, __pyx_v_id);

  /* "pysam/libcbcf.pyx":493
 *     cdef int number = bcf_hdr_id2number(hdr, hl_type, id)
 * 
 *     scalar[0] = 0             # <<<<<<<<<<<<<<
 * 
 *     if hl_type == BCF_HL_FMT and is_gt_fmt(hdr, id):
 */
  (__pyx_v_scalar[0]) = 0;

  /* "pysam/libcbcf.pyx":495
 *     scalar[0] = 0
 * 
 *     if hl_type == BCF_HL_FMT and is_gt_fmt(hdr, id):             # <<<<<<<<<<<<<<
 *         count[0] = number
 *     elif length == BCF_VL_FIXED:
 */
  __pyx_t_1 = ((__pyx_v_hl_type == BCF_HL_FMT) != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = (__pyx_f_5pysam_7libcbcf_is_gt_fmt(__pyx_v_hdr, __pyx_v_id) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":496
 * 
 *     if hl_type == BCF_HL_FMT and is_gt_fmt(hdr, id):
 *         count[0] = number             # <<<<<<<<<<<<<<
 *     elif length == BCF_VL_FIXED:
 *         if number == 1:
 */
    (__pyx_v_count[0]) = __pyx_v_number;

    /* "pysam/libcbcf.pyx":495
 *     scalar[0] = 0
 * 
 *     if hl_type == BCF_HL_FMT and is_gt_fmt(hdr, id):             # <<<<<<<<<<<<<<
 *         count[0] = number
 *     elif length == BCF_VL_FIXED:
 */
    goto __pyx_L5;
  }

  /* "pysam/libcbcf.pyx":497
 *     if hl_type == BCF_HL_FMT and is_gt_fmt(hdr, id):
 *         count[0] = number
 *     elif length == BCF_VL_FIXED:             # <<<<<<<<<<<<<<
 *         if number == 1:
 *             scalar[0] = 1
 */
  __pyx_t_2 = ((__pyx_v_length == BCF_VL_FIXED) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":498
 *         count[0] = number
 *     elif length == BCF_VL_FIXED:
 *         if number == 1:             # <<<<<<<<<<<<<<
 *             scalar[0] = 1
 *         count[0] = number
 */
    __pyx_t_2 = ((__pyx_v_number == 1) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":499
 *     elif length == BCF_VL_FIXED:
 *         if number == 1:
 *             scalar[0] = 1             # <<<<<<<<<<<<<<
 *         count[0] = number
 *     elif length == BCF_VL_R:
 */
      (__pyx_v_scalar[0]) = 1;

      /* "pysam/libcbcf.pyx":498
 *         count[0] = number
 *     elif length == BCF_VL_FIXED:
 *         if number == 1:             # <<<<<<<<<<<<<<
 *             scalar[0] = 1
 *         count[0] = number
 */
    }

    /* "pysam/libcbcf.pyx":500
 *         if number == 1:
 *             scalar[0] = 1
 *         count[0] = number             # <<<<<<<<<<<<<<
 *     elif length == BCF_VL_R:
 *         count[0] = r.n_allele
 */
    (__pyx_v_count[0]) = __pyx_v_number;

    /* "pysam/libcbcf.pyx":497
 *     if hl_type == BCF_HL_FMT and is_gt_fmt(hdr, id):
 *         count[0] = number
 *     elif length == BCF_VL_FIXED:             # <<<<<<<<<<<<<<
 *         if number == 1:
 *             scalar[0] = 1
 */
    goto __pyx_L5;
  }

  /* "pysam/libcbcf.pyx":501
 *             scalar[0] = 1
 *         count[0] = number
 *     elif length == BCF_VL_R:             # <<<<<<<<<<<<<<
 *         count[0] = r.n_allele
 *     elif length == BCF_VL_A:
 */
  __pyx_t_2 = ((__pyx_v_length == BCF_VL_R) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":502
 *         count[0] = number
 *     elif length == BCF_VL_R:
 *         count[0] = r.n_allele             # <<<<<<<<<<<<<<
 *     elif length == BCF_VL_A:
 *         count[0] = r.n_allele - 1
 */
    __pyx_t_6 = __pyx_v_r->n_allele;
    (__pyx_v_count[0]) = __pyx_t_6;

    /* "pysam/libcbcf.pyx":501
 *             scalar[0] = 1
 *         count[0] = number
 *     elif length == BCF_VL_R:             # <<<<<<<<<<<<<<
 *         count[0] = r.n_allele
 *     elif length == BCF_VL_A:
 */
    goto __pyx_L5;
  }

  /* "pysam/libcbcf.pyx":503
 *     elif length == BCF_VL_R:
 *         count[0] = r.n_allele
 *     elif length == BCF_VL_A:             # <<<<<<<<<<<<<<
 *         count[0] = r.n_allele - 1
 *     elif length == BCF_VL_G:
 */
  __pyx_t_2 = ((__pyx_v_length == BCF_VL_A) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":504
 *         count[0] = r.n_allele
 *     elif length == BCF_VL_A:
 *         count[0] = r.n_allele - 1             # <<<<<<<<<<<<<<
 *     elif length == BCF_VL_G:
 *         count[0] = bcf_genotype_count(hdr, r, sample)
 */
    (__pyx_v_count[0]) = (__pyx_v_r->n_allele - 1);

    /* "pysam/libcbcf.pyx":503
 *     elif length == BCF_VL_R:
 *         count[0] = r.n_allele
 *     elif length == BCF_VL_A:             # <<<<<<<<<<<<<<
 *         count[0] = r.n_allele - 1
 *     elif length == BCF_VL_G:
 */
    goto __pyx_L5;
  }

  /* "pysam/libcbcf.pyx":505
 *     elif length == BCF_VL_A:
 *         count[0] = r.n_allele - 1
 *     elif length == BCF_VL_G:             # <<<<<<<<<<<<<<
 *         count[0] = bcf_genotype_count(hdr, r, sample)
 *     elif length == BCF_VL_VAR:
 */
  __pyx_t_2 = ((__pyx_v_length == BCF_VL_G) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":506
 *         count[0] = r.n_allele - 1
 *     elif length == BCF_VL_G:
 *         count[0] = bcf_genotype_count(hdr, r, sample)             # <<<<<<<<<<<<<<
 *     elif length == BCF_VL_VAR:
 *         count[0] = -1
 */
    __pyx_t_7 = __pyx_f_5pysam_7libcbcf_bcf_genotype_count(__pyx_v_hdr, __pyx_v_r, __pyx_v_sample); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 506, __pyx_L1_error)
    (__pyx_v_count[0]) = __pyx_t_7;

    /* "pysam/libcbcf.pyx":505
 *     elif length == BCF_VL_A:
 *         count[0] = r.n_allele - 1
 *     elif length == BCF_VL_G:             # <<<<<<<<<<<<<<
 *         count[0] = bcf_genotype_count(hdr, r, sample)
 *     elif length == BCF_VL_VAR:
 */
    goto __pyx_L5;
  }

  /* "pysam/libcbcf.pyx":507
 *     elif length == BCF_VL_G:
 *         count[0] = bcf_genotype_count(hdr, r, sample)
 *     elif length == BCF_VL_VAR:             # <<<<<<<<<<<<<<
 *         count[0] = -1
 *     else:
 */
  __pyx_t_2 = ((__pyx_v_length == BCF_VL_VAR) != 0);
  if (likely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":508
 *         count[0] = bcf_genotype_count(hdr, r, sample)
 *     elif length == BCF_VL_VAR:
 *         count[0] = -1             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError('Unknown format length')
 */
    (__pyx_v_count[0]) = -1L;

    /* "pysam/libcbcf.pyx":507
 *     elif length == BCF_VL_G:
 *         count[0] = bcf_genotype_count(hdr, r, sample)
 *     elif length == BCF_VL_VAR:             # <<<<<<<<<<<<<<
 *         count[0] = -1
 *     else:
 */
    goto __pyx_L5;
  }

  /* "pysam/libcbcf.pyx":510
 *         count[0] = -1
 *     else:
 *         raise ValueError('Unknown format length')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 510, __pyx_L1_error)
  }
  __pyx_L5:;

  /* "pysam/libcbcf.pyx":480
 * 
 * 
 * cdef bcf_get_value_count(VariantRecord record, int hl_type, int id, ssize_t *count, int *scalar, int sample):             # <<<<<<<<<<<<<<
 *     if record is None:
 *         raise ValueError('record must not be None')
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_get_value_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":513
 * 
 * 
 * cdef object bcf_info_get_value(VariantRecord record, const bcf_info_t *z):             # <<<<<<<<<<<<<<
 *     if record is None:
 *         raise ValueError('record must not be None')
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_info_get_value(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record, bcf_info_t const *__pyx_v_z) {
  bcf_hdr_t *__pyx_v_hdr;
  Py_ssize_t __pyx_v_count;
  int __pyx_v_scalar;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("bcf_info_get_value", 0);
  __Pyx_TraceCall("bcf_info_get_value", __pyx_f[0], 513, 0, __PYX_ERR(0, 513, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":514
 * 
 * cdef object bcf_info_get_value(VariantRecord record, const bcf_info_t *z):
 *     if record is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('record must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_record) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":515
 * cdef object bcf_info_get_value(VariantRecord record, const bcf_info_t *z):
 *     if record is None:
 *         raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 515, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":514
 * 
 * cdef object bcf_info_get_value(VariantRecord record, const bcf_info_t *z):
 *     if record is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('record must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":517
 *         raise ValueError('record must not be None')
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr             # <<<<<<<<<<<<<<
 * 
 *     cdef char *s
 */
  __pyx_t_4 = __pyx_v_record->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":523
 *     cdef int scalar
 * 
 *     bcf_get_value_count(record, BCF_HL_INFO, z.key, &count, &scalar, -1)             # <<<<<<<<<<<<<<
 * 
 *     if z.len == 0:
 */
  __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_get_value_count(__pyx_v_record, BCF_HL_INFO, __pyx_v_z->key, (&__pyx_v_count), (&__pyx_v_scalar), -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 523, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":525
 *     bcf_get_value_count(record, BCF_HL_INFO, z.key, &count, &scalar, -1)
 * 
 *     if z.len == 0:             # <<<<<<<<<<<<<<
 *         if  bcf_hdr_id2type(hdr, BCF_HL_INFO, z.key) == BCF_HT_FLAG:
 *             value = True
 */
  switch (__pyx_v_z->len) {
    case 0:

    /* "pysam/libcbcf.pyx":526
 * 
 *     if z.len == 0:
 *         if  bcf_hdr_id2type(hdr, BCF_HL_INFO, z.key) == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *             value = True
 *         elif scalar:
 */
    __pyx_t_2 = ((bcf_hdr_id2type(__pyx_v_hdr, BCF_HL_INFO, __pyx_v_z->key) == BCF_HT_FLAG) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":527
 *     if z.len == 0:
 *         if  bcf_hdr_id2type(hdr, BCF_HL_INFO, z.key) == BCF_HT_FLAG:
 *             value = True             # <<<<<<<<<<<<<<
 *         elif scalar:
 *             value = None
 */
      __Pyx_INCREF(Py_True);
      __pyx_v_value = Py_True;

      /* "pysam/libcbcf.pyx":526
 * 
 *     if z.len == 0:
 *         if  bcf_hdr_id2type(hdr, BCF_HL_INFO, z.key) == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *             value = True
 *         elif scalar:
 */
      goto __pyx_L4;
    }

    /* "pysam/libcbcf.pyx":528
 *         if  bcf_hdr_id2type(hdr, BCF_HL_INFO, z.key) == BCF_HT_FLAG:
 *             value = True
 *         elif scalar:             # <<<<<<<<<<<<<<
 *             value = None
 *         else:
 */
    __pyx_t_2 = (__pyx_v_scalar != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":529
 *             value = True
 *         elif scalar:
 *             value = None             # <<<<<<<<<<<<<<
 *         else:
 *             value = ()
 */
      __Pyx_INCREF(Py_None);
      __pyx_v_value = Py_None;

      /* "pysam/libcbcf.pyx":528
 *         if  bcf_hdr_id2type(hdr, BCF_HL_INFO, z.key) == BCF_HT_FLAG:
 *             value = True
 *         elif scalar:             # <<<<<<<<<<<<<<
 *             value = None
 *         else:
 */
      goto __pyx_L4;
    }

    /* "pysam/libcbcf.pyx":531
 *             value = None
 *         else:
 *             value = ()             # <<<<<<<<<<<<<<
 *     elif z.len == 1:
 *         if z.type == BCF_BT_INT8:
 */
    /*else*/ {
      __Pyx_INCREF(__pyx_empty_tuple);
      __pyx_v_value = __pyx_empty_tuple;
    }
    __pyx_L4:;

    /* "pysam/libcbcf.pyx":525
 *     bcf_get_value_count(record, BCF_HL_INFO, z.key, &count, &scalar, -1)
 * 
 *     if z.len == 0:             # <<<<<<<<<<<<<<
 *         if  bcf_hdr_id2type(hdr, BCF_HL_INFO, z.key) == BCF_HT_FLAG:
 *             value = True
 */
    break;

    /* "pysam/libcbcf.pyx":532
 *         else:
 *             value = ()
 *     elif z.len == 1:             # <<<<<<<<<<<<<<
 *         if z.type == BCF_BT_INT8:
 *             value = z.v1.i if z.v1.i != bcf_int8_missing else None
 */
    case 1:

    /* "pysam/libcbcf.pyx":533
 *             value = ()
 *     elif z.len == 1:
 *         if z.type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *             value = z.v1.i if z.v1.i != bcf_int8_missing else None
 *         elif z.type == BCF_BT_INT16:
 */
    __pyx_t_2 = ((__pyx_v_z->type == BCF_BT_INT8) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":534
 *     elif z.len == 1:
 *         if z.type == BCF_BT_INT8:
 *             value = z.v1.i if z.v1.i != bcf_int8_missing else None             # <<<<<<<<<<<<<<
 *         elif z.type == BCF_BT_INT16:
 *             value = z.v1.i if z.v1.i != bcf_int16_missing else None
 */
      if (((__pyx_v_z->v1.i != bcf_int8_missing) != 0)) {
        __pyx_t_5 = __Pyx_PyInt_From_int32_t(__pyx_v_z->v1.i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 534, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = __pyx_t_5;
        __pyx_t_5 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_3 = Py_None;
      }
      __pyx_v_value = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":533
 *             value = ()
 *     elif z.len == 1:
 *         if z.type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *             value = z.v1.i if z.v1.i != bcf_int8_missing else None
 *         elif z.type == BCF_BT_INT16:
 */
      goto __pyx_L5;
    }

    /* "pysam/libcbcf.pyx":535
 *         if z.type == BCF_BT_INT8:
 *             value = z.v1.i if z.v1.i != bcf_int8_missing else None
 *         elif z.type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *             value = z.v1.i if z.v1.i != bcf_int16_missing else None
 *         elif z.type == BCF_BT_INT32:
 */
    __pyx_t_2 = ((__pyx_v_z->type == BCF_BT_INT16) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":536
 *             value = z.v1.i if z.v1.i != bcf_int8_missing else None
 *         elif z.type == BCF_BT_INT16:
 *             value = z.v1.i if z.v1.i != bcf_int16_missing else None             # <<<<<<<<<<<<<<
 *         elif z.type == BCF_BT_INT32:
 *             value = z.v1.i if z.v1.i != bcf_int32_missing else None
 */
      if (((__pyx_v_z->v1.i != bcf_int16_missing) != 0)) {
        __pyx_t_5 = __Pyx_PyInt_From_int32_t(__pyx_v_z->v1.i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 536, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = __pyx_t_5;
        __pyx_t_5 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_3 = Py_None;
      }
      __pyx_v_value = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":535
 *         if z.type == BCF_BT_INT8:
 *             value = z.v1.i if z.v1.i != bcf_int8_missing else None
 *         elif z.type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *             value = z.v1.i if z.v1.i != bcf_int16_missing else None
 *         elif z.type == BCF_BT_INT32:
 */
      goto __pyx_L5;
    }

    /* "pysam/libcbcf.pyx":537
 *         elif z.type == BCF_BT_INT16:
 *             value = z.v1.i if z.v1.i != bcf_int16_missing else None
 *         elif z.type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *             value = z.v1.i if z.v1.i != bcf_int32_missing else None
 *         elif z.type == BCF_BT_FLOAT:
 */
    __pyx_t_2 = ((__pyx_v_z->type == BCF_BT_INT32) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":538
 *             value = z.v1.i if z.v1.i != bcf_int16_missing else None
 *         elif z.type == BCF_BT_INT32:
 *             value = z.v1.i if z.v1.i != bcf_int32_missing else None             # <<<<<<<<<<<<<<
 *         elif z.type == BCF_BT_FLOAT:
 *             value = z.v1.f if not bcf_float_is_missing(z.v1.f) else None
 */
      if (((__pyx_v_z->v1.i != bcf_int32_missing) != 0)) {
        __pyx_t_5 = __Pyx_PyInt_From_int32_t(__pyx_v_z->v1.i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 538, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = __pyx_t_5;
        __pyx_t_5 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_3 = Py_None;
      }
      __pyx_v_value = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":537
 *         elif z.type == BCF_BT_INT16:
 *             value = z.v1.i if z.v1.i != bcf_int16_missing else None
 *         elif z.type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *             value = z.v1.i if z.v1.i != bcf_int32_missing else None
 *         elif z.type == BCF_BT_FLOAT:
 */
      goto __pyx_L5;
    }

    /* "pysam/libcbcf.pyx":539
 *         elif z.type == BCF_BT_INT32:
 *             value = z.v1.i if z.v1.i != bcf_int32_missing else None
 *         elif z.type == BCF_BT_FLOAT:             # <<<<<<<<<<<<<<
 *             value = z.v1.f if not bcf_float_is_missing(z.v1.f) else None
 *         elif z.type == BCF_BT_CHAR:
 */
    __pyx_t_2 = ((__pyx_v_z->type == BCF_BT_FLOAT) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":540
 *             value = z.v1.i if z.v1.i != bcf_int32_missing else None
 *         elif z.type == BCF_BT_FLOAT:
 *             value = z.v1.f if not bcf_float_is_missing(z.v1.f) else None             # <<<<<<<<<<<<<<
 *         elif z.type == BCF_BT_CHAR:
 *             value = force_str(chr(z.v1.i))
 */
      if (((!(bcf_float_is_missing(__pyx_v_z->v1.f) != 0)) != 0)) {
        __pyx_t_5 = PyFloat_FromDouble(__pyx_v_z->v1.f); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 540, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = __pyx_t_5;
        __pyx_t_5 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_3 = Py_None;
      }
      __pyx_v_value = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":539
 *         elif z.type == BCF_BT_INT32:
 *             value = z.v1.i if z.v1.i != bcf_int32_missing else None
 *         elif z.type == BCF_BT_FLOAT:             # <<<<<<<<<<<<<<
 *             value = z.v1.f if not bcf_float_is_missing(z.v1.f) else None
 *         elif z.type == BCF_BT_CHAR:
 */
      goto __pyx_L5;
    }

    /* "pysam/libcbcf.pyx":541
 *         elif z.type == BCF_BT_FLOAT:
 *             value = z.v1.f if not bcf_float_is_missing(z.v1.f) else None
 *         elif z.type == BCF_BT_CHAR:             # <<<<<<<<<<<<<<
 *             value = force_str(chr(z.v1.i))
 *         else:
 */
    __pyx_t_2 = ((__pyx_v_z->type == BCF_BT_CHAR) != 0);
    if (likely(__pyx_t_2)) {

      /* "pysam/libcbcf.pyx":542
 *             value = z.v1.f if not bcf_float_is_missing(z.v1.f) else None
 *         elif z.type == BCF_BT_CHAR:
 *             value = force_str(chr(z.v1.i))             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('unsupported info type code')
 */
      __pyx_t_3 = __Pyx_PyInt_From_int32_t(__pyx_v_z->v1.i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 542, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 542, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_str(__pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 542, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_value = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":541
 *         elif z.type == BCF_BT_FLOAT:
 *             value = z.v1.f if not bcf_float_is_missing(z.v1.f) else None
 *         elif z.type == BCF_BT_CHAR:             # <<<<<<<<<<<<<<
 *             value = force_str(chr(z.v1.i))
 *         else:
 */
      goto __pyx_L5;
    }

    /* "pysam/libcbcf.pyx":544
 *             value = force_str(chr(z.v1.i))
 *         else:
 *             raise TypeError('unsupported info type code')             # <<<<<<<<<<<<<<
 * 
 *         if not scalar and value != ():
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 544, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 544, __pyx_L1_error)
    }
    __pyx_L5:;

    /* "pysam/libcbcf.pyx":546
 *             raise TypeError('unsupported info type code')
 * 
 *         if not scalar and value != ():             # <<<<<<<<<<<<<<
 *             value = (value,)
 *     else:
 */
    __pyx_t_1 = ((!(__pyx_v_scalar != 0)) != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_value, __pyx_empty_tuple, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 546, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 546, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":547
 * 
 *         if not scalar and value != ():
 *             value = (value,)             # <<<<<<<<<<<<<<
 *     else:
 *         value = bcf_array_to_object(z.vptr, z.type, z.len, count, scalar)
 */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 547, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_value);
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":546
 *             raise TypeError('unsupported info type code')
 * 
 *         if not scalar and value != ():             # <<<<<<<<<<<<<<
 *             value = (value,)
 *     else:
 */
    }

    /* "pysam/libcbcf.pyx":532
 *         else:
 *             value = ()
 *     elif z.len == 1:             # <<<<<<<<<<<<<<
 *         if z.type == BCF_BT_INT8:
 *             value = z.v1.i if z.v1.i != bcf_int8_missing else None
 */
    break;
    default:

    /* "pysam/libcbcf.pyx":549
 *             value = (value,)
 *     else:
 *         value = bcf_array_to_object(z.vptr, z.type, z.len, count, scalar)             # <<<<<<<<<<<<<<
 * 
 *     return value
 */
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_array_to_object(__pyx_v_z->vptr, __pyx_v_z->type, __pyx_v_z->len, __pyx_v_count, __pyx_v_scalar); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_value = __pyx_t_3;
    __pyx_t_3 = 0;
    break;
  }

  /* "pysam/libcbcf.pyx":551
 *         value = bcf_array_to_object(z.vptr, z.type, z.len, count, scalar)
 * 
 *     return value             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_value);
  __pyx_r = __pyx_v_value;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":513
 * 
 * 
 * cdef object bcf_info_get_value(VariantRecord record, const bcf_info_t *z):             # <<<<<<<<<<<<<<
 *     if record is None:
 *         raise ValueError('record must not be None')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_info_get_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_16bcf_check_values_2generator31(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":593
 *                 raise ValueError('Integer value too small/large to store in VCF/BCF')
 *     elif ht_type == BCF_HT_STR:
 *         values = b','.join(force_bytes(v) if v is not None else b'' for v in values)             # <<<<<<<<<<<<<<
 *     elif ht_type == BCF_HT_FLAG:
 *         if values[0] not in (True, False, None, 1, 0):
 */

static PyObject *__pyx_pf_5pysam_7libcbcf_16bcf_check_values_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_7_genexpr(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_7_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 593, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_16bcf_check_values_2generator31, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_bcf_check_values_locals_genexpr, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 593, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.bcf_check_values.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_5pysam_7libcbcf_16bcf_check_values_2generator31(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __Pyx_TraceCall("genexpr", __pyx_f[0], 593, 0, __PYX_ERR(0, 593, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 593, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_values)) { __Pyx_RaiseClosureNameError("values"); __PYX_ERR(0, 593, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_values)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_values)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 593, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 593, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 593, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 593, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 593, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 593, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 593, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_5 = (__pyx_cur_scope->__pyx_v_v != Py_None);
    if ((__pyx_t_5 != 0)) {
      __pyx_t_6 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_cur_scope->__pyx_v_v, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __pyx_t_6;
      __pyx_t_6 = 0;
    } else {
      __Pyx_INCREF(__pyx_kp_b__15);
      __pyx_t_4 = __pyx_kp_b__15;
    }
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 593, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":554
 * 
 * 
 * cdef object bcf_check_values(VariantRecord record, value, int sample,             # <<<<<<<<<<<<<<
 *                              int hl_type, int ht_type,
 *                              int id, int bt_type, ssize_t bt_len,
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_check_values(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record, PyObject *__pyx_v_value, int __pyx_v_sample, int __pyx_v_hl_type, int __pyx_v_ht_type, int __pyx_v_id, int __pyx_v_bt_type, Py_ssize_t __pyx_v_bt_len, Py_ssize_t *__pyx_v_value_count, int *__pyx_v_scalar, int *__pyx_v_realloc) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *__pyx_cur_scope;
  int __pyx_v_given;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("bcf_check_values", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 554, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __Pyx_TraceCall("bcf_check_values", __pyx_f[0], 554, 0, __PYX_ERR(0, 554, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":559
 *                              ssize_t *value_count, int *scalar, int *realloc):
 * 
 *     if record is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('record must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_record) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":560
 * 
 *     if record is None:
 *         raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *     bcf_get_value_count(record, hl_type, id, value_count, scalar, sample)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 560, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":559
 *                              ssize_t *value_count, int *scalar, int *realloc):
 * 
 *     if record is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('record must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":562
 *         raise ValueError('record must not be None')
 * 
 *     bcf_get_value_count(record, hl_type, id, value_count, scalar, sample)             # <<<<<<<<<<<<<<
 * 
 *     # Validate values now that we know the type and size
 */
  __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_get_value_count(__pyx_v_record, __pyx_v_hl_type, __pyx_v_id, __pyx_v_value_count, __pyx_v_scalar, __pyx_v_sample); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":565
 * 
 *     # Validate values now that we know the type and size
 *     values = (value,) if not isinstance(value, (list, tuple)) else value             # <<<<<<<<<<<<<<
 * 
 *     # Validate values now that we know the type and size
 */
  __pyx_t_1 = PyList_Check(__pyx_v_value); 
  __pyx_t_4 = (__pyx_t_1 != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = PyTuple_Check(__pyx_v_value); 
  __pyx_t_1 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L4_bool_binop_done:;
  if (((!(__pyx_t_2 != 0)) != 0)) {
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_value);
    __pyx_t_3 = __pyx_t_5;
    __pyx_t_5 = 0;
  } else {
    __Pyx_INCREF(__pyx_v_value);
    __pyx_t_3 = __pyx_v_value;
  }
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_values = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":568
 * 
 *     # Validate values now that we know the type and size
 *     if ht_type == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *         value_count[0] = 1
 *     elif hl_type == BCF_HL_FMT and is_gt_fmt(record.header.ptr, id):
 */
  __pyx_t_2 = ((__pyx_v_ht_type == BCF_HT_FLAG) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":569
 *     # Validate values now that we know the type and size
 *     if ht_type == BCF_HT_FLAG:
 *         value_count[0] = 1             # <<<<<<<<<<<<<<
 *     elif hl_type == BCF_HL_FMT and is_gt_fmt(record.header.ptr, id):
 *         # KBJ: htslib lies about the cardinality of GT fields-- they're really VLEN (-1)
 */
    (__pyx_v_value_count[0]) = 1;

    /* "pysam/libcbcf.pyx":568
 * 
 *     # Validate values now that we know the type and size
 *     if ht_type == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *         value_count[0] = 1
 *     elif hl_type == BCF_HL_FMT and is_gt_fmt(record.header.ptr, id):
 */
    goto __pyx_L6;
  }

  /* "pysam/libcbcf.pyx":570
 *     if ht_type == BCF_HT_FLAG:
 *         value_count[0] = 1
 *     elif hl_type == BCF_HL_FMT and is_gt_fmt(record.header.ptr, id):             # <<<<<<<<<<<<<<
 *         # KBJ: htslib lies about the cardinality of GT fields-- they're really VLEN (-1)
 *         value_count[0] = -1
 */
  __pyx_t_1 = ((__pyx_v_hl_type == BCF_HL_FMT) != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_1 = (__pyx_f_5pysam_7libcbcf_is_gt_fmt(__pyx_v_record->header->ptr, __pyx_v_id) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":572
 *     elif hl_type == BCF_HL_FMT and is_gt_fmt(record.header.ptr, id):
 *         # KBJ: htslib lies about the cardinality of GT fields-- they're really VLEN (-1)
 *         value_count[0] = -1             # <<<<<<<<<<<<<<
 * 
 *     cdef int given = len(values)
 */
    (__pyx_v_value_count[0]) = -1L;

    /* "pysam/libcbcf.pyx":570
 *     if ht_type == BCF_HT_FLAG:
 *         value_count[0] = 1
 *     elif hl_type == BCF_HL_FMT and is_gt_fmt(record.header.ptr, id):             # <<<<<<<<<<<<<<
 *         # KBJ: htslib lies about the cardinality of GT fields-- they're really VLEN (-1)
 *         value_count[0] = -1
 */
  }
  __pyx_L6:;

  /* "pysam/libcbcf.pyx":574
 *         value_count[0] = -1
 * 
 *     cdef int given = len(values)             # <<<<<<<<<<<<<<
 *     if value_count[0] != -1 and value_count[0] != given:
 *         if scalar[0]:
 */
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_values;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_6 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 574, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_given = __pyx_t_6;

  /* "pysam/libcbcf.pyx":575
 * 
 *     cdef int given = len(values)
 *     if value_count[0] != -1 and value_count[0] != given:             # <<<<<<<<<<<<<<
 *         if scalar[0]:
 *             raise TypeError('value expected to be scalar, given len={}'.format(value_count[0], given))
 */
  __pyx_t_1 = (((__pyx_v_value_count[0]) != -1L) != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_1 = (((__pyx_v_value_count[0]) != __pyx_v_given) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L10_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":576
 *     cdef int given = len(values)
 *     if value_count[0] != -1 and value_count[0] != given:
 *         if scalar[0]:             # <<<<<<<<<<<<<<
 *             raise TypeError('value expected to be scalar, given len={}'.format(value_count[0], given))
 *         else:
 */
    __pyx_t_2 = ((__pyx_v_scalar[0]) != 0);
    if (unlikely(__pyx_t_2)) {

      /* "pysam/libcbcf.pyx":577
 *     if value_count[0] != -1 and value_count[0] != given:
 *         if scalar[0]:
 *             raise TypeError('value expected to be scalar, given len={}'.format(value_count[0], given))             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('values expected to be {}-tuple, given len={}'.format(value_count[0], given))
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_value_expected_to_be_scalar_give, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 577, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = PyInt_FromSsize_t((__pyx_v_value_count[0])); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 577, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_given); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 577, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_7, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 577, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_7, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 577, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 577, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        if (__pyx_t_9) {
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_8);
        __pyx_t_7 = 0;
        __pyx_t_8 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 577, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 577, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 577, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":576
 *     cdef int given = len(values)
 *     if value_count[0] != -1 and value_count[0] != given:
 *         if scalar[0]:             # <<<<<<<<<<<<<<
 *             raise TypeError('value expected to be scalar, given len={}'.format(value_count[0], given))
 *         else:
 */
    }

    /* "pysam/libcbcf.pyx":579
 *             raise TypeError('value expected to be scalar, given len={}'.format(value_count[0], given))
 *         else:
 *             raise TypeError('values expected to be {}-tuple, given len={}'.format(value_count[0], given))             # <<<<<<<<<<<<<<
 * 
 *     if ht_type == BCF_HT_REAL:
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_values_expected_to_be_tuple_give, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 579, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_11 = PyInt_FromSsize_t((__pyx_v_value_count[0])); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 579, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_given); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 579, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_11, __pyx_t_8};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 579, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_11, __pyx_t_8};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 579, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 579, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_10, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_10, __pyx_t_8);
        __pyx_t_11 = 0;
        __pyx_t_8 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 579, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 579, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 579, __pyx_L1_error)
    }

    /* "pysam/libcbcf.pyx":575
 * 
 *     cdef int given = len(values)
 *     if value_count[0] != -1 and value_count[0] != given:             # <<<<<<<<<<<<<<
 *         if scalar[0]:
 *             raise TypeError('value expected to be scalar, given len={}'.format(value_count[0], given))
 */
  }

  /* "pysam/libcbcf.pyx":581
 *             raise TypeError('values expected to be {}-tuple, given len={}'.format(value_count[0], given))
 * 
 *     if ht_type == BCF_HT_REAL:             # <<<<<<<<<<<<<<
 *         for v in values:
 *             if not(v is None or isinstance(v, (float, int))):
 */
  __pyx_t_2 = ((__pyx_v_ht_type == BCF_HT_REAL) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":582
 * 
 *     if ht_type == BCF_HT_REAL:
 *         for v in values:             # <<<<<<<<<<<<<<
 *             if not(v is None or isinstance(v, (float, int))):
 *                 raise TypeError('invalid value for Float format')
 */
    if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_values)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_values)) {
      __pyx_t_3 = __pyx_cur_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 582, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_12 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 582, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 582, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 582, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 582, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 582, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        }
      } else {
        __pyx_t_5 = __pyx_t_12(__pyx_t_3);
        if (unlikely(!__pyx_t_5)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 582, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "pysam/libcbcf.pyx":583
 *     if ht_type == BCF_HT_REAL:
 *         for v in values:
 *             if not(v is None or isinstance(v, (float, int))):             # <<<<<<<<<<<<<<
 *                 raise TypeError('invalid value for Float format')
 *     elif ht_type == BCF_HT_INT:
 */
      __pyx_t_1 = (__pyx_v_v == Py_None);
      __pyx_t_4 = (__pyx_t_1 != 0);
      if (!__pyx_t_4) {
      } else {
        __pyx_t_2 = __pyx_t_4;
        goto __pyx_L17_bool_binop_done;
      }
      __pyx_t_1 = PyFloat_Check(__pyx_v_v); 
      __pyx_t_13 = (__pyx_t_1 != 0);
      if (!__pyx_t_13) {
      } else {
        __pyx_t_4 = __pyx_t_13;
        goto __pyx_L19_bool_binop_done;
      }
      __pyx_t_13 = PyInt_Check(__pyx_v_v); 
      __pyx_t_1 = (__pyx_t_13 != 0);
      __pyx_t_4 = __pyx_t_1;
      __pyx_L19_bool_binop_done:;
      __pyx_t_1 = (__pyx_t_4 != 0);
      __pyx_t_2 = __pyx_t_1;
      __pyx_L17_bool_binop_done:;
      __pyx_t_1 = ((!__pyx_t_2) != 0);
      if (unlikely(__pyx_t_1)) {

        /* "pysam/libcbcf.pyx":584
 *         for v in values:
 *             if not(v is None or isinstance(v, (float, int))):
 *                 raise TypeError('invalid value for Float format')             # <<<<<<<<<<<<<<
 *     elif ht_type == BCF_HT_INT:
 *         for v in values:
 */
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 584, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __PYX_ERR(0, 584, __pyx_L1_error)

        /* "pysam/libcbcf.pyx":583
 *     if ht_type == BCF_HT_REAL:
 *         for v in values:
 *             if not(v is None or isinstance(v, (float, int))):             # <<<<<<<<<<<<<<
 *                 raise TypeError('invalid value for Float format')
 *     elif ht_type == BCF_HT_INT:
 */
      }

      /* "pysam/libcbcf.pyx":582
 * 
 *     if ht_type == BCF_HT_REAL:
 *         for v in values:             # <<<<<<<<<<<<<<
 *             if not(v is None or isinstance(v, (float, int))):
 *                 raise TypeError('invalid value for Float format')
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":581
 *             raise TypeError('values expected to be {}-tuple, given len={}'.format(value_count[0], given))
 * 
 *     if ht_type == BCF_HT_REAL:             # <<<<<<<<<<<<<<
 *         for v in values:
 *             if not(v is None or isinstance(v, (float, int))):
 */
    goto __pyx_L13;
  }

  /* "pysam/libcbcf.pyx":585
 *             if not(v is None or isinstance(v, (float, int))):
 *                 raise TypeError('invalid value for Float format')
 *     elif ht_type == BCF_HT_INT:             # <<<<<<<<<<<<<<
 *         for v in values:
 *             if not(v is None or (isinstance(v, (float, int)) and int(v) == v)):
 */
  __pyx_t_1 = ((__pyx_v_ht_type == BCF_HT_INT) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":586
 *                 raise TypeError('invalid value for Float format')
 *     elif ht_type == BCF_HT_INT:
 *         for v in values:             # <<<<<<<<<<<<<<
 *             if not(v is None or (isinstance(v, (float, int)) and int(v) == v)):
 *                 raise TypeError('invalid value for Integer format')
 */
    if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_values)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_values)) {
      __pyx_t_3 = __pyx_cur_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 586, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_12 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 586, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 586, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 586, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 586, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 586, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        }
      } else {
        __pyx_t_5 = __pyx_t_12(__pyx_t_3);
        if (unlikely(!__pyx_t_5)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 586, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "pysam/libcbcf.pyx":587
 *     elif ht_type == BCF_HT_INT:
 *         for v in values:
 *             if not(v is None or (isinstance(v, (float, int)) and int(v) == v)):             # <<<<<<<<<<<<<<
 *                 raise TypeError('invalid value for Integer format')
 *         for v in values:
 */
      __pyx_t_2 = (__pyx_v_v == Py_None);
      __pyx_t_4 = (__pyx_t_2 != 0);
      if (!__pyx_t_4) {
      } else {
        __pyx_t_1 = __pyx_t_4;
        goto __pyx_L24_bool_binop_done;
      }
      __pyx_t_2 = PyFloat_Check(__pyx_v_v); 
      __pyx_t_13 = (__pyx_t_2 != 0);
      if (!__pyx_t_13) {
      } else {
        __pyx_t_4 = __pyx_t_13;
        goto __pyx_L27_bool_binop_done;
      }
      __pyx_t_13 = PyInt_Check(__pyx_v_v); 
      __pyx_t_2 = (__pyx_t_13 != 0);
      __pyx_t_4 = __pyx_t_2;
      __pyx_L27_bool_binop_done:;
      __pyx_t_2 = (__pyx_t_4 != 0);
      if (__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L24_bool_binop_done;
      }
      __pyx_t_5 = __Pyx_PyNumber_Int(__pyx_v_v); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 587, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = PyObject_RichCompare(__pyx_t_5, __pyx_v_v, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 587, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 587, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_1 = __pyx_t_2;
      __pyx_L24_bool_binop_done:;
      __pyx_t_2 = ((!__pyx_t_1) != 0);
      if (unlikely(__pyx_t_2)) {

        /* "pysam/libcbcf.pyx":588
 *         for v in values:
 *             if not(v is None or (isinstance(v, (float, int)) and int(v) == v)):
 *                 raise TypeError('invalid value for Integer format')             # <<<<<<<<<<<<<<
 *         for v in values:
 *             if not(v is None or bcf_int32_missing < v <= INT32_MAX):
 */
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 588, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_Raise(__pyx_t_9, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __PYX_ERR(0, 588, __pyx_L1_error)

        /* "pysam/libcbcf.pyx":587
 *     elif ht_type == BCF_HT_INT:
 *         for v in values:
 *             if not(v is None or (isinstance(v, (float, int)) and int(v) == v)):             # <<<<<<<<<<<<<<
 *                 raise TypeError('invalid value for Integer format')
 *         for v in values:
 */
      }

      /* "pysam/libcbcf.pyx":586
 *                 raise TypeError('invalid value for Float format')
 *     elif ht_type == BCF_HT_INT:
 *         for v in values:             # <<<<<<<<<<<<<<
 *             if not(v is None or (isinstance(v, (float, int)) and int(v) == v)):
 *                 raise TypeError('invalid value for Integer format')
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":589
 *             if not(v is None or (isinstance(v, (float, int)) and int(v) == v)):
 *                 raise TypeError('invalid value for Integer format')
 *         for v in values:             # <<<<<<<<<<<<<<
 *             if not(v is None or bcf_int32_missing < v <= INT32_MAX):
 *                 raise ValueError('Integer value too small/large to store in VCF/BCF')
 */
    if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_values)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_values)) {
      __pyx_t_3 = __pyx_cur_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 589, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_12 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 589, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_9); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 589, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 589, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_9); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 589, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 589, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_12(__pyx_t_3);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 589, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "pysam/libcbcf.pyx":590
 *                 raise TypeError('invalid value for Integer format')
 *         for v in values:
 *             if not(v is None or bcf_int32_missing < v <= INT32_MAX):             # <<<<<<<<<<<<<<
 *                 raise ValueError('Integer value too small/large to store in VCF/BCF')
 *     elif ht_type == BCF_HT_STR:
 */
      __pyx_t_1 = (__pyx_v_v == Py_None);
      __pyx_t_4 = (__pyx_t_1 != 0);
      if (!__pyx_t_4) {
      } else {
        __pyx_t_2 = __pyx_t_4;
        goto __pyx_L32_bool_binop_done;
      }
      __pyx_t_9 = __Pyx_PyInt_From_int32_t(bcf_int32_missing); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 590, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = PyObject_RichCompare(__pyx_t_9, __pyx_v_v, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 590, __pyx_L1_error)
      if (__Pyx_PyObject_IsTrue(__pyx_t_5)) {
        __Pyx_DECREF(__pyx_t_5);
        __pyx_t_8 = __Pyx_PyInt_From_int32_t(INT32_MAX); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 590, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_5 = PyObject_RichCompare(__pyx_v_v, __pyx_t_8, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 590, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 590, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_2 = __pyx_t_4;
      __pyx_L32_bool_binop_done:;
      __pyx_t_4 = ((!__pyx_t_2) != 0);
      if (unlikely(__pyx_t_4)) {

        /* "pysam/libcbcf.pyx":591
 *         for v in values:
 *             if not(v is None or bcf_int32_missing < v <= INT32_MAX):
 *                 raise ValueError('Integer value too small/large to store in VCF/BCF')             # <<<<<<<<<<<<<<
 *     elif ht_type == BCF_HT_STR:
 *         values = b','.join(force_bytes(v) if v is not None else b'' for v in values)
 */
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 591, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __PYX_ERR(0, 591, __pyx_L1_error)

        /* "pysam/libcbcf.pyx":590
 *                 raise TypeError('invalid value for Integer format')
 *         for v in values:
 *             if not(v is None or bcf_int32_missing < v <= INT32_MAX):             # <<<<<<<<<<<<<<
 *                 raise ValueError('Integer value too small/large to store in VCF/BCF')
 *     elif ht_type == BCF_HT_STR:
 */
      }

      /* "pysam/libcbcf.pyx":589
 *             if not(v is None or (isinstance(v, (float, int)) and int(v) == v)):
 *                 raise TypeError('invalid value for Integer format')
 *         for v in values:             # <<<<<<<<<<<<<<
 *             if not(v is None or bcf_int32_missing < v <= INT32_MAX):
 *                 raise ValueError('Integer value too small/large to store in VCF/BCF')
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":585
 *             if not(v is None or isinstance(v, (float, int))):
 *                 raise TypeError('invalid value for Float format')
 *     elif ht_type == BCF_HT_INT:             # <<<<<<<<<<<<<<
 *         for v in values:
 *             if not(v is None or (isinstance(v, (float, int)) and int(v) == v)):
 */
    goto __pyx_L13;
  }

  /* "pysam/libcbcf.pyx":592
 *             if not(v is None or bcf_int32_missing < v <= INT32_MAX):
 *                 raise ValueError('Integer value too small/large to store in VCF/BCF')
 *     elif ht_type == BCF_HT_STR:             # <<<<<<<<<<<<<<
 *         values = b','.join(force_bytes(v) if v is not None else b'' for v in values)
 *     elif ht_type == BCF_HT_FLAG:
 */
  __pyx_t_4 = ((__pyx_v_ht_type == BCF_HT_STR) != 0);
  if (__pyx_t_4) {

    /* "pysam/libcbcf.pyx":593
 *                 raise ValueError('Integer value too small/large to store in VCF/BCF')
 *     elif ht_type == BCF_HT_STR:
 *         values = b','.join(force_bytes(v) if v is not None else b'' for v in values)             # <<<<<<<<<<<<<<
 *     elif ht_type == BCF_HT_FLAG:
 *         if values[0] not in (True, False, None, 1, 0):
 */
    __pyx_t_3 = __pyx_pf_5pysam_7libcbcf_16bcf_check_values_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 593, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyBytes_Join(__pyx_kp_b__2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 593, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_values);
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_values, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;

    /* "pysam/libcbcf.pyx":592
 *             if not(v is None or bcf_int32_missing < v <= INT32_MAX):
 *                 raise ValueError('Integer value too small/large to store in VCF/BCF')
 *     elif ht_type == BCF_HT_STR:             # <<<<<<<<<<<<<<
 *         values = b','.join(force_bytes(v) if v is not None else b'' for v in values)
 *     elif ht_type == BCF_HT_FLAG:
 */
    goto __pyx_L13;
  }

  /* "pysam/libcbcf.pyx":594
 *     elif ht_type == BCF_HT_STR:
 *         values = b','.join(force_bytes(v) if v is not None else b'' for v in values)
 *     elif ht_type == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *         if values[0] not in (True, False, None, 1, 0):
 *             raise ValueError('Flag values must be: True, False, None, 1, 0')
 */
  __pyx_t_4 = ((__pyx_v_ht_type == BCF_HT_FLAG) != 0);
  if (likely(__pyx_t_4)) {

    /* "pysam/libcbcf.pyx":595
 *         values = b','.join(force_bytes(v) if v is not None else b'' for v in values)
 *     elif ht_type == BCF_HT_FLAG:
 *         if values[0] not in (True, False, None, 1, 0):             # <<<<<<<<<<<<<<
 *             raise ValueError('Flag values must be: True, False, None, 1, 0')
 *     else:
 */
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_values, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 595, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, Py_True, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 595, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 595, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {
    } else {
      __pyx_t_4 = __pyx_t_2;
      goto __pyx_L35_bool_binop_done;
    }
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, Py_False, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 595, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 595, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {
    } else {
      __pyx_t_4 = __pyx_t_2;
      goto __pyx_L35_bool_binop_done;
    }
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 595, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 595, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {
    } else {
      __pyx_t_4 = __pyx_t_2;
      goto __pyx_L35_bool_binop_done;
    }
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 595, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 595, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {
    } else {
      __pyx_t_4 = __pyx_t_2;
      goto __pyx_L35_bool_binop_done;
    }
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 595, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 595, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = __pyx_t_2;
    __pyx_L35_bool_binop_done:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = (__pyx_t_4 != 0);
    if (unlikely(__pyx_t_2)) {

      /* "pysam/libcbcf.pyx":596
 *     elif ht_type == BCF_HT_FLAG:
 *         if values[0] not in (True, False, None, 1, 0):
 *             raise ValueError('Flag values must be: True, False, None, 1, 0')             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError('unsupported type')
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 596, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 596, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":595
 *         values = b','.join(force_bytes(v) if v is not None else b'' for v in values)
 *     elif ht_type == BCF_HT_FLAG:
 *         if values[0] not in (True, False, None, 1, 0):             # <<<<<<<<<<<<<<
 *             raise ValueError('Flag values must be: True, False, None, 1, 0')
 *     else:
 */
    }

    /* "pysam/libcbcf.pyx":594
 *     elif ht_type == BCF_HT_STR:
 *         values = b','.join(force_bytes(v) if v is not None else b'' for v in values)
 *     elif ht_type == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *         if values[0] not in (True, False, None, 1, 0):
 *             raise ValueError('Flag values must be: True, False, None, 1, 0')
 */
    goto __pyx_L13;
  }

  /* "pysam/libcbcf.pyx":598
 *             raise ValueError('Flag values must be: True, False, None, 1, 0')
 *     else:
 *         raise TypeError('unsupported type')             # <<<<<<<<<<<<<<
 * 
 *     realloc[0] = 0
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 598, __pyx_L1_error)
  }
  __pyx_L13:;

  /* "pysam/libcbcf.pyx":600
 *         raise TypeError('unsupported type')
 * 
 *     realloc[0] = 0             # <<<<<<<<<<<<<<
 *     if len(values) <= 1 and hl_type == BCF_HL_INFO:
 *         realloc[0] = 0
 */
  (__pyx_v_realloc[0]) = 0;

  /* "pysam/libcbcf.pyx":601
 * 
 *     realloc[0] = 0
 *     if len(values) <= 1 and hl_type == BCF_HL_INFO:             # <<<<<<<<<<<<<<
 *         realloc[0] = 0
 *     elif len(values) > bt_len:
 */
  __pyx_t_5 = __pyx_cur_scope->__pyx_v_values;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_6 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 601, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_4 = ((__pyx_t_6 <= 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L41_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_hl_type == BCF_HL_INFO) != 0);
  __pyx_t_2 = __pyx_t_4;
  __pyx_L41_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":602
 *     realloc[0] = 0
 *     if len(values) <= 1 and hl_type == BCF_HL_INFO:
 *         realloc[0] = 0             # <<<<<<<<<<<<<<
 *     elif len(values) > bt_len:
 *         realloc[0] = 1
 */
    (__pyx_v_realloc[0]) = 0;

    /* "pysam/libcbcf.pyx":601
 * 
 *     realloc[0] = 0
 *     if len(values) <= 1 and hl_type == BCF_HL_INFO:             # <<<<<<<<<<<<<<
 *         realloc[0] = 0
 *     elif len(values) > bt_len:
 */
    goto __pyx_L40;
  }

  /* "pysam/libcbcf.pyx":603
 *     if len(values) <= 1 and hl_type == BCF_HL_INFO:
 *         realloc[0] = 0
 *     elif len(values) > bt_len:             # <<<<<<<<<<<<<<
 *         realloc[0] = 1
 *     elif bt_type == BCF_BT_INT8:
 */
  __pyx_t_5 = __pyx_cur_scope->__pyx_v_values;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_6 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 603, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = ((__pyx_t_6 > __pyx_v_bt_len) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":604
 *         realloc[0] = 0
 *     elif len(values) > bt_len:
 *         realloc[0] = 1             # <<<<<<<<<<<<<<
 *     elif bt_type == BCF_BT_INT8:
 *         for v in values:
 */
    (__pyx_v_realloc[0]) = 1;

    /* "pysam/libcbcf.pyx":603
 *     if len(values) <= 1 and hl_type == BCF_HL_INFO:
 *         realloc[0] = 0
 *     elif len(values) > bt_len:             # <<<<<<<<<<<<<<
 *         realloc[0] = 1
 *     elif bt_type == BCF_BT_INT8:
 */
    goto __pyx_L40;
  }

  /* "pysam/libcbcf.pyx":605
 *     elif len(values) > bt_len:
 *         realloc[0] = 1
 *     elif bt_type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *         for v in values:
 *             if v is not None and not(bcf_int8_missing < v <= INT8_MAX):
 */
  __pyx_t_2 = ((__pyx_v_bt_type == BCF_BT_INT8) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":606
 *         realloc[0] = 1
 *     elif bt_type == BCF_BT_INT8:
 *         for v in values:             # <<<<<<<<<<<<<<
 *             if v is not None and not(bcf_int8_missing < v <= INT8_MAX):
 *                 realloc[0] = 1
 */
    if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_values)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_values)) {
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_values); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 606, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_12 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 606, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 606, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 606, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 606, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 606, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_12(__pyx_t_5);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 606, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":607
 *     elif bt_type == BCF_BT_INT8:
 *         for v in values:
 *             if v is not None and not(bcf_int8_missing < v <= INT8_MAX):             # <<<<<<<<<<<<<<
 *                 realloc[0] = 1
 *                 break
 */
      __pyx_t_4 = (__pyx_v_v != Py_None);
      __pyx_t_1 = (__pyx_t_4 != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L46_bool_binop_done;
      }
      __pyx_t_3 = __Pyx_PyInt_From_int32_t(bcf_int8_missing); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 607, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = PyObject_RichCompare(__pyx_t_3, __pyx_v_v, Py_LT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 607, __pyx_L1_error)
      if (__Pyx_PyObject_IsTrue(__pyx_t_9)) {
        __Pyx_DECREF(__pyx_t_9);
        __pyx_t_8 = __Pyx_PyInt_From_int8_t(INT8_MAX); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 607, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = PyObject_RichCompare(__pyx_v_v, __pyx_t_8, Py_LE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 607, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 607, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_4 = ((!__pyx_t_1) != 0);
      __pyx_t_2 = __pyx_t_4;
      __pyx_L46_bool_binop_done:;
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":608
 *         for v in values:
 *             if v is not None and not(bcf_int8_missing < v <= INT8_MAX):
 *                 realloc[0] = 1             # <<<<<<<<<<<<<<
 *                 break
 *     elif bt_type == BCF_BT_INT16:
 */
        (__pyx_v_realloc[0]) = 1;

        /* "pysam/libcbcf.pyx":609
 *             if v is not None and not(bcf_int8_missing < v <= INT8_MAX):
 *                 realloc[0] = 1
 *                 break             # <<<<<<<<<<<<<<
 *     elif bt_type == BCF_BT_INT16:
 *         for v in values:
 */
        goto __pyx_L44_break;

        /* "pysam/libcbcf.pyx":607
 *     elif bt_type == BCF_BT_INT8:
 *         for v in values:
 *             if v is not None and not(bcf_int8_missing < v <= INT8_MAX):             # <<<<<<<<<<<<<<
 *                 realloc[0] = 1
 *                 break
 */
      }

      /* "pysam/libcbcf.pyx":606
 *         realloc[0] = 1
 *     elif bt_type == BCF_BT_INT8:
 *         for v in values:             # <<<<<<<<<<<<<<
 *             if v is not None and not(bcf_int8_missing < v <= INT8_MAX):
 *                 realloc[0] = 1
 */
    }
    __pyx_L44_break:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "pysam/libcbcf.pyx":605
 *     elif len(values) > bt_len:
 *         realloc[0] = 1
 *     elif bt_type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *         for v in values:
 *             if v is not None and not(bcf_int8_missing < v <= INT8_MAX):
 */
    goto __pyx_L40;
  }

  /* "pysam/libcbcf.pyx":610
 *                 realloc[0] = 1
 *                 break
 *     elif bt_type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *         for v in values:
 *             if v is not None and not(bcf_int16_missing < v <= INT16_MAX):
 */
  __pyx_t_2 = ((__pyx_v_bt_type == BCF_BT_INT16) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":611
 *                 break
 *     elif bt_type == BCF_BT_INT16:
 *         for v in values:             # <<<<<<<<<<<<<<
 *             if v is not None and not(bcf_int16_missing < v <= INT16_MAX):
 *                 realloc[0] = 1
 */
    if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_values)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_values)) {
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_values); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_12 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 611, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_9); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 611, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_9); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 611, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_12(__pyx_t_5);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 611, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "pysam/libcbcf.pyx":612
 *     elif bt_type == BCF_BT_INT16:
 *         for v in values:
 *             if v is not None and not(bcf_int16_missing < v <= INT16_MAX):             # <<<<<<<<<<<<<<
 *                 realloc[0] = 1
 *                 break
 */
      __pyx_t_4 = (__pyx_v_v != Py_None);
      __pyx_t_1 = (__pyx_t_4 != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L51_bool_binop_done;
      }
      __pyx_t_9 = __Pyx_PyInt_From_int32_t(bcf_int16_missing); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 612, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_9, __pyx_v_v, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 612, __pyx_L1_error)
      if (__Pyx_PyObject_IsTrue(__pyx_t_3)) {
        __Pyx_DECREF(__pyx_t_3);
        __pyx_t_8 = __Pyx_PyInt_From_int16_t(INT16_MAX); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 612, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_3 = PyObject_RichCompare(__pyx_v_v, __pyx_t_8, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 612, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 612, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = ((!__pyx_t_1) != 0);
      __pyx_t_2 = __pyx_t_4;
      __pyx_L51_bool_binop_done:;
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":613
 *         for v in values:
 *             if v is not None and not(bcf_int16_missing < v <= INT16_MAX):
 *                 realloc[0] = 1             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
        (__pyx_v_realloc[0]) = 1;

        /* "pysam/libcbcf.pyx":614
 *             if v is not None and not(bcf_int16_missing < v <= INT16_MAX):
 *                 realloc[0] = 1
 *                 break             # <<<<<<<<<<<<<<
 * 
 *     return values
 */
        goto __pyx_L49_break;

        /* "pysam/libcbcf.pyx":612
 *     elif bt_type == BCF_BT_INT16:
 *         for v in values:
 *             if v is not None and not(bcf_int16_missing < v <= INT16_MAX):             # <<<<<<<<<<<<<<
 *                 realloc[0] = 1
 *                 break
 */
      }

      /* "pysam/libcbcf.pyx":611
 *                 break
 *     elif bt_type == BCF_BT_INT16:
 *         for v in values:             # <<<<<<<<<<<<<<
 *             if v is not None and not(bcf_int16_missing < v <= INT16_MAX):
 *                 realloc[0] = 1
 */
    }
    __pyx_L49_break:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "pysam/libcbcf.pyx":610
 *                 realloc[0] = 1
 *                 break
 *     elif bt_type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *         for v in values:
 *             if v is not None and not(bcf_int16_missing < v <= INT16_MAX):
 */
  }
  __pyx_L40:;

  /* "pysam/libcbcf.pyx":616
 *                 break
 * 
 *     return values             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_values);
  __pyx_r = __pyx_cur_scope->__pyx_v_values;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":554
 * 
 * 
 * cdef object bcf_check_values(VariantRecord record, value, int sample,             # <<<<<<<<<<<<<<
 *                              int hl_type, int ht_type,
 *                              int id, int bt_type, ssize_t bt_len,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_check_values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":619
 * 
 * 
 * cdef bcf_encode_alleles(VariantRecord record, values):             # <<<<<<<<<<<<<<
 *     if record is None:
 *         raise ValueError('record must not be None')
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_encode_alleles(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record, PyObject *__pyx_v_values) {
  bcf1_t *__pyx_v_r;
  int32_t __pyx_v_nalleles;
  PyObject *__pyx_v_gt_values = 0;
  char *__pyx_v_s;
  int __pyx_v_i;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_bvalue = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf1_t *__pyx_t_4;
  uint32_t __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  char *__pyx_t_11;
  uint32_t __pyx_t_12;
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("bcf_encode_alleles", 0);
  __Pyx_TraceCall("bcf_encode_alleles", __pyx_f[0], 619, 0, __PYX_ERR(0, 619, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_values);

  /* "pysam/libcbcf.pyx":620
 * 
 * cdef bcf_encode_alleles(VariantRecord record, values):
 *     if record is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('record must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_record) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":621
 * cdef bcf_encode_alleles(VariantRecord record, values):
 *     if record is None:
 *         raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf1_t *r = record.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 621, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 621, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":620
 * 
 * cdef bcf_encode_alleles(VariantRecord record, values):
 *     if record is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('record must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":623
 *         raise ValueError('record must not be None')
 * 
 *     cdef bcf1_t *r = record.ptr             # <<<<<<<<<<<<<<
 *     cdef int32_t nalleles = r.n_allele
 *     cdef list gt_values = []
 */
  __pyx_t_4 = __pyx_v_record->ptr;
  __pyx_v_r = __pyx_t_4;

  /* "pysam/libcbcf.pyx":624
 * 
 *     cdef bcf1_t *r = record.ptr
 *     cdef int32_t nalleles = r.n_allele             # <<<<<<<<<<<<<<
 *     cdef list gt_values = []
 *     cdef char *s
 */
  __pyx_t_5 = __pyx_v_r->n_allele;
  __pyx_v_nalleles = __pyx_t_5;

  /* "pysam/libcbcf.pyx":625
 *     cdef bcf1_t *r = record.ptr
 *     cdef int32_t nalleles = r.n_allele
 *     cdef list gt_values = []             # <<<<<<<<<<<<<<
 *     cdef char *s
 *     cdef int i
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_gt_values = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":629
 *     cdef int i
 * 
 *     if values is None:             # <<<<<<<<<<<<<<
 *         return ()
 * 
 */
  __pyx_t_2 = (__pyx_v_values == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":630
 * 
 *     if values is None:
 *         return ()             # <<<<<<<<<<<<<<
 * 
 *     if not isinstance(values, (list, tuple)):
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":629
 *     cdef int i
 * 
 *     if values is None:             # <<<<<<<<<<<<<<
 *         return ()
 * 
 */
  }

  /* "pysam/libcbcf.pyx":632
 *         return ()
 * 
 *     if not isinstance(values, (list, tuple)):             # <<<<<<<<<<<<<<
 *         values = (values,)
 * 
 */
  __pyx_t_2 = PyList_Check(__pyx_v_values); 
  __pyx_t_6 = (__pyx_t_2 != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_1 = __pyx_t_6;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_6 = PyTuple_Check(__pyx_v_values); 
  __pyx_t_2 = (__pyx_t_6 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":633
 * 
 *     if not isinstance(values, (list, tuple)):
 *         values = (values,)             # <<<<<<<<<<<<<<
 * 
 *     for value in values:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_values);
    __Pyx_GIVEREF(__pyx_v_values);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_values);
    __Pyx_DECREF_SET(__pyx_v_values, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":632
 *         return ()
 * 
 *     if not isinstance(values, (list, tuple)):             # <<<<<<<<<<<<<<
 *         values = (values,)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":635
 *         values = (values,)
 * 
 *     for value in values:             # <<<<<<<<<<<<<<
 *         if value is None:
 *             gt_values.append(bcf_gt_missing)
 */
  if (likely(PyList_CheckExact(__pyx_v_values)) || PyTuple_CheckExact(__pyx_v_values)) {
    __pyx_t_3 = __pyx_v_values; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 635, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 635, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 635, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 635, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 635, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 635, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      }
    } else {
      __pyx_t_9 = __pyx_t_8(__pyx_t_3);
      if (unlikely(!__pyx_t_9)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 635, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_9);
    }
    __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "pysam/libcbcf.pyx":636
 * 
 *     for value in values:
 *         if value is None:             # <<<<<<<<<<<<<<
 *             gt_values.append(bcf_gt_missing)
 *         elif isinstance(value, (str, bytes)):
 */
    __pyx_t_2 = (__pyx_v_value == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":637
 *     for value in values:
 *         if value is None:
 *             gt_values.append(bcf_gt_missing)             # <<<<<<<<<<<<<<
 *         elif isinstance(value, (str, bytes)):
 *             bvalue = force_bytes(value)
 */
      __pyx_t_9 = __Pyx_PyInt_From_uint32_t(bcf_gt_missing); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 637, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_gt_values, __pyx_t_9); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 637, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "pysam/libcbcf.pyx":636
 * 
 *     for value in values:
 *         if value is None:             # <<<<<<<<<<<<<<
 *             gt_values.append(bcf_gt_missing)
 *         elif isinstance(value, (str, bytes)):
 */
      goto __pyx_L10;
    }

    /* "pysam/libcbcf.pyx":638
 *         if value is None:
 *             gt_values.append(bcf_gt_missing)
 *         elif isinstance(value, (str, bytes)):             # <<<<<<<<<<<<<<
 *             bvalue = force_bytes(value)
 *             s = bvalue
 */
    __pyx_t_2 = PyString_Check(__pyx_v_value); 
    __pyx_t_6 = (__pyx_t_2 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_1 = __pyx_t_6;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_6 = PyBytes_Check(__pyx_v_value); 
    __pyx_t_2 = (__pyx_t_6 != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L11_bool_binop_done:;
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":639
 *             gt_values.append(bcf_gt_missing)
 *         elif isinstance(value, (str, bytes)):
 *             bvalue = force_bytes(value)             # <<<<<<<<<<<<<<
 *             s = bvalue
 *             for i in range(r.n_allele):
 */
      __pyx_t_9 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_value, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 639, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_XDECREF_SET(__pyx_v_bvalue, ((PyObject*)__pyx_t_9));
      __pyx_t_9 = 0;

      /* "pysam/libcbcf.pyx":640
 *         elif isinstance(value, (str, bytes)):
 *             bvalue = force_bytes(value)
 *             s = bvalue             # <<<<<<<<<<<<<<
 *             for i in range(r.n_allele):
 *                 if strcmp(r.d.allele[i], s) != 0:
 */
      if (unlikely(__pyx_v_bvalue == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
        __PYX_ERR(0, 640, __pyx_L1_error)
      }
      __pyx_t_11 = __Pyx_PyBytes_AsWritableString(__pyx_v_bvalue); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 640, __pyx_L1_error)
      __pyx_v_s = __pyx_t_11;

      /* "pysam/libcbcf.pyx":641
 *             bvalue = force_bytes(value)
 *             s = bvalue
 *             for i in range(r.n_allele):             # <<<<<<<<<<<<<<
 *                 if strcmp(r.d.allele[i], s) != 0:
 *                     gt_values.append(bcf_gt_unphased(i))
 */
      __pyx_t_5 = __pyx_v_r->n_allele;
      __pyx_t_12 = __pyx_t_5;
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
        __pyx_v_i = __pyx_t_13;

        /* "pysam/libcbcf.pyx":642
 *             s = bvalue
 *             for i in range(r.n_allele):
 *                 if strcmp(r.d.allele[i], s) != 0:             # <<<<<<<<<<<<<<
 *                     gt_values.append(bcf_gt_unphased(i))
 *                     break
 */
        __pyx_t_2 = ((strcmp((__pyx_v_r->d.allele[__pyx_v_i]), __pyx_v_s) != 0) != 0);
        if (__pyx_t_2) {

          /* "pysam/libcbcf.pyx":643
 *             for i in range(r.n_allele):
 *                 if strcmp(r.d.allele[i], s) != 0:
 *                     gt_values.append(bcf_gt_unphased(i))             # <<<<<<<<<<<<<<
 *                     break
 *             else:
 */
          __pyx_t_9 = __Pyx_PyInt_From_uint32_t(bcf_gt_unphased(__pyx_v_i)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 643, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_gt_values, __pyx_t_9); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 643, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

          /* "pysam/libcbcf.pyx":644
 *                 if strcmp(r.d.allele[i], s) != 0:
 *                     gt_values.append(bcf_gt_unphased(i))
 *                     break             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError('Unknown allele')
 */
          goto __pyx_L14_break;

          /* "pysam/libcbcf.pyx":642
 *             s = bvalue
 *             for i in range(r.n_allele):
 *                 if strcmp(r.d.allele[i], s) != 0:             # <<<<<<<<<<<<<<
 *                     gt_values.append(bcf_gt_unphased(i))
 *                     break
 */
        }
      }
      /*else*/ {

        /* "pysam/libcbcf.pyx":646
 *                     break
 *             else:
 *                 raise ValueError('Unknown allele')             # <<<<<<<<<<<<<<
 *         else:
 *             i = value
 */
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 646, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_Raise(__pyx_t_9, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __PYX_ERR(0, 646, __pyx_L1_error)
      }
      __pyx_L14_break:;

      /* "pysam/libcbcf.pyx":638
 *         if value is None:
 *             gt_values.append(bcf_gt_missing)
 *         elif isinstance(value, (str, bytes)):             # <<<<<<<<<<<<<<
 *             bvalue = force_bytes(value)
 *             s = bvalue
 */
      goto __pyx_L10;
    }

    /* "pysam/libcbcf.pyx":648
 *                 raise ValueError('Unknown allele')
 *         else:
 *             i = value             # <<<<<<<<<<<<<<
 *             if not (0 <= i < nalleles):
 *                 raise ValueError('Invalid allele index')
 */
    /*else*/ {
      __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 648, __pyx_L1_error)
      __pyx_v_i = __pyx_t_13;

      /* "pysam/libcbcf.pyx":649
 *         else:
 *             i = value
 *             if not (0 <= i < nalleles):             # <<<<<<<<<<<<<<
 *                 raise ValueError('Invalid allele index')
 *             gt_values.append(bcf_gt_unphased(i))
 */
      __pyx_t_2 = (0 <= __pyx_v_i);
      if (__pyx_t_2) {
        __pyx_t_2 = (__pyx_v_i < __pyx_v_nalleles);
      }
      __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
      if (unlikely(__pyx_t_1)) {

        /* "pysam/libcbcf.pyx":650
 *             i = value
 *             if not (0 <= i < nalleles):
 *                 raise ValueError('Invalid allele index')             # <<<<<<<<<<<<<<
 *             gt_values.append(bcf_gt_unphased(i))
 * 
 */
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 650, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_Raise(__pyx_t_9, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __PYX_ERR(0, 650, __pyx_L1_error)

        /* "pysam/libcbcf.pyx":649
 *         else:
 *             i = value
 *             if not (0 <= i < nalleles):             # <<<<<<<<<<<<<<
 *                 raise ValueError('Invalid allele index')
 *             gt_values.append(bcf_gt_unphased(i))
 */
      }

      /* "pysam/libcbcf.pyx":651
 *             if not (0 <= i < nalleles):
 *                 raise ValueError('Invalid allele index')
 *             gt_values.append(bcf_gt_unphased(i))             # <<<<<<<<<<<<<<
 * 
 *     return gt_values
 */
      __pyx_t_9 = __Pyx_PyInt_From_uint32_t(bcf_gt_unphased(__pyx_v_i)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 651, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_gt_values, __pyx_t_9); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 651, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __pyx_L10:;

    /* "pysam/libcbcf.pyx":635
 *         values = (values,)
 * 
 *     for value in values:             # <<<<<<<<<<<<<<
 *         if value is None:
 *             gt_values.append(bcf_gt_missing)
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":653
 *             gt_values.append(bcf_gt_unphased(i))
 * 
 *     return gt_values             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_gt_values);
  __pyx_r = __pyx_v_gt_values;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":619
 * 
 * 
 * cdef bcf_encode_alleles(VariantRecord record, values):             # <<<<<<<<<<<<<<
 *     if record is None:
 *         raise ValueError('record must not be None')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_encode_alleles", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_gt_values);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_bvalue);
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":656
 * 
 * 
 * cdef bcf_info_set_value(VariantRecord record, key, value):             # <<<<<<<<<<<<<<
 *     if record is None:
 *         raise ValueError('record must not be None')
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_info_set_value(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int __pyx_v_info_id;
  int __pyx_v_info_type;
  int __pyx_v_scalar;
  int __pyx_v_dst_type;
  int __pyx_v_realloc;
  int __pyx_v_vlen;
  Py_ssize_t __pyx_v_value_count;
  Py_ssize_t __pyx_v_alloc_len;
  PyObject *__pyx_v_bkey = 0;
  bcf_info_t *__pyx_v_info;
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_new_values = NULL;
  char *__pyx_v_valp;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  bcf1_t *__pyx_t_5;
  char const *__pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  char const *__pyx_t_12;
  Py_ssize_t __pyx_t_13;
  long __pyx_t_14;
  Py_ssize_t __pyx_t_15;
  char *__pyx_t_16;
  __Pyx_RefNannySetupContext("bcf_info_set_value", 0);
  __Pyx_TraceCall("bcf_info_set_value", __pyx_f[0], 656, 0, __PYX_ERR(0, 656, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":657
 * 
 * cdef bcf_info_set_value(VariantRecord record, key, value):
 *     if record is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('record must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_record) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":658
 * cdef bcf_info_set_value(VariantRecord record, key, value):
 *     if record is None:
 *         raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 658, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 658, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":657
 * 
 * cdef bcf_info_set_value(VariantRecord record, key, value):
 *     if record is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('record must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":660
 *         raise ValueError('record must not be None')
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr             # <<<<<<<<<<<<<<
 *     cdef bcf1_t *r = record.ptr
 *     cdef int info_id, info_type, scalar, dst_type, realloc, vlen = 0
 */
  __pyx_t_4 = __pyx_v_record->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":661
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 *     cdef bcf1_t *r = record.ptr             # <<<<<<<<<<<<<<
 *     cdef int info_id, info_type, scalar, dst_type, realloc, vlen = 0
 *     cdef ssize_t i, value_count, alloc_len, alloc_size, dst_size
 */
  __pyx_t_5 = __pyx_v_record->ptr;
  __pyx_v_r = __pyx_t_5;

  /* "pysam/libcbcf.pyx":662
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 *     cdef bcf1_t *r = record.ptr
 *     cdef int info_id, info_type, scalar, dst_type, realloc, vlen = 0             # <<<<<<<<<<<<<<
 *     cdef ssize_t i, value_count, alloc_len, alloc_size, dst_size
 * 
 */
  __pyx_v_vlen = 0;

  /* "pysam/libcbcf.pyx":665
 *     cdef ssize_t i, value_count, alloc_len, alloc_size, dst_size
 * 
 *     if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":666
 * 
 *     if bcf_unpack(r, BCF_UN_INFO) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef bytes bkey = force_bytes(key)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 666, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 666, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":665
 *     cdef ssize_t i, value_count, alloc_len, alloc_size, dst_size
 * 
 *     if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":668
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 *     cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *     cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 * 
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 668, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_bkey = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":669
 * 
 *     cdef bytes bkey = force_bytes(key)
 *     cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)             # <<<<<<<<<<<<<<
 * 
 *     if info:
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 669, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 669, __pyx_L1_error)
  __pyx_v_info = bcf_get_info(__pyx_v_hdr, __pyx_v_r, __pyx_t_6);

  /* "pysam/libcbcf.pyx":671
 *     cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 * 
 *     if info:             # <<<<<<<<<<<<<<
 *         info_id = info.key
 *     else:
 */
  __pyx_t_2 = (__pyx_v_info != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":672
 * 
 *     if info:
 *         info_id = info.key             # <<<<<<<<<<<<<<
 *     else:
 *         info_id = bcf_header_get_info_id(hdr, bkey)
 */
    __pyx_t_7 = __pyx_v_info->key;
    __pyx_v_info_id = __pyx_t_7;

    /* "pysam/libcbcf.pyx":671
 *     cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 * 
 *     if info:             # <<<<<<<<<<<<<<
 *         info_id = info.key
 *     else:
 */
    goto __pyx_L5;
  }

  /* "pysam/libcbcf.pyx":674
 *         info_id = info.key
 *     else:
 *         info_id = bcf_header_get_info_id(hdr, bkey)             # <<<<<<<<<<<<<<
 * 
 *     if info_id < 0:
 */
  /*else*/ {
    __pyx_t_7 = __pyx_f_5pysam_7libcbcf_bcf_header_get_info_id(__pyx_v_hdr, __pyx_v_bkey); if (unlikely(__pyx_t_7 == ((int)-2) && PyErr_Occurred())) __PYX_ERR(0, 674, __pyx_L1_error)
    __pyx_v_info_id = __pyx_t_7;
  }
  __pyx_L5:;

  /* "pysam/libcbcf.pyx":676
 *         info_id = bcf_header_get_info_id(hdr, bkey)
 * 
 *     if info_id < 0:             # <<<<<<<<<<<<<<
 *         raise KeyError('unknown INFO: {}'.format(key))
 * 
 */
  __pyx_t_2 = ((__pyx_v_info_id < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":677
 * 
 *     if info_id < 0:
 *         raise KeyError('unknown INFO: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *     if not check_header_id(hdr, BCF_HL_INFO, info_id):
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_unknown_INFO, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 677, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_key};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_key};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 677, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_key);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 677, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __PYX_ERR(0, 677, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":676
 *         info_id = bcf_header_get_info_id(hdr, bkey)
 * 
 *     if info_id < 0:             # <<<<<<<<<<<<<<
 *         raise KeyError('unknown INFO: {}'.format(key))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":679
 *         raise KeyError('unknown INFO: {}'.format(key))
 * 
 *     if not check_header_id(hdr, BCF_HL_INFO, info_id):             # <<<<<<<<<<<<<<
 *         raise ValueError('Invalid header')
 * 
 */
  __pyx_t_2 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, BCF_HL_INFO, __pyx_v_info_id) != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":680
 * 
 *     if not check_header_id(hdr, BCF_HL_INFO, info_id):
 *         raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *     info_type = bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id)
 */
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 680, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __PYX_ERR(0, 680, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":679
 *         raise KeyError('unknown INFO: {}'.format(key))
 * 
 *     if not check_header_id(hdr, BCF_HL_INFO, info_id):             # <<<<<<<<<<<<<<
 *         raise ValueError('Invalid header')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":682
 *         raise ValueError('Invalid header')
 * 
 *     info_type = bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id)             # <<<<<<<<<<<<<<
 *     values = bcf_check_values(record, value, -1,
 *                               BCF_HL_INFO, info_type, info_id,
 */
  __pyx_v_info_type = bcf_hdr_id2type(__pyx_v_hdr, BCF_HL_INFO, __pyx_v_info_id);

  /* "pysam/libcbcf.pyx":685
 *     values = bcf_check_values(record, value, -1,
 *                               BCF_HL_INFO, info_type, info_id,
 *                               info.type if info else -1,             # <<<<<<<<<<<<<<
 *                               info.len  if info else -1,
 *                               &value_count, &scalar, &realloc)
 */
  if ((__pyx_v_info != 0)) {
    __pyx_t_7 = __pyx_v_info->type;
  } else {
    __pyx_t_7 = -1;
  }

  /* "pysam/libcbcf.pyx":686
 *                               BCF_HL_INFO, info_type, info_id,
 *                               info.type if info else -1,
 *                               info.len  if info else -1,             # <<<<<<<<<<<<<<
 *                               &value_count, &scalar, &realloc)
 * 
 */
  if ((__pyx_v_info != 0)) {
    __pyx_t_11 = __pyx_v_info->len;
  } else {
    __pyx_t_11 = -1L;
  }

  /* "pysam/libcbcf.pyx":683
 * 
 *     info_type = bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id)
 *     values = bcf_check_values(record, value, -1,             # <<<<<<<<<<<<<<
 *                               BCF_HL_INFO, info_type, info_id,
 *                               info.type if info else -1,
 */
  __pyx_t_8 = __pyx_f_5pysam_7libcbcf_bcf_check_values(__pyx_v_record, __pyx_v_value, -1, BCF_HL_INFO, __pyx_v_info_type, __pyx_v_info_id, __pyx_t_7, __pyx_t_11, (&__pyx_v_value_count), (&__pyx_v_scalar), (&__pyx_v_realloc)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_values = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "pysam/libcbcf.pyx":689
 *                               &value_count, &scalar, &realloc)
 * 
 *     if info_type == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *         if bcf_update_info(hdr, r, bkey, NULL, bool(values[0]), info_type) < 0:
 *             raise ValueError('Unable to update INFO values')
 */
  __pyx_t_2 = ((__pyx_v_info_type == BCF_HT_FLAG) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":690
 * 
 *     if info_type == BCF_HT_FLAG:
 *         if bcf_update_info(hdr, r, bkey, NULL, bool(values[0]), info_type) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Unable to update INFO values')
 *         return
 */
    if (unlikely(__pyx_v_bkey == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 690, __pyx_L1_error)
    }
    __pyx_t_12 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 690, __pyx_L1_error)
    __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_values, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 690, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 690, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_1 = ((bcf_update_info(__pyx_v_hdr, __pyx_v_r, __pyx_t_12, NULL, (!(!__pyx_t_2)), __pyx_v_info_type) < 0) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":691
 *     if info_type == BCF_HT_FLAG:
 *         if bcf_update_info(hdr, r, bkey, NULL, bool(values[0]), info_type) < 0:
 *             raise ValueError('Unable to update INFO values')             # <<<<<<<<<<<<<<
 *         return
 * 
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 691, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(0, 691, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":690
 * 
 *     if info_type == BCF_HT_FLAG:
 *         if bcf_update_info(hdr, r, bkey, NULL, bool(values[0]), info_type) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Unable to update INFO values')
 *         return
 */
    }

    /* "pysam/libcbcf.pyx":692
 *         if bcf_update_info(hdr, r, bkey, NULL, bool(values[0]), info_type) < 0:
 *             raise ValueError('Unable to update INFO values')
 *         return             # <<<<<<<<<<<<<<
 * 
 *     vlen = value_count < 0
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":689
 *                               &value_count, &scalar, &realloc)
 * 
 *     if info_type == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *         if bcf_update_info(hdr, r, bkey, NULL, bool(values[0]), info_type) < 0:
 *             raise ValueError('Unable to update INFO values')
 */
  }

  /* "pysam/libcbcf.pyx":694
 *         return
 * 
 *     vlen = value_count < 0             # <<<<<<<<<<<<<<
 *     value_count = len(values)
 * 
 */
  __pyx_v_vlen = (__pyx_v_value_count < 0);

  /* "pysam/libcbcf.pyx":695
 * 
 *     vlen = value_count < 0
 *     value_count = len(values)             # <<<<<<<<<<<<<<
 * 
 *     # DISABLED DUE TO ISSUES WITH THE CRAZY POINTERS
 */
  __pyx_t_13 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 695, __pyx_L1_error)
  __pyx_v_value_count = __pyx_t_13;

  /* "pysam/libcbcf.pyx":724
 *         return
 * 
 *     alloc_len = max(1, value_count)             # <<<<<<<<<<<<<<
 *     if info and info.len > alloc_len:
 *         alloc_len = info.len
 */
  __pyx_t_11 = __pyx_v_value_count;
  __pyx_t_14 = 1;
  if (((__pyx_t_11 > __pyx_t_14) != 0)) {
    __pyx_t_15 = __pyx_t_11;
  } else {
    __pyx_t_15 = __pyx_t_14;
  }
  __pyx_v_alloc_len = __pyx_t_15;

  /* "pysam/libcbcf.pyx":725
 * 
 *     alloc_len = max(1, value_count)
 *     if info and info.len > alloc_len:             # <<<<<<<<<<<<<<
 *         alloc_len = info.len
 * 
 */
  __pyx_t_2 = (__pyx_v_info != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L11_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_info->len > __pyx_v_alloc_len) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L11_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":726
 *     alloc_len = max(1, value_count)
 *     if info and info.len > alloc_len:
 *         alloc_len = info.len             # <<<<<<<<<<<<<<
 * 
 *     new_values = bcf_empty_array(info_type, alloc_len, vlen)
 */
    __pyx_t_7 = __pyx_v_info->len;
    __pyx_v_alloc_len = __pyx_t_7;

    /* "pysam/libcbcf.pyx":725
 * 
 *     alloc_len = max(1, value_count)
 *     if info and info.len > alloc_len:             # <<<<<<<<<<<<<<
 *         alloc_len = info.len
 * 
 */
  }

  /* "pysam/libcbcf.pyx":728
 *         alloc_len = info.len
 * 
 *     new_values = bcf_empty_array(info_type, alloc_len, vlen)             # <<<<<<<<<<<<<<
 *     cdef char *valp = <char *>new_values
 * 
 */
  __pyx_t_8 = __pyx_f_5pysam_7libcbcf_bcf_empty_array(__pyx_v_info_type, __pyx_v_alloc_len, __pyx_v_vlen); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_new_values = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "pysam/libcbcf.pyx":729
 * 
 *     new_values = bcf_empty_array(info_type, alloc_len, vlen)
 *     cdef char *valp = <char *>new_values             # <<<<<<<<<<<<<<
 * 
 *     if info_type == BCF_HT_INT:
 */
  __pyx_t_16 = __Pyx_PyObject_AsWritableString(__pyx_v_new_values); if (unlikely((!__pyx_t_16) && PyErr_Occurred())) __PYX_ERR(0, 729, __pyx_L1_error)
  __pyx_v_valp = ((char *)__pyx_t_16);

  /* "pysam/libcbcf.pyx":731
 *     cdef char *valp = <char *>new_values
 * 
 *     if info_type == BCF_HT_INT:             # <<<<<<<<<<<<<<
 *         dst_type = BCF_BT_INT32
 *     elif info_type == BCF_HT_REAL:
 */
  __pyx_t_1 = ((__pyx_v_info_type == BCF_HT_INT) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":732
 * 
 *     if info_type == BCF_HT_INT:
 *         dst_type = BCF_BT_INT32             # <<<<<<<<<<<<<<
 *     elif info_type == BCF_HT_REAL:
 *         dst_type = BCF_BT_FLOAT
 */
    __pyx_v_dst_type = BCF_BT_INT32;

    /* "pysam/libcbcf.pyx":731
 *     cdef char *valp = <char *>new_values
 * 
 *     if info_type == BCF_HT_INT:             # <<<<<<<<<<<<<<
 *         dst_type = BCF_BT_INT32
 *     elif info_type == BCF_HT_REAL:
 */
    goto __pyx_L13;
  }

  /* "pysam/libcbcf.pyx":733
 *     if info_type == BCF_HT_INT:
 *         dst_type = BCF_BT_INT32
 *     elif info_type == BCF_HT_REAL:             # <<<<<<<<<<<<<<
 *         dst_type = BCF_BT_FLOAT
 *     elif info_type == BCF_HT_STR:
 */
  __pyx_t_1 = ((__pyx_v_info_type == BCF_HT_REAL) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":734
 *         dst_type = BCF_BT_INT32
 *     elif info_type == BCF_HT_REAL:
 *         dst_type = BCF_BT_FLOAT             # <<<<<<<<<<<<<<
 *     elif info_type == BCF_HT_STR:
 *         dst_type = BCF_BT_CHAR
 */
    __pyx_v_dst_type = BCF_BT_FLOAT;

    /* "pysam/libcbcf.pyx":733
 *     if info_type == BCF_HT_INT:
 *         dst_type = BCF_BT_INT32
 *     elif info_type == BCF_HT_REAL:             # <<<<<<<<<<<<<<
 *         dst_type = BCF_BT_FLOAT
 *     elif info_type == BCF_HT_STR:
 */
    goto __pyx_L13;
  }

  /* "pysam/libcbcf.pyx":735
 *     elif info_type == BCF_HT_REAL:
 *         dst_type = BCF_BT_FLOAT
 *     elif info_type == BCF_HT_STR:             # <<<<<<<<<<<<<<
 *         dst_type = BCF_BT_CHAR
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_info_type == BCF_HT_STR) != 0);
  if (likely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":736
 *         dst_type = BCF_BT_FLOAT
 *     elif info_type == BCF_HT_STR:
 *         dst_type = BCF_BT_CHAR             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError('Unsupported INFO type')
 */
    __pyx_v_dst_type = BCF_BT_CHAR;

    /* "pysam/libcbcf.pyx":735
 *     elif info_type == BCF_HT_REAL:
 *         dst_type = BCF_BT_FLOAT
 *     elif info_type == BCF_HT_STR:             # <<<<<<<<<<<<<<
 *         dst_type = BCF_BT_CHAR
 *     else:
 */
    goto __pyx_L13;
  }

  /* "pysam/libcbcf.pyx":738
 *         dst_type = BCF_BT_CHAR
 *     else:
 *         raise ValueError('Unsupported INFO type')             # <<<<<<<<<<<<<<
 * 
 *     bcf_object_to_array(values, valp, dst_type, alloc_len, vlen)
 */
  /*else*/ {
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 738, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __PYX_ERR(0, 738, __pyx_L1_error)
  }
  __pyx_L13:;

  /* "pysam/libcbcf.pyx":740
 *         raise ValueError('Unsupported INFO type')
 * 
 *     bcf_object_to_array(values, valp, dst_type, alloc_len, vlen)             # <<<<<<<<<<<<<<
 * 
 *     if bcf_update_info(hdr, r, bkey, valp, <int>alloc_len, info_type) < 0:
 */
  __pyx_t_8 = __pyx_f_5pysam_7libcbcf_bcf_object_to_array(__pyx_v_values, __pyx_v_valp, __pyx_v_dst_type, __pyx_v_alloc_len, __pyx_v_vlen); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "pysam/libcbcf.pyx":742
 *     bcf_object_to_array(values, valp, dst_type, alloc_len, vlen)
 * 
 *     if bcf_update_info(hdr, r, bkey, valp, <int>alloc_len, info_type) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Unable to update INFO values')
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 742, __pyx_L1_error)
  }
  __pyx_t_12 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 742, __pyx_L1_error)
  __pyx_t_1 = ((bcf_update_info(__pyx_v_hdr, __pyx_v_r, __pyx_t_12, __pyx_v_valp, ((int)__pyx_v_alloc_len), __pyx_v_info_type) < 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":743
 * 
 *     if bcf_update_info(hdr, r, bkey, valp, <int>alloc_len, info_type) < 0:
 *         raise ValueError('Unable to update INFO values')             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __PYX_ERR(0, 743, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":742
 *     bcf_object_to_array(values, valp, dst_type, alloc_len, vlen)
 * 
 *     if bcf_update_info(hdr, r, bkey, valp, <int>alloc_len, info_type) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Unable to update INFO values')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":656
 * 
 * 
 * cdef bcf_info_set_value(VariantRecord record, key, value):             # <<<<<<<<<<<<<<
 *     if record is None:
 *         raise ValueError('record must not be None')
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_info_set_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_new_values);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":746
 * 
 * 
 * cdef bcf_info_del_value(VariantRecord record, key):             # <<<<<<<<<<<<<<
 *     if record is None:
 *         raise ValueError('record must not be None')
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_info_del_value(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  Py_ssize_t __pyx_v_value_count;
  int __pyx_v_scalar;
  PyObject *__pyx_v_bkey = 0;
  bcf_info_t *__pyx_v_info;
  PyObject *__pyx_v_null_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  bcf1_t *__pyx_t_5;
  char const *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("bcf_info_del_value", 0);
  __Pyx_TraceCall("bcf_info_del_value", __pyx_f[0], 746, 0, __PYX_ERR(0, 746, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":747
 * 
 * cdef bcf_info_del_value(VariantRecord record, key):
 *     if record is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('record must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_record) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":748
 * cdef bcf_info_del_value(VariantRecord record, key):
 *     if record is None:
 *         raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 748, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":747
 * 
 * cdef bcf_info_del_value(VariantRecord record, key):
 *     if record is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('record must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":750
 *         raise ValueError('record must not be None')
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr             # <<<<<<<<<<<<<<
 *     cdef bcf1_t *r = record.ptr
 *     cdef ssize_t value_count
 */
  __pyx_t_4 = __pyx_v_record->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":751
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 *     cdef bcf1_t *r = record.ptr             # <<<<<<<<<<<<<<
 *     cdef ssize_t value_count
 *     cdef int scalar
 */
  __pyx_t_5 = __pyx_v_record->ptr;
  __pyx_v_r = __pyx_t_5;

  /* "pysam/libcbcf.pyx":755
 *     cdef int scalar
 * 
 *     if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":756
 * 
 *     if bcf_unpack(r, BCF_UN_INFO) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef bytes bkey = force_bytes(key)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 756, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 756, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":755
 *     cdef int scalar
 * 
 *     if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":758
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 *     cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *     cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 * 
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_bkey = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":759
 * 
 *     cdef bytes bkey = force_bytes(key)
 *     cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)             # <<<<<<<<<<<<<<
 * 
 *     if not info:
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 759, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 759, __pyx_L1_error)
  __pyx_v_info = bcf_get_info(__pyx_v_hdr, __pyx_v_r, __pyx_t_6);

  /* "pysam/libcbcf.pyx":761
 *     cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 * 
 *     if not info:             # <<<<<<<<<<<<<<
 *         raise KeyError(key)
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_info != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":762
 * 
 *     if not info:
 *         raise KeyError(key)             # <<<<<<<<<<<<<<
 * 
 *     bcf_get_value_count(record, BCF_HL_INFO, info.key, &value_count, &scalar, -1)
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 762, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 762, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":761
 *     cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 * 
 *     if not info:             # <<<<<<<<<<<<<<
 *         raise KeyError(key)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":764
 *         raise KeyError(key)
 * 
 *     bcf_get_value_count(record, BCF_HL_INFO, info.key, &value_count, &scalar, -1)             # <<<<<<<<<<<<<<
 * 
 *     if value_count <= 0:
 */
  __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_get_value_count(__pyx_v_record, BCF_HL_INFO, __pyx_v_info->key, (&__pyx_v_value_count), (&__pyx_v_scalar), -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 764, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":766
 *     bcf_get_value_count(record, BCF_HL_INFO, info.key, &value_count, &scalar, -1)
 * 
 *     if value_count <= 0:             # <<<<<<<<<<<<<<
 *         null_value = ()
 *     elif scalar:
 */
  __pyx_t_2 = ((__pyx_v_value_count <= 0) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":767
 * 
 *     if value_count <= 0:
 *         null_value = ()             # <<<<<<<<<<<<<<
 *     elif scalar:
 *         null_value = None
 */
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_v_null_value = __pyx_empty_tuple;

    /* "pysam/libcbcf.pyx":766
 *     bcf_get_value_count(record, BCF_HL_INFO, info.key, &value_count, &scalar, -1)
 * 
 *     if value_count <= 0:             # <<<<<<<<<<<<<<
 *         null_value = ()
 *     elif scalar:
 */
    goto __pyx_L6;
  }

  /* "pysam/libcbcf.pyx":768
 *     if value_count <= 0:
 *         null_value = ()
 *     elif scalar:             # <<<<<<<<<<<<<<
 *         null_value = None
 *     else:
 */
  __pyx_t_2 = (__pyx_v_scalar != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":769
 *         null_value = ()
 *     elif scalar:
 *         null_value = None             # <<<<<<<<<<<<<<
 *     else:
 *         null_value = (None,)*value_count
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_null_value = ((PyObject*)Py_None);

    /* "pysam/libcbcf.pyx":768
 *     if value_count <= 0:
 *         null_value = ()
 *     elif scalar:             # <<<<<<<<<<<<<<
 *         null_value = None
 *     else:
 */
    goto __pyx_L6;
  }

  /* "pysam/libcbcf.pyx":771
 *         null_value = None
 *     else:
 *         null_value = (None,)*value_count             # <<<<<<<<<<<<<<
 * 
 *     bcf_info_set_value(record, bkey, null_value)
 */
  /*else*/ {
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_value_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 771, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyNumber_Multiply(__pyx_tuple__33, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 771, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_null_value = ((PyObject*)__pyx_t_7);
    __pyx_t_7 = 0;
  }
  __pyx_L6:;

  /* "pysam/libcbcf.pyx":773
 *         null_value = (None,)*value_count
 * 
 *     bcf_info_set_value(record, bkey, null_value)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_7 = __pyx_f_5pysam_7libcbcf_bcf_info_set_value(__pyx_v_record, __pyx_v_bkey, __pyx_v_null_value); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "pysam/libcbcf.pyx":746
 * 
 * 
 * cdef bcf_info_del_value(VariantRecord record, key):             # <<<<<<<<<<<<<<
 *     if record is None:
 *         raise ValueError('record must not be None')
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_info_del_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XDECREF(__pyx_v_null_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":776
 * 
 * 
 * cdef bcf_format_get_value(VariantRecordSample sample, key):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_format_get_value(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_sample, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  Py_ssize_t __pyx_v_count;
  int __pyx_v_scalar;
  PyObject *__pyx_v_bkey = 0;
  bcf_fmt_t *__pyx_v_fmt;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  bcf1_t *__pyx_t_5;
  char const *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("bcf_format_get_value", 0);
  __Pyx_TraceCall("bcf_format_get_value", __pyx_f[0], 776, 0, __PYX_ERR(0, 776, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":777
 * 
 * cdef bcf_format_get_value(VariantRecordSample sample, key):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_sample) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":778
 * cdef bcf_format_get_value(VariantRecordSample sample, key):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 778, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":777
 * 
 * cdef bcf_format_get_value(VariantRecordSample sample, key):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":780
 *         raise ValueError('sample must not be None')
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr             # <<<<<<<<<<<<<<
 *     cdef bcf1_t *r = sample.record.ptr
 *     cdef ssize_t count
 */
  __pyx_t_4 = __pyx_v_sample->record->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":781
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 *     cdef bcf1_t *r = sample.record.ptr             # <<<<<<<<<<<<<<
 *     cdef ssize_t count
 *     cdef int scalar
 */
  __pyx_t_5 = __pyx_v_sample->record->ptr;
  __pyx_v_r = __pyx_t_5;

  /* "pysam/libcbcf.pyx":785
 *     cdef int scalar
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_ALL) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":786
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef bytes bkey = force_bytes(key)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 786, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":785
 *     cdef int scalar
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":788
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 *     cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *     cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_bkey = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":789
 * 
 *     cdef bytes bkey = force_bytes(key)
 *     cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)             # <<<<<<<<<<<<<<
 * 
 *     if not fmt or not fmt.p:
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 789, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 789, __pyx_L1_error)
  __pyx_v_fmt = bcf_get_fmt(__pyx_v_hdr, __pyx_v_r, __pyx_t_6);

  /* "pysam/libcbcf.pyx":791
 *     cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 *     if not fmt or not fmt.p:             # <<<<<<<<<<<<<<
 *         raise KeyError('invalid FORMAT: {}'.format(key))
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_fmt != 0)) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = ((!(__pyx_v_fmt->p != 0)) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L6_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":792
 * 
 *     if not fmt or not fmt.p:
 *         raise KeyError('invalid FORMAT: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *     if is_gt_fmt(hdr, fmt.id):
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_invalid_FORMAT, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 792, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 792, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_key};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 792, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_key};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 792, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 792, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_key);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 792, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 792, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __PYX_ERR(0, 792, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":791
 *     cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 *     if not fmt or not fmt.p:             # <<<<<<<<<<<<<<
 *         raise KeyError('invalid FORMAT: {}'.format(key))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":794
 *         raise KeyError('invalid FORMAT: {}'.format(key))
 * 
 *     if is_gt_fmt(hdr, fmt.id):             # <<<<<<<<<<<<<<
 *         return bcf_format_get_allele_indices(sample)
 * 
 */
  __pyx_t_2 = (__pyx_f_5pysam_7libcbcf_is_gt_fmt(__pyx_v_hdr, __pyx_v_fmt->id) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":795
 * 
 *     if is_gt_fmt(hdr, fmt.id):
 *         return bcf_format_get_allele_indices(sample)             # <<<<<<<<<<<<<<
 * 
 *     bcf_get_value_count(sample.record, BCF_HL_FMT, fmt.id, &count, &scalar, sample.index)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_7 = __pyx_f_5pysam_7libcbcf_bcf_format_get_allele_indices(__pyx_v_sample); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 795, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":794
 *         raise KeyError('invalid FORMAT: {}'.format(key))
 * 
 *     if is_gt_fmt(hdr, fmt.id):             # <<<<<<<<<<<<<<
 *         return bcf_format_get_allele_indices(sample)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":797
 *         return bcf_format_get_allele_indices(sample)
 * 
 *     bcf_get_value_count(sample.record, BCF_HL_FMT, fmt.id, &count, &scalar, sample.index)             # <<<<<<<<<<<<<<
 * 
 *     if fmt.p and fmt.n and fmt.size:
 */
  __pyx_t_7 = ((PyObject *)__pyx_v_sample->record);
  __Pyx_INCREF(__pyx_t_7);
  __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_get_value_count(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_7), BCF_HL_FMT, __pyx_v_fmt->id, (&__pyx_v_count), (&__pyx_v_scalar), __pyx_v_sample->index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 797, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":799
 *     bcf_get_value_count(sample.record, BCF_HL_FMT, fmt.id, &count, &scalar, sample.index)
 * 
 *     if fmt.p and fmt.n and fmt.size:             # <<<<<<<<<<<<<<
 *         return bcf_array_to_object(fmt.p + sample.index * fmt.size, fmt.type, fmt.n, count, scalar)
 *     elif scalar:
 */
  __pyx_t_1 = (__pyx_v_fmt->p != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_1 = (__pyx_v_fmt->n != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_1 = (__pyx_v_fmt->size != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L10_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":800
 * 
 *     if fmt.p and fmt.n and fmt.size:
 *         return bcf_array_to_object(fmt.p + sample.index * fmt.size, fmt.type, fmt.n, count, scalar)             # <<<<<<<<<<<<<<
 *     elif scalar:
 *         return None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_array_to_object((__pyx_v_fmt->p + (__pyx_v_sample->index * __pyx_v_fmt->size)), __pyx_v_fmt->type, __pyx_v_fmt->n, __pyx_v_count, __pyx_v_scalar); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 800, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":799
 *     bcf_get_value_count(sample.record, BCF_HL_FMT, fmt.id, &count, &scalar, sample.index)
 * 
 *     if fmt.p and fmt.n and fmt.size:             # <<<<<<<<<<<<<<
 *         return bcf_array_to_object(fmt.p + sample.index * fmt.size, fmt.type, fmt.n, count, scalar)
 *     elif scalar:
 */
  }

  /* "pysam/libcbcf.pyx":801
 *     if fmt.p and fmt.n and fmt.size:
 *         return bcf_array_to_object(fmt.p + sample.index * fmt.size, fmt.type, fmt.n, count, scalar)
 *     elif scalar:             # <<<<<<<<<<<<<<
 *         return None
 *     elif count <= 0:
 */
  __pyx_t_2 = (__pyx_v_scalar != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":802
 *         return bcf_array_to_object(fmt.p + sample.index * fmt.size, fmt.type, fmt.n, count, scalar)
 *     elif scalar:
 *         return None             # <<<<<<<<<<<<<<
 *     elif count <= 0:
 *         return ()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":801
 *     if fmt.p and fmt.n and fmt.size:
 *         return bcf_array_to_object(fmt.p + sample.index * fmt.size, fmt.type, fmt.n, count, scalar)
 *     elif scalar:             # <<<<<<<<<<<<<<
 *         return None
 *     elif count <= 0:
 */
  }

  /* "pysam/libcbcf.pyx":803
 *     elif scalar:
 *         return None
 *     elif count <= 0:             # <<<<<<<<<<<<<<
 *         return ()
 *     else:
 */
  __pyx_t_2 = ((__pyx_v_count <= 0) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":804
 *         return None
 *     elif count <= 0:
 *         return ()             # <<<<<<<<<<<<<<
 *     else:
 *         return (None,)*count
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":803
 *     elif scalar:
 *         return None
 *     elif count <= 0:             # <<<<<<<<<<<<<<
 *         return ()
 *     else:
 */
  }

  /* "pysam/libcbcf.pyx":806
 *         return ()
 *     else:
 *         return (None,)*count             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 806, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyNumber_Multiply(__pyx_tuple__36, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 806, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":776
 * 
 * 
 * cdef bcf_format_get_value(VariantRecordSample sample, key):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_format_get_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":809
 * 
 * 
 * cdef bcf_format_set_value(VariantRecordSample sample, key, value):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_format_set_value(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_sample, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int __pyx_v_fmt_id;
  vdict_t *__pyx_v_d;
  khiter_t __pyx_v_k;
  int __pyx_v_fmt_type;
  int __pyx_v_scalar;
  int __pyx_v_realloc;
  int __pyx_v_dst_type;
  int __pyx_v_vlen;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_value_count;
  Py_ssize_t __pyx_v_alloc_len;
  Py_ssize_t __pyx_v_dst_size;
  PyObject *__pyx_v_bkey = 0;
  bcf_fmt_t *__pyx_v_fmt;
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_new_values = NULL;
  char *__pyx_v_valp;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  bcf1_t *__pyx_t_5;
  char const *__pyx_t_6;
  int __pyx_t_7;
  char const *__pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  Py_ssize_t __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  long __pyx_t_14;
  Py_ssize_t __pyx_t_15;
  uint32_t __pyx_t_16;
  char *__pyx_t_17;
  Py_ssize_t __pyx_t_18;
  char const *__pyx_t_19;
  __Pyx_RefNannySetupContext("bcf_format_set_value", 0);
  __Pyx_TraceCall("bcf_format_set_value", __pyx_f[0], 809, 0, __PYX_ERR(0, 809, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_value);

  /* "pysam/libcbcf.pyx":810
 * 
 * cdef bcf_format_set_value(VariantRecordSample sample, key, value):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_sample) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":811
 * cdef bcf_format_set_value(VariantRecordSample sample, key, value):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     if key == 'phased':
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 811, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":810
 * 
 * cdef bcf_format_set_value(VariantRecordSample sample, key, value):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":813
 *         raise ValueError('sample must not be None')
 * 
 *     if key == 'phased':             # <<<<<<<<<<<<<<
 *         sample.phased = bool(value)
 *         return
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_key, __pyx_n_s_phased, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 813, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":814
 * 
 *     if key == 'phased':
 *         sample.phased = bool(value)             # <<<<<<<<<<<<<<
 *         return
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 814, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 814, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_sample), __pyx_n_s_phased, __pyx_t_3) < 0) __PYX_ERR(0, 814, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":815
 *     if key == 'phased':
 *         sample.phased = bool(value)
 *         return             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":813
 *         raise ValueError('sample must not be None')
 * 
 *     if key == 'phased':             # <<<<<<<<<<<<<<
 *         sample.phased = bool(value)
 *         return
 */
  }

  /* "pysam/libcbcf.pyx":817
 *         return
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr             # <<<<<<<<<<<<<<
 *     cdef bcf1_t *r = sample.record.ptr
 *     cdef int fmt_id
 */
  __pyx_t_4 = __pyx_v_sample->record->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":818
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 *     cdef bcf1_t *r = sample.record.ptr             # <<<<<<<<<<<<<<
 *     cdef int fmt_id
 *     cdef vdict_t *d
 */
  __pyx_t_5 = __pyx_v_sample->record->ptr;
  __pyx_v_r = __pyx_t_5;

  /* "pysam/libcbcf.pyx":822
 *     cdef vdict_t *d
 *     cdef khiter_t k
 *     cdef int fmt_type, scalar, realloc, dst_type, vlen = 0             # <<<<<<<<<<<<<<
 *     cdef ssize_t i, n, value_count, alloc_size, alloc_len, dst_size
 * 
 */
  __pyx_v_vlen = 0;

  /* "pysam/libcbcf.pyx":825
 *     cdef ssize_t i, n, value_count, alloc_size, alloc_len, dst_size
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_ALL) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":826
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef bytes bkey = force_bytes(key)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 826, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 826, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":825
 *     cdef ssize_t i, n, value_count, alloc_size, alloc_len, dst_size
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":828
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 *     cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *     cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_bkey = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":829
 * 
 *     cdef bytes bkey = force_bytes(key)
 *     cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)             # <<<<<<<<<<<<<<
 * 
 *     if fmt:
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 829, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 829, __pyx_L1_error)
  __pyx_v_fmt = bcf_get_fmt(__pyx_v_hdr, __pyx_v_r, __pyx_t_6);

  /* "pysam/libcbcf.pyx":831
 *     cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 *     if fmt:             # <<<<<<<<<<<<<<
 *         fmt_id = fmt.id
 *     else:
 */
  __pyx_t_2 = (__pyx_v_fmt != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":832
 * 
 *     if fmt:
 *         fmt_id = fmt.id             # <<<<<<<<<<<<<<
 *     else:
 *         d = <vdict_t *>hdr.dict[BCF_DT_ID]
 */
    __pyx_t_7 = __pyx_v_fmt->id;
    __pyx_v_fmt_id = __pyx_t_7;

    /* "pysam/libcbcf.pyx":831
 *     cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 *     if fmt:             # <<<<<<<<<<<<<<
 *         fmt_id = fmt.id
 *     else:
 */
    goto __pyx_L6;
  }

  /* "pysam/libcbcf.pyx":834
 *         fmt_id = fmt.id
 *     else:
 *         d = <vdict_t *>hdr.dict[BCF_DT_ID]             # <<<<<<<<<<<<<<
 *         k = kh_get_vdict(d, bkey)
 * 
 */
  /*else*/ {
    __pyx_v_d = ((vdict_t *)(__pyx_v_hdr->dict[BCF_DT_ID]));

    /* "pysam/libcbcf.pyx":835
 *     else:
 *         d = <vdict_t *>hdr.dict[BCF_DT_ID]
 *         k = kh_get_vdict(d, bkey)             # <<<<<<<<<<<<<<
 * 
 *         if k == kh_end(d) or kh_val_vdict(d, k).info[BCF_HL_FMT] & 0xF == 0xF:
 */
    if (unlikely(__pyx_v_bkey == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 835, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 835, __pyx_L1_error)
    __pyx_v_k = kh_get_vdict(__pyx_v_d, __pyx_t_8);

    /* "pysam/libcbcf.pyx":837
 *         k = kh_get_vdict(d, bkey)
 * 
 *         if k == kh_end(d) or kh_val_vdict(d, k).info[BCF_HL_FMT] & 0xF == 0xF:             # <<<<<<<<<<<<<<
 *             raise KeyError('unknown format: {}'.format(key))
 * 
 */
    __pyx_t_1 = ((__pyx_v_k == kh_end(__pyx_v_d)) != 0);
    if (!__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_1 = ((((kh_val(__pyx_v_d, __pyx_v_k).info[BCF_HL_FMT]) & 0xF) == 0xF) != 0);
    __pyx_t_2 = __pyx_t_1;
    __pyx_L8_bool_binop_done:;
    if (unlikely(__pyx_t_2)) {

      /* "pysam/libcbcf.pyx":838
 * 
 *         if k == kh_end(d) or kh_val_vdict(d, k).info[BCF_HL_FMT] & 0xF == 0xF:
 *             raise KeyError('unknown format: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         fmt_id = kh_val_vdict(d, k).id
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_unknown_format, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 838, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 838, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 838, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 838, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 838, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_key);
          __Pyx_GIVEREF(__pyx_v_key);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_key);
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 838, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 838, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 838, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":837
 *         k = kh_get_vdict(d, bkey)
 * 
 *         if k == kh_end(d) or kh_val_vdict(d, k).info[BCF_HL_FMT] & 0xF == 0xF:             # <<<<<<<<<<<<<<
 *             raise KeyError('unknown format: {}'.format(key))
 * 
 */
    }

    /* "pysam/libcbcf.pyx":840
 *             raise KeyError('unknown format: {}'.format(key))
 * 
 *         fmt_id = kh_val_vdict(d, k).id             # <<<<<<<<<<<<<<
 * 
 *     if not check_header_id(hdr, BCF_HL_FMT, fmt_id):
 */
    __pyx_t_7 = kh_val(__pyx_v_d, __pyx_v_k).id;
    __pyx_v_fmt_id = __pyx_t_7;
  }
  __pyx_L6:;

  /* "pysam/libcbcf.pyx":842
 *         fmt_id = kh_val_vdict(d, k).id
 * 
 *     if not check_header_id(hdr, BCF_HL_FMT, fmt_id):             # <<<<<<<<<<<<<<
 *         raise ValueError('Invalid header')
 * 
 */
  __pyx_t_2 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, BCF_HL_FMT, __pyx_v_fmt_id) != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":843
 * 
 *     if not check_header_id(hdr, BCF_HL_FMT, fmt_id):
 *         raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *     fmt_type = bcf_hdr_id2type(hdr, BCF_HL_FMT, fmt_id)
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 843, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":842
 *         fmt_id = kh_val_vdict(d, k).id
 * 
 *     if not check_header_id(hdr, BCF_HL_FMT, fmt_id):             # <<<<<<<<<<<<<<
 *         raise ValueError('Invalid header')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":845
 *         raise ValueError('Invalid header')
 * 
 *     fmt_type = bcf_hdr_id2type(hdr, BCF_HL_FMT, fmt_id)             # <<<<<<<<<<<<<<
 * 
 *     if fmt_type == BCF_HT_FLAG:
 */
  __pyx_v_fmt_type = bcf_hdr_id2type(__pyx_v_hdr, BCF_HL_FMT, __pyx_v_fmt_id);

  /* "pysam/libcbcf.pyx":847
 *     fmt_type = bcf_hdr_id2type(hdr, BCF_HL_FMT, fmt_id)
 * 
 *     if fmt_type == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *         raise ValueError('Flag types are not allowed on FORMATs')
 * 
 */
  __pyx_t_2 = ((__pyx_v_fmt_type == BCF_HT_FLAG) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":848
 * 
 *     if fmt_type == BCF_HT_FLAG:
 *         raise ValueError('Flag types are not allowed on FORMATs')             # <<<<<<<<<<<<<<
 * 
 *     if is_gt_fmt(hdr, fmt_id):
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 848, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 848, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":847
 *     fmt_type = bcf_hdr_id2type(hdr, BCF_HL_FMT, fmt_id)
 * 
 *     if fmt_type == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *         raise ValueError('Flag types are not allowed on FORMATs')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":850
 *         raise ValueError('Flag types are not allowed on FORMATs')
 * 
 *     if is_gt_fmt(hdr, fmt_id):             # <<<<<<<<<<<<<<
 *         value = bcf_encode_alleles(sample.record, value)
 *         # KBJ: GT field is considered to be a string by the VCF header but BCF represents it as INT.
 */
  __pyx_t_2 = (__pyx_f_5pysam_7libcbcf_is_gt_fmt(__pyx_v_hdr, __pyx_v_fmt_id) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":851
 * 
 *     if is_gt_fmt(hdr, fmt_id):
 *         value = bcf_encode_alleles(sample.record, value)             # <<<<<<<<<<<<<<
 *         # KBJ: GT field is considered to be a string by the VCF header but BCF represents it as INT.
 *         fmt_type = BCF_HT_INT
 */
    __pyx_t_9 = ((PyObject *)__pyx_v_sample->record);
    __Pyx_INCREF(__pyx_t_9);
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_encode_alleles(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_9), __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 851, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":853
 *         value = bcf_encode_alleles(sample.record, value)
 *         # KBJ: GT field is considered to be a string by the VCF header but BCF represents it as INT.
 *         fmt_type = BCF_HT_INT             # <<<<<<<<<<<<<<
 * 
 *     values = bcf_check_values(sample.record, value, sample.index,
 */
    __pyx_v_fmt_type = BCF_HT_INT;

    /* "pysam/libcbcf.pyx":850
 *         raise ValueError('Flag types are not allowed on FORMATs')
 * 
 *     if is_gt_fmt(hdr, fmt_id):             # <<<<<<<<<<<<<<
 *         value = bcf_encode_alleles(sample.record, value)
 *         # KBJ: GT field is considered to be a string by the VCF header but BCF represents it as INT.
 */
  }

  /* "pysam/libcbcf.pyx":855
 *         fmt_type = BCF_HT_INT
 * 
 *     values = bcf_check_values(sample.record, value, sample.index,             # <<<<<<<<<<<<<<
 *                               BCF_HL_FMT, fmt_type, fmt_id,
 *                               fmt.type if fmt else -1,
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_sample->record);
  __Pyx_INCREF(__pyx_t_3);

  /* "pysam/libcbcf.pyx":857
 *     values = bcf_check_values(sample.record, value, sample.index,
 *                               BCF_HL_FMT, fmt_type, fmt_id,
 *                               fmt.type if fmt else -1,             # <<<<<<<<<<<<<<
 *                               fmt.n    if fmt else -1,
 *                               &value_count, &scalar, &realloc)
 */
  if ((__pyx_v_fmt != 0)) {
    __pyx_t_7 = __pyx_v_fmt->type;
  } else {
    __pyx_t_7 = -1;
  }

  /* "pysam/libcbcf.pyx":858
 *                               BCF_HL_FMT, fmt_type, fmt_id,
 *                               fmt.type if fmt else -1,
 *                               fmt.n    if fmt else -1,             # <<<<<<<<<<<<<<
 *                               &value_count, &scalar, &realloc)
 * 
 */
  if ((__pyx_v_fmt != 0)) {
    __pyx_t_12 = __pyx_v_fmt->n;
  } else {
    __pyx_t_12 = -1L;
  }

  /* "pysam/libcbcf.pyx":855
 *         fmt_type = BCF_HT_INT
 * 
 *     values = bcf_check_values(sample.record, value, sample.index,             # <<<<<<<<<<<<<<
 *                               BCF_HL_FMT, fmt_type, fmt_id,
 *                               fmt.type if fmt else -1,
 */
  __pyx_t_9 = __pyx_f_5pysam_7libcbcf_bcf_check_values(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_3), __pyx_v_value, __pyx_v_sample->index, BCF_HL_FMT, __pyx_v_fmt_type, __pyx_v_fmt_id, __pyx_t_7, __pyx_t_12, (&__pyx_v_value_count), (&__pyx_v_scalar), (&__pyx_v_realloc)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_values = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "pysam/libcbcf.pyx":861
 *                               &value_count, &scalar, &realloc)
 * 
 *     vlen = value_count < 0             # <<<<<<<<<<<<<<
 *     value_count = len(values)
 * 
 */
  __pyx_v_vlen = (__pyx_v_value_count < 0);

  /* "pysam/libcbcf.pyx":862
 * 
 *     vlen = value_count < 0
 *     value_count = len(values)             # <<<<<<<<<<<<<<
 * 
 *     # If we can, write updated values to existing allocated storage
 */
  __pyx_t_13 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 862, __pyx_L1_error)
  __pyx_v_value_count = __pyx_t_13;

  /* "pysam/libcbcf.pyx":865
 * 
 *     # If we can, write updated values to existing allocated storage
 *     if fmt and not realloc:             # <<<<<<<<<<<<<<
 *         r.d.indiv_dirty = 1
 *         bcf_object_to_array(values, fmt.p + sample.index * fmt.size, fmt.type, fmt.n, vlen)
 */
  __pyx_t_1 = (__pyx_v_fmt != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L14_bool_binop_done;
  }
  __pyx_t_1 = ((!(__pyx_v_realloc != 0)) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L14_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":866
 *     # If we can, write updated values to existing allocated storage
 *     if fmt and not realloc:
 *         r.d.indiv_dirty = 1             # <<<<<<<<<<<<<<
 *         bcf_object_to_array(values, fmt.p + sample.index * fmt.size, fmt.type, fmt.n, vlen)
 *         return
 */
    __pyx_v_r->d.indiv_dirty = 1;

    /* "pysam/libcbcf.pyx":867
 *     if fmt and not realloc:
 *         r.d.indiv_dirty = 1
 *         bcf_object_to_array(values, fmt.p + sample.index * fmt.size, fmt.type, fmt.n, vlen)             # <<<<<<<<<<<<<<
 *         return
 * 
 */
    __pyx_t_9 = __pyx_f_5pysam_7libcbcf_bcf_object_to_array(__pyx_v_values, (__pyx_v_fmt->p + (__pyx_v_sample->index * __pyx_v_fmt->size)), __pyx_v_fmt->type, __pyx_v_fmt->n, __pyx_v_vlen); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 867, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pysam/libcbcf.pyx":868
 *         r.d.indiv_dirty = 1
 *         bcf_object_to_array(values, fmt.p + sample.index * fmt.size, fmt.type, fmt.n, vlen)
 *         return             # <<<<<<<<<<<<<<
 * 
 *     alloc_len = max(1, value_count)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":865
 * 
 *     # If we can, write updated values to existing allocated storage
 *     if fmt and not realloc:             # <<<<<<<<<<<<<<
 *         r.d.indiv_dirty = 1
 *         bcf_object_to_array(values, fmt.p + sample.index * fmt.size, fmt.type, fmt.n, vlen)
 */
  }

  /* "pysam/libcbcf.pyx":870
 *         return
 * 
 *     alloc_len = max(1, value_count)             # <<<<<<<<<<<<<<
 *     if fmt and fmt.n > alloc_len:
 *         alloc_len = fmt.n
 */
  __pyx_t_12 = __pyx_v_value_count;
  __pyx_t_14 = 1;
  if (((__pyx_t_12 > __pyx_t_14) != 0)) {
    __pyx_t_15 = __pyx_t_12;
  } else {
    __pyx_t_15 = __pyx_t_14;
  }
  __pyx_v_alloc_len = __pyx_t_15;

  /* "pysam/libcbcf.pyx":871
 * 
 *     alloc_len = max(1, value_count)
 *     if fmt and fmt.n > alloc_len:             # <<<<<<<<<<<<<<
 *         alloc_len = fmt.n
 * 
 */
  __pyx_t_1 = (__pyx_v_fmt != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L17_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_fmt->n > __pyx_v_alloc_len) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L17_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":872
 *     alloc_len = max(1, value_count)
 *     if fmt and fmt.n > alloc_len:
 *         alloc_len = fmt.n             # <<<<<<<<<<<<<<
 * 
 *     n = r.n_sample
 */
    __pyx_t_7 = __pyx_v_fmt->n;
    __pyx_v_alloc_len = __pyx_t_7;

    /* "pysam/libcbcf.pyx":871
 * 
 *     alloc_len = max(1, value_count)
 *     if fmt and fmt.n > alloc_len:             # <<<<<<<<<<<<<<
 *         alloc_len = fmt.n
 * 
 */
  }

  /* "pysam/libcbcf.pyx":874
 *         alloc_len = fmt.n
 * 
 *     n = r.n_sample             # <<<<<<<<<<<<<<
 *     new_values = bcf_empty_array(fmt_type, n*alloc_len, vlen)
 *     cdef char *valp = <char *>new_values
 */
  __pyx_t_16 = __pyx_v_r->n_sample;
  __pyx_v_n = __pyx_t_16;

  /* "pysam/libcbcf.pyx":875
 * 
 *     n = r.n_sample
 *     new_values = bcf_empty_array(fmt_type, n*alloc_len, vlen)             # <<<<<<<<<<<<<<
 *     cdef char *valp = <char *>new_values
 * 
 */
  __pyx_t_9 = __pyx_f_5pysam_7libcbcf_bcf_empty_array(__pyx_v_fmt_type, (__pyx_v_n * __pyx_v_alloc_len), __pyx_v_vlen); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 875, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_v_new_values = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "pysam/libcbcf.pyx":876
 *     n = r.n_sample
 *     new_values = bcf_empty_array(fmt_type, n*alloc_len, vlen)
 *     cdef char *valp = <char *>new_values             # <<<<<<<<<<<<<<
 * 
 *     if fmt_type == BCF_HT_INT:
 */
  __pyx_t_17 = __Pyx_PyObject_AsWritableString(__pyx_v_new_values); if (unlikely((!__pyx_t_17) && PyErr_Occurred())) __PYX_ERR(0, 876, __pyx_L1_error)
  __pyx_v_valp = ((char *)__pyx_t_17);

  /* "pysam/libcbcf.pyx":878
 *     cdef char *valp = <char *>new_values
 * 
 *     if fmt_type == BCF_HT_INT:             # <<<<<<<<<<<<<<
 *         dst_type = BCF_BT_INT32
 *         dst_size = sizeof(int32_t) * alloc_len
 */
  __pyx_t_2 = ((__pyx_v_fmt_type == BCF_HT_INT) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":879
 * 
 *     if fmt_type == BCF_HT_INT:
 *         dst_type = BCF_BT_INT32             # <<<<<<<<<<<<<<
 *         dst_size = sizeof(int32_t) * alloc_len
 *     elif fmt_type == BCF_HT_REAL:
 */
    __pyx_v_dst_type = BCF_BT_INT32;

    /* "pysam/libcbcf.pyx":880
 *     if fmt_type == BCF_HT_INT:
 *         dst_type = BCF_BT_INT32
 *         dst_size = sizeof(int32_t) * alloc_len             # <<<<<<<<<<<<<<
 *     elif fmt_type == BCF_HT_REAL:
 *         dst_type = BCF_BT_FLOAT
 */
    __pyx_v_dst_size = ((sizeof(int32_t)) * __pyx_v_alloc_len);

    /* "pysam/libcbcf.pyx":878
 *     cdef char *valp = <char *>new_values
 * 
 *     if fmt_type == BCF_HT_INT:             # <<<<<<<<<<<<<<
 *         dst_type = BCF_BT_INT32
 *         dst_size = sizeof(int32_t) * alloc_len
 */
    goto __pyx_L19;
  }

  /* "pysam/libcbcf.pyx":881
 *         dst_type = BCF_BT_INT32
 *         dst_size = sizeof(int32_t) * alloc_len
 *     elif fmt_type == BCF_HT_REAL:             # <<<<<<<<<<<<<<
 *         dst_type = BCF_BT_FLOAT
 *         dst_size = sizeof(float) * alloc_len
 */
  __pyx_t_2 = ((__pyx_v_fmt_type == BCF_HT_REAL) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":882
 *         dst_size = sizeof(int32_t) * alloc_len
 *     elif fmt_type == BCF_HT_REAL:
 *         dst_type = BCF_BT_FLOAT             # <<<<<<<<<<<<<<
 *         dst_size = sizeof(float) * alloc_len
 *     elif fmt_type == BCF_HT_STR:
 */
    __pyx_v_dst_type = BCF_BT_FLOAT;

    /* "pysam/libcbcf.pyx":883
 *     elif fmt_type == BCF_HT_REAL:
 *         dst_type = BCF_BT_FLOAT
 *         dst_size = sizeof(float) * alloc_len             # <<<<<<<<<<<<<<
 *     elif fmt_type == BCF_HT_STR:
 *         dst_type = BCF_BT_CHAR
 */
    __pyx_v_dst_size = ((sizeof(float)) * __pyx_v_alloc_len);

    /* "pysam/libcbcf.pyx":881
 *         dst_type = BCF_BT_INT32
 *         dst_size = sizeof(int32_t) * alloc_len
 *     elif fmt_type == BCF_HT_REAL:             # <<<<<<<<<<<<<<
 *         dst_type = BCF_BT_FLOAT
 *         dst_size = sizeof(float) * alloc_len
 */
    goto __pyx_L19;
  }

  /* "pysam/libcbcf.pyx":884
 *         dst_type = BCF_BT_FLOAT
 *         dst_size = sizeof(float) * alloc_len
 *     elif fmt_type == BCF_HT_STR:             # <<<<<<<<<<<<<<
 *         dst_type = BCF_BT_CHAR
 *         dst_size = sizeof(char) * alloc_len
 */
  __pyx_t_2 = ((__pyx_v_fmt_type == BCF_HT_STR) != 0);
  if (likely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":885
 *         dst_size = sizeof(float) * alloc_len
 *     elif fmt_type == BCF_HT_STR:
 *         dst_type = BCF_BT_CHAR             # <<<<<<<<<<<<<<
 *         dst_size = sizeof(char) * alloc_len
 *     else:
 */
    __pyx_v_dst_type = BCF_BT_CHAR;

    /* "pysam/libcbcf.pyx":886
 *     elif fmt_type == BCF_HT_STR:
 *         dst_type = BCF_BT_CHAR
 *         dst_size = sizeof(char) * alloc_len             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError('Unsupported FORMAT type')
 */
    __pyx_v_dst_size = ((sizeof(char)) * __pyx_v_alloc_len);

    /* "pysam/libcbcf.pyx":884
 *         dst_type = BCF_BT_FLOAT
 *         dst_size = sizeof(float) * alloc_len
 *     elif fmt_type == BCF_HT_STR:             # <<<<<<<<<<<<<<
 *         dst_type = BCF_BT_CHAR
 *         dst_size = sizeof(char) * alloc_len
 */
    goto __pyx_L19;
  }

  /* "pysam/libcbcf.pyx":888
 *         dst_size = sizeof(char) * alloc_len
 *     else:
 *         raise ValueError('Unsupported FORMAT type')             # <<<<<<<<<<<<<<
 * 
 *     if fmt and n > 1:
 */
  /*else*/ {
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 888, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 888, __pyx_L1_error)
  }
  __pyx_L19:;

  /* "pysam/libcbcf.pyx":890
 *         raise ValueError('Unsupported FORMAT type')
 * 
 *     if fmt and n > 1:             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             bcf_copy_expand_array(fmt.p + i*fmt.size, fmt.type, fmt.n,
 */
  __pyx_t_1 = (__pyx_v_fmt != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L21_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_n > 1) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L21_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":891
 * 
 *     if fmt and n > 1:
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             bcf_copy_expand_array(fmt.p + i*fmt.size, fmt.type, fmt.n,
 *                                   valp  + i*dst_size, dst_type, alloc_len,
 */
    __pyx_t_15 = __pyx_v_n;
    __pyx_t_12 = __pyx_t_15;
    for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_12; __pyx_t_18+=1) {
      __pyx_v_i = __pyx_t_18;

      /* "pysam/libcbcf.pyx":892
 *     if fmt and n > 1:
 *         for i in range(n):
 *             bcf_copy_expand_array(fmt.p + i*fmt.size, fmt.type, fmt.n,             # <<<<<<<<<<<<<<
 *                                   valp  + i*dst_size, dst_type, alloc_len,
 *                                   vlen)
 */
      __pyx_t_9 = __pyx_f_5pysam_7libcbcf_bcf_copy_expand_array((__pyx_v_fmt->p + (__pyx_v_i * __pyx_v_fmt->size)), __pyx_v_fmt->type, __pyx_v_fmt->n, (__pyx_v_valp + (__pyx_v_i * __pyx_v_dst_size)), __pyx_v_dst_type, __pyx_v_alloc_len, __pyx_v_vlen); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 892, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }

    /* "pysam/libcbcf.pyx":890
 *         raise ValueError('Unsupported FORMAT type')
 * 
 *     if fmt and n > 1:             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             bcf_copy_expand_array(fmt.p + i*fmt.size, fmt.type, fmt.n,
 */
  }

  /* "pysam/libcbcf.pyx":896
 *                                   vlen)
 * 
 *     bcf_object_to_array(values, valp + sample.index*dst_size, dst_type, alloc_len, vlen)             # <<<<<<<<<<<<<<
 * 
 *     if bcf_update_format(hdr, r, bkey, valp, <int>(n*alloc_len), fmt_type) < 0:
 */
  __pyx_t_9 = __pyx_f_5pysam_7libcbcf_bcf_object_to_array(__pyx_v_values, (__pyx_v_valp + (__pyx_v_sample->index * __pyx_v_dst_size)), __pyx_v_dst_type, __pyx_v_alloc_len, __pyx_v_vlen); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 896, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "pysam/libcbcf.pyx":898
 *     bcf_object_to_array(values, valp + sample.index*dst_size, dst_type, alloc_len, vlen)
 * 
 *     if bcf_update_format(hdr, r, bkey, valp, <int>(n*alloc_len), fmt_type) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Unable to update format values')
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 898, __pyx_L1_error)
  }
  __pyx_t_19 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_19) && PyErr_Occurred())) __PYX_ERR(0, 898, __pyx_L1_error)
  __pyx_t_2 = ((bcf_update_format(__pyx_v_hdr, __pyx_v_r, __pyx_t_19, __pyx_v_valp, ((int)(__pyx_v_n * __pyx_v_alloc_len)), __pyx_v_fmt_type) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":899
 * 
 *     if bcf_update_format(hdr, r, bkey, valp, <int>(n*alloc_len), fmt_type) < 0:
 *         raise ValueError('Unable to update format values')             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 899, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 899, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":898
 *     bcf_object_to_array(values, valp + sample.index*dst_size, dst_type, alloc_len, vlen)
 * 
 *     if bcf_update_format(hdr, r, bkey, valp, <int>(n*alloc_len), fmt_type) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Unable to update format values')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":809
 * 
 * 
 * cdef bcf_format_set_value(VariantRecordSample sample, key, value):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_format_set_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_new_values);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":902
 * 
 * 
 * cdef bcf_format_del_value(VariantRecordSample sample, key):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_format_del_value(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_sample, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  Py_ssize_t __pyx_v_value_count;
  int __pyx_v_scalar;
  PyObject *__pyx_v_bkey = 0;
  bcf_fmt_t *__pyx_v_fmt;
  PyObject *__pyx_v_null_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  bcf1_t *__pyx_t_5;
  char const *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("bcf_format_del_value", 0);
  __Pyx_TraceCall("bcf_format_del_value", __pyx_f[0], 902, 0, __PYX_ERR(0, 902, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":903
 * 
 * cdef bcf_format_del_value(VariantRecordSample sample, key):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_sample) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":904
 * cdef bcf_format_del_value(VariantRecordSample sample, key):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 904, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 904, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":903
 * 
 * cdef bcf_format_del_value(VariantRecordSample sample, key):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":906
 *         raise ValueError('sample must not be None')
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr             # <<<<<<<<<<<<<<
 *     cdef bcf1_t *r = sample.record.ptr
 *     cdef ssize_t value_count
 */
  __pyx_t_4 = __pyx_v_sample->record->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":907
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 *     cdef bcf1_t *r = sample.record.ptr             # <<<<<<<<<<<<<<
 *     cdef ssize_t value_count
 *     cdef int scalar
 */
  __pyx_t_5 = __pyx_v_sample->record->ptr;
  __pyx_v_r = __pyx_t_5;

  /* "pysam/libcbcf.pyx":911
 *     cdef int scalar
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_ALL) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":912
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef bytes bkey = force_bytes(key)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 912, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 912, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":911
 *     cdef int scalar
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":914
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 *     cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *     cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 914, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_bkey = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":915
 * 
 *     cdef bytes bkey = force_bytes(key)
 *     cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)             # <<<<<<<<<<<<<<
 * 
 *     if not fmt or not fmt.p:
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 915, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 915, __pyx_L1_error)
  __pyx_v_fmt = bcf_get_fmt(__pyx_v_hdr, __pyx_v_r, __pyx_t_6);

  /* "pysam/libcbcf.pyx":917
 *     cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 *     if not fmt or not fmt.p:             # <<<<<<<<<<<<<<
 *         raise KeyError(key)
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_fmt != 0)) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = ((!(__pyx_v_fmt->p != 0)) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L6_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":918
 * 
 *     if not fmt or not fmt.p:
 *         raise KeyError(key)             # <<<<<<<<<<<<<<
 * 
 *     bcf_get_value_count(sample.record, BCF_HL_FMT, fmt.id, &value_count, &scalar, sample.index)
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 918, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":917
 *     cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 *     if not fmt or not fmt.p:             # <<<<<<<<<<<<<<
 *         raise KeyError(key)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":920
 *         raise KeyError(key)
 * 
 *     bcf_get_value_count(sample.record, BCF_HL_FMT, fmt.id, &value_count, &scalar, sample.index)             # <<<<<<<<<<<<<<
 * 
 *     if value_count <= 0:
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_sample->record);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_7 = __pyx_f_5pysam_7libcbcf_bcf_get_value_count(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_3), BCF_HL_FMT, __pyx_v_fmt->id, (&__pyx_v_value_count), (&__pyx_v_scalar), __pyx_v_sample->index); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 920, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "pysam/libcbcf.pyx":922
 *     bcf_get_value_count(sample.record, BCF_HL_FMT, fmt.id, &value_count, &scalar, sample.index)
 * 
 *     if value_count <= 0:             # <<<<<<<<<<<<<<
 *         null_value = ()
 *     elif scalar:
 */
  __pyx_t_2 = ((__pyx_v_value_count <= 0) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":923
 * 
 *     if value_count <= 0:
 *         null_value = ()             # <<<<<<<<<<<<<<
 *     elif scalar:
 *         null_value = None
 */
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_v_null_value = __pyx_empty_tuple;

    /* "pysam/libcbcf.pyx":922
 *     bcf_get_value_count(sample.record, BCF_HL_FMT, fmt.id, &value_count, &scalar, sample.index)
 * 
 *     if value_count <= 0:             # <<<<<<<<<<<<<<
 *         null_value = ()
 *     elif scalar:
 */
    goto __pyx_L8;
  }

  /* "pysam/libcbcf.pyx":924
 *     if value_count <= 0:
 *         null_value = ()
 *     elif scalar:             # <<<<<<<<<<<<<<
 *         null_value = None
 *     else:
 */
  __pyx_t_2 = (__pyx_v_scalar != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":925
 *         null_value = ()
 *     elif scalar:
 *         null_value = None             # <<<<<<<<<<<<<<
 *     else:
 *         null_value = (None,)*value_count
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_null_value = ((PyObject*)Py_None);

    /* "pysam/libcbcf.pyx":924
 *     if value_count <= 0:
 *         null_value = ()
 *     elif scalar:             # <<<<<<<<<<<<<<
 *         null_value = None
 *     else:
 */
    goto __pyx_L8;
  }

  /* "pysam/libcbcf.pyx":927
 *         null_value = None
 *     else:
 *         null_value = (None,)*value_count             # <<<<<<<<<<<<<<
 * 
 *     bcf_format_set_value(sample, bkey, null_value)
 */
  /*else*/ {
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_value_count); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 927, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__45, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 927, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_null_value = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L8:;

  /* "pysam/libcbcf.pyx":929
 *         null_value = (None,)*value_count
 * 
 *     bcf_format_set_value(sample, bkey, null_value)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_format_set_value(__pyx_v_sample, __pyx_v_bkey, __pyx_v_null_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":902
 * 
 * 
 * cdef bcf_format_del_value(VariantRecordSample sample, key):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_format_del_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XDECREF(__pyx_v_null_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":932
 * 
 * 
 * cdef bcf_format_get_allele_indices(VariantRecordSample sample):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_format_get_allele_indices(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_sample) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int32_t __pyx_v_n;
  bcf_fmt_t *__pyx_v_fmt0;
  int __pyx_v_gt0;
  int8_t *__pyx_v_data8;
  int16_t *__pyx_v_data16;
  int32_t *__pyx_v_data32;
  int32_t __pyx_v_a;
  int32_t __pyx_v_nalleles;
  PyObject *__pyx_v_alleles = 0;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  bcf1_t *__pyx_t_5;
  uint32_t __pyx_t_6;
  bcf_fmt_t *__pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("bcf_format_get_allele_indices", 0);
  __Pyx_TraceCall("bcf_format_get_allele_indices", __pyx_f[0], 932, 0, __PYX_ERR(0, 932, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":933
 * 
 * cdef bcf_format_get_allele_indices(VariantRecordSample sample):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_sample) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":934
 * cdef bcf_format_get_allele_indices(VariantRecordSample sample):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 934, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 934, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":933
 * 
 * cdef bcf_format_get_allele_indices(VariantRecordSample sample):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":936
 *         raise ValueError('sample must not be None')
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr             # <<<<<<<<<<<<<<
 *     cdef bcf1_t *r = sample.record.ptr
 *     cdef int32_t n = r.n_sample
 */
  __pyx_t_4 = __pyx_v_sample->record->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":937
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 *     cdef bcf1_t *r = sample.record.ptr             # <<<<<<<<<<<<<<
 *     cdef int32_t n = r.n_sample
 * 
 */
  __pyx_t_5 = __pyx_v_sample->record->ptr;
  __pyx_v_r = __pyx_t_5;

  /* "pysam/libcbcf.pyx":938
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 *     cdef bcf1_t *r = sample.record.ptr
 *     cdef int32_t n = r.n_sample             # <<<<<<<<<<<<<<
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 */
  __pyx_t_6 = __pyx_v_r->n_sample;
  __pyx_v_n = __pyx_t_6;

  /* "pysam/libcbcf.pyx":940
 *     cdef int32_t n = r.n_sample
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_ALL) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":941
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 941, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 941, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":940
 *     cdef int32_t n = r.n_sample
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":943
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:             # <<<<<<<<<<<<<<
 *         return ()
 * 
 */
  __pyx_t_1 = ((__pyx_v_sample->index < 0) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_sample->index >= __pyx_v_n) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = ((!(__pyx_v_r->n_fmt != 0)) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":944
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:
 *         return ()             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_fmt_t *fmt0 = r.d.fmt
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":943
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:             # <<<<<<<<<<<<<<
 *         return ()
 * 
 */
  }

  /* "pysam/libcbcf.pyx":946
 *         return ()
 * 
 *     cdef bcf_fmt_t *fmt0 = r.d.fmt             # <<<<<<<<<<<<<<
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)
 * 
 */
  __pyx_t_7 = __pyx_v_r->d.fmt;
  __pyx_v_fmt0 = __pyx_t_7;

  /* "pysam/libcbcf.pyx":947
 * 
 *     cdef bcf_fmt_t *fmt0 = r.d.fmt
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)             # <<<<<<<<<<<<<<
 * 
 *     if not gt0 or not fmt0.n:
 */
  __pyx_v_gt0 = __pyx_f_5pysam_7libcbcf_is_gt_fmt(__pyx_v_hdr, __pyx_v_fmt0->id);

  /* "pysam/libcbcf.pyx":949
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)
 * 
 *     if not gt0 or not fmt0.n:             # <<<<<<<<<<<<<<
 *         return ()
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_gt0 != 0)) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_1 = ((!(__pyx_v_fmt0->n != 0)) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L10_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":950
 * 
 *     if not gt0 or not fmt0.n:
 *         return ()             # <<<<<<<<<<<<<<
 * 
 *     cdef int8_t  *data8
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":949
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)
 * 
 *     if not gt0 or not fmt0.n:             # <<<<<<<<<<<<<<
 *         return ()
 * 
 */
  }

  /* "pysam/libcbcf.pyx":955
 *     cdef int16_t *data16
 *     cdef int32_t *data32
 *     cdef int32_t a, nalleles = r.n_allele             # <<<<<<<<<<<<<<
 *     cdef list alleles = []
 * 
 */
  __pyx_t_6 = __pyx_v_r->n_allele;
  __pyx_v_nalleles = __pyx_t_6;

  /* "pysam/libcbcf.pyx":956
 *     cdef int32_t *data32
 *     cdef int32_t a, nalleles = r.n_allele
 *     cdef list alleles = []             # <<<<<<<<<<<<<<
 * 
 *     if fmt0.type == BCF_BT_INT8:
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 956, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_alleles = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":958
 *     cdef list alleles = []
 * 
 *     if fmt0.type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  __pyx_t_2 = ((__pyx_v_fmt0->type == BCF_BT_INT8) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":959
 * 
 *     if fmt0.type == BCF_BT_INT8:
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)             # <<<<<<<<<<<<<<
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:
 */
    __pyx_v_data8 = ((int8_t *)(__pyx_v_fmt0->p + (__pyx_v_sample->index * __pyx_v_fmt0->size)));

    /* "pysam/libcbcf.pyx":960
 *     if fmt0.type == BCF_BT_INT8:
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):             # <<<<<<<<<<<<<<
 *             if data8[i] == bcf_int8_vector_end:
 *                 break
 */
    __pyx_t_8 = __pyx_v_fmt0->n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":961
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data8[i] == bcf_gt_missing:
 */
      __pyx_t_2 = (((__pyx_v_data8[__pyx_v_i]) == bcf_int8_vector_end) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":962
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:
 *                 break             # <<<<<<<<<<<<<<
 *             elif data8[i] == bcf_gt_missing:
 *                 a = -1
 */
        goto __pyx_L14_break;

        /* "pysam/libcbcf.pyx":961
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data8[i] == bcf_gt_missing:
 */
      }

      /* "pysam/libcbcf.pyx":963
 *             if data8[i] == bcf_int8_vector_end:
 *                 break
 *             elif data8[i] == bcf_gt_missing:             # <<<<<<<<<<<<<<
 *                 a = -1
 *             else:
 */
      __pyx_t_2 = (((__pyx_v_data8[__pyx_v_i]) == bcf_gt_missing) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":964
 *                 break
 *             elif data8[i] == bcf_gt_missing:
 *                 a = -1             # <<<<<<<<<<<<<<
 *             else:
 *                 a = bcf_gt_allele(data8[i])
 */
        __pyx_v_a = -1;

        /* "pysam/libcbcf.pyx":963
 *             if data8[i] == bcf_int8_vector_end:
 *                 break
 *             elif data8[i] == bcf_gt_missing:             # <<<<<<<<<<<<<<
 *                 a = -1
 *             else:
 */
        goto __pyx_L15;
      }

      /* "pysam/libcbcf.pyx":966
 *                 a = -1
 *             else:
 *                 a = bcf_gt_allele(data8[i])             # <<<<<<<<<<<<<<
 *             alleles.append(a if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT16:
 */
      /*else*/ {
        __pyx_v_a = bcf_gt_allele((__pyx_v_data8[__pyx_v_i]));
      }
      __pyx_L15:;

      /* "pysam/libcbcf.pyx":967
 *             else:
 *                 a = bcf_gt_allele(data8[i])
 *             alleles.append(a if 0 <= a < nalleles else None)             # <<<<<<<<<<<<<<
 *     elif fmt0.type == BCF_BT_INT16:
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 */
      __pyx_t_2 = (0 <= __pyx_v_a);
      if (__pyx_t_2) {
        __pyx_t_2 = (__pyx_v_a < __pyx_v_nalleles);
      }
      if ((__pyx_t_2 != 0)) {
        __pyx_t_11 = __Pyx_PyInt_From_int32_t(__pyx_v_a); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 967, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_3 = __pyx_t_11;
        __pyx_t_11 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_3 = Py_None;
      }
      __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_alleles, __pyx_t_3); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 967, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_L14_break:;

    /* "pysam/libcbcf.pyx":958
 *     cdef list alleles = []
 * 
 *     if fmt0.type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
    goto __pyx_L12;
  }

  /* "pysam/libcbcf.pyx":968
 *                 a = bcf_gt_allele(data8[i])
 *             alleles.append(a if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  __pyx_t_2 = ((__pyx_v_fmt0->type == BCF_BT_INT16) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":969
 *             alleles.append(a if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT16:
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)             # <<<<<<<<<<<<<<
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:
 */
    __pyx_v_data16 = ((int16_t *)(__pyx_v_fmt0->p + (__pyx_v_sample->index * __pyx_v_fmt0->size)));

    /* "pysam/libcbcf.pyx":970
 *     elif fmt0.type == BCF_BT_INT16:
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):             # <<<<<<<<<<<<<<
 *             if data16[i] == bcf_int16_vector_end:
 *                 break
 */
    __pyx_t_8 = __pyx_v_fmt0->n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":971
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data16[i] == bcf_gt_missing:
 */
      __pyx_t_2 = (((__pyx_v_data16[__pyx_v_i]) == bcf_int16_vector_end) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":972
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:
 *                 break             # <<<<<<<<<<<<<<
 *             elif data16[i] == bcf_gt_missing:
 *                 a = -1
 */
        goto __pyx_L17_break;

        /* "pysam/libcbcf.pyx":971
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data16[i] == bcf_gt_missing:
 */
      }

      /* "pysam/libcbcf.pyx":973
 *             if data16[i] == bcf_int16_vector_end:
 *                 break
 *             elif data16[i] == bcf_gt_missing:             # <<<<<<<<<<<<<<
 *                 a = -1
 *             else:
 */
      __pyx_t_2 = (((__pyx_v_data16[__pyx_v_i]) == bcf_gt_missing) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":974
 *                 break
 *             elif data16[i] == bcf_gt_missing:
 *                 a = -1             # <<<<<<<<<<<<<<
 *             else:
 *                 a = bcf_gt_allele(data16[i])
 */
        __pyx_v_a = -1;

        /* "pysam/libcbcf.pyx":973
 *             if data16[i] == bcf_int16_vector_end:
 *                 break
 *             elif data16[i] == bcf_gt_missing:             # <<<<<<<<<<<<<<
 *                 a = -1
 *             else:
 */
        goto __pyx_L18;
      }

      /* "pysam/libcbcf.pyx":976
 *                 a = -1
 *             else:
 *                 a = bcf_gt_allele(data16[i])             # <<<<<<<<<<<<<<
 *             alleles.append(a if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT32:
 */
      /*else*/ {
        __pyx_v_a = bcf_gt_allele((__pyx_v_data16[__pyx_v_i]));
      }
      __pyx_L18:;

      /* "pysam/libcbcf.pyx":977
 *             else:
 *                 a = bcf_gt_allele(data16[i])
 *             alleles.append(a if 0 <= a < nalleles else None)             # <<<<<<<<<<<<<<
 *     elif fmt0.type == BCF_BT_INT32:
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 */
      __pyx_t_2 = (0 <= __pyx_v_a);
      if (__pyx_t_2) {
        __pyx_t_2 = (__pyx_v_a < __pyx_v_nalleles);
      }
      if ((__pyx_t_2 != 0)) {
        __pyx_t_11 = __Pyx_PyInt_From_int32_t(__pyx_v_a); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 977, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_3 = __pyx_t_11;
        __pyx_t_11 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_3 = Py_None;
      }
      __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_alleles, __pyx_t_3); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 977, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_L17_break:;

    /* "pysam/libcbcf.pyx":968
 *                 a = bcf_gt_allele(data8[i])
 *             alleles.append(a if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
    goto __pyx_L12;
  }

  /* "pysam/libcbcf.pyx":978
 *                 a = bcf_gt_allele(data16[i])
 *             alleles.append(a if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  __pyx_t_2 = ((__pyx_v_fmt0->type == BCF_BT_INT32) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":979
 *             alleles.append(a if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT32:
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)             # <<<<<<<<<<<<<<
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:
 */
    __pyx_v_data32 = ((int32_t *)(__pyx_v_fmt0->p + (__pyx_v_sample->index * __pyx_v_fmt0->size)));

    /* "pysam/libcbcf.pyx":980
 *     elif fmt0.type == BCF_BT_INT32:
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):             # <<<<<<<<<<<<<<
 *             if data32[i] == bcf_int32_vector_end:
 *                 break
 */
    __pyx_t_8 = __pyx_v_fmt0->n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":981
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data32[i] == bcf_gt_missing:
 */
      __pyx_t_2 = (((__pyx_v_data32[__pyx_v_i]) == bcf_int32_vector_end) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":982
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:
 *                 break             # <<<<<<<<<<<<<<
 *             elif data32[i] == bcf_gt_missing:
 *                 a = -1
 */
        goto __pyx_L20_break;

        /* "pysam/libcbcf.pyx":981
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data32[i] == bcf_gt_missing:
 */
      }

      /* "pysam/libcbcf.pyx":983
 *             if data32[i] == bcf_int32_vector_end:
 *                 break
 *             elif data32[i] == bcf_gt_missing:             # <<<<<<<<<<<<<<
 *                 a = -1
 *             else:
 */
      __pyx_t_2 = (((__pyx_v_data32[__pyx_v_i]) == bcf_gt_missing) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":984
 *                 break
 *             elif data32[i] == bcf_gt_missing:
 *                 a = -1             # <<<<<<<<<<<<<<
 *             else:
 *                 a = bcf_gt_allele(data32[i])
 */
        __pyx_v_a = -1;

        /* "pysam/libcbcf.pyx":983
 *             if data32[i] == bcf_int32_vector_end:
 *                 break
 *             elif data32[i] == bcf_gt_missing:             # <<<<<<<<<<<<<<
 *                 a = -1
 *             else:
 */
        goto __pyx_L21;
      }

      /* "pysam/libcbcf.pyx":986
 *                 a = -1
 *             else:
 *                 a = bcf_gt_allele(data32[i])             # <<<<<<<<<<<<<<
 *             alleles.append(a if 0 <= a < nalleles else None)
 * 
 */
      /*else*/ {
        __pyx_v_a = bcf_gt_allele((__pyx_v_data32[__pyx_v_i]));
      }
      __pyx_L21:;

      /* "pysam/libcbcf.pyx":987
 *             else:
 *                 a = bcf_gt_allele(data32[i])
 *             alleles.append(a if 0 <= a < nalleles else None)             # <<<<<<<<<<<<<<
 * 
 *     return tuple(alleles)
 */
      __pyx_t_2 = (0 <= __pyx_v_a);
      if (__pyx_t_2) {
        __pyx_t_2 = (__pyx_v_a < __pyx_v_nalleles);
      }
      if ((__pyx_t_2 != 0)) {
        __pyx_t_11 = __Pyx_PyInt_From_int32_t(__pyx_v_a); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 987, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_3 = __pyx_t_11;
        __pyx_t_11 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_3 = Py_None;
      }
      __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_alleles, __pyx_t_3); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 987, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_L20_break:;

    /* "pysam/libcbcf.pyx":978
 *                 a = bcf_gt_allele(data16[i])
 *             alleles.append(a if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  }
  __pyx_L12:;

  /* "pysam/libcbcf.pyx":989
 *             alleles.append(a if 0 <= a < nalleles else None)
 * 
 *     return tuple(alleles)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyList_AsTuple(__pyx_v_alleles); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 989, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":932
 * 
 * 
 * cdef bcf_format_get_allele_indices(VariantRecordSample sample):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_format_get_allele_indices", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_alleles);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":992
 * 
 * 
 * cdef bcf_format_get_alleles(VariantRecordSample sample):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_format_get_alleles(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_sample) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int32_t __pyx_v_nsamples;
  int32_t __pyx_v_nalleles;
  bcf_fmt_t *__pyx_v_fmt0;
  int __pyx_v_gt0;
  int32_t __pyx_v_a;
  int8_t *__pyx_v_data8;
  int16_t *__pyx_v_data16;
  int32_t *__pyx_v_data32;
  PyObject *__pyx_v_alleles = NULL;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  bcf1_t *__pyx_t_5;
  uint32_t __pyx_t_6;
  bcf_fmt_t *__pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("bcf_format_get_alleles", 0);
  __Pyx_TraceCall("bcf_format_get_alleles", __pyx_f[0], 992, 0, __PYX_ERR(0, 992, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":993
 * 
 * cdef bcf_format_get_alleles(VariantRecordSample sample):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_sample) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":994
 * cdef bcf_format_get_alleles(VariantRecordSample sample):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 994, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 994, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":993
 * 
 * cdef bcf_format_get_alleles(VariantRecordSample sample):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":996
 *         raise ValueError('sample must not be None')
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr             # <<<<<<<<<<<<<<
 *     cdef bcf1_t *r = sample.record.ptr
 *     cdef int32_t nsamples = r.n_sample
 */
  __pyx_t_4 = __pyx_v_sample->record->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":997
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 *     cdef bcf1_t *r = sample.record.ptr             # <<<<<<<<<<<<<<
 *     cdef int32_t nsamples = r.n_sample
 * 
 */
  __pyx_t_5 = __pyx_v_sample->record->ptr;
  __pyx_v_r = __pyx_t_5;

  /* "pysam/libcbcf.pyx":998
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 *     cdef bcf1_t *r = sample.record.ptr
 *     cdef int32_t nsamples = r.n_sample             # <<<<<<<<<<<<<<
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 */
  __pyx_t_6 = __pyx_v_r->n_sample;
  __pyx_v_nsamples = __pyx_t_6;

  /* "pysam/libcbcf.pyx":1000
 *     cdef int32_t nsamples = r.n_sample
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_ALL) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1001
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef int32_t nalleles = r.n_allele
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1001, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1001, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1000
 *     cdef int32_t nsamples = r.n_sample
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1003
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 *     cdef int32_t nalleles = r.n_allele             # <<<<<<<<<<<<<<
 * 
 *     if sample.index < 0 or sample.index >= nsamples or not r.n_fmt:
 */
  __pyx_t_6 = __pyx_v_r->n_allele;
  __pyx_v_nalleles = __pyx_t_6;

  /* "pysam/libcbcf.pyx":1005
 *     cdef int32_t nalleles = r.n_allele
 * 
 *     if sample.index < 0 or sample.index >= nsamples or not r.n_fmt:             # <<<<<<<<<<<<<<
 *         return ()
 * 
 */
  __pyx_t_1 = ((__pyx_v_sample->index < 0) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_sample->index >= __pyx_v_nsamples) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = ((!(__pyx_v_r->n_fmt != 0)) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1006
 * 
 *     if sample.index < 0 or sample.index >= nsamples or not r.n_fmt:
 *         return ()             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_fmt_t *fmt0 = r.d.fmt
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1005
 *     cdef int32_t nalleles = r.n_allele
 * 
 *     if sample.index < 0 or sample.index >= nsamples or not r.n_fmt:             # <<<<<<<<<<<<<<
 *         return ()
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1008
 *         return ()
 * 
 *     cdef bcf_fmt_t *fmt0 = r.d.fmt             # <<<<<<<<<<<<<<
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)
 * 
 */
  __pyx_t_7 = __pyx_v_r->d.fmt;
  __pyx_v_fmt0 = __pyx_t_7;

  /* "pysam/libcbcf.pyx":1009
 * 
 *     cdef bcf_fmt_t *fmt0 = r.d.fmt
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)             # <<<<<<<<<<<<<<
 * 
 *     if not gt0 or not fmt0.n:
 */
  __pyx_v_gt0 = __pyx_f_5pysam_7libcbcf_is_gt_fmt(__pyx_v_hdr, __pyx_v_fmt0->id);

  /* "pysam/libcbcf.pyx":1011
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)
 * 
 *     if not gt0 or not fmt0.n:             # <<<<<<<<<<<<<<
 *         return ()
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_gt0 != 0)) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_1 = ((!(__pyx_v_fmt0->n != 0)) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L10_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1012
 * 
 *     if not gt0 or not fmt0.n:
 *         return ()             # <<<<<<<<<<<<<<
 * 
 *     cdef int32_t  a
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1011
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)
 * 
 *     if not gt0 or not fmt0.n:             # <<<<<<<<<<<<<<
 *         return ()
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1018
 *     cdef int16_t *data16
 *     cdef int32_t *data32
 *     alleles = []             # <<<<<<<<<<<<<<
 *     if fmt0.type == BCF_BT_INT8:
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_alleles = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":1019
 *     cdef int32_t *data32
 *     alleles = []
 *     if fmt0.type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  __pyx_t_2 = ((__pyx_v_fmt0->type == BCF_BT_INT8) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1020
 *     alleles = []
 *     if fmt0.type == BCF_BT_INT8:
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)             # <<<<<<<<<<<<<<
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:
 */
    __pyx_v_data8 = ((int8_t *)(__pyx_v_fmt0->p + (__pyx_v_sample->index * __pyx_v_fmt0->size)));

    /* "pysam/libcbcf.pyx":1021
 *     if fmt0.type == BCF_BT_INT8:
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):             # <<<<<<<<<<<<<<
 *             if data8[i] == bcf_int8_vector_end:
 *                 break
 */
    __pyx_t_8 = __pyx_v_fmt0->n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":1022
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             a = bcf_gt_allele(data8[i])
 */
      __pyx_t_2 = (((__pyx_v_data8[__pyx_v_i]) == bcf_int8_vector_end) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1023
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:
 *                 break             # <<<<<<<<<<<<<<
 *             a = bcf_gt_allele(data8[i])
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 */
        goto __pyx_L14_break;

        /* "pysam/libcbcf.pyx":1022
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             a = bcf_gt_allele(data8[i])
 */
      }

      /* "pysam/libcbcf.pyx":1024
 *             if data8[i] == bcf_int8_vector_end:
 *                 break
 *             a = bcf_gt_allele(data8[i])             # <<<<<<<<<<<<<<
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT16:
 */
      __pyx_v_a = bcf_gt_allele((__pyx_v_data8[__pyx_v_i]));

      /* "pysam/libcbcf.pyx":1025
 *                 break
 *             a = bcf_gt_allele(data8[i])
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)             # <<<<<<<<<<<<<<
 *     elif fmt0.type == BCF_BT_INT16:
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 */
      __pyx_t_2 = (0 <= __pyx_v_a);
      if (__pyx_t_2) {
        __pyx_t_2 = (__pyx_v_a < __pyx_v_nalleles);
      }
      if ((__pyx_t_2 != 0)) {
        __pyx_t_11 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_v_r->d.allele[__pyx_v_a]), NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1025, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_3 = __pyx_t_11;
        __pyx_t_11 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_3 = Py_None;
      }
      __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_alleles, __pyx_t_3); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 1025, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_L14_break:;

    /* "pysam/libcbcf.pyx":1019
 *     cdef int32_t *data32
 *     alleles = []
 *     if fmt0.type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
    goto __pyx_L12;
  }

  /* "pysam/libcbcf.pyx":1026
 *             a = bcf_gt_allele(data8[i])
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  __pyx_t_2 = ((__pyx_v_fmt0->type == BCF_BT_INT16) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1027
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT16:
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)             # <<<<<<<<<<<<<<
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:
 */
    __pyx_v_data16 = ((int16_t *)(__pyx_v_fmt0->p + (__pyx_v_sample->index * __pyx_v_fmt0->size)));

    /* "pysam/libcbcf.pyx":1028
 *     elif fmt0.type == BCF_BT_INT16:
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):             # <<<<<<<<<<<<<<
 *             if data16[i] == bcf_int16_vector_end:
 *                 break
 */
    __pyx_t_8 = __pyx_v_fmt0->n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":1029
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             a = bcf_gt_allele(data16[i])
 */
      __pyx_t_2 = (((__pyx_v_data16[__pyx_v_i]) == bcf_int16_vector_end) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1030
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:
 *                 break             # <<<<<<<<<<<<<<
 *             a = bcf_gt_allele(data16[i])
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 */
        goto __pyx_L17_break;

        /* "pysam/libcbcf.pyx":1029
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             a = bcf_gt_allele(data16[i])
 */
      }

      /* "pysam/libcbcf.pyx":1031
 *             if data16[i] == bcf_int16_vector_end:
 *                 break
 *             a = bcf_gt_allele(data16[i])             # <<<<<<<<<<<<<<
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT32:
 */
      __pyx_v_a = bcf_gt_allele((__pyx_v_data16[__pyx_v_i]));

      /* "pysam/libcbcf.pyx":1032
 *                 break
 *             a = bcf_gt_allele(data16[i])
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)             # <<<<<<<<<<<<<<
 *     elif fmt0.type == BCF_BT_INT32:
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 */
      __pyx_t_2 = (0 <= __pyx_v_a);
      if (__pyx_t_2) {
        __pyx_t_2 = (__pyx_v_a < __pyx_v_nalleles);
      }
      if ((__pyx_t_2 != 0)) {
        __pyx_t_11 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_v_r->d.allele[__pyx_v_a]), NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1032, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_3 = __pyx_t_11;
        __pyx_t_11 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_3 = Py_None;
      }
      __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_alleles, __pyx_t_3); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 1032, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_L17_break:;

    /* "pysam/libcbcf.pyx":1026
 *             a = bcf_gt_allele(data8[i])
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
    goto __pyx_L12;
  }

  /* "pysam/libcbcf.pyx":1033
 *             a = bcf_gt_allele(data16[i])
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  __pyx_t_2 = ((__pyx_v_fmt0->type == BCF_BT_INT32) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1034
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT32:
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)             # <<<<<<<<<<<<<<
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:
 */
    __pyx_v_data32 = ((int32_t *)(__pyx_v_fmt0->p + (__pyx_v_sample->index * __pyx_v_fmt0->size)));

    /* "pysam/libcbcf.pyx":1035
 *     elif fmt0.type == BCF_BT_INT32:
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):             # <<<<<<<<<<<<<<
 *             if data32[i] == bcf_int32_vector_end:
 *                 break
 */
    __pyx_t_8 = __pyx_v_fmt0->n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":1036
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             a = bcf_gt_allele(data32[i])
 */
      __pyx_t_2 = (((__pyx_v_data32[__pyx_v_i]) == bcf_int32_vector_end) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1037
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:
 *                 break             # <<<<<<<<<<<<<<
 *             a = bcf_gt_allele(data32[i])
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 */
        goto __pyx_L20_break;

        /* "pysam/libcbcf.pyx":1036
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             a = bcf_gt_allele(data32[i])
 */
      }

      /* "pysam/libcbcf.pyx":1038
 *             if data32[i] == bcf_int32_vector_end:
 *                 break
 *             a = bcf_gt_allele(data32[i])             # <<<<<<<<<<<<<<
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 *     return tuple(alleles)
 */
      __pyx_v_a = bcf_gt_allele((__pyx_v_data32[__pyx_v_i]));

      /* "pysam/libcbcf.pyx":1039
 *                 break
 *             a = bcf_gt_allele(data32[i])
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)             # <<<<<<<<<<<<<<
 *     return tuple(alleles)
 * 
 */
      __pyx_t_2 = (0 <= __pyx_v_a);
      if (__pyx_t_2) {
        __pyx_t_2 = (__pyx_v_a < __pyx_v_nalleles);
      }
      if ((__pyx_t_2 != 0)) {
        __pyx_t_11 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_v_r->d.allele[__pyx_v_a]), NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1039, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_3 = __pyx_t_11;
        __pyx_t_11 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_3 = Py_None;
      }
      __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_alleles, __pyx_t_3); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 1039, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_L20_break:;

    /* "pysam/libcbcf.pyx":1033
 *             a = bcf_gt_allele(data16[i])
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 *     elif fmt0.type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  }
  __pyx_L12:;

  /* "pysam/libcbcf.pyx":1040
 *             a = bcf_gt_allele(data32[i])
 *             alleles.append(charptr_to_str(r.d.allele[a]) if 0 <= a < nalleles else None)
 *     return tuple(alleles)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyList_AsTuple(__pyx_v_alleles); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1040, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":992
 * 
 * 
 * cdef bcf_format_get_alleles(VariantRecordSample sample):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_format_get_alleles", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_alleles);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1043
 * 
 * 
 * cdef bint bcf_sample_get_phased(VariantRecordSample sample):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

static int __pyx_f_5pysam_7libcbcf_bcf_sample_get_phased(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_sample) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int32_t __pyx_v_n;
  bcf_fmt_t *__pyx_v_fmt0;
  int __pyx_v_gt0;
  int8_t *__pyx_v_data8;
  int16_t *__pyx_v_data16;
  int32_t *__pyx_v_data32;
  int __pyx_v_phased;
  int __pyx_v_i;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  bcf1_t *__pyx_t_5;
  uint32_t __pyx_t_6;
  bcf_fmt_t *__pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("bcf_sample_get_phased", 0);
  __Pyx_TraceCall("bcf_sample_get_phased", __pyx_f[0], 1043, 0, __PYX_ERR(0, 1043, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1044
 * 
 * cdef bint bcf_sample_get_phased(VariantRecordSample sample):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_sample) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1045
 * cdef bint bcf_sample_get_phased(VariantRecordSample sample):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1045, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1045, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1044
 * 
 * cdef bint bcf_sample_get_phased(VariantRecordSample sample):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1047
 *         raise ValueError('sample must not be None')
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr             # <<<<<<<<<<<<<<
 *     cdef bcf1_t *r = sample.record.ptr
 *     cdef int32_t n = r.n_sample
 */
  __pyx_t_4 = __pyx_v_sample->record->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":1048
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 *     cdef bcf1_t *r = sample.record.ptr             # <<<<<<<<<<<<<<
 *     cdef int32_t n = r.n_sample
 * 
 */
  __pyx_t_5 = __pyx_v_sample->record->ptr;
  __pyx_v_r = __pyx_t_5;

  /* "pysam/libcbcf.pyx":1049
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 *     cdef bcf1_t *r = sample.record.ptr
 *     cdef int32_t n = r.n_sample             # <<<<<<<<<<<<<<
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 */
  __pyx_t_6 = __pyx_v_r->n_sample;
  __pyx_v_n = __pyx_t_6;

  /* "pysam/libcbcf.pyx":1051
 *     cdef int32_t n = r.n_sample
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_ALL) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1052
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1052, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1052, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1051
 *     cdef int32_t n = r.n_sample
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1054
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = ((__pyx_v_sample->index < 0) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_sample->index >= __pyx_v_n) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = ((!(__pyx_v_r->n_fmt != 0)) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1055
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_fmt_t *fmt0 = r.d.fmt
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1054
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1057
 *         return False
 * 
 *     cdef bcf_fmt_t *fmt0 = r.d.fmt             # <<<<<<<<<<<<<<
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)
 * 
 */
  __pyx_t_7 = __pyx_v_r->d.fmt;
  __pyx_v_fmt0 = __pyx_t_7;

  /* "pysam/libcbcf.pyx":1058
 * 
 *     cdef bcf_fmt_t *fmt0 = r.d.fmt
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)             # <<<<<<<<<<<<<<
 * 
 *     if not gt0 or not fmt0.n:
 */
  __pyx_v_gt0 = __pyx_f_5pysam_7libcbcf_is_gt_fmt(__pyx_v_hdr, __pyx_v_fmt0->id);

  /* "pysam/libcbcf.pyx":1060
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)
 * 
 *     if not gt0 or not fmt0.n:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_gt0 != 0)) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_1 = ((!(__pyx_v_fmt0->n != 0)) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L10_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1061
 * 
 *     if not gt0 or not fmt0.n:
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     cdef int8_t  *data8
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1060
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)
 * 
 *     if not gt0 or not fmt0.n:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1067
 *     cdef int32_t *data32
 * 
 *     cdef bint phased = False             # <<<<<<<<<<<<<<
 * 
 *     if fmt0.type == BCF_BT_INT8:
 */
  __pyx_v_phased = 0;

  /* "pysam/libcbcf.pyx":1069
 *     cdef bint phased = False
 * 
 *     if fmt0.type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  __pyx_t_2 = ((__pyx_v_fmt0->type == BCF_BT_INT8) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1070
 * 
 *     if fmt0.type == BCF_BT_INT8:
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)             # <<<<<<<<<<<<<<
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:
 */
    __pyx_v_data8 = ((int8_t *)(__pyx_v_fmt0->p + (__pyx_v_sample->index * __pyx_v_fmt0->size)));

    /* "pysam/libcbcf.pyx":1071
 *     if fmt0.type == BCF_BT_INT8:
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):             # <<<<<<<<<<<<<<
 *             if data8[i] == bcf_int8_vector_end:
 *                 break
 */
    __pyx_t_8 = __pyx_v_fmt0->n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":1072
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data8[i] == bcf_int8_missing:
 */
      __pyx_t_2 = (((__pyx_v_data8[__pyx_v_i]) == bcf_int8_vector_end) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1073
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:
 *                 break             # <<<<<<<<<<<<<<
 *             elif data8[i] == bcf_int8_missing:
 *                 continue
 */
        goto __pyx_L14_break;

        /* "pysam/libcbcf.pyx":1072
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data8[i] == bcf_int8_missing:
 */
      }

      /* "pysam/libcbcf.pyx":1074
 *             if data8[i] == bcf_int8_vector_end:
 *                 break
 *             elif data8[i] == bcf_int8_missing:             # <<<<<<<<<<<<<<
 *                 continue
 *             elif i and not bcf_gt_is_phased(data8[i]):
 */
      __pyx_t_2 = (((__pyx_v_data8[__pyx_v_i]) == bcf_int8_missing) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1075
 *                 break
 *             elif data8[i] == bcf_int8_missing:
 *                 continue             # <<<<<<<<<<<<<<
 *             elif i and not bcf_gt_is_phased(data8[i]):
 *                 return False
 */
        goto __pyx_L13_continue;

        /* "pysam/libcbcf.pyx":1074
 *             if data8[i] == bcf_int8_vector_end:
 *                 break
 *             elif data8[i] == bcf_int8_missing:             # <<<<<<<<<<<<<<
 *                 continue
 *             elif i and not bcf_gt_is_phased(data8[i]):
 */
      }

      /* "pysam/libcbcf.pyx":1076
 *             elif data8[i] == bcf_int8_missing:
 *                 continue
 *             elif i and not bcf_gt_is_phased(data8[i]):             # <<<<<<<<<<<<<<
 *                 return False
 *             else:
 */
      __pyx_t_1 = (__pyx_v_i != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L16_bool_binop_done;
      }
      __pyx_t_1 = ((!(bcf_gt_is_phased((__pyx_v_data8[__pyx_v_i])) != 0)) != 0);
      __pyx_t_2 = __pyx_t_1;
      __pyx_L16_bool_binop_done:;
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1077
 *                 continue
 *             elif i and not bcf_gt_is_phased(data8[i]):
 *                 return False             # <<<<<<<<<<<<<<
 *             else:
 *                 phased = True
 */
        __pyx_r = 0;
        goto __pyx_L0;

        /* "pysam/libcbcf.pyx":1076
 *             elif data8[i] == bcf_int8_missing:
 *                 continue
 *             elif i and not bcf_gt_is_phased(data8[i]):             # <<<<<<<<<<<<<<
 *                 return False
 *             else:
 */
      }

      /* "pysam/libcbcf.pyx":1079
 *                 return False
 *             else:
 *                 phased = True             # <<<<<<<<<<<<<<
 *     elif fmt0.type == BCF_BT_INT16:
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 */
      /*else*/ {
        __pyx_v_phased = 1;
      }
      __pyx_L13_continue:;
    }
    __pyx_L14_break:;

    /* "pysam/libcbcf.pyx":1069
 *     cdef bint phased = False
 * 
 *     if fmt0.type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
    goto __pyx_L12;
  }

  /* "pysam/libcbcf.pyx":1080
 *             else:
 *                 phased = True
 *     elif fmt0.type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  __pyx_t_2 = ((__pyx_v_fmt0->type == BCF_BT_INT16) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1081
 *                 phased = True
 *     elif fmt0.type == BCF_BT_INT16:
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)             # <<<<<<<<<<<<<<
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:
 */
    __pyx_v_data16 = ((int16_t *)(__pyx_v_fmt0->p + (__pyx_v_sample->index * __pyx_v_fmt0->size)));

    /* "pysam/libcbcf.pyx":1082
 *     elif fmt0.type == BCF_BT_INT16:
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):             # <<<<<<<<<<<<<<
 *             if data16[i] == bcf_int16_vector_end:
 *                 break
 */
    __pyx_t_8 = __pyx_v_fmt0->n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":1083
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data16[i] == bcf_int16_missing:
 */
      __pyx_t_2 = (((__pyx_v_data16[__pyx_v_i]) == bcf_int16_vector_end) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1084
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:
 *                 break             # <<<<<<<<<<<<<<
 *             elif data16[i] == bcf_int16_missing:
 *                 continue
 */
        goto __pyx_L19_break;

        /* "pysam/libcbcf.pyx":1083
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data16[i] == bcf_int16_missing:
 */
      }

      /* "pysam/libcbcf.pyx":1085
 *             if data16[i] == bcf_int16_vector_end:
 *                 break
 *             elif data16[i] == bcf_int16_missing:             # <<<<<<<<<<<<<<
 *                 continue
 *             elif i and not bcf_gt_is_phased(data16[i]):
 */
      __pyx_t_2 = (((__pyx_v_data16[__pyx_v_i]) == bcf_int16_missing) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1086
 *                 break
 *             elif data16[i] == bcf_int16_missing:
 *                 continue             # <<<<<<<<<<<<<<
 *             elif i and not bcf_gt_is_phased(data16[i]):
 *                 return False
 */
        goto __pyx_L18_continue;

        /* "pysam/libcbcf.pyx":1085
 *             if data16[i] == bcf_int16_vector_end:
 *                 break
 *             elif data16[i] == bcf_int16_missing:             # <<<<<<<<<<<<<<
 *                 continue
 *             elif i and not bcf_gt_is_phased(data16[i]):
 */
      }

      /* "pysam/libcbcf.pyx":1087
 *             elif data16[i] == bcf_int16_missing:
 *                 continue
 *             elif i and not bcf_gt_is_phased(data16[i]):             # <<<<<<<<<<<<<<
 *                 return False
 *             else:
 */
      __pyx_t_1 = (__pyx_v_i != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L21_bool_binop_done;
      }
      __pyx_t_1 = ((!(bcf_gt_is_phased((__pyx_v_data16[__pyx_v_i])) != 0)) != 0);
      __pyx_t_2 = __pyx_t_1;
      __pyx_L21_bool_binop_done:;
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1088
 *                 continue
 *             elif i and not bcf_gt_is_phased(data16[i]):
 *                 return False             # <<<<<<<<<<<<<<
 *             else:
 *                 phased = True
 */
        __pyx_r = 0;
        goto __pyx_L0;

        /* "pysam/libcbcf.pyx":1087
 *             elif data16[i] == bcf_int16_missing:
 *                 continue
 *             elif i and not bcf_gt_is_phased(data16[i]):             # <<<<<<<<<<<<<<
 *                 return False
 *             else:
 */
      }

      /* "pysam/libcbcf.pyx":1090
 *                 return False
 *             else:
 *                 phased = True             # <<<<<<<<<<<<<<
 *     elif fmt0.type == BCF_BT_INT32:
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 */
      /*else*/ {
        __pyx_v_phased = 1;
      }
      __pyx_L18_continue:;
    }
    __pyx_L19_break:;

    /* "pysam/libcbcf.pyx":1080
 *             else:
 *                 phased = True
 *     elif fmt0.type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
    goto __pyx_L12;
  }

  /* "pysam/libcbcf.pyx":1091
 *             else:
 *                 phased = True
 *     elif fmt0.type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  __pyx_t_2 = ((__pyx_v_fmt0->type == BCF_BT_INT32) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1092
 *                 phased = True
 *     elif fmt0.type == BCF_BT_INT32:
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)             # <<<<<<<<<<<<<<
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:
 */
    __pyx_v_data32 = ((int32_t *)(__pyx_v_fmt0->p + (__pyx_v_sample->index * __pyx_v_fmt0->size)));

    /* "pysam/libcbcf.pyx":1093
 *     elif fmt0.type == BCF_BT_INT32:
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):             # <<<<<<<<<<<<<<
 *             if data32[i] == bcf_int32_vector_end:
 *                 break
 */
    __pyx_t_8 = __pyx_v_fmt0->n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":1094
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data32[i] == bcf_int32_missing:
 */
      __pyx_t_2 = (((__pyx_v_data32[__pyx_v_i]) == bcf_int32_vector_end) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1095
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:
 *                 break             # <<<<<<<<<<<<<<
 *             elif data32[i] == bcf_int32_missing:
 *                 continue
 */
        goto __pyx_L24_break;

        /* "pysam/libcbcf.pyx":1094
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data32[i] == bcf_int32_missing:
 */
      }

      /* "pysam/libcbcf.pyx":1096
 *             if data32[i] == bcf_int32_vector_end:
 *                 break
 *             elif data32[i] == bcf_int32_missing:             # <<<<<<<<<<<<<<
 *                 continue
 *             elif i and not bcf_gt_is_phased(data32[i]):
 */
      __pyx_t_2 = (((__pyx_v_data32[__pyx_v_i]) == bcf_int32_missing) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1097
 *                 break
 *             elif data32[i] == bcf_int32_missing:
 *                 continue             # <<<<<<<<<<<<<<
 *             elif i and not bcf_gt_is_phased(data32[i]):
 *                 return False
 */
        goto __pyx_L23_continue;

        /* "pysam/libcbcf.pyx":1096
 *             if data32[i] == bcf_int32_vector_end:
 *                 break
 *             elif data32[i] == bcf_int32_missing:             # <<<<<<<<<<<<<<
 *                 continue
 *             elif i and not bcf_gt_is_phased(data32[i]):
 */
      }

      /* "pysam/libcbcf.pyx":1098
 *             elif data32[i] == bcf_int32_missing:
 *                 continue
 *             elif i and not bcf_gt_is_phased(data32[i]):             # <<<<<<<<<<<<<<
 *                 return False
 *             else:
 */
      __pyx_t_1 = (__pyx_v_i != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L26_bool_binop_done;
      }
      __pyx_t_1 = ((!(bcf_gt_is_phased((__pyx_v_data32[__pyx_v_i])) != 0)) != 0);
      __pyx_t_2 = __pyx_t_1;
      __pyx_L26_bool_binop_done:;
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1099
 *                 continue
 *             elif i and not bcf_gt_is_phased(data32[i]):
 *                 return False             # <<<<<<<<<<<<<<
 *             else:
 *                 phased = True
 */
        __pyx_r = 0;
        goto __pyx_L0;

        /* "pysam/libcbcf.pyx":1098
 *             elif data32[i] == bcf_int32_missing:
 *                 continue
 *             elif i and not bcf_gt_is_phased(data32[i]):             # <<<<<<<<<<<<<<
 *                 return False
 *             else:
 */
      }

      /* "pysam/libcbcf.pyx":1101
 *                 return False
 *             else:
 *                 phased = True             # <<<<<<<<<<<<<<
 * 
 *     return phased
 */
      /*else*/ {
        __pyx_v_phased = 1;
      }
      __pyx_L23_continue:;
    }
    __pyx_L24_break:;

    /* "pysam/libcbcf.pyx":1091
 *             else:
 *                 phased = True
 *     elif fmt0.type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  }
  __pyx_L12:;

  /* "pysam/libcbcf.pyx":1103
 *                 phased = True
 * 
 *     return phased             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_phased;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1043
 * 
 * 
 * cdef bint bcf_sample_get_phased(VariantRecordSample sample):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("pysam.libcbcf.bcf_sample_get_phased", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1106
 * 
 * 
 * cdef bcf_sample_set_phased(VariantRecordSample sample, bint phased):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_sample_set_phased(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_sample, int __pyx_v_phased) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int32_t __pyx_v_n;
  bcf_fmt_t *__pyx_v_fmt0;
  int __pyx_v_gt0;
  int8_t *__pyx_v_data8;
  int16_t *__pyx_v_data16;
  int32_t *__pyx_v_data32;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  bcf1_t *__pyx_t_5;
  uint32_t __pyx_t_6;
  bcf_fmt_t *__pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int32_t __pyx_t_13;
  __Pyx_RefNannySetupContext("bcf_sample_set_phased", 0);
  __Pyx_TraceCall("bcf_sample_set_phased", __pyx_f[0], 1106, 0, __PYX_ERR(0, 1106, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1107
 * 
 * cdef bcf_sample_set_phased(VariantRecordSample sample, bint phased):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_sample) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1108
 * cdef bcf_sample_set_phased(VariantRecordSample sample, bint phased):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1108, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1107
 * 
 * cdef bcf_sample_set_phased(VariantRecordSample sample, bint phased):
 *     if sample is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('sample must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1110
 *         raise ValueError('sample must not be None')
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr             # <<<<<<<<<<<<<<
 *     cdef bcf1_t *r = sample.record.ptr
 *     cdef int32_t n = r.n_sample
 */
  __pyx_t_4 = __pyx_v_sample->record->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":1111
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 *     cdef bcf1_t *r = sample.record.ptr             # <<<<<<<<<<<<<<
 *     cdef int32_t n = r.n_sample
 * 
 */
  __pyx_t_5 = __pyx_v_sample->record->ptr;
  __pyx_v_r = __pyx_t_5;

  /* "pysam/libcbcf.pyx":1112
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 *     cdef bcf1_t *r = sample.record.ptr
 *     cdef int32_t n = r.n_sample             # <<<<<<<<<<<<<<
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 */
  __pyx_t_6 = __pyx_v_r->n_sample;
  __pyx_v_n = __pyx_t_6;

  /* "pysam/libcbcf.pyx":1114
 *     cdef int32_t n = r.n_sample
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_ALL) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1115
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1115, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1115, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1114
 *     cdef int32_t n = r.n_sample
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1117
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  __pyx_t_1 = ((__pyx_v_sample->index < 0) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_sample->index >= __pyx_v_n) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = ((!(__pyx_v_r->n_fmt != 0)) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1118
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:
 *         return             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_fmt_t *fmt0 = r.d.fmt
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1117
 *         raise ValueError('Error unpacking VariantRecord')
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1120
 *         return
 * 
 *     cdef bcf_fmt_t *fmt0 = r.d.fmt             # <<<<<<<<<<<<<<
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)
 * 
 */
  __pyx_t_7 = __pyx_v_r->d.fmt;
  __pyx_v_fmt0 = __pyx_t_7;

  /* "pysam/libcbcf.pyx":1121
 * 
 *     cdef bcf_fmt_t *fmt0 = r.d.fmt
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)             # <<<<<<<<<<<<<<
 * 
 *     if not gt0 or not fmt0.n:
 */
  __pyx_v_gt0 = __pyx_f_5pysam_7libcbcf_is_gt_fmt(__pyx_v_hdr, __pyx_v_fmt0->id);

  /* "pysam/libcbcf.pyx":1123
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)
 * 
 *     if not gt0 or not fmt0.n:             # <<<<<<<<<<<<<<
 *         raise ValueError('Cannot set phased before genotype is set')
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_gt0 != 0)) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_1 = ((!(__pyx_v_fmt0->n != 0)) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L10_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1124
 * 
 *     if not gt0 or not fmt0.n:
 *         raise ValueError('Cannot set phased before genotype is set')             # <<<<<<<<<<<<<<
 * 
 *     cdef int8_t  *data8
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1124, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1123
 *     cdef int gt0 = is_gt_fmt(hdr, fmt0.id)
 * 
 *     if not gt0 or not fmt0.n:             # <<<<<<<<<<<<<<
 *         raise ValueError('Cannot set phased before genotype is set')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1130
 *     cdef int32_t *data32
 * 
 *     if fmt0.type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  __pyx_t_2 = ((__pyx_v_fmt0->type == BCF_BT_INT8) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1131
 * 
 *     if fmt0.type == BCF_BT_INT8:
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)             # <<<<<<<<<<<<<<
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:
 */
    __pyx_v_data8 = ((int8_t *)(__pyx_v_fmt0->p + (__pyx_v_sample->index * __pyx_v_fmt0->size)));

    /* "pysam/libcbcf.pyx":1132
 *     if fmt0.type == BCF_BT_INT8:
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):             # <<<<<<<<<<<<<<
 *             if data8[i] == bcf_int8_vector_end:
 *                 break
 */
    __pyx_t_8 = __pyx_v_fmt0->n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":1133
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data8[i] == bcf_int8_missing:
 */
      __pyx_t_2 = (((__pyx_v_data8[__pyx_v_i]) == bcf_int8_vector_end) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1134
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:
 *                 break             # <<<<<<<<<<<<<<
 *             elif data8[i] == bcf_int8_missing:
 *                 continue
 */
        goto __pyx_L14_break;

        /* "pysam/libcbcf.pyx":1133
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data8[i] == bcf_int8_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data8[i] == bcf_int8_missing:
 */
      }

      /* "pysam/libcbcf.pyx":1135
 *             if data8[i] == bcf_int8_vector_end:
 *                 break
 *             elif data8[i] == bcf_int8_missing:             # <<<<<<<<<<<<<<
 *                 continue
 *             elif i:
 */
      __pyx_t_2 = (((__pyx_v_data8[__pyx_v_i]) == bcf_int8_missing) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1136
 *                 break
 *             elif data8[i] == bcf_int8_missing:
 *                 continue             # <<<<<<<<<<<<<<
 *             elif i:
 *                 data8[i] = (data8[i] & 0xFE) | phased
 */
        goto __pyx_L13_continue;

        /* "pysam/libcbcf.pyx":1135
 *             if data8[i] == bcf_int8_vector_end:
 *                 break
 *             elif data8[i] == bcf_int8_missing:             # <<<<<<<<<<<<<<
 *                 continue
 *             elif i:
 */
      }

      /* "pysam/libcbcf.pyx":1137
 *             elif data8[i] == bcf_int8_missing:
 *                 continue
 *             elif i:             # <<<<<<<<<<<<<<
 *                 data8[i] = (data8[i] & 0xFE) | phased
 *     elif fmt0.type == BCF_BT_INT16:
 */
      __pyx_t_2 = (__pyx_v_i != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1138
 *                 continue
 *             elif i:
 *                 data8[i] = (data8[i] & 0xFE) | phased             # <<<<<<<<<<<<<<
 *     elif fmt0.type == BCF_BT_INT16:
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 */
        (__pyx_v_data8[__pyx_v_i]) = (((__pyx_v_data8[__pyx_v_i]) & 0xFE) | __pyx_v_phased);

        /* "pysam/libcbcf.pyx":1137
 *             elif data8[i] == bcf_int8_missing:
 *                 continue
 *             elif i:             # <<<<<<<<<<<<<<
 *                 data8[i] = (data8[i] & 0xFE) | phased
 *     elif fmt0.type == BCF_BT_INT16:
 */
      }
      __pyx_L13_continue:;
    }
    __pyx_L14_break:;

    /* "pysam/libcbcf.pyx":1130
 *     cdef int32_t *data32
 * 
 *     if fmt0.type == BCF_BT_INT8:             # <<<<<<<<<<<<<<
 *         data8 = <int8_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
    goto __pyx_L12;
  }

  /* "pysam/libcbcf.pyx":1139
 *             elif i:
 *                 data8[i] = (data8[i] & 0xFE) | phased
 *     elif fmt0.type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  __pyx_t_2 = ((__pyx_v_fmt0->type == BCF_BT_INT16) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1140
 *                 data8[i] = (data8[i] & 0xFE) | phased
 *     elif fmt0.type == BCF_BT_INT16:
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)             # <<<<<<<<<<<<<<
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:
 */
    __pyx_v_data16 = ((int16_t *)(__pyx_v_fmt0->p + (__pyx_v_sample->index * __pyx_v_fmt0->size)));

    /* "pysam/libcbcf.pyx":1141
 *     elif fmt0.type == BCF_BT_INT16:
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):             # <<<<<<<<<<<<<<
 *             if data16[i] == bcf_int16_vector_end:
 *                 break
 */
    __pyx_t_8 = __pyx_v_fmt0->n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":1142
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data16[i] == bcf_int16_missing:
 */
      __pyx_t_2 = (((__pyx_v_data16[__pyx_v_i]) == bcf_int16_vector_end) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1143
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:
 *                 break             # <<<<<<<<<<<<<<
 *             elif data16[i] == bcf_int16_missing:
 *                 continue
 */
        goto __pyx_L17_break;

        /* "pysam/libcbcf.pyx":1142
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data16[i] == bcf_int16_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data16[i] == bcf_int16_missing:
 */
      }

      /* "pysam/libcbcf.pyx":1144
 *             if data16[i] == bcf_int16_vector_end:
 *                 break
 *             elif data16[i] == bcf_int16_missing:             # <<<<<<<<<<<<<<
 *                 continue
 *             elif i:
 */
      __pyx_t_2 = (((__pyx_v_data16[__pyx_v_i]) == bcf_int16_missing) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1145
 *                 break
 *             elif data16[i] == bcf_int16_missing:
 *                 continue             # <<<<<<<<<<<<<<
 *             elif i:
 *                 data16[i] = (data16[i] & 0xFFFE) | phased
 */
        goto __pyx_L16_continue;

        /* "pysam/libcbcf.pyx":1144
 *             if data16[i] == bcf_int16_vector_end:
 *                 break
 *             elif data16[i] == bcf_int16_missing:             # <<<<<<<<<<<<<<
 *                 continue
 *             elif i:
 */
      }

      /* "pysam/libcbcf.pyx":1146
 *             elif data16[i] == bcf_int16_missing:
 *                 continue
 *             elif i:             # <<<<<<<<<<<<<<
 *                 data16[i] = (data16[i] & 0xFFFE) | phased
 *     elif fmt0.type == BCF_BT_INT32:
 */
      __pyx_t_2 = (__pyx_v_i != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1147
 *                 continue
 *             elif i:
 *                 data16[i] = (data16[i] & 0xFFFE) | phased             # <<<<<<<<<<<<<<
 *     elif fmt0.type == BCF_BT_INT32:
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 */
        (__pyx_v_data16[__pyx_v_i]) = (((__pyx_v_data16[__pyx_v_i]) & 0xFFFE) | __pyx_v_phased);

        /* "pysam/libcbcf.pyx":1146
 *             elif data16[i] == bcf_int16_missing:
 *                 continue
 *             elif i:             # <<<<<<<<<<<<<<
 *                 data16[i] = (data16[i] & 0xFFFE) | phased
 *     elif fmt0.type == BCF_BT_INT32:
 */
      }
      __pyx_L16_continue:;
    }
    __pyx_L17_break:;

    /* "pysam/libcbcf.pyx":1139
 *             elif i:
 *                 data8[i] = (data8[i] & 0xFE) | phased
 *     elif fmt0.type == BCF_BT_INT16:             # <<<<<<<<<<<<<<
 *         data16 = <int16_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
    goto __pyx_L12;
  }

  /* "pysam/libcbcf.pyx":1148
 *             elif i:
 *                 data16[i] = (data16[i] & 0xFFFE) | phased
 *     elif fmt0.type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  __pyx_t_2 = ((__pyx_v_fmt0->type == BCF_BT_INT32) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1149
 *                 data16[i] = (data16[i] & 0xFFFE) | phased
 *     elif fmt0.type == BCF_BT_INT32:
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)             # <<<<<<<<<<<<<<
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:
 */
    __pyx_v_data32 = ((int32_t *)(__pyx_v_fmt0->p + (__pyx_v_sample->index * __pyx_v_fmt0->size)));

    /* "pysam/libcbcf.pyx":1150
 *     elif fmt0.type == BCF_BT_INT32:
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):             # <<<<<<<<<<<<<<
 *             if data32[i] == bcf_int32_vector_end:
 *                 break
 */
    __pyx_t_8 = __pyx_v_fmt0->n;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pysam/libcbcf.pyx":1151
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data32[i] == bcf_int32_missing:
 */
      __pyx_t_2 = (((__pyx_v_data32[__pyx_v_i]) == bcf_int32_vector_end) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1152
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:
 *                 break             # <<<<<<<<<<<<<<
 *             elif data32[i] == bcf_int32_missing:
 *                 continue
 */
        goto __pyx_L20_break;

        /* "pysam/libcbcf.pyx":1151
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 *             if data32[i] == bcf_int32_vector_end:             # <<<<<<<<<<<<<<
 *                 break
 *             elif data32[i] == bcf_int32_missing:
 */
      }

      /* "pysam/libcbcf.pyx":1153
 *             if data32[i] == bcf_int32_vector_end:
 *                 break
 *             elif data32[i] == bcf_int32_missing:             # <<<<<<<<<<<<<<
 *                 continue
 *             elif i:
 */
      __pyx_t_2 = (((__pyx_v_data32[__pyx_v_i]) == bcf_int32_missing) != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1154
 *                 break
 *             elif data32[i] == bcf_int32_missing:
 *                 continue             # <<<<<<<<<<<<<<
 *             elif i:
 *                 data32[i] = (data32[i] & 0xFFFFFFFE) | phased
 */
        goto __pyx_L19_continue;

        /* "pysam/libcbcf.pyx":1153
 *             if data32[i] == bcf_int32_vector_end:
 *                 break
 *             elif data32[i] == bcf_int32_missing:             # <<<<<<<<<<<<<<
 *                 continue
 *             elif i:
 */
      }

      /* "pysam/libcbcf.pyx":1155
 *             elif data32[i] == bcf_int32_missing:
 *                 continue
 *             elif i:             # <<<<<<<<<<<<<<
 *                 data32[i] = (data32[i] & 0xFFFFFFFE) | phased
 * 
 */
      __pyx_t_2 = (__pyx_v_i != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1156
 *                 continue
 *             elif i:
 *                 data32[i] = (data32[i] & 0xFFFFFFFE) | phased             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_3 = __Pyx_PyInt_From_int32_t((__pyx_v_data32[__pyx_v_i])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1156, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_11 = PyNumber_And(__pyx_t_3, __pyx_int_4294967294); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1156, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_phased); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1156, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_12 = PyNumber_Or(__pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1156, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_13 = __Pyx_PyInt_As_int32_t(__pyx_t_12); if (unlikely((__pyx_t_13 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1156, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        (__pyx_v_data32[__pyx_v_i]) = __pyx_t_13;

        /* "pysam/libcbcf.pyx":1155
 *             elif data32[i] == bcf_int32_missing:
 *                 continue
 *             elif i:             # <<<<<<<<<<<<<<
 *                 data32[i] = (data32[i] & 0xFFFFFFFE) | phased
 * 
 */
      }
      __pyx_L19_continue:;
    }
    __pyx_L20_break:;

    /* "pysam/libcbcf.pyx":1148
 *             elif i:
 *                 data16[i] = (data16[i] & 0xFFFE) | phased
 *     elif fmt0.type == BCF_BT_INT32:             # <<<<<<<<<<<<<<
 *         data32 = <int32_t *>(fmt0.p + sample.index * fmt0.size)
 *         for i in range(fmt0.n):
 */
  }
  __pyx_L12:;

  /* "pysam/libcbcf.pyx":1106
 * 
 * 
 * cdef bcf_sample_set_phased(VariantRecordSample sample, bint phased):             # <<<<<<<<<<<<<<
 *     if sample is None:
 *         raise ValueError('sample must not be None')
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_sample_set_phased", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1159
 * 
 * 
 * cdef inline bcf_sync_end(VariantRecord record):             # <<<<<<<<<<<<<<
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 *     cdef bcf_info_t *info
 */

static CYTHON_INLINE PyObject *__pyx_f_5pysam_7libcbcf_bcf_sync_end(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf_info_t *__pyx_v_info;
  int __pyx_v_end_id;
  int __pyx_v_ref_len;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("bcf_sync_end", 0);
  __Pyx_TraceCall("bcf_sync_end", __pyx_f[0], 1159, 0, __PYX_ERR(0, 1159, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1160
 * 
 * cdef inline bcf_sync_end(VariantRecord record):
 *     cdef bcf_hdr_t *hdr = record.header.ptr             # <<<<<<<<<<<<<<
 *     cdef bcf_info_t *info
 *     cdef int end_id = bcf_header_get_info_id(record.header.ptr, b'END')
 */
  __pyx_t_1 = __pyx_v_record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1162
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 *     cdef bcf_info_t *info
 *     cdef int end_id = bcf_header_get_info_id(record.header.ptr, b'END')             # <<<<<<<<<<<<<<
 *     cdef int ref_len
 * 
 */
  __pyx_t_2 = __pyx_f_5pysam_7libcbcf_bcf_header_get_info_id(__pyx_v_record->header->ptr, __pyx_n_b_END); if (unlikely(__pyx_t_2 == ((int)-2) && PyErr_Occurred())) __PYX_ERR(0, 1162, __pyx_L1_error)
  __pyx_v_end_id = __pyx_t_2;

  /* "pysam/libcbcf.pyx":1166
 * 
 *     # allow missing ref when instantiating a new record
 *     if record.ref is not None:             # <<<<<<<<<<<<<<
 *         ref_len = len(record.ref)
 *     else:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_record), __pyx_n_s_ref); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = (__pyx_t_3 != Py_None);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pysam/libcbcf.pyx":1167
 *     # allow missing ref when instantiating a new record
 *     if record.ref is not None:
 *         ref_len = len(record.ref)             # <<<<<<<<<<<<<<
 *     else:
 *         ref_len = 0
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_record), __pyx_n_s_ref); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1167, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_ref_len = __pyx_t_6;

    /* "pysam/libcbcf.pyx":1166
 * 
 *     # allow missing ref when instantiating a new record
 *     if record.ref is not None:             # <<<<<<<<<<<<<<
 *         ref_len = len(record.ref)
 *     else:
 */
    goto __pyx_L3;
  }

  /* "pysam/libcbcf.pyx":1169
 *         ref_len = len(record.ref)
 *     else:
 *         ref_len = 0             # <<<<<<<<<<<<<<
 * 
 *     # Delete INFO/END if no alleles are present or if rlen is equal to len(ref)
 */
  /*else*/ {
    __pyx_v_ref_len = 0;
  }
  __pyx_L3:;

  /* "pysam/libcbcf.pyx":1173
 *     # Delete INFO/END if no alleles are present or if rlen is equal to len(ref)
 *     # Always keep END for symbolic alleles
 *     if not has_symbolic_allele(record) and (not record.ptr.n_allele or record.ptr.rlen == ref_len):             # <<<<<<<<<<<<<<
 *         # If INFO/END is not defined in the header, it doesn't exist in the record
 *         if end_id >= 0:
 */
  __pyx_t_4 = ((!(__pyx_f_5pysam_7libcbcf_has_symbolic_allele(__pyx_v_record) != 0)) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_5 = __pyx_t_4;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = ((!(__pyx_v_record->ptr->n_allele != 0)) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_5 = __pyx_t_4;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_record->ptr->rlen == __pyx_v_ref_len) != 0);
  __pyx_t_5 = __pyx_t_4;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_5) {

    /* "pysam/libcbcf.pyx":1175
 *     if not has_symbolic_allele(record) and (not record.ptr.n_allele or record.ptr.rlen == ref_len):
 *         # If INFO/END is not defined in the header, it doesn't exist in the record
 *         if end_id >= 0:             # <<<<<<<<<<<<<<
 *             info = bcf_get_info(hdr, record.ptr, b'END')
 *             if info and info.vptr:
 */
    __pyx_t_5 = ((__pyx_v_end_id >= 0) != 0);
    if (__pyx_t_5) {

      /* "pysam/libcbcf.pyx":1176
 *         # If INFO/END is not defined in the header, it doesn't exist in the record
 *         if end_id >= 0:
 *             info = bcf_get_info(hdr, record.ptr, b'END')             # <<<<<<<<<<<<<<
 *             if info and info.vptr:
 *                 if bcf_update_info(hdr, record.ptr, b'END', NULL, 0, info.type) < 0:
 */
      __pyx_v_info = bcf_get_info(__pyx_v_hdr, __pyx_v_record->ptr, ((char const *)"END"));

      /* "pysam/libcbcf.pyx":1177
 *         if end_id >= 0:
 *             info = bcf_get_info(hdr, record.ptr, b'END')
 *             if info and info.vptr:             # <<<<<<<<<<<<<<
 *                 if bcf_update_info(hdr, record.ptr, b'END', NULL, 0, info.type) < 0:
 *                     raise ValueError('Unable to delete END')
 */
      __pyx_t_4 = (__pyx_v_info != 0);
      if (__pyx_t_4) {
      } else {
        __pyx_t_5 = __pyx_t_4;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_4 = (__pyx_v_info->vptr != 0);
      __pyx_t_5 = __pyx_t_4;
      __pyx_L10_bool_binop_done:;
      if (__pyx_t_5) {

        /* "pysam/libcbcf.pyx":1178
 *             info = bcf_get_info(hdr, record.ptr, b'END')
 *             if info and info.vptr:
 *                 if bcf_update_info(hdr, record.ptr, b'END', NULL, 0, info.type) < 0:             # <<<<<<<<<<<<<<
 *                     raise ValueError('Unable to delete END')
 *     else:
 */
        __pyx_t_5 = ((bcf_update_info(__pyx_v_hdr, __pyx_v_record->ptr, ((char const *)"END"), NULL, 0, __pyx_v_info->type) < 0) != 0);
        if (unlikely(__pyx_t_5)) {

          /* "pysam/libcbcf.pyx":1179
 *             if info and info.vptr:
 *                 if bcf_update_info(hdr, record.ptr, b'END', NULL, 0, info.type) < 0:
 *                     raise ValueError('Unable to delete END')             # <<<<<<<<<<<<<<
 *     else:
 *         # Create END header, if not present
 */
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1179, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __PYX_ERR(0, 1179, __pyx_L1_error)

          /* "pysam/libcbcf.pyx":1178
 *             info = bcf_get_info(hdr, record.ptr, b'END')
 *             if info and info.vptr:
 *                 if bcf_update_info(hdr, record.ptr, b'END', NULL, 0, info.type) < 0:             # <<<<<<<<<<<<<<
 *                     raise ValueError('Unable to delete END')
 *     else:
 */
        }

        /* "pysam/libcbcf.pyx":1177
 *         if end_id >= 0:
 *             info = bcf_get_info(hdr, record.ptr, b'END')
 *             if info and info.vptr:             # <<<<<<<<<<<<<<
 *                 if bcf_update_info(hdr, record.ptr, b'END', NULL, 0, info.type) < 0:
 *                     raise ValueError('Unable to delete END')
 */
      }

      /* "pysam/libcbcf.pyx":1175
 *     if not has_symbolic_allele(record) and (not record.ptr.n_allele or record.ptr.rlen == ref_len):
 *         # If INFO/END is not defined in the header, it doesn't exist in the record
 *         if end_id >= 0:             # <<<<<<<<<<<<<<
 *             info = bcf_get_info(hdr, record.ptr, b'END')
 *             if info and info.vptr:
 */
    }

    /* "pysam/libcbcf.pyx":1173
 *     # Delete INFO/END if no alleles are present or if rlen is equal to len(ref)
 *     # Always keep END for symbolic alleles
 *     if not has_symbolic_allele(record) and (not record.ptr.n_allele or record.ptr.rlen == ref_len):             # <<<<<<<<<<<<<<
 *         # If INFO/END is not defined in the header, it doesn't exist in the record
 *         if end_id >= 0:
 */
    goto __pyx_L4;
  }

  /* "pysam/libcbcf.pyx":1182
 *     else:
 *         # Create END header, if not present
 *         if end_id < 0:             # <<<<<<<<<<<<<<
 *             record.header.info.add('END', number=1, type='Integer', description='Stop position of the interval')
 * 
 */
  /*else*/ {
    __pyx_t_5 = ((__pyx_v_end_id < 0) != 0);
    if (__pyx_t_5) {

      /* "pysam/libcbcf.pyx":1183
 *         # Create END header, if not present
 *         if end_id < 0:
 *             record.header.info.add('END', number=1, type='Integer', description='Stop position of the interval')             # <<<<<<<<<<<<<<
 * 
 *         # Update to reflect stop position
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_record->header), __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_add); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_number, __pyx_int_1) < 0) __PYX_ERR(0, 1183, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_type, __pyx_n_s_Integer) < 0) __PYX_ERR(0, 1183, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_description, __pyx_kp_s_Stop_position_of_the_interval) < 0) __PYX_ERR(0, 1183, __pyx_L1_error)
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__56, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "pysam/libcbcf.pyx":1182
 *     else:
 *         # Create END header, if not present
 *         if end_id < 0:             # <<<<<<<<<<<<<<
 *             record.header.info.add('END', number=1, type='Integer', description='Stop position of the interval')
 * 
 */
    }

    /* "pysam/libcbcf.pyx":1186
 * 
 *         # Update to reflect stop position
 *         bcf_info_set_value(record, b'END', record.ptr.pos + record.ptr.rlen)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_8 = __Pyx_PyInt_From_int32_t((__pyx_v_record->ptr->pos + __pyx_v_record->ptr->rlen)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_info_set_value(__pyx_v_record, __pyx_n_b_END, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L4:;

  /* "pysam/libcbcf.pyx":1159
 * 
 * 
 * cdef inline bcf_sync_end(VariantRecord record):             # <<<<<<<<<<<<<<
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 *     cdef bcf_info_t *info
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_sync_end", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1189
 * 
 * 
 * cdef inline int has_symbolic_allele(VariantRecord record):             # <<<<<<<<<<<<<<
 *     """Return index of first symbolic allele. 0 if no symbolic alleles."""
 * 
 */

static CYTHON_INLINE int __pyx_f_5pysam_7libcbcf_has_symbolic_allele(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record) {
  long __pyx_v_i;
  char *__pyx_v_alt;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  uint32_t __pyx_t_1;
  uint32_t __pyx_t_2;
  long __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  size_t __pyx_t_6;
  __Pyx_RefNannySetupContext("has_symbolic_allele", 0);
  __Pyx_TraceCall("has_symbolic_allele", __pyx_f[0], 1189, 0, __PYX_ERR(0, 1189, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1192
 *     """Return index of first symbolic allele. 0 if no symbolic alleles."""
 * 
 *     for i in range(1, record.ptr.n_allele):             # <<<<<<<<<<<<<<
 *         alt = record.ptr.d.allele[i]
 *         if alt[0] == b'<' and alt[len(alt) - 1] == b'>':
 */
  __pyx_t_1 = __pyx_v_record->ptr->n_allele;
  __pyx_t_2 = __pyx_t_1;
  for (__pyx_t_3 = 1; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "pysam/libcbcf.pyx":1193
 * 
 *     for i in range(1, record.ptr.n_allele):
 *         alt = record.ptr.d.allele[i]             # <<<<<<<<<<<<<<
 *         if alt[0] == b'<' and alt[len(alt) - 1] == b'>':
 *             return i
 */
    __pyx_v_alt = (__pyx_v_record->ptr->d.allele[__pyx_v_i]);

    /* "pysam/libcbcf.pyx":1194
 *     for i in range(1, record.ptr.n_allele):
 *         alt = record.ptr.d.allele[i]
 *         if alt[0] == b'<' and alt[len(alt) - 1] == b'>':             # <<<<<<<<<<<<<<
 *             return i
 * 
 */
    __pyx_t_5 = (((__pyx_v_alt[0]) == '<') != 0);
    if (__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_6 = strlen(__pyx_v_alt); 
    __pyx_t_5 = (((__pyx_v_alt[(__pyx_t_6 - 1)]) == '>') != 0);
    __pyx_t_4 = __pyx_t_5;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_4) {

      /* "pysam/libcbcf.pyx":1195
 *         alt = record.ptr.d.allele[i]
 *         if alt[0] == b'<' and alt[len(alt) - 1] == b'>':
 *             return i             # <<<<<<<<<<<<<<
 * 
 *     return 0
 */
      __pyx_r = __pyx_v_i;
      goto __pyx_L0;

      /* "pysam/libcbcf.pyx":1194
 *     for i in range(1, record.ptr.n_allele):
 *         alt = record.ptr.d.allele[i]
 *         if alt[0] == b'<' and alt[len(alt) - 1] == b'>':             # <<<<<<<<<<<<<<
 *             return i
 * 
 */
    }
  }

  /* "pysam/libcbcf.pyx":1197
 *             return i
 * 
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1189
 * 
 * 
 * cdef inline int has_symbolic_allele(VariantRecord record):             # <<<<<<<<<<<<<<
 *     """Return index of first symbolic allele. 0 if no symbolic alleles."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pysam.libcbcf.has_symbolic_allele", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1206
 * 
 * 
 * cdef bcf_header_remove_hrec(VariantHeader header, int i):             # <<<<<<<<<<<<<<
 *     if header is None:
 *         raise ValueError('header must not be None')
 */

static PyObject *__pyx_f_5pysam_7libcbcf_bcf_header_remove_hrec(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header, int __pyx_v_i) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf_hrec_t *__pyx_v_hrec;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  __Pyx_RefNannySetupContext("bcf_header_remove_hrec", 0);
  __Pyx_TraceCall("bcf_header_remove_hrec", __pyx_f[0], 1206, 0, __PYX_ERR(0, 1206, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1207
 * 
 * cdef bcf_header_remove_hrec(VariantHeader header, int i):
 *     if header is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('header must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_header) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1208
 * cdef bcf_header_remove_hrec(VariantHeader header, int i):
 *     if header is None:
 *         raise ValueError('header must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = header.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1208, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1208, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1207
 * 
 * cdef bcf_header_remove_hrec(VariantHeader header, int i):
 *     if header is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('header must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1210
 *         raise ValueError('header must not be None')
 * 
 *     cdef bcf_hdr_t *hdr = header.ptr             # <<<<<<<<<<<<<<
 * 
 *     if i < 0 or i >= hdr.nhrec:
 */
  __pyx_t_4 = __pyx_v_header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":1212
 *     cdef bcf_hdr_t *hdr = header.ptr
 * 
 *     if i < 0 or i >= hdr.nhrec:             # <<<<<<<<<<<<<<
 *         raise ValueError('Invalid header record index')
 * 
 */
  __pyx_t_1 = ((__pyx_v_i < 0) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_i >= __pyx_v_hdr->nhrec) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1213
 * 
 *     if i < 0 or i >= hdr.nhrec:
 *         raise ValueError('Invalid header record index')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hrec_t *hrec = hdr.hrec[i]
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1213, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1213, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1212
 *     cdef bcf_hdr_t *hdr = header.ptr
 * 
 *     if i < 0 or i >= hdr.nhrec:             # <<<<<<<<<<<<<<
 *         raise ValueError('Invalid header record index')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1215
 *         raise ValueError('Invalid header record index')
 * 
 *     cdef bcf_hrec_t *hrec = hdr.hrec[i]             # <<<<<<<<<<<<<<
 *     hdr.nhrec -= 1
 * 
 */
  __pyx_v_hrec = (__pyx_v_hdr->hrec[__pyx_v_i]);

  /* "pysam/libcbcf.pyx":1216
 * 
 *     cdef bcf_hrec_t *hrec = hdr.hrec[i]
 *     hdr.nhrec -= 1             # <<<<<<<<<<<<<<
 * 
 *     if i < hdr.nhrec:
 */
  __pyx_v_hdr->nhrec = (__pyx_v_hdr->nhrec - 1);

  /* "pysam/libcbcf.pyx":1218
 *     hdr.nhrec -= 1
 * 
 *     if i < hdr.nhrec:             # <<<<<<<<<<<<<<
 *         memmove(&hdr.hrec[i], &hdr.hrec[i+1], (hdr.nhrec-i)*sizeof(bcf_hrec_t*))
 * 
 */
  __pyx_t_2 = ((__pyx_v_i < __pyx_v_hdr->nhrec) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1219
 * 
 *     if i < hdr.nhrec:
 *         memmove(&hdr.hrec[i], &hdr.hrec[i+1], (hdr.nhrec-i)*sizeof(bcf_hrec_t*))             # <<<<<<<<<<<<<<
 * 
 *     bcf_hrec_destroy(hrec)
 */
    (void)(memmove((&(__pyx_v_hdr->hrec[__pyx_v_i])), (&(__pyx_v_hdr->hrec[(__pyx_v_i + 1)])), ((__pyx_v_hdr->nhrec - __pyx_v_i) * (sizeof(bcf_hrec_t *)))));

    /* "pysam/libcbcf.pyx":1218
 *     hdr.nhrec -= 1
 * 
 *     if i < hdr.nhrec:             # <<<<<<<<<<<<<<
 *         memmove(&hdr.hrec[i], &hdr.hrec[i+1], (hdr.nhrec-i)*sizeof(bcf_hrec_t*))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1221
 *         memmove(&hdr.hrec[i], &hdr.hrec[i+1], (hdr.nhrec-i)*sizeof(bcf_hrec_t*))
 * 
 *     bcf_hrec_destroy(hrec)             # <<<<<<<<<<<<<<
 *     hdr.hrec[hdr.nhrec] = NULL
 *     hdr.dirty = 1
 */
  bcf_hrec_destroy(__pyx_v_hrec);

  /* "pysam/libcbcf.pyx":1222
 * 
 *     bcf_hrec_destroy(hrec)
 *     hdr.hrec[hdr.nhrec] = NULL             # <<<<<<<<<<<<<<
 *     hdr.dirty = 1
 * 
 */
  (__pyx_v_hdr->hrec[__pyx_v_hdr->nhrec]) = NULL;

  /* "pysam/libcbcf.pyx":1223
 *     bcf_hrec_destroy(hrec)
 *     hdr.hrec[hdr.nhrec] = NULL
 *     hdr.dirty = 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_hdr->dirty = 1;

  /* "pysam/libcbcf.pyx":1206
 * 
 * 
 * cdef bcf_header_remove_hrec(VariantHeader header, int i):             # <<<<<<<<<<<<<<
 *     if header is None:
 *         raise ValueError('header must not be None')
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_header_remove_hrec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1231
 * cdef class VariantHeaderRecord(object):
 *     """header record from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 1231, 0, __PYX_ERR(0, 1231, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1232
 *     """header record from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1232, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 1232, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1231
 * cdef class VariantHeaderRecord(object):
 *     """header record from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1235
 * 
 *     @property
 *     def type(self):             # <<<<<<<<<<<<<<
 *         """header type: FILTER, INFO, FORMAT, CONTIG, STRUCTURED, or GENERIC"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_4type_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_4type_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_4type___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_4type___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  bcf_hrec_t *__pyx_v_r;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hrec_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1235, 0, __PYX_ERR(0, 1235, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1237
 *     def type(self):
 *         """header type: FILTER, INFO, FORMAT, CONTIG, STRUCTURED, or GENERIC"""
 *         cdef bcf_hrec_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if not r:
 *             return None
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1238
 *         """header type: FILTER, INFO, FORMAT, CONTIG, STRUCTURED, or GENERIC"""
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:             # <<<<<<<<<<<<<<
 *             return None
 *         return METADATA_TYPES[r.type]
 */
  __pyx_t_2 = ((!(__pyx_v_r != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1239
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:
 *             return None             # <<<<<<<<<<<<<<
 *         return METADATA_TYPES[r.type]
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1238
 *         """header type: FILTER, INFO, FORMAT, CONTIG, STRUCTURED, or GENERIC"""
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:             # <<<<<<<<<<<<<<
 *             return None
 *         return METADATA_TYPES[r.type]
 */
  }

  /* "pysam/libcbcf.pyx":1240
 *         if not r:
 *             return None
 *         return METADATA_TYPES[r.type]             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_5pysam_7libcbcf_METADATA_TYPES == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1240, __pyx_L1_error)
  }
  __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_5pysam_7libcbcf_METADATA_TYPES, __pyx_v_r->type, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1235
 * 
 *     @property
 *     def type(self):             # <<<<<<<<<<<<<<
 *         """header type: FILTER, INFO, FORMAT, CONTIG, STRUCTURED, or GENERIC"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.type.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1243
 * 
 *     @property
 *     def key(self):             # <<<<<<<<<<<<<<
 *         """header key (the part before '=', in FILTER/INFO/FORMAT/contig/fileformat etc.)"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_3key_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_3key_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_3key___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_3key___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  bcf_hrec_t *__pyx_v_r;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hrec_t *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1243, 0, __PYX_ERR(0, 1243, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1245
 *     def key(self):
 *         """header key (the part before '=', in FILTER/INFO/FORMAT/contig/fileformat etc.)"""
 *         cdef bcf_hrec_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         return bcf_str_cache_get_charptr(r.key) if r and r.key else None
 * 
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1246
 *         """header key (the part before '=', in FILTER/INFO/FORMAT/contig/fileformat etc.)"""
 *         cdef bcf_hrec_t *r = self.ptr
 *         return bcf_str_cache_get_charptr(r.key) if r and r.key else None             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = (__pyx_v_r != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_r->key != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L3_bool_binop_done:;
  if (__pyx_t_3) {
    __pyx_t_5 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(__pyx_v_r->key); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1246, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __pyx_t_5;
    __pyx_t_5 = 0;
  } else {
    __Pyx_INCREF(Py_None);
    __pyx_t_2 = Py_None;
  }
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1243
 * 
 *     @property
 *     def key(self):             # <<<<<<<<<<<<<<
 *         """header key (the part before '=', in FILTER/INFO/FORMAT/contig/fileformat etc.)"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.key.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1249
 * 
 *     @property
 *     def value(self):             # <<<<<<<<<<<<<<
 *         """header value.  Set only for generic lines, None for FILTER/INFO, etc."""
 *         cdef bcf_hrec_t *r = self.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_5value_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_5value_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_5value___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_5value___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  bcf_hrec_t *__pyx_v_r;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hrec_t *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1249, 0, __PYX_ERR(0, 1249, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1251
 *     def value(self):
 *         """header value.  Set only for generic lines, None for FILTER/INFO, etc."""
 *         cdef bcf_hrec_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         return charptr_to_str(r.value) if r and r.value else None
 * 
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1252
 *         """header value.  Set only for generic lines, None for FILTER/INFO, etc."""
 *         cdef bcf_hrec_t *r = self.ptr
 *         return charptr_to_str(r.value) if r and r.value else None             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = (__pyx_v_r != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_r->value != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L3_bool_binop_done:;
  if (__pyx_t_3) {
    __pyx_t_5 = __pyx_f_5pysam_9libcutils_charptr_to_str(__pyx_v_r->value, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1252, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __pyx_t_5;
    __pyx_t_5 = 0;
  } else {
    __Pyx_INCREF(Py_None);
    __pyx_t_2 = Py_None;
  }
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1249
 * 
 *     @property
 *     def value(self):             # <<<<<<<<<<<<<<
 *         """header value.  Set only for generic lines, None for FILTER/INFO, etc."""
 *         cdef bcf_hrec_t *r = self.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.value.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1255
 * 
 *     @property
 *     def attrs(self):             # <<<<<<<<<<<<<<
 *         """sequence of additional header attributes"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_5attrs_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_5attrs_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_5attrs___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantHeaderRecord_5attrs_7__get___2generator32(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":1261
 *             return ()
 *         cdef int i
 *         return tuple((bcf_str_cache_get_charptr(r.keys[i]) if r.keys[i] else None,             # <<<<<<<<<<<<<<
 *                       charptr_to_str(r.vals[i]) if r.vals[i] else None)
 *                      for i in range(r.nkeys))
 */

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_5attrs_7__get___genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_9_genexpr(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_9_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1261, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__ *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantHeaderRecord_5attrs_7__get___2generator32, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_VariantHeaderRecord___get___loca, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 1261, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.attrs.__get__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantHeaderRecord_5attrs_7__get___2generator32(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  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_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __Pyx_TraceCall("genexpr", __pyx_f[0], 1261, 0, __PYX_ERR(0, 1261, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1261, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1263
 *         return tuple((bcf_str_cache_get_charptr(r.keys[i]) if r.keys[i] else None,
 *                       charptr_to_str(r.vals[i]) if r.vals[i] else None)
 *                      for i in range(r.nkeys))             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_r->nkeys;
  __pyx_t_2 = __pyx_t_1;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_3;

    /* "pysam/libcbcf.pyx":1261
 *             return ()
 *         cdef int i
 *         return tuple((bcf_str_cache_get_charptr(r.keys[i]) if r.keys[i] else None,             # <<<<<<<<<<<<<<
 *                       charptr_to_str(r.vals[i]) if r.vals[i] else None)
 *                      for i in range(r.nkeys))
 */
    if (((__pyx_cur_scope->__pyx_outer_scope->__pyx_v_r->keys[__pyx_cur_scope->__pyx_v_i]) != 0)) {
      __pyx_t_5 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr((__pyx_cur_scope->__pyx_outer_scope->__pyx_v_r->keys[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1261, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __pyx_t_5;
      __pyx_t_5 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_4 = Py_None;
    }

    /* "pysam/libcbcf.pyx":1262
 *         cdef int i
 *         return tuple((bcf_str_cache_get_charptr(r.keys[i]) if r.keys[i] else None,
 *                       charptr_to_str(r.vals[i]) if r.vals[i] else None)             # <<<<<<<<<<<<<<
 *                      for i in range(r.nkeys))
 * 
 */
    if (((__pyx_cur_scope->__pyx_outer_scope->__pyx_v_r->vals[__pyx_cur_scope->__pyx_v_i]) != 0)) {
      __pyx_t_6 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_cur_scope->__pyx_outer_scope->__pyx_v_r->vals[__pyx_cur_scope->__pyx_v_i]), NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1262, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __pyx_t_6;
      __pyx_t_6 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_5 = Py_None;
    }

    /* "pysam/libcbcf.pyx":1261
 *             return ()
 *         cdef int i
 *         return tuple((bcf_str_cache_get_charptr(r.keys[i]) if r.keys[i] else None,             # <<<<<<<<<<<<<<
 *                       charptr_to_str(r.vals[i]) if r.vals[i] else None)
 *                      for i in range(r.nkeys))
 */
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1261, __pyx_L1_error)
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1255
 * 
 *     @property
 *     def attrs(self):             # <<<<<<<<<<<<<<
 *         """sequence of additional header attributes"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_5attrs___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__ *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hrec_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__ *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_8___get__(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_8___get__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1255, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __Pyx_TraceCall("__get__", __pyx_f[0], 1255, 0, __PYX_ERR(0, 1255, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1257
 *     def attrs(self):
 *         """sequence of additional header attributes"""
 *         cdef bcf_hrec_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if not r:
 *             return ()
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1258
 *         """sequence of additional header attributes"""
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:             # <<<<<<<<<<<<<<
 *             return ()
 *         cdef int i
 */
  __pyx_t_2 = ((!(__pyx_cur_scope->__pyx_v_r != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1259
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:
 *             return ()             # <<<<<<<<<<<<<<
 *         cdef int i
 *         return tuple((bcf_str_cache_get_charptr(r.keys[i]) if r.keys[i] else None,
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1258
 *         """sequence of additional header attributes"""
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:             # <<<<<<<<<<<<<<
 *             return ()
 *         cdef int i
 */
  }

  /* "pysam/libcbcf.pyx":1261
 *             return ()
 *         cdef int i
 *         return tuple((bcf_str_cache_get_charptr(r.keys[i]) if r.keys[i] else None,             # <<<<<<<<<<<<<<
 *                       charptr_to_str(r.vals[i]) if r.vals[i] else None)
 *                      for i in range(r.nkeys))
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_5attrs_7__get___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1261, __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;

  /* "pysam/libcbcf.pyx":1255
 * 
 *     @property
 *     def attrs(self):             # <<<<<<<<<<<<<<
 *         """sequence of additional header attributes"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.attrs.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1265
 *                      for i in range(r.nkeys))
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *r = self.ptr
 *         return r.nkeys if r else 0
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_3__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_3__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_2__len__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  bcf_hrec_t *__pyx_v_r;
  Py_ssize_t __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hrec_t *__pyx_t_1;
  Py_ssize_t __pyx_t_2;
  __Pyx_RefNannySetupContext("__len__", 0);
  __Pyx_TraceCall("__len__", __pyx_f[0], 1265, 0, __PYX_ERR(0, 1265, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1266
 * 
 *     def __len__(self):
 *         cdef bcf_hrec_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         return r.nkeys if r else 0
 * 
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1267
 *     def __len__(self):
 *         cdef bcf_hrec_t *r = self.ptr
 *         return r.nkeys if r else 0             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
  if ((__pyx_v_r != 0)) {
    __pyx_t_2 = __pyx_v_r->nkeys;
  } else {
    __pyx_t_2 = 0;
  }
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1265
 *                      for i in range(r.nkeys))
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *r = self.ptr
 *         return r.nkeys if r else 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1269
 *         return r.nkeys if r else 0
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *r = self.ptr
 *         return r != NULL and r.nkeys != 0
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_5__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_5__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_4__bool__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  bcf_hrec_t *__pyx_v_r;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hrec_t *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("__bool__", 0);
  __Pyx_TraceCall("__bool__", __pyx_f[0], 1269, 0, __PYX_ERR(0, 1269, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1270
 * 
 *     def __bool__(self):
 *         cdef bcf_hrec_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         return r != NULL and r.nkeys != 0
 * 
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1271
 *     def __bool__(self):
 *         cdef bcf_hrec_t *r = self.ptr
 *         return r != NULL and r.nkeys != 0             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key):
 */
  __pyx_t_3 = (__pyx_v_r != NULL);
  if (__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_r->nkeys != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1269
 *         return r.nkeys if r else 0
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *r = self.ptr
 *         return r != NULL and r.nkeys != 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1273
 *         return r != NULL and r.nkeys != 0
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         """get attribute value"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_6__getitem__[] = "get attribute value";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_5pysam_7libcbcf_19VariantHeaderRecord_6__getitem__;
#endif
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_6__getitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hrec_t *__pyx_v_r;
  int __pyx_v_i;
  PyObject *__pyx_v_bkey = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hrec_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_TraceCall("__getitem__", __pyx_f[0], 1273, 0, __PYX_ERR(0, 1273, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1275
 *     def __getitem__(self, key):
 *         """get attribute value"""
 *         cdef bcf_hrec_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         cdef int i
 *         if r:
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1277
 *         cdef bcf_hrec_t *r = self.ptr
 *         cdef int i
 *         if r:             # <<<<<<<<<<<<<<
 *             bkey = force_bytes(key)
 *             for i in range(r.nkeys):
 */
  __pyx_t_2 = (__pyx_v_r != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1278
 *         cdef int i
 *         if r:
 *             bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *             for i in range(r.nkeys):
 *                 if r.keys[i] and r.keys[i] == bkey:
 */
    __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1278, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_bkey = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":1279
 *         if r:
 *             bkey = force_bytes(key)
 *             for i in range(r.nkeys):             # <<<<<<<<<<<<<<
 *                 if r.keys[i] and r.keys[i] == bkey:
 *                     return charptr_to_str(r.vals[i]) if r.vals[i] else None
 */
    __pyx_t_4 = __pyx_v_r->nkeys;
    __pyx_t_5 = __pyx_t_4;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_v_i = __pyx_t_6;

      /* "pysam/libcbcf.pyx":1280
 *             bkey = force_bytes(key)
 *             for i in range(r.nkeys):
 *                 if r.keys[i] and r.keys[i] == bkey:             # <<<<<<<<<<<<<<
 *                     return charptr_to_str(r.vals[i]) if r.vals[i] else None
 *         raise KeyError('cannot find metadata key')
 */
      __pyx_t_7 = ((__pyx_v_r->keys[__pyx_v_i]) != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_2 = __pyx_t_7;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_3 = __Pyx_PyBytes_FromString((__pyx_v_r->keys[__pyx_v_i])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1280, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = (__Pyx_PyBytes_Equals(__pyx_t_3, __pyx_v_bkey, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1280, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = __pyx_t_7;
      __pyx_L7_bool_binop_done:;
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":1281
 *             for i in range(r.nkeys):
 *                 if r.keys[i] and r.keys[i] == bkey:
 *                     return charptr_to_str(r.vals[i]) if r.vals[i] else None             # <<<<<<<<<<<<<<
 *         raise KeyError('cannot find metadata key')
 * 
 */
        __Pyx_XDECREF(__pyx_r);
        if (((__pyx_v_r->vals[__pyx_v_i]) != 0)) {
          __pyx_t_8 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_v_r->vals[__pyx_v_i]), NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1281, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_3 = __pyx_t_8;
          __pyx_t_8 = 0;
        } else {
          __Pyx_INCREF(Py_None);
          __pyx_t_3 = Py_None;
        }
        __pyx_r = __pyx_t_3;
        __pyx_t_3 = 0;
        goto __pyx_L0;

        /* "pysam/libcbcf.pyx":1280
 *             bkey = force_bytes(key)
 *             for i in range(r.nkeys):
 *                 if r.keys[i] and r.keys[i] == bkey:             # <<<<<<<<<<<<<<
 *                     return charptr_to_str(r.vals[i]) if r.vals[i] else None
 *         raise KeyError('cannot find metadata key')
 */
      }
    }

    /* "pysam/libcbcf.pyx":1277
 *         cdef bcf_hrec_t *r = self.ptr
 *         cdef int i
 *         if r:             # <<<<<<<<<<<<<<
 *             bkey = force_bytes(key)
 *             for i in range(r.nkeys):
 */
  }

  /* "pysam/libcbcf.pyx":1282
 *                 if r.keys[i] and r.keys[i] == bkey:
 *                     return charptr_to_str(r.vals[i]) if r.vals[i] else None
 *         raise KeyError('cannot find metadata key')             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __PYX_ERR(0, 1282, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1273
 *         return r != NULL and r.nkeys != 0
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         """get attribute value"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantHeaderRecord_10generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":1284
 *         raise KeyError('cannot find metadata key')
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_9__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_9__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_8__iter__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_8__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__ *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__ *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_10___iter__(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_10___iter__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1284, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantHeaderRecord_10generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_VariantHeaderRecord___iter, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 1284, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.__iter__", __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_5pysam_7libcbcf_19VariantHeaderRecord_10generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__ *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hrec_t *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 1284, 0, __PYX_ERR(0, 1284, __pyx_L1_error));
  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_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1284, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1285
 * 
 *     def __iter__(self):
 *         cdef bcf_hrec_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if not r:
 *             return
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1286
 *     def __iter__(self):
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:             # <<<<<<<<<<<<<<
 *             return
 *         cdef int i
 */
  __pyx_t_2 = ((!(__pyx_cur_scope->__pyx_v_r != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1287
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:
 *             return             # <<<<<<<<<<<<<<
 *         cdef int i
 *         for i in range(r.nkeys):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = NULL;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1286
 *     def __iter__(self):
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:             # <<<<<<<<<<<<<<
 *             return
 *         cdef int i
 */
  }

  /* "pysam/libcbcf.pyx":1289
 *             return
 *         cdef int i
 *         for i in range(r.nkeys):             # <<<<<<<<<<<<<<
 *             if r.keys[i]:
 *                 yield bcf_str_cache_get_charptr(r.keys[i])
 */
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_r->nkeys;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_5;

    /* "pysam/libcbcf.pyx":1290
 *         cdef int i
 *         for i in range(r.nkeys):
 *             if r.keys[i]:             # <<<<<<<<<<<<<<
 *                 yield bcf_str_cache_get_charptr(r.keys[i])
 * 
 */
    __pyx_t_2 = ((__pyx_cur_scope->__pyx_v_r->keys[__pyx_cur_scope->__pyx_v_i]) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":1291
 *         for i in range(r.nkeys):
 *             if r.keys[i]:
 *                 yield bcf_str_cache_get_charptr(r.keys[i])             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
      __pyx_t_6 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr((__pyx_cur_scope->__pyx_v_r->keys[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1291, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_r = __pyx_t_6;
      __pyx_t_6 = 0;
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_TraceReturn(__pyx_r, 0);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L8_resume_from_yield:;
      __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
      __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1291, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":1290
 *         cdef int i
 *         for i in range(r.nkeys):
 *             if r.keys[i]:             # <<<<<<<<<<<<<<
 *                 yield bcf_str_cache_get_charptr(r.keys[i])
 * 
 */
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":1284
 *         raise KeyError('cannot find metadata key')
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1293
 *                 yield bcf_str_cache_get_charptr(r.keys[i])
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_12get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_11get[] = "VariantHeaderRecord.get(self, key, default=None)\nD.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_12get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 1293, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1293, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_11get(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_11get(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("get", 0);
  __Pyx_TraceCall("get", __pyx_f[0], 1293, 0, __PYX_ERR(0, 1293, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1295
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":1296
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 *             return self[key]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return default
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1296, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "pysam/libcbcf.pyx":1295
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":1297
 *         try:
 *             return self[key]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 1297, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":1298
 *             return self[key]
 *         except KeyError:
 *             return default             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_default);
      __pyx_r = __pyx_v_default;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":1295
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":1293
 *                 yield bcf_str_cache_get_charptr(r.keys[i])
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1300
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         try:
 *             self[key]
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_14__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_14__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_13__contains__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_13__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("__contains__", 0);
  __Pyx_TraceCall("__contains__", __pyx_f[0], 1300, 0, __PYX_ERR(0, 1300, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1301
 * 
 *     def __contains__(self, key):
 *         try:             # <<<<<<<<<<<<<<
 *             self[key]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":1302
 *     def __contains__(self, key):
 *         try:
 *             self[key]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return False
 */
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1302, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pysam/libcbcf.pyx":1301
 * 
 *     def __contains__(self, key):
 *         try:             # <<<<<<<<<<<<<<
 *             self[key]
 *         except KeyError:
 */
    }

    /* "pysam/libcbcf.pyx":1306
 *             return False
 *         else:
 *             return True             # <<<<<<<<<<<<<<
 * 
 *     def iterkeys(self):
 */
    /*else:*/ {
      __pyx_r = 1;
      goto __pyx_L6_except_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":1303
 *         try:
 *             self[key]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return False
 *         else:
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 1303, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":1304
 *             self[key]
 *         except KeyError:
 *             return False             # <<<<<<<<<<<<<<
 *         else:
 *             return True
 */
      __pyx_r = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":1301
 * 
 *     def __contains__(self, key):
 *         try:             # <<<<<<<<<<<<<<
 *             self[key]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":1300
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         try:
 *             self[key]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1308
 *             return True
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_16iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_15iterkeys[] = "VariantHeaderRecord.iterkeys(self)\nD.iterkeys() -> an iterator over the keys of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_16iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iterkeys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_15iterkeys(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_15iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("iterkeys", 0);
  __Pyx_TraceCall("iterkeys", __pyx_f[0], 1308, 0, __PYX_ERR(0, 1308, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1310
 *     def iterkeys(self):
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)             # <<<<<<<<<<<<<<
 * 
 *     def itervalues(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1308
 *             return True
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.iterkeys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantHeaderRecord_19generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":1312
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_18itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_17itervalues[] = "VariantHeaderRecord.itervalues(self)\nD.itervalues() -> an iterator over the values of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_18itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_17itervalues(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_17itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_11_itervalues(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_11_itervalues, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1312, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantHeaderRecord_19generator1, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_itervalues, __pyx_n_s_VariantHeaderRecord_itervalues, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 1312, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.itervalues", __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_5pysam_7libcbcf_19VariantHeaderRecord_19generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hrec_t *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __Pyx_TraceCall("itervalues", __pyx_f[0], 1312, 0, __PYX_ERR(0, 1312, __pyx_L1_error));
  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_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1312, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1314
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hrec_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if not r:
 *             return
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1315
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:             # <<<<<<<<<<<<<<
 *             return
 *         cdef int i
 */
  __pyx_t_2 = ((!(__pyx_cur_scope->__pyx_v_r != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1316
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:
 *             return             # <<<<<<<<<<<<<<
 *         cdef int i
 *         for i in range(r.nkeys):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = NULL;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1315
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:             # <<<<<<<<<<<<<<
 *             return
 *         cdef int i
 */
  }

  /* "pysam/libcbcf.pyx":1318
 *             return
 *         cdef int i
 *         for i in range(r.nkeys):             # <<<<<<<<<<<<<<
 *             if r.keys[i]:
 *                 yield charptr_to_str(r.vals[i]) if r.vals[i] else None
 */
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_r->nkeys;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_5;

    /* "pysam/libcbcf.pyx":1319
 *         cdef int i
 *         for i in range(r.nkeys):
 *             if r.keys[i]:             # <<<<<<<<<<<<<<
 *                 yield charptr_to_str(r.vals[i]) if r.vals[i] else None
 * 
 */
    __pyx_t_2 = ((__pyx_cur_scope->__pyx_v_r->keys[__pyx_cur_scope->__pyx_v_i]) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":1320
 *         for i in range(r.nkeys):
 *             if r.keys[i]:
 *                 yield charptr_to_str(r.vals[i]) if r.vals[i] else None             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
      if (((__pyx_cur_scope->__pyx_v_r->vals[__pyx_cur_scope->__pyx_v_i]) != 0)) {
        __pyx_t_7 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_cur_scope->__pyx_v_r->vals[__pyx_cur_scope->__pyx_v_i]), NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1320, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_6 = __pyx_t_7;
        __pyx_t_7 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_6 = Py_None;
      }
      __pyx_r = __pyx_t_6;
      __pyx_t_6 = 0;
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_TraceReturn(__pyx_r, 0);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L8_resume_from_yield:;
      __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
      __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1320, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":1319
 *         cdef int i
 *         for i in range(r.nkeys):
 *             if r.keys[i]:             # <<<<<<<<<<<<<<
 *                 yield charptr_to_str(r.vals[i]) if r.vals[i] else None
 * 
 */
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":1312
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("itervalues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantHeaderRecord_22generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":1322
 *                 yield charptr_to_str(r.vals[i]) if r.vals[i] else None
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_21iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_20iteritems[] = "VariantHeaderRecord.iteritems(self)\nD.iteritems() -> an iterator over the (key, value) items of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_21iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_20iteritems(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_20iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_12_iteritems(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_12_iteritems, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1322, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantHeaderRecord_22generator2, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iteritems, __pyx_n_s_VariantHeaderRecord_iteritems, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 1322, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.iteritems", __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_5pysam_7libcbcf_19VariantHeaderRecord_22generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hrec_t *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __Pyx_TraceCall("iteritems", __pyx_f[0], 1322, 0, __PYX_ERR(0, 1322, __pyx_L1_error));
  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_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1322, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1324
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hrec_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if not r:
 *             return
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1325
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:             # <<<<<<<<<<<<<<
 *             return
 *         cdef int i
 */
  __pyx_t_2 = ((!(__pyx_cur_scope->__pyx_v_r != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1326
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:
 *             return             # <<<<<<<<<<<<<<
 *         cdef int i
 *         for i in range(r.nkeys):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = NULL;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1325
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:             # <<<<<<<<<<<<<<
 *             return
 *         cdef int i
 */
  }

  /* "pysam/libcbcf.pyx":1328
 *             return
 *         cdef int i
 *         for i in range(r.nkeys):             # <<<<<<<<<<<<<<
 *             if r.keys[i]:
 *                 yield (bcf_str_cache_get_charptr(r.keys[i]), charptr_to_str(r.vals[i]) if r.vals[i] else None)
 */
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_r->nkeys;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_5;

    /* "pysam/libcbcf.pyx":1329
 *         cdef int i
 *         for i in range(r.nkeys):
 *             if r.keys[i]:             # <<<<<<<<<<<<<<
 *                 yield (bcf_str_cache_get_charptr(r.keys[i]), charptr_to_str(r.vals[i]) if r.vals[i] else None)
 * 
 */
    __pyx_t_2 = ((__pyx_cur_scope->__pyx_v_r->keys[__pyx_cur_scope->__pyx_v_i]) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":1330
 *         for i in range(r.nkeys):
 *             if r.keys[i]:
 *                 yield (bcf_str_cache_get_charptr(r.keys[i]), charptr_to_str(r.vals[i]) if r.vals[i] else None)             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
      __pyx_t_6 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr((__pyx_cur_scope->__pyx_v_r->keys[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1330, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (((__pyx_cur_scope->__pyx_v_r->vals[__pyx_cur_scope->__pyx_v_i]) != 0)) {
        __pyx_t_8 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_cur_scope->__pyx_v_r->vals[__pyx_cur_scope->__pyx_v_i]), NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1330, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_7 = __pyx_t_8;
        __pyx_t_8 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_7 = Py_None;
      }
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1330, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_r = __pyx_t_8;
      __pyx_t_8 = 0;
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_TraceReturn(__pyx_r, 0);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L8_resume_from_yield:;
      __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
      __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1330, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":1329
 *         cdef int i
 *         for i in range(r.nkeys):
 *             if r.keys[i]:             # <<<<<<<<<<<<<<
 *                 yield (bcf_str_cache_get_charptr(r.keys[i]), charptr_to_str(r.vals[i]) if r.vals[i] else None)
 * 
 */
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":1322
 *                 yield charptr_to_str(r.vals[i]) if r.vals[i] else None
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hrec_t *r = self.ptr
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("iteritems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1332
 *                 yield (bcf_str_cache_get_charptr(r.keys[i]), charptr_to_str(r.vals[i]) if r.vals[i] else None)
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_24keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_23keys[] = "VariantHeaderRecord.keys(self)\nD.keys() -> list of D's keys";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_24keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_23keys(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_23keys(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("keys", 0);
  __Pyx_TraceCall("keys", __pyx_f[0], 1332, 0, __PYX_ERR(0, 1332, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1334
 *     def keys(self):
 *         """D.keys() -> list of D's keys"""
 *         return list(self)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_List(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1332
 *                 yield (bcf_str_cache_get_charptr(r.keys[i]), charptr_to_str(r.vals[i]) if r.vals[i] else None)
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1336
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_26items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_25items[] = "VariantHeaderRecord.items(self)\nD.items() -> list of D's (key, value) pairs, as 2-tuples";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_26items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("items (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_25items(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_25items(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("items", 0);
  __Pyx_TraceCall("items", __pyx_f[0], 1336, 0, __PYX_ERR(0, 1336, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1338
 *     def items(self):
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_iteritems); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1338, __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, 1338, __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, 1338, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1336
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.items", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1340
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_28values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_27values[] = "VariantHeaderRecord.values(self)\nD.values() -> list of D's values";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_28values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("values (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_27values(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_27values(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("values", 0);
  __Pyx_TraceCall("values", __pyx_f[0], 1340, 0, __PYX_ERR(0, 1340, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1342
 *     def values(self):
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())             # <<<<<<<<<<<<<<
 * 
 *     def update(self, items=None, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itervalues); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1342, __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, 1342, __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, 1342, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1340
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1344
 *         return list(self.itervalues())
 * 
 *     def update(self, items=None, **kwargs):             # <<<<<<<<<<<<<<
 *         """D.update([E, ]**F) -> None.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_30update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_29update[] = "VariantHeaderRecord.update(self, items=None, **kwargs)\nD.update([E, ]**F) -> None.\n\n        Update D from dict/iterable E and F.\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_30update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update (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_items,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "update") < 0)) __PYX_ERR(0, 1344, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("update", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1344, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_29update(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self), __pyx_v_items, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_29update(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("update", 0);
  __Pyx_TraceCall("update", __pyx_f[0], 1344, 0, __PYX_ERR(0, 1344, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1349
 *         Update D from dict/iterable E and F.
 *         """
 *         for k, v in items.items():             # <<<<<<<<<<<<<<
 *             self[k] = v
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1349, __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, 1349, __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, 1349, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1349, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1349, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1349, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1349, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1349, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1349, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1349, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 1349, __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, 1349, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1349, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1349, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 1349, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 1349, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pysam/libcbcf.pyx":1350
 *         """
 *         for k, v in items.items():
 *             self[k] = v             # <<<<<<<<<<<<<<
 * 
 *         if kwargs:
 */
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_k, __pyx_v_v) < 0)) __PYX_ERR(0, 1350, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1349
 *         Update D from dict/iterable E and F.
 *         """
 *         for k, v in items.items():             # <<<<<<<<<<<<<<
 *             self[k] = v
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":1352
 *             self[k] = v
 * 
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             for k, v in kwargs.items():
 *                 self[k] = v
 */
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1352, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "pysam/libcbcf.pyx":1353
 * 
 *         if kwargs:
 *             for k, v in kwargs.items():             # <<<<<<<<<<<<<<
 *                 self[k] = v
 * 
 */
    __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1353, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1353, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1353, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1353, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1353, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1353, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1353, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1353, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 1353, __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_3 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1353, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1353, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1353, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L10_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L10_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 1353, __pyx_L1_error)
        __pyx_t_8 = NULL;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L11_unpacking_done;
        __pyx_L10_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, 1353, __pyx_L1_error)
        __pyx_L11_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":1354
 *         if kwargs:
 *             for k, v in kwargs.items():
 *                 self[k] = v             # <<<<<<<<<<<<<<
 * 
 *     def pop(self, key, default=_nothing):
 */
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_k, __pyx_v_v) < 0)) __PYX_ERR(0, 1354, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":1353
 * 
 *         if kwargs:
 *             for k, v in kwargs.items():             # <<<<<<<<<<<<<<
 *                 self[k] = v
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":1352
 *             self[k] = v
 * 
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             for k, v in kwargs.items():
 *                 self[k] = v
 */
  }

  /* "pysam/libcbcf.pyx":1344
 *         return list(self.itervalues())
 * 
 *     def update(self, items=None, **kwargs):             # <<<<<<<<<<<<<<
 *         """D.update([E, ]**F) -> None.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1356
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         try:
 *             value = self[key]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_32pop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_31pop[] = "VariantHeaderRecord.pop(self, key, default=_nothing)";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_32pop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pop (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k__61;
    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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "pop") < 0)) __PYX_ERR(0, 1356, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("pop", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1356, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_31pop(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_31pop(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("pop", 0);
  __Pyx_TraceCall("pop", __pyx_f[0], 1356, 0, __PYX_ERR(0, 1356, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1357
 * 
 *     def pop(self, key, default=_nothing):
 *         try:             # <<<<<<<<<<<<<<
 *             value = self[key]
 *             del self[key]
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":1358
 *     def pop(self, key, default=_nothing):
 *         try:
 *             value = self[key]             # <<<<<<<<<<<<<<
 *             del self[key]
 *             return value
 */
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1358, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_value = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "pysam/libcbcf.pyx":1359
 *         try:
 *             value = self[key]
 *             del self[key]             # <<<<<<<<<<<<<<
 *             return value
 *         except KeyError:
 */
      if (unlikely(PyObject_DelItem(((PyObject *)__pyx_v_self), __pyx_v_key) < 0)) __PYX_ERR(0, 1359, __pyx_L3_error)

      /* "pysam/libcbcf.pyx":1360
 *             value = self[key]
 *             del self[key]
 *             return value             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             if default is not _nothing:
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_value);
      __pyx_r = __pyx_v_value;
      goto __pyx_L7_try_return;

      /* "pysam/libcbcf.pyx":1357
 * 
 *     def pop(self, key, default=_nothing):
 *         try:             # <<<<<<<<<<<<<<
 *             value = self[key]
 *             del self[key]
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":1361
 *             del self[key]
 *             return value
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             if default is not _nothing:
 *                 return default
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 1361, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":1362
 *             return value
 *         except KeyError:
 *             if default is not _nothing:             # <<<<<<<<<<<<<<
 *                 return default
 *             raise
 */
      __pyx_t_8 = (__pyx_v_default != __pyx_v_5pysam_7libcbcf__nothing);
      __pyx_t_9 = (__pyx_t_8 != 0);
      if (__pyx_t_9) {

        /* "pysam/libcbcf.pyx":1363
 *         except KeyError:
 *             if default is not _nothing:
 *                 return default             # <<<<<<<<<<<<<<
 *             raise
 * 
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_v_default);
        __pyx_r = __pyx_v_default;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L6_except_return;

        /* "pysam/libcbcf.pyx":1362
 *             return value
 *         except KeyError:
 *             if default is not _nothing:             # <<<<<<<<<<<<<<
 *                 return default
 *             raise
 */
      }

      /* "pysam/libcbcf.pyx":1364
 *             if default is not _nothing:
 *                 return default
 *             raise             # <<<<<<<<<<<<<<
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 */
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_6, __pyx_t_7);
      __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; 
      __PYX_ERR(0, 1364, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":1357
 * 
 *     def pop(self, key, default=_nothing):
 *         try:             # <<<<<<<<<<<<<<
 *             value = self[key]
 *             del self[key]
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":1356
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         try:
 *             value = self[key]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1371
 *     #TODO: implement __richcmp__
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *r = self.ptr
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_34__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_34__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_33__str__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_33__str__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  bcf_hrec_t *__pyx_v_r;
  kstring_t __pyx_v_hrec_str;
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hrec_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__str__", 0);
  __Pyx_TraceCall("__str__", __pyx_f[0], 1371, 0, __PYX_ERR(0, 1371, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1372
 * 
 *     def __str__(self):
 *         cdef bcf_hrec_t *r = self.ptr             # <<<<<<<<<<<<<<
 * 
 *         if not r:
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1374
 *         cdef bcf_hrec_t *r = self.ptr
 * 
 *         if not r:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot convert deleted record to str')
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_r != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1375
 * 
 *         if not r:
 *             raise ValueError('cannot convert deleted record to str')             # <<<<<<<<<<<<<<
 * 
 *         cdef kstring_t hrec_str
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1375, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1375, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1374
 *         cdef bcf_hrec_t *r = self.ptr
 * 
 *         if not r:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot convert deleted record to str')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1378
 * 
 *         cdef kstring_t hrec_str
 *         hrec_str.l = hrec_str.m = 0             # <<<<<<<<<<<<<<
 *         hrec_str.s = NULL
 * 
 */
  __pyx_v_hrec_str.l = 0;
  __pyx_v_hrec_str.m = 0;

  /* "pysam/libcbcf.pyx":1379
 *         cdef kstring_t hrec_str
 *         hrec_str.l = hrec_str.m = 0
 *         hrec_str.s = NULL             # <<<<<<<<<<<<<<
 * 
 *         bcf_hrec_format(r, &hrec_str)
 */
  __pyx_v_hrec_str.s = NULL;

  /* "pysam/libcbcf.pyx":1381
 *         hrec_str.s = NULL
 * 
 *         bcf_hrec_format(r, &hrec_str)             # <<<<<<<<<<<<<<
 * 
 *         ret = charptr_to_str_w_len(hrec_str.s, hrec_str.l)
 */
  bcf_hrec_format(__pyx_v_r, (&__pyx_v_hrec_str));

  /* "pysam/libcbcf.pyx":1383
 *         bcf_hrec_format(r, &hrec_str)
 * 
 *         ret = charptr_to_str_w_len(hrec_str.s, hrec_str.l)             # <<<<<<<<<<<<<<
 * 
 *         if hrec_str.m:
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_charptr_to_str_w_len(__pyx_v_hrec_str.s, __pyx_v_hrec_str.l, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ret = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":1385
 *         ret = charptr_to_str_w_len(hrec_str.s, hrec_str.l)
 * 
 *         if hrec_str.m:             # <<<<<<<<<<<<<<
 *             free(hrec_str.s)
 * 
 */
  __pyx_t_2 = (__pyx_v_hrec_str.m != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1386
 * 
 *         if hrec_str.m:
 *             free(hrec_str.s)             # <<<<<<<<<<<<<<
 * 
 *         return ret
 */
    free(__pyx_v_hrec_str.s);

    /* "pysam/libcbcf.pyx":1385
 *         ret = charptr_to_str_w_len(hrec_str.s, hrec_str.l)
 * 
 *         if hrec_str.m:             # <<<<<<<<<<<<<<
 *             free(hrec_str.s)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1388
 *             free(hrec_str.s)
 * 
 *         return ret             # <<<<<<<<<<<<<<
 * 
 *     # FIXME: Not safe -- causes trivial segfaults at the moment
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1371
 *     #TODO: implement __richcmp__
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *r = self.ptr
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1391
 * 
 *     # FIXME: Not safe -- causes trivial segfaults at the moment
 *     def remove(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_hrec_t *r = self.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_36remove(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_35remove[] = "VariantHeaderRecord.remove(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_36remove(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_35remove(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_35remove(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf_hrec_t *__pyx_v_r;
  char *__pyx_v_key;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf_hrec_t *__pyx_t_2;
  int __pyx_t_3;
  char *__pyx_t_4;
  __Pyx_RefNannySetupContext("remove", 0);
  __Pyx_TraceCall("remove", __pyx_f[0], 1391, 0, __PYX_ERR(0, 1391, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1392
 *     # FIXME: Not safe -- causes trivial segfaults at the moment
 *     def remove(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1393
 *     def remove(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_hrec_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if not r:
 *             return
 */
  __pyx_t_2 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":1394
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:             # <<<<<<<<<<<<<<
 *             return
 *         assert r.key
 */
  __pyx_t_3 = ((!(__pyx_v_r != 0)) != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":1395
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:
 *             return             # <<<<<<<<<<<<<<
 *         assert r.key
 *         cdef char *key = r.key if r.type == BCF_HL_GEN else r.value
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1394
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_hrec_t *r = self.ptr
 *         if not r:             # <<<<<<<<<<<<<<
 *             return
 *         assert r.key
 */
  }

  /* "pysam/libcbcf.pyx":1396
 *         if not r:
 *             return
 *         assert r.key             # <<<<<<<<<<<<<<
 *         cdef char *key = r.key if r.type == BCF_HL_GEN else r.value
 *         bcf_hdr_remove(hdr, r.type, key)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!(__pyx_v_r->key != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 1396, __pyx_L1_error)
    }
  }
  #endif

  /* "pysam/libcbcf.pyx":1397
 *             return
 *         assert r.key
 *         cdef char *key = r.key if r.type == BCF_HL_GEN else r.value             # <<<<<<<<<<<<<<
 *         bcf_hdr_remove(hdr, r.type, key)
 *         self.ptr = NULL
 */
  if (((__pyx_v_r->type == BCF_HL_GEN) != 0)) {
    __pyx_t_4 = __pyx_v_r->key;
  } else {
    __pyx_t_4 = __pyx_v_r->value;
  }
  __pyx_v_key = __pyx_t_4;

  /* "pysam/libcbcf.pyx":1398
 *         assert r.key
 *         cdef char *key = r.key if r.type == BCF_HL_GEN else r.value
 *         bcf_hdr_remove(hdr, r.type, key)             # <<<<<<<<<<<<<<
 *         self.ptr = NULL
 * 
 */
  bcf_hdr_remove(__pyx_v_hdr, __pyx_v_r->type, __pyx_v_key);

  /* "pysam/libcbcf.pyx":1399
 *         cdef char *key = r.key if r.type == BCF_HL_GEN else r.value
 *         bcf_hdr_remove(hdr, r.type, key)
 *         self.ptr = NULL             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_self->ptr = NULL;

  /* "pysam/libcbcf.pyx":1391
 * 
 *     # FIXME: Not safe -- causes trivial segfaults at the moment
 *     def remove(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_hrec_t *r = self.ptr
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.remove", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":45
 * 
 * cdef class VariantHeaderRecord(object):
 *     cdef readonly VariantHeader header             # <<<<<<<<<<<<<<
 *     cdef bcf_hrec_t *ptr
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_6header_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_6header_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_6header___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 45, 0, __PYX_ERR(1, 45, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __pyx_r = ((PyObject *)__pyx_v_self->header);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.header.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_38__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_37__reduce_cython__[] = "VariantHeaderRecord.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_38__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_37__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_37__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_40__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_39__setstate_cython__[] = "VariantHeaderRecord.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_40__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_39__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantHeaderRecord_39__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 3, 0, __PYX_ERR(2, 3, __pyx_L1_error));

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecord.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1402
 * 
 * 
 * cdef VariantHeaderRecord makeVariantHeaderRecord(VariantHeader header, bcf_hrec_t *hdr):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_f_5pysam_7libcbcf_makeVariantHeaderRecord(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header, bcf_hrec_t *__pyx_v_hdr) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_record = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("makeVariantHeaderRecord", 0);
  __Pyx_TraceCall("makeVariantHeaderRecord", __pyx_f[0], 1402, 0, __PYX_ERR(0, 1402, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1403
 * 
 * cdef VariantHeaderRecord makeVariantHeaderRecord(VariantHeader header, bcf_hrec_t *hdr):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_header)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1403, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1404
 * cdef VariantHeaderRecord makeVariantHeaderRecord(VariantHeader header, bcf_hrec_t *hdr):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     if not hdr:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1404, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1403
 * 
 * cdef VariantHeaderRecord makeVariantHeaderRecord(VariantHeader header, bcf_hrec_t *hdr):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1406
 *         raise ValueError('invalid VariantHeader')
 * 
 *     if not hdr:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_hdr != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1407
 * 
 *     if not hdr:
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantHeaderRecord record = VariantHeaderRecord.__new__(VariantHeaderRecord)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_r = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)Py_None); __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1406
 *         raise ValueError('invalid VariantHeader')
 * 
 *     if not hdr:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1409
 *         return None
 * 
 *     cdef VariantHeaderRecord record = VariantHeaderRecord.__new__(VariantHeaderRecord)             # <<<<<<<<<<<<<<
 *     record.header = header
 *     record.ptr = hdr
 */
  __pyx_t_3 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantHeaderRecord(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderRecord), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1409, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_record = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":1410
 * 
 *     cdef VariantHeaderRecord record = VariantHeaderRecord.__new__(VariantHeaderRecord)
 *     record.header = header             # <<<<<<<<<<<<<<
 *     record.ptr = hdr
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_header));
  __Pyx_GOTREF(__pyx_v_record->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_record->header));
  __pyx_v_record->header = __pyx_v_header;

  /* "pysam/libcbcf.pyx":1411
 *     cdef VariantHeaderRecord record = VariantHeaderRecord.__new__(VariantHeaderRecord)
 *     record.header = header
 *     record.ptr = hdr             # <<<<<<<<<<<<<<
 * 
 *     return record
 */
  __pyx_v_record->ptr = __pyx_v_hdr;

  /* "pysam/libcbcf.pyx":1413
 *     record.ptr = hdr
 * 
 *     return record             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_record));
  __pyx_r = __pyx_v_record;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1402
 * 
 * 
 * cdef VariantHeaderRecord makeVariantHeaderRecord(VariantHeader header, bcf_hrec_t *hdr):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantHeaderRecord", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_record);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1418
 * cdef class VariantHeaderRecords(object):
 *     """sequence of :class:`VariantHeaderRecord` object from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 1418, 0, __PYX_ERR(0, 1418, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1419
 *     """sequence of :class:`VariantHeaderRecord` object from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 1419, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1418
 * cdef class VariantHeaderRecords(object):
 *     """sequence of :class:`VariantHeaderRecord` object from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecords.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1421
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.header.ptr.nhrec
 * 
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_3__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_3__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_2__len__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);
  __Pyx_TraceCall("__len__", __pyx_f[0], 1421, 0, __PYX_ERR(0, 1421, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1422
 * 
 *     def __len__(self):
 *         return self.header.ptr.nhrec             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
  __pyx_r = __pyx_v_self->header->ptr->nhrec;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1421
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.header.ptr.nhrec
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecords.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1424
 *         return self.header.ptr.nhrec
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         return self.header.ptr.nhrec != 0
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_5__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_5__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_4__bool__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__", 0);
  __Pyx_TraceCall("__bool__", __pyx_f[0], 1424, 0, __PYX_ERR(0, 1424, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1425
 * 
 *     def __bool__(self):
 *         return self.header.ptr.nhrec != 0             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, index):
 */
  __pyx_r = (__pyx_v_self->header->ptr->nhrec != 0);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1424
 *         return self.header.ptr.nhrec
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         return self.header.ptr.nhrec != 0
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecords.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1427
 *         return self.header.ptr.nhrec != 0
 * 
 *     def __getitem__(self, index):             # <<<<<<<<<<<<<<
 *         cdef int32_t i = index
 *         if i < 0 or i >= self.header.ptr.nhrec:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_6__getitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)__pyx_v_self), ((PyObject *)__pyx_v_index));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self, PyObject *__pyx_v_index) {
  int32_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int32_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_TraceCall("__getitem__", __pyx_f[0], 1427, 0, __PYX_ERR(0, 1427, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1428
 * 
 *     def __getitem__(self, index):
 *         cdef int32_t i = index             # <<<<<<<<<<<<<<
 *         if i < 0 or i >= self.header.ptr.nhrec:
 *             raise IndexError('invalid header record index')
 */
  __pyx_t_1 = __Pyx_PyInt_As_int32_t(__pyx_v_index); if (unlikely((__pyx_t_1 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1428, __pyx_L1_error)
  __pyx_v_i = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1429
 *     def __getitem__(self, index):
 *         cdef int32_t i = index
 *         if i < 0 or i >= self.header.ptr.nhrec:             # <<<<<<<<<<<<<<
 *             raise IndexError('invalid header record index')
 *         return makeVariantHeaderRecord(self.header, self.header.ptr.hrec[i])
 */
  __pyx_t_3 = ((__pyx_v_i < 0) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = ((__pyx_v_i >= __pyx_v_self->header->ptr->nhrec) != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1430
 *         cdef int32_t i = index
 *         if i < 0 or i >= self.header.ptr.nhrec:
 *             raise IndexError('invalid header record index')             # <<<<<<<<<<<<<<
 *         return makeVariantHeaderRecord(self.header, self.header.ptr.hrec[i])
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1430, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 1430, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1429
 *     def __getitem__(self, index):
 *         cdef int32_t i = index
 *         if i < 0 or i >= self.header.ptr.nhrec:             # <<<<<<<<<<<<<<
 *             raise IndexError('invalid header record index')
 *         return makeVariantHeaderRecord(self.header, self.header.ptr.hrec[i])
 */
  }

  /* "pysam/libcbcf.pyx":1431
 *         if i < 0 or i >= self.header.ptr.nhrec:
 *             raise IndexError('invalid header record index')
 *         return makeVariantHeaderRecord(self.header, self.header.ptr.hrec[i])             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = ((PyObject *)__pyx_v_self->header);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_5 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeaderRecord(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_4), (__pyx_v_self->header->ptr->hrec[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1427
 *         return self.header.ptr.nhrec != 0
 * 
 *     def __getitem__(self, index):             # <<<<<<<<<<<<<<
 *         cdef int32_t i = index
 *         if i < 0 or i >= self.header.ptr.nhrec:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecords.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_20VariantHeaderRecords_10generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":1433
 *         return makeVariantHeaderRecord(self.header, self.header.ptr.hrec[i])
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef int32_t i
 *         for i in range(self.header.ptr.nhrec):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_9__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_9__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_8__iter__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_8__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__ *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__ *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_13___iter__(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_13___iter__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1433, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_20VariantHeaderRecords_10generator3, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_VariantHeaderRecords___iter, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 1433, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecords.__iter__", __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_5pysam_7libcbcf_20VariantHeaderRecords_10generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__ *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int32_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 1433, 0, __PYX_ERR(0, 1433, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1433, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1435
 *     def __iter__(self):
 *         cdef int32_t i
 *         for i in range(self.header.ptr.nhrec):             # <<<<<<<<<<<<<<
 *             yield makeVariantHeaderRecord(self.header, self.header.ptr.hrec[i])
 * 
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->header->ptr->nhrec;
  __pyx_t_2 = __pyx_t_1;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_3;

    /* "pysam/libcbcf.pyx":1436
 *         cdef int32_t i
 *         for i in range(self.header.ptr.nhrec):
 *             yield makeVariantHeaderRecord(self.header, self.header.ptr.hrec[i])             # <<<<<<<<<<<<<<
 * 
 *     __hash__ = None
 */
    __pyx_t_4 = ((PyObject *)__pyx_cur_scope->__pyx_v_self->header);
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_5 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeaderRecord(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_4), (__pyx_cur_scope->__pyx_v_self->header->ptr->hrec[__pyx_cur_scope->__pyx_v_i]))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1436, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1436, __pyx_L1_error)
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":1433
 *         return makeVariantHeaderRecord(self.header, self.header.ptr.hrec[i])
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef int32_t i
 *         for i in range(self.header.ptr.nhrec):
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":50
 * 
 * cdef class VariantHeaderRecords(object):
 *     cdef readonly VariantHeader header             # <<<<<<<<<<<<<<
 * 
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_6header_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_6header_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_6header___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 50, 0, __PYX_ERR(1, 50, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __pyx_r = ((PyObject *)__pyx_v_self->header);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecords.header.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.header,)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_12__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderRecords_11__reduce_cython__[] = "VariantHeaderRecords.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_12__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_11__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_11__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.header,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->header));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->header));
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.header,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":5
 *     state = (self.header,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.header is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.header,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.header is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_VariantHeaderRecords, (type(self), 0x099fb99, None), state
 */
  /*else*/ {
    __pyx_t_3 = (((PyObject *)__pyx_v_self->header) != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.header is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantHeaderRecords, (type(self), 0x099fb99, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":11
 *         use_setstate = self.header is not None
 *     if use_setstate:
 *         return __pyx_unpickle_VariantHeaderRecords, (type(self), 0x099fb99, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_VariantHeaderRecords, (type(self), 0x099fb99, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantHeaderReco); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_10091417);
    __Pyx_GIVEREF(__pyx_int_10091417);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_10091417);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.header is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantHeaderRecords, (type(self), 0x099fb99, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_VariantHeaderRecords, (type(self), 0x099fb99, None), state
 *     else:
 *         return __pyx_unpickle_VariantHeaderRecords, (type(self), 0x099fb99, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantHeaderRecords__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantHeaderReco); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_10091417);
    __Pyx_GIVEREF(__pyx_int_10091417);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_10091417);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.header,)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecords.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantHeaderRecords, (type(self), 0x099fb99, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantHeaderRecords__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_14__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderRecords_13__setstate_cython__[] = "VariantHeaderRecords.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_14__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_13__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderRecords_13__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 14, 0, __PYX_ERR(2, 14, __pyx_L1_error));

  /* "(tree fragment)":15
 *         return __pyx_unpickle_VariantHeaderRecords, (type(self), 0x099fb99, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantHeaderRecords__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderRecords__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantHeaderRecords, (type(self), 0x099fb99, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantHeaderRecords__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderRecords.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1441
 * 
 * 
 * cdef VariantHeaderRecords makeVariantHeaderRecords(VariantHeader header):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_f_5pysam_7libcbcf_makeVariantHeaderRecords(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v_records = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("makeVariantHeaderRecords", 0);
  __Pyx_TraceCall("makeVariantHeaderRecords", __pyx_f[0], 1441, 0, __PYX_ERR(0, 1441, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1442
 * 
 * cdef VariantHeaderRecords makeVariantHeaderRecords(VariantHeader header):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_header)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1442, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1443
 * cdef VariantHeaderRecords makeVariantHeaderRecords(VariantHeader header):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantHeaderRecords records = VariantHeaderRecords.__new__(VariantHeaderRecords)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1443, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1443, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1442
 * 
 * cdef VariantHeaderRecords makeVariantHeaderRecords(VariantHeader header):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1445
 *         raise ValueError('invalid VariantHeader')
 * 
 *     cdef VariantHeaderRecords records = VariantHeaderRecords.__new__(VariantHeaderRecords)             # <<<<<<<<<<<<<<
 *     records.header = header
 *     return records
 */
  __pyx_t_3 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantHeaderRecords(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderRecords), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1445, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_records = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":1446
 * 
 *     cdef VariantHeaderRecords records = VariantHeaderRecords.__new__(VariantHeaderRecords)
 *     records.header = header             # <<<<<<<<<<<<<<
 *     return records
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_header));
  __Pyx_GOTREF(__pyx_v_records->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_records->header));
  __pyx_v_records->header = __pyx_v_header;

  /* "pysam/libcbcf.pyx":1447
 *     cdef VariantHeaderRecords records = VariantHeaderRecords.__new__(VariantHeaderRecords)
 *     records.header = header
 *     return records             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_records));
  __pyx_r = __pyx_v_records;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1441
 * 
 * 
 * cdef VariantHeaderRecords makeVariantHeaderRecords(VariantHeader header):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantHeaderRecords", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_records);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1452
 * cdef class VariantMetadata(object):
 *     """filter, info or format metadata record from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_15VariantMetadata_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_15VariantMetadata_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_15VariantMetadata___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_15VariantMetadata___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 1452, 0, __PYX_ERR(0, 1452, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1453
 *     """filter, info or format metadata record from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 1453, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1452
 * cdef class VariantMetadata(object):
 *     """filter, info or format metadata record from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantMetadata.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1456
 * 
 *     @property
 *     def name(self):             # <<<<<<<<<<<<<<
 *         """metadata name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_4name_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_15VariantMetadata_4name___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_4name___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1456, 0, __PYX_ERR(0, 1456, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1458
 *     def name(self):
 *         """metadata name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         return bcf_str_cache_get_charptr(hdr.id[BCF_DT_ID][self.id].key)
 * 
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1459
 *         """metadata name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         return bcf_str_cache_get_charptr(hdr.id[BCF_DT_ID][self.id].key)             # <<<<<<<<<<<<<<
 * 
 *     # Q: Should this be exposed?
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(((__pyx_v_hdr->id[BCF_DT_ID])[__pyx_v_self->id]).key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1456
 * 
 *     @property
 *     def name(self):             # <<<<<<<<<<<<<<
 *         """metadata name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantMetadata.name.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1463
 *     # Q: Should this be exposed?
 *     @property
 *     def id(self):             # <<<<<<<<<<<<<<
 *         """metadata internal header id number"""
 *         return self.id
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_2id_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_2id_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_15VariantMetadata_2id___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_2id___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1463, 0, __PYX_ERR(0, 1463, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1465
 *     def id(self):
 *         """metadata internal header id number"""
 *         return self.id             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1465, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1463
 *     # Q: Should this be exposed?
 *     @property
 *     def id(self):             # <<<<<<<<<<<<<<
 *         """metadata internal header id number"""
 *         return self.id
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantMetadata.id.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1468
 * 
 *     @property
 *     def number(self):             # <<<<<<<<<<<<<<
 *         """metadata number (i.e. cardinality)"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_6number_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_6number_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_15VariantMetadata_6number___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_6number___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_l;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1468, 0, __PYX_ERR(0, 1468, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1470
 *     def number(self):
 *         """metadata number (i.e. cardinality)"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 * 
 *         if not check_header_id(hdr, self.type, self.id):
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1472
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 * 
 *         if not check_header_id(hdr, self.type, self.id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header id')
 * 
 */
  __pyx_t_2 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, __pyx_v_self->type, __pyx_v_self->id) != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1473
 * 
 *         if not check_header_id(hdr, self.type, self.id):
 *             raise ValueError('Invalid header id')             # <<<<<<<<<<<<<<
 * 
 *         if self.type == BCF_HL_FLT:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1473, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1473, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1472
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 * 
 *         if not check_header_id(hdr, self.type, self.id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header id')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1475
 *             raise ValueError('Invalid header id')
 * 
 *         if self.type == BCF_HL_FLT:             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  __pyx_t_2 = ((__pyx_v_self->type == BCF_HL_FLT) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1476
 * 
 *         if self.type == BCF_HL_FLT:
 *             return None             # <<<<<<<<<<<<<<
 * 
 *         cdef int l = bcf_hdr_id2length(hdr, self.type, self.id)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1475
 *             raise ValueError('Invalid header id')
 * 
 *         if self.type == BCF_HL_FLT:             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1478
 *             return None
 * 
 *         cdef int l = bcf_hdr_id2length(hdr, self.type, self.id)             # <<<<<<<<<<<<<<
 *         if l == BCF_VL_FIXED:
 *             return bcf_hdr_id2number(hdr, self.type, self.id)
 */
  __pyx_v_l = bcf_hdr_id2length(__pyx_v_hdr, __pyx_v_self->type, __pyx_v_self->id);

  /* "pysam/libcbcf.pyx":1479
 * 
 *         cdef int l = bcf_hdr_id2length(hdr, self.type, self.id)
 *         if l == BCF_VL_FIXED:             # <<<<<<<<<<<<<<
 *             return bcf_hdr_id2number(hdr, self.type, self.id)
 *         elif l == BCF_VL_VAR:
 */
  __pyx_t_2 = ((__pyx_v_l == BCF_VL_FIXED) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1480
 *         cdef int l = bcf_hdr_id2length(hdr, self.type, self.id)
 *         if l == BCF_VL_FIXED:
 *             return bcf_hdr_id2number(hdr, self.type, self.id)             # <<<<<<<<<<<<<<
 *         elif l == BCF_VL_VAR:
 *             return '.'
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyInt_From_int(bcf_hdr_id2number(__pyx_v_hdr, __pyx_v_self->type, __pyx_v_self->id)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1479
 * 
 *         cdef int l = bcf_hdr_id2length(hdr, self.type, self.id)
 *         if l == BCF_VL_FIXED:             # <<<<<<<<<<<<<<
 *             return bcf_hdr_id2number(hdr, self.type, self.id)
 *         elif l == BCF_VL_VAR:
 */
  }

  /* "pysam/libcbcf.pyx":1481
 *         if l == BCF_VL_FIXED:
 *             return bcf_hdr_id2number(hdr, self.type, self.id)
 *         elif l == BCF_VL_VAR:             # <<<<<<<<<<<<<<
 *             return '.'
 *         else:
 */
  __pyx_t_2 = ((__pyx_v_l == BCF_VL_VAR) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1482
 *             return bcf_hdr_id2number(hdr, self.type, self.id)
 *         elif l == BCF_VL_VAR:
 *             return '.'             # <<<<<<<<<<<<<<
 *         else:
 *             return METADATA_LENGTHS[l]
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_s__71);
    __pyx_r = __pyx_kp_s__71;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1481
 *         if l == BCF_VL_FIXED:
 *             return bcf_hdr_id2number(hdr, self.type, self.id)
 *         elif l == BCF_VL_VAR:             # <<<<<<<<<<<<<<
 *             return '.'
 *         else:
 */
  }

  /* "pysam/libcbcf.pyx":1484
 *             return '.'
 *         else:
 *             return METADATA_LENGTHS[l]             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_5pysam_7libcbcf_METADATA_LENGTHS == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1484, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_5pysam_7libcbcf_METADATA_LENGTHS, __pyx_v_l, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1484, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":1468
 * 
 *     @property
 *     def number(self):             # <<<<<<<<<<<<<<
 *         """metadata number (i.e. cardinality)"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantMetadata.number.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1487
 * 
 *     @property
 *     def type(self):             # <<<<<<<<<<<<<<
 *         """metadata value type"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_4type_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_4type_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_15VariantMetadata_4type___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_4type___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1487, 0, __PYX_ERR(0, 1487, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1489
 *     def type(self):
 *         """metadata value type"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         if not check_header_id(hdr, self.type, self.id):
 *             raise ValueError('Invalid header id')
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1490
 *         """metadata value type"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         if not check_header_id(hdr, self.type, self.id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header id')
 * 
 */
  __pyx_t_2 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, __pyx_v_self->type, __pyx_v_self->id) != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1491
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         if not check_header_id(hdr, self.type, self.id):
 *             raise ValueError('Invalid header id')             # <<<<<<<<<<<<<<
 * 
 *         if self.type == BCF_HL_FLT:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1491, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1491, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1490
 *         """metadata value type"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         if not check_header_id(hdr, self.type, self.id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header id')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1493
 *             raise ValueError('Invalid header id')
 * 
 *         if self.type == BCF_HL_FLT:             # <<<<<<<<<<<<<<
 *             return None
 *         return VALUE_TYPES[bcf_hdr_id2type(hdr, self.type, self.id)]
 */
  __pyx_t_2 = ((__pyx_v_self->type == BCF_HL_FLT) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1494
 * 
 *         if self.type == BCF_HL_FLT:
 *             return None             # <<<<<<<<<<<<<<
 *         return VALUE_TYPES[bcf_hdr_id2type(hdr, self.type, self.id)]
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1493
 *             raise ValueError('Invalid header id')
 * 
 *         if self.type == BCF_HL_FLT:             # <<<<<<<<<<<<<<
 *             return None
 *         return VALUE_TYPES[bcf_hdr_id2type(hdr, self.type, self.id)]
 */
  }

  /* "pysam/libcbcf.pyx":1495
 *         if self.type == BCF_HL_FLT:
 *             return None
 *         return VALUE_TYPES[bcf_hdr_id2type(hdr, self.type, self.id)]             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_5pysam_7libcbcf_VALUE_TYPES == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1495, __pyx_L1_error)
  }
  __pyx_t_4 = bcf_hdr_id2type(__pyx_v_hdr, __pyx_v_self->type, __pyx_v_self->id);
  __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_5pysam_7libcbcf_VALUE_TYPES, __pyx_t_4, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1495, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1487
 * 
 *     @property
 *     def type(self):             # <<<<<<<<<<<<<<
 *         """metadata value type"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantMetadata.type.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1498
 * 
 *     @property
 *     def description(self):             # <<<<<<<<<<<<<<
 *         """metadata description (or None if not set)"""
 *         descr = self.record.get('Description')
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_11description_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_11description_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_15VariantMetadata_11description___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_11description___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self) {
  PyObject *__pyx_v_descr = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1498, 0, __PYX_ERR(0, 1498, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1500
 *     def description(self):
 *         """metadata description (or None if not set)"""
 *         descr = self.record.get('Description')             # <<<<<<<<<<<<<<
 *         if descr:
 *             descr = descr.strip('"')
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_record); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get); 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_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_descr = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":1501
 *         """metadata description (or None if not set)"""
 *         descr = self.record.get('Description')
 *         if descr:             # <<<<<<<<<<<<<<
 *             descr = descr.strip('"')
 *         return force_str(descr)
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_descr); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1501, __pyx_L1_error)
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":1502
 *         descr = self.record.get('Description')
 *         if descr:
 *             descr = descr.strip('"')             # <<<<<<<<<<<<<<
 *         return force_str(descr)
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_descr, __pyx_n_s_strip); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1502, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__75, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1502, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_descr, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pysam/libcbcf.pyx":1501
 *         """metadata description (or None if not set)"""
 *         descr = self.record.get('Description')
 *         if descr:             # <<<<<<<<<<<<<<
 *             descr = descr.strip('"')
 *         return force_str(descr)
 */
  }

  /* "pysam/libcbcf.pyx":1503
 *         if descr:
 *             descr = descr.strip('"')
 *         return force_str(descr)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_f_5pysam_9libcutils_force_str(__pyx_v_descr, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1503, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1498
 * 
 *     @property
 *     def description(self):             # <<<<<<<<<<<<<<
 *         """metadata description (or None if not set)"""
 *         descr = self.record.get('Description')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantMetadata.description.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_descr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1506
 * 
 *     @property
 *     def record(self):             # <<<<<<<<<<<<<<
 *         """:class:`VariantHeaderRecord` associated with this :class:`VariantMetadata` object"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_6record_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_6record_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_15VariantMetadata_6record___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_6record___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf_hrec_t *__pyx_v_hrec;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1506, 0, __PYX_ERR(0, 1506, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1508
 *     def record(self):
 *         """:class:`VariantHeaderRecord` associated with this :class:`VariantMetadata` object"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         if not check_header_id(hdr, self.type, self.id):
 *             raise ValueError('Invalid header id')
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1509
 *         """:class:`VariantHeaderRecord` associated with this :class:`VariantMetadata` object"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         if not check_header_id(hdr, self.type, self.id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header id')
 *         cdef bcf_hrec_t *hrec = hdr.id[BCF_DT_ID][self.id].val.hrec[self.type]
 */
  __pyx_t_2 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, __pyx_v_self->type, __pyx_v_self->id) != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1510
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         if not check_header_id(hdr, self.type, self.id):
 *             raise ValueError('Invalid header id')             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *hrec = hdr.id[BCF_DT_ID][self.id].val.hrec[self.type]
 *         if not hrec:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1510, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1509
 *         """:class:`VariantHeaderRecord` associated with this :class:`VariantMetadata` object"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         if not check_header_id(hdr, self.type, self.id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header id')
 *         cdef bcf_hrec_t *hrec = hdr.id[BCF_DT_ID][self.id].val.hrec[self.type]
 */
  }

  /* "pysam/libcbcf.pyx":1511
 *         if not check_header_id(hdr, self.type, self.id):
 *             raise ValueError('Invalid header id')
 *         cdef bcf_hrec_t *hrec = hdr.id[BCF_DT_ID][self.id].val.hrec[self.type]             # <<<<<<<<<<<<<<
 *         if not hrec:
 *             return None
 */
  __pyx_v_hrec = (((__pyx_v_hdr->id[BCF_DT_ID])[__pyx_v_self->id]).val->hrec[__pyx_v_self->type]);

  /* "pysam/libcbcf.pyx":1512
 *             raise ValueError('Invalid header id')
 *         cdef bcf_hrec_t *hrec = hdr.id[BCF_DT_ID][self.id].val.hrec[self.type]
 *         if not hrec:             # <<<<<<<<<<<<<<
 *             return None
 *         return makeVariantHeaderRecord(self.header, hrec)
 */
  __pyx_t_2 = ((!(__pyx_v_hrec != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1513
 *         cdef bcf_hrec_t *hrec = hdr.id[BCF_DT_ID][self.id].val.hrec[self.type]
 *         if not hrec:
 *             return None             # <<<<<<<<<<<<<<
 *         return makeVariantHeaderRecord(self.header, hrec)
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1512
 *             raise ValueError('Invalid header id')
 *         cdef bcf_hrec_t *hrec = hdr.id[BCF_DT_ID][self.id].val.hrec[self.type]
 *         if not hrec:             # <<<<<<<<<<<<<<
 *             return None
 *         return makeVariantHeaderRecord(self.header, hrec)
 */
  }

  /* "pysam/libcbcf.pyx":1514
 *         if not hrec:
 *             return None
 *         return makeVariantHeaderRecord(self.header, hrec)             # <<<<<<<<<<<<<<
 * 
 *     def remove_header(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = ((PyObject *)__pyx_v_self->header);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeaderRecord(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_3), __pyx_v_hrec)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1514, __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;

  /* "pysam/libcbcf.pyx":1506
 * 
 *     @property
 *     def record(self):             # <<<<<<<<<<<<<<
 *         """:class:`VariantHeaderRecord` associated with this :class:`VariantMetadata` object"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantMetadata.record.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1516
 *         return makeVariantHeaderRecord(self.header, hrec)
 * 
 *     def remove_header(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef const char *key = hdr.id[BCF_DT_ID][self.id].key
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_3remove_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_15VariantMetadata_2remove_header[] = "VariantMetadata.remove_header(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_3remove_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_header (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_15VariantMetadata_2remove_header(((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_2remove_header(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  char const *__pyx_v_key;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  char const *__pyx_t_2;
  __Pyx_RefNannySetupContext("remove_header", 0);
  __Pyx_TraceCall("remove_header", __pyx_f[0], 1516, 0, __PYX_ERR(0, 1516, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1517
 * 
 *     def remove_header(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef const char *key = hdr.id[BCF_DT_ID][self.id].key
 *         bcf_hdr_remove(hdr, self.type, key)
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1518
 *     def remove_header(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef const char *key = hdr.id[BCF_DT_ID][self.id].key             # <<<<<<<<<<<<<<
 *         bcf_hdr_remove(hdr, self.type, key)
 * 
 */
  __pyx_t_2 = ((__pyx_v_hdr->id[BCF_DT_ID])[__pyx_v_self->id]).key;
  __pyx_v_key = __pyx_t_2;

  /* "pysam/libcbcf.pyx":1519
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef const char *key = hdr.id[BCF_DT_ID][self.id].key
 *         bcf_hdr_remove(hdr, self.type, key)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  bcf_hdr_remove(__pyx_v_hdr, __pyx_v_self->type, __pyx_v_key);

  /* "pysam/libcbcf.pyx":1516
 *         return makeVariantHeaderRecord(self.header, hrec)
 * 
 *     def remove_header(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef const char *key = hdr.id[BCF_DT_ID][self.id].key
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantMetadata.remove_header", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":67
 * 
 * cdef class VariantMetadata(object):
 *     cdef readonly VariantHeader header             # <<<<<<<<<<<<<<
 *     cdef int type
 *     cdef int id
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_6header_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_6header_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_15VariantMetadata_6header___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 67, 0, __PYX_ERR(1, 67, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __pyx_r = ((PyObject *)__pyx_v_self->header);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantMetadata.header.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.header, self.id, self.type)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_15VariantMetadata_4__reduce_cython__[] = "VariantMetadata.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_15VariantMetadata_4__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_4__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.header, self.id, self.type)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->id); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->type); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->header));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->header));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.header, self.id, self.type)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__dict = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":5
 *     state = (self.header, self.id, self.type)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_4 = (__pyx_v__dict != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.header is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.header, self.id, self.type)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.header is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_VariantMetadata, (type(self), 0x9d0a56c, None), state
 */
  /*else*/ {
    __pyx_t_5 = (((PyObject *)__pyx_v_self->header) != Py_None);
    __pyx_v_use_setstate = __pyx_t_5;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.header is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantMetadata, (type(self), 0x9d0a56c, None), state
 *     else:
 */
  __pyx_t_5 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":11
 *         use_setstate = self.header is not None
 *     if use_setstate:
 *         return __pyx_unpickle_VariantMetadata, (type(self), 0x9d0a56c, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_VariantMetadata, (type(self), 0x9d0a56c, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantMetadata); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_164668780);
    __Pyx_GIVEREF(__pyx_int_164668780);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_164668780);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.header is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantMetadata, (type(self), 0x9d0a56c, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_VariantMetadata, (type(self), 0x9d0a56c, None), state
 *     else:
 *         return __pyx_unpickle_VariantMetadata, (type(self), 0x9d0a56c, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantMetadata__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantMetadata); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_164668780);
    __Pyx_GIVEREF(__pyx_int_164668780);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_164668780);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.header, self.id, self.type)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantMetadata.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantMetadata, (type(self), 0x9d0a56c, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantMetadata__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_15VariantMetadata_6__setstate_cython__[] = "VariantMetadata.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_15VariantMetadata_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_15VariantMetadata_6__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_15VariantMetadata_6__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 14, 0, __PYX_ERR(2, 14, __pyx_L1_error));

  /* "(tree fragment)":15
 *         return __pyx_unpickle_VariantMetadata, (type(self), 0x9d0a56c, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantMetadata__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantMetadata__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantMetadata, (type(self), 0x9d0a56c, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantMetadata__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantMetadata.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1522
 * 
 * 
 * cdef VariantMetadata makeVariantMetadata(VariantHeader header, int type, int id):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_f_5pysam_7libcbcf_makeVariantMetadata(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header, int __pyx_v_type, int __pyx_v_id) {
  struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v_meta = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("makeVariantMetadata", 0);
  __Pyx_TraceCall("makeVariantMetadata", __pyx_f[0], 1522, 0, __PYX_ERR(0, 1522, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1523
 * 
 * cdef VariantMetadata makeVariantMetadata(VariantHeader header, int type, int id):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_header)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1523, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1524
 * cdef VariantMetadata makeVariantMetadata(VariantHeader header, int type, int id):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     if type != BCF_HL_FLT and type != BCF_HL_INFO and type != BCF_HL_FMT:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1524, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1524, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1523
 * 
 * cdef VariantMetadata makeVariantMetadata(VariantHeader header, int type, int id):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1526
 *         raise ValueError('invalid VariantHeader')
 * 
 *     if type != BCF_HL_FLT and type != BCF_HL_INFO and type != BCF_HL_FMT:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid metadata type')
 * 
 */
  __pyx_t_1 = ((__pyx_v_type != BCF_HL_FLT) != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_type != BCF_HL_INFO) != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_type != BCF_HL_FMT) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1527
 * 
 *     if type != BCF_HL_FLT and type != BCF_HL_INFO and type != BCF_HL_FMT:
 *         raise ValueError('invalid metadata type')             # <<<<<<<<<<<<<<
 * 
 *     if id < 0 or id >= header.ptr.n[BCF_DT_ID]:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1527, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1527, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1526
 *         raise ValueError('invalid VariantHeader')
 * 
 *     if type != BCF_HL_FLT and type != BCF_HL_INFO and type != BCF_HL_FMT:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid metadata type')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1529
 *         raise ValueError('invalid metadata type')
 * 
 *     if id < 0 or id >= header.ptr.n[BCF_DT_ID]:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid metadata id')
 * 
 */
  __pyx_t_1 = ((__pyx_v_id < 0) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_id >= (__pyx_v_header->ptr->n[BCF_DT_ID])) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L9_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1530
 * 
 *     if id < 0 or id >= header.ptr.n[BCF_DT_ID]:
 *         raise ValueError('invalid metadata id')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantMetadata meta = VariantMetadata.__new__(VariantMetadata)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1530, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1530, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1529
 *         raise ValueError('invalid metadata type')
 * 
 *     if id < 0 or id >= header.ptr.n[BCF_DT_ID]:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid metadata id')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1532
 *         raise ValueError('invalid metadata id')
 * 
 *     cdef VariantMetadata meta = VariantMetadata.__new__(VariantMetadata)             # <<<<<<<<<<<<<<
 *     meta.header = header
 *     meta.type = type
 */
  __pyx_t_3 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantMetadata(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantMetadata), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1532, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_meta = ((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":1533
 * 
 *     cdef VariantMetadata meta = VariantMetadata.__new__(VariantMetadata)
 *     meta.header = header             # <<<<<<<<<<<<<<
 *     meta.type = type
 *     meta.id = id
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_header));
  __Pyx_GOTREF(__pyx_v_meta->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_meta->header));
  __pyx_v_meta->header = __pyx_v_header;

  /* "pysam/libcbcf.pyx":1534
 *     cdef VariantMetadata meta = VariantMetadata.__new__(VariantMetadata)
 *     meta.header = header
 *     meta.type = type             # <<<<<<<<<<<<<<
 *     meta.id = id
 * 
 */
  __pyx_v_meta->type = __pyx_v_type;

  /* "pysam/libcbcf.pyx":1535
 *     meta.header = header
 *     meta.type = type
 *     meta.id = id             # <<<<<<<<<<<<<<
 * 
 *     return meta
 */
  __pyx_v_meta->id = __pyx_v_id;

  /* "pysam/libcbcf.pyx":1537
 *     meta.id = id
 * 
 *     return meta             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_meta));
  __pyx_r = __pyx_v_meta;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1522
 * 
 * 
 * cdef VariantMetadata makeVariantMetadata(VariantHeader header, int type, int id):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantMetadata", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_meta);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1542
 * cdef class VariantHeaderMetadata(object):
 *     """mapping from filter, info or format name to :class:`VariantMetadata` object"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 1542, 0, __PYX_ERR(0, 1542, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1543
 *     """mapping from filter, info or format name to :class:`VariantMetadata` object"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def add(self, id, number, type, description, **kwargs):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 1543, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1542
 * cdef class VariantHeaderMetadata(object):
 *     """mapping from filter, info or format name to :class:`VariantMetadata` object"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1545
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def add(self, id, number, type, description, **kwargs):             # <<<<<<<<<<<<<<
 *         """Add a new filter, info or format record"""
 *         if id in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_3add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_2add[] = "VariantHeaderMetadata.add(self, id, number, type, description, **kwargs)\nAdd a new filter, info or format record";
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_3add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_id = 0;
  PyObject *__pyx_v_number = 0;
  PyObject *__pyx_v_type = 0;
  PyObject *__pyx_v_description = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (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_id,&__pyx_n_s_number,&__pyx_n_s_type,&__pyx_n_s_description,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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_id)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_number)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 4, 4, 1); __PYX_ERR(0, 1545, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 4, 4, 2); __PYX_ERR(0, 1545, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_description)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 4, 4, 3); __PYX_ERR(0, 1545, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "add") < 0)) __PYX_ERR(0, 1545, __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_id = values[0];
    __pyx_v_number = values[1];
    __pyx_v_type = values[2];
    __pyx_v_description = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1545, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_2add(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self), __pyx_v_id, __pyx_v_number, __pyx_v_type, __pyx_v_description, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_2add(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, PyObject *__pyx_v_id, PyObject *__pyx_v_number, PyObject *__pyx_v_type, PyObject *__pyx_v_description, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_items = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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("add", 0);
  __Pyx_TraceCall("add", __pyx_f[0], 1545, 0, __PYX_ERR(0, 1545, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_number);

  /* "pysam/libcbcf.pyx":1547
 *     def add(self, id, number, type, description, **kwargs):
 *         """Add a new filter, info or format record"""
 *         if id in self:             # <<<<<<<<<<<<<<
 *             raise ValueError('Header already exists for id={}'.format(id))
 * 
 */
  __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_id, ((PyObject *)__pyx_v_self), Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1547, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1548
 *         """Add a new filter, info or format record"""
 *         if id in self:
 *             raise ValueError('Header already exists for id={}'.format(id))             # <<<<<<<<<<<<<<
 * 
 *         if self.type == BCF_HL_FLT:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Header_already_exists_for_id, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1548, __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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1548, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_id};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1548, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_id};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1548, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1548, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_INCREF(__pyx_v_id);
        __Pyx_GIVEREF(__pyx_v_id);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_id);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1548, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 1548, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1547
 *     def add(self, id, number, type, description, **kwargs):
 *         """Add a new filter, info or format record"""
 *         if id in self:             # <<<<<<<<<<<<<<
 *             raise ValueError('Header already exists for id={}'.format(id))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1550
 *             raise ValueError('Header already exists for id={}'.format(id))
 * 
 *         if self.type == BCF_HL_FLT:             # <<<<<<<<<<<<<<
 *             if number is not None:
 *                 raise ValueError('Number must be None when adding a filter')
 */
  __pyx_t_2 = ((__pyx_v_self->type == BCF_HL_FLT) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":1551
 * 
 *         if self.type == BCF_HL_FLT:
 *             if number is not None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Number must be None when adding a filter')
 *             if type is not None:
 */
    __pyx_t_2 = (__pyx_v_number != Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":1552
 *         if self.type == BCF_HL_FLT:
 *             if number is not None:
 *                 raise ValueError('Number must be None when adding a filter')             # <<<<<<<<<<<<<<
 *             if type is not None:
 *                 raise ValueError('Type must be None when adding a filter')
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1552, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 1552, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":1551
 * 
 *         if self.type == BCF_HL_FLT:
 *             if number is not None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Number must be None when adding a filter')
 *             if type is not None:
 */
    }

    /* "pysam/libcbcf.pyx":1553
 *             if number is not None:
 *                 raise ValueError('Number must be None when adding a filter')
 *             if type is not None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Type must be None when adding a filter')
 * 
 */
    __pyx_t_1 = (__pyx_v_type != Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (unlikely(__pyx_t_2)) {

      /* "pysam/libcbcf.pyx":1554
 *                 raise ValueError('Number must be None when adding a filter')
 *             if type is not None:
 *                 raise ValueError('Type must be None when adding a filter')             # <<<<<<<<<<<<<<
 * 
 *             items = [('ID', id), ('Description', description)]
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1554, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 1554, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":1553
 *             if number is not None:
 *                 raise ValueError('Number must be None when adding a filter')
 *             if type is not None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Type must be None when adding a filter')
 * 
 */
    }

    /* "pysam/libcbcf.pyx":1556
 *                 raise ValueError('Type must be None when adding a filter')
 * 
 *             items = [('ID', id), ('Description', description)]             # <<<<<<<<<<<<<<
 *         else:
 *             if type not in VALUE_TYPES:
 */
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_n_s_ID);
    __Pyx_GIVEREF(__pyx_n_s_ID);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_ID);
    __Pyx_INCREF(__pyx_v_id);
    __Pyx_GIVEREF(__pyx_v_id);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_id);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_n_s_Description);
    __Pyx_GIVEREF(__pyx_n_s_Description);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_Description);
    __Pyx_INCREF(__pyx_v_description);
    __Pyx_GIVEREF(__pyx_v_description);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_description);
    __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyList_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
    __pyx_t_4 = 0;
    __pyx_t_3 = 0;
    __pyx_v_items = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "pysam/libcbcf.pyx":1550
 *             raise ValueError('Header already exists for id={}'.format(id))
 * 
 *         if self.type == BCF_HL_FLT:             # <<<<<<<<<<<<<<
 *             if number is not None:
 *                 raise ValueError('Number must be None when adding a filter')
 */
    goto __pyx_L4;
  }

  /* "pysam/libcbcf.pyx":1558
 *             items = [('ID', id), ('Description', description)]
 *         else:
 *             if type not in VALUE_TYPES:             # <<<<<<<<<<<<<<
 *                 raise ValueError('unknown type specified: {}'.format(type))
 *             if number is None:
 */
  /*else*/ {
    __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_type, __pyx_v_5pysam_7libcbcf_VALUE_TYPES, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1558, __pyx_L1_error)
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":1559
 *         else:
 *             if type not in VALUE_TYPES:
 *                 raise ValueError('unknown type specified: {}'.format(type))             # <<<<<<<<<<<<<<
 *             if number is None:
 *                 number = '.'
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_unknown_type_specified, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1559, __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_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1559, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_type};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1559, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_type};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1559, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1559, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
          __Pyx_INCREF(__pyx_v_type);
          __Pyx_GIVEREF(__pyx_v_type);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_type);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1559, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1559, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 1559, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":1558
 *             items = [('ID', id), ('Description', description)]
 *         else:
 *             if type not in VALUE_TYPES:             # <<<<<<<<<<<<<<
 *                 raise ValueError('unknown type specified: {}'.format(type))
 *             if number is None:
 */
    }

    /* "pysam/libcbcf.pyx":1560
 *             if type not in VALUE_TYPES:
 *                 raise ValueError('unknown type specified: {}'.format(type))
 *             if number is None:             # <<<<<<<<<<<<<<
 *                 number = '.'
 * 
 */
    __pyx_t_1 = (__pyx_v_number == Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":1561
 *                 raise ValueError('unknown type specified: {}'.format(type))
 *             if number is None:
 *                 number = '.'             # <<<<<<<<<<<<<<
 * 
 *             items = [('ID', id),
 */
      __Pyx_INCREF(__pyx_kp_s__71);
      __Pyx_DECREF_SET(__pyx_v_number, __pyx_kp_s__71);

      /* "pysam/libcbcf.pyx":1560
 *             if type not in VALUE_TYPES:
 *                 raise ValueError('unknown type specified: {}'.format(type))
 *             if number is None:             # <<<<<<<<<<<<<<
 *                 number = '.'
 * 
 */
    }

    /* "pysam/libcbcf.pyx":1563
 *                 number = '.'
 * 
 *             items = [('ID', id),             # <<<<<<<<<<<<<<
 *                      ('Number', number),
 *                      ('Type', type),
 */
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_n_s_ID);
    __Pyx_GIVEREF(__pyx_n_s_ID);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_ID);
    __Pyx_INCREF(__pyx_v_id);
    __Pyx_GIVEREF(__pyx_v_id);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_id);

    /* "pysam/libcbcf.pyx":1564
 * 
 *             items = [('ID', id),
 *                      ('Number', number),             # <<<<<<<<<<<<<<
 *                      ('Type', type),
 *                      ('Description', description)]
 */
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_n_s_Number);
    __Pyx_GIVEREF(__pyx_n_s_Number);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_n_s_Number);
    __Pyx_INCREF(__pyx_v_number);
    __Pyx_GIVEREF(__pyx_v_number);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_number);

    /* "pysam/libcbcf.pyx":1565
 *             items = [('ID', id),
 *                      ('Number', number),
 *                      ('Type', type),             # <<<<<<<<<<<<<<
 *                      ('Description', description)]
 * 
 */
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_n_s_Type);
    __Pyx_GIVEREF(__pyx_n_s_Type);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_Type);
    __Pyx_INCREF(__pyx_v_type);
    __Pyx_GIVEREF(__pyx_v_type);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_type);

    /* "pysam/libcbcf.pyx":1566
 *                      ('Number', number),
 *                      ('Type', type),
 *                      ('Description', description)]             # <<<<<<<<<<<<<<
 * 
 *         items += kwargs.items()
 */
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1566, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_n_s_Description);
    __Pyx_GIVEREF(__pyx_n_s_Description);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_Description);
    __Pyx_INCREF(__pyx_v_description);
    __Pyx_GIVEREF(__pyx_v_description);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_description);

    /* "pysam/libcbcf.pyx":1563
 *                 number = '.'
 * 
 *             items = [('ID', id),             # <<<<<<<<<<<<<<
 *                      ('Number', number),
 *                      ('Type', type),
 */
    __pyx_t_7 = PyList_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_3);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_6);
    PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyList_SET_ITEM(__pyx_t_7, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyList_SET_ITEM(__pyx_t_7, 3, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_6 = 0;
    __pyx_t_5 = 0;
    __pyx_t_4 = 0;
    __pyx_v_items = __pyx_t_7;
    __pyx_t_7 = 0;
  }
  __pyx_L4:;

  /* "pysam/libcbcf.pyx":1568
 *                      ('Description', description)]
 * 
 *         items += kwargs.items()             # <<<<<<<<<<<<<<
 *         self.header.add_meta(METADATA_TYPES[self.type], items=items)
 * 
 */
  __pyx_t_7 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_items, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":1569
 * 
 *         items += kwargs.items()
 *         self.header.add_meta(METADATA_TYPES[self.type], items=items)             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->header), __pyx_n_s_add_meta); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (unlikely(__pyx_v_5pysam_7libcbcf_METADATA_TYPES == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1569, __pyx_L1_error)
  }
  __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v_5pysam_7libcbcf_METADATA_TYPES, __pyx_v_self->type, int32_t, 1, __Pyx_PyInt_From_int32_t, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_items, __pyx_v_items) < 0) __PYX_ERR(0, 1569, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1569, __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_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "pysam/libcbcf.pyx":1545
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def add(self, id, number, type, description, **kwargs):             # <<<<<<<<<<<<<<
 *         """Add a new filter, info or format record"""
 *         if id in self:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_number);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1571
 *         self.header.add_meta(METADATA_TYPES[self.type], items=items)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_idpair_t *idpair
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_5__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_5__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_4__len__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_4__len__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf_idpair_t *__pyx_v_idpair;
  int32_t __pyx_v_i;
  int32_t __pyx_v_n;
  Py_ssize_t __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  int32_t __pyx_t_2;
  int32_t __pyx_t_3;
  int32_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__len__", 0);
  __Pyx_TraceCall("__len__", __pyx_f[0], 1571, 0, __PYX_ERR(0, 1571, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1572
 * 
 *     def __len__(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_idpair_t *idpair
 *         cdef int32_t i, n = 0
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1574
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_idpair_t *idpair
 *         cdef int32_t i, n = 0             # <<<<<<<<<<<<<<
 * 
 *         for i in range(hdr.n[BCF_DT_ID]):
 */
  __pyx_v_n = 0;

  /* "pysam/libcbcf.pyx":1576
 *         cdef int32_t i, n = 0
 * 
 *         for i in range(hdr.n[BCF_DT_ID]):             # <<<<<<<<<<<<<<
 *             idpair = hdr.id[BCF_DT_ID] + i
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:
 */
  __pyx_t_2 = (__pyx_v_hdr->n[BCF_DT_ID]);
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "pysam/libcbcf.pyx":1577
 * 
 *         for i in range(hdr.n[BCF_DT_ID]):
 *             idpair = hdr.id[BCF_DT_ID] + i             # <<<<<<<<<<<<<<
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:
 *                 n += 1
 */
    __pyx_v_idpair = ((__pyx_v_hdr->id[BCF_DT_ID]) + __pyx_v_i);

    /* "pysam/libcbcf.pyx":1578
 *         for i in range(hdr.n[BCF_DT_ID]):
 *             idpair = hdr.id[BCF_DT_ID] + i
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:             # <<<<<<<<<<<<<<
 *                 n += 1
 *         return n
 */
    __pyx_t_6 = (__pyx_v_idpair->key != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_idpair->val != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_6 = ((((__pyx_v_idpair->val->info[__pyx_v_self->type]) & 0xF) != 0xF) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_5) {

      /* "pysam/libcbcf.pyx":1579
 *             idpair = hdr.id[BCF_DT_ID] + i
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:
 *                 n += 1             # <<<<<<<<<<<<<<
 *         return n
 * 
 */
      __pyx_v_n = (__pyx_v_n + 1);

      /* "pysam/libcbcf.pyx":1578
 *         for i in range(hdr.n[BCF_DT_ID]):
 *             idpair = hdr.id[BCF_DT_ID] + i
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:             # <<<<<<<<<<<<<<
 *                 n += 1
 *         return n
 */
    }
  }

  /* "pysam/libcbcf.pyx":1580
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:
 *                 n += 1
 *         return n             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
  __pyx_r = __pyx_v_n;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1571
 *         self.header.add_meta(METADATA_TYPES[self.type], items=items)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_idpair_t *idpair
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1582
 *         return n
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_idpair_t *idpair
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_7__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_7__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_6__bool__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_6__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf_idpair_t *__pyx_v_idpair;
  int32_t __pyx_v_i;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  int32_t __pyx_t_2;
  int32_t __pyx_t_3;
  int32_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__bool__", 0);
  __Pyx_TraceCall("__bool__", __pyx_f[0], 1582, 0, __PYX_ERR(0, 1582, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1583
 * 
 *     def __bool__(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_idpair_t *idpair
 *         cdef int32_t i
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1587
 *         cdef int32_t i
 * 
 *         for i in range(hdr.n[BCF_DT_ID]):             # <<<<<<<<<<<<<<
 *             idpair = hdr.id[BCF_DT_ID] + i
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:
 */
  __pyx_t_2 = (__pyx_v_hdr->n[BCF_DT_ID]);
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "pysam/libcbcf.pyx":1588
 * 
 *         for i in range(hdr.n[BCF_DT_ID]):
 *             idpair = hdr.id[BCF_DT_ID] + i             # <<<<<<<<<<<<<<
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:
 *                 return True
 */
    __pyx_v_idpair = ((__pyx_v_hdr->id[BCF_DT_ID]) + __pyx_v_i);

    /* "pysam/libcbcf.pyx":1589
 *         for i in range(hdr.n[BCF_DT_ID]):
 *             idpair = hdr.id[BCF_DT_ID] + i
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:             # <<<<<<<<<<<<<<
 *                 return True
 *         return False
 */
    __pyx_t_6 = (__pyx_v_idpair->key != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_idpair->val != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_6 = ((((__pyx_v_idpair->val->info[__pyx_v_self->type]) & 0xF) != 0xF) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_5) {

      /* "pysam/libcbcf.pyx":1590
 *             idpair = hdr.id[BCF_DT_ID] + i
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:
 *                 return True             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
      __pyx_r = 1;
      goto __pyx_L0;

      /* "pysam/libcbcf.pyx":1589
 *         for i in range(hdr.n[BCF_DT_ID]):
 *             idpair = hdr.id[BCF_DT_ID] + i
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:             # <<<<<<<<<<<<<<
 *                 return True
 *         return False
 */
    }
  }

  /* "pysam/libcbcf.pyx":1591
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:
 *                 return True
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1582
 *         return n
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_idpair_t *idpair
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1593
 *         return False
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_ID]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_9__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_9__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_8__getitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_8__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  vdict_t *__pyx_v_d;
  PyObject *__pyx_v_bkey = 0;
  khiter_t __pyx_v_k;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  char const *__pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_TraceCall("__getitem__", __pyx_f[0], 1593, 0, __PYX_ERR(0, 1593, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1594
 * 
 *     def __getitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_ID]
 * 
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1595
 *     def __getitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_ID]             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_v_d = ((vdict_t *)(__pyx_v_hdr->dict[BCF_DT_ID]));

  /* "pysam/libcbcf.pyx":1597
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_ID]
 * 
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 * 
 */
  __pyx_t_2 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_bkey = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":1598
 * 
 *         cdef bytes bkey = force_bytes(key)
 *         cdef khiter_t k = kh_get_vdict(d, bkey)             # <<<<<<<<<<<<<<
 * 
 *         if k == kh_end(d) or kh_val_vdict(d, k).info[self.type] & 0xF == 0xF:
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 1598, __pyx_L1_error)
  }
  __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 1598, __pyx_L1_error)
  __pyx_v_k = kh_get_vdict(__pyx_v_d, __pyx_t_3);

  /* "pysam/libcbcf.pyx":1600
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 * 
 *         if k == kh_end(d) or kh_val_vdict(d, k).info[self.type] & 0xF == 0xF:             # <<<<<<<<<<<<<<
 *             raise KeyError('invalid key: {}'.format(key))
 * 
 */
  __pyx_t_5 = ((__pyx_v_k == kh_end(__pyx_v_d)) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = ((((kh_val(__pyx_v_d, __pyx_v_k).info[__pyx_v_self->type]) & 0xF) == 0xF) != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_4)) {

    /* "pysam/libcbcf.pyx":1601
 * 
 *         if k == kh_end(d) or kh_val_vdict(d, k).info[self.type] & 0xF == 0xF:
 *             raise KeyError('invalid key: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         return makeVariantMetadata(self.header, self.type, kh_val_vdict(d, k).id)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_invalid_key, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1601, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_key};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1601, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_key};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1601, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1601, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_key);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1601, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(0, 1601, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1600
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 * 
 *         if k == kh_end(d) or kh_val_vdict(d, k).info[self.type] & 0xF == 0xF:             # <<<<<<<<<<<<<<
 *             raise KeyError('invalid key: {}'.format(key))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1603
 *             raise KeyError('invalid key: {}'.format(key))
 * 
 *         return makeVariantMetadata(self.header, self.type, kh_val_vdict(d, k).id)             # <<<<<<<<<<<<<<
 * 
 *     def remove_header(self, key):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = ((PyObject *)__pyx_v_self->header);
  __Pyx_INCREF(__pyx_t_6);
  __pyx_t_2 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantMetadata(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_6), __pyx_v_self->type, kh_val(__pyx_v_d, __pyx_v_k).id)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1593
 *         return False
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_ID]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1605
 *         return makeVariantMetadata(self.header, self.type, kh_val_vdict(d, k).id)
 * 
 *     def remove_header(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_ID]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_11remove_header(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_10remove_header[] = "VariantHeaderMetadata.remove_header(self, key)";
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_11remove_header(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_header (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_10remove_header(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_10remove_header(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  vdict_t *__pyx_v_d;
  PyObject *__pyx_v_bkey = 0;
  khiter_t __pyx_v_k;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  char const *__pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  char const *__pyx_t_9;
  __Pyx_RefNannySetupContext("remove_header", 0);
  __Pyx_TraceCall("remove_header", __pyx_f[0], 1605, 0, __PYX_ERR(0, 1605, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1606
 * 
 *     def remove_header(self, key):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_ID]
 * 
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1607
 *     def remove_header(self, key):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_ID]             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_v_d = ((vdict_t *)(__pyx_v_hdr->dict[BCF_DT_ID]));

  /* "pysam/libcbcf.pyx":1609
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_ID]
 * 
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 * 
 */
  __pyx_t_2 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1609, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_bkey = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":1610
 * 
 *         cdef bytes bkey = force_bytes(key)
 *         cdef khiter_t k = kh_get_vdict(d, bkey)             # <<<<<<<<<<<<<<
 * 
 *         if k == kh_end(d) or kh_val_vdict(d, k).info[self.type] & 0xF == 0xF:
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 1610, __pyx_L1_error)
  }
  __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 1610, __pyx_L1_error)
  __pyx_v_k = kh_get_vdict(__pyx_v_d, __pyx_t_3);

  /* "pysam/libcbcf.pyx":1612
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 * 
 *         if k == kh_end(d) or kh_val_vdict(d, k).info[self.type] & 0xF == 0xF:             # <<<<<<<<<<<<<<
 *             raise KeyError('invalid key: {}'.format(key))
 * 
 */
  __pyx_t_5 = ((__pyx_v_k == kh_end(__pyx_v_d)) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = ((((kh_val(__pyx_v_d, __pyx_v_k).info[__pyx_v_self->type]) & 0xF) == 0xF) != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_4)) {

    /* "pysam/libcbcf.pyx":1613
 * 
 *         if k == kh_end(d) or kh_val_vdict(d, k).info[self.type] & 0xF == 0xF:
 *             raise KeyError('invalid key: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         bcf_hdr_remove(hdr, self.type, bkey)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_invalid_key, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1613, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1613, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_key};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1613, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_key};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1613, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1613, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_key);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1613, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1613, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(0, 1613, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1612
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 * 
 *         if k == kh_end(d) or kh_val_vdict(d, k).info[self.type] & 0xF == 0xF:             # <<<<<<<<<<<<<<
 *             raise KeyError('invalid key: {}'.format(key))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1615
 *             raise KeyError('invalid key: {}'.format(key))
 * 
 *         bcf_hdr_remove(hdr, self.type, bkey)             # <<<<<<<<<<<<<<
 *         #bcf_hdr_sync(hdr)
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 1615, __pyx_L1_error)
  }
  __pyx_t_9 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_9) && PyErr_Occurred())) __PYX_ERR(0, 1615, __pyx_L1_error)
  bcf_hdr_remove(__pyx_v_hdr, __pyx_v_self->type, __pyx_t_9);

  /* "pysam/libcbcf.pyx":1605
 *         return makeVariantMetadata(self.header, self.type, kh_val_vdict(d, k).id)
 * 
 *     def remove_header(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_ID]
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.remove_header", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1618
 *         #bcf_hdr_sync(hdr)
 * 
 *     def clear_header(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         bcf_hdr_remove(hdr, self.type, NULL)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_13clear_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_12clear_header[] = "VariantHeaderMetadata.clear_header(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_13clear_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear_header (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_12clear_header(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_12clear_header(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  __Pyx_RefNannySetupContext("clear_header", 0);
  __Pyx_TraceCall("clear_header", __pyx_f[0], 1618, 0, __PYX_ERR(0, 1618, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1619
 * 
 *     def clear_header(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         bcf_hdr_remove(hdr, self.type, NULL)
 *         #bcf_hdr_sync(hdr)
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1620
 *     def clear_header(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         bcf_hdr_remove(hdr, self.type, NULL)             # <<<<<<<<<<<<<<
 *         #bcf_hdr_sync(hdr)
 * 
 */
  bcf_hdr_remove(__pyx_v_hdr, __pyx_v_self->type, NULL);

  /* "pysam/libcbcf.pyx":1618
 *         #bcf_hdr_sync(hdr)
 * 
 *     def clear_header(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         bcf_hdr_remove(hdr, self.type, NULL)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.clear_header", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_21VariantHeaderMetadata_16generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":1623
 *         #bcf_hdr_sync(hdr)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_idpair_t *idpair
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_15__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_15__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_14__iter__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_14__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__ *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__ *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_14___iter__(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_14___iter__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1623, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_21VariantHeaderMetadata_16generator4, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_VariantHeaderMetadata___iter, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 1623, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.__iter__", __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_5pysam_7libcbcf_21VariantHeaderMetadata_16generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__ *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hdr_t *__pyx_t_1;
  int32_t __pyx_t_2;
  int32_t __pyx_t_3;
  int32_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 1623, 0, __PYX_ERR(0, 1623, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L10_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1623, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1624
 * 
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_idpair_t *idpair
 *         cdef int32_t i
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->header->ptr;
  __pyx_cur_scope->__pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1628
 *         cdef int32_t i
 * 
 *         for i in range(hdr.n[BCF_DT_ID]):             # <<<<<<<<<<<<<<
 *             idpair = hdr.id[BCF_DT_ID] + i
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:
 */
  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_hdr->n[BCF_DT_ID]);
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_4;

    /* "pysam/libcbcf.pyx":1629
 * 
 *         for i in range(hdr.n[BCF_DT_ID]):
 *             idpair = hdr.id[BCF_DT_ID] + i             # <<<<<<<<<<<<<<
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:
 *                 yield bcf_str_cache_get_charptr(idpair.key)
 */
    __pyx_cur_scope->__pyx_v_idpair = ((__pyx_cur_scope->__pyx_v_hdr->id[BCF_DT_ID]) + __pyx_cur_scope->__pyx_v_i);

    /* "pysam/libcbcf.pyx":1630
 *         for i in range(hdr.n[BCF_DT_ID]):
 *             idpair = hdr.id[BCF_DT_ID] + i
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:             # <<<<<<<<<<<<<<
 *                 yield bcf_str_cache_get_charptr(idpair.key)
 * 
 */
    __pyx_t_6 = (__pyx_cur_scope->__pyx_v_idpair->key != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_cur_scope->__pyx_v_idpair->val != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_6 = ((((__pyx_cur_scope->__pyx_v_idpair->val->info[__pyx_cur_scope->__pyx_v_self->type]) & 0xF) != 0xF) != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_5) {

      /* "pysam/libcbcf.pyx":1631
 *             idpair = hdr.id[BCF_DT_ID] + i
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:
 *                 yield bcf_str_cache_get_charptr(idpair.key)             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
      __pyx_t_7 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(__pyx_cur_scope->__pyx_v_idpair->key); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1631, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_r = __pyx_t_7;
      __pyx_t_7 = 0;
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_4;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_TraceReturn(__pyx_r, 0);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L10_resume_from_yield:;
      __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
      __pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_4 = __pyx_cur_scope->__pyx_t_2;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1631, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":1630
 *         for i in range(hdr.n[BCF_DT_ID]):
 *             idpair = hdr.id[BCF_DT_ID] + i
 *             if idpair.key and idpair.val and idpair.val.info[self.type] & 0xF != 0xF:             # <<<<<<<<<<<<<<
 *                 yield bcf_str_cache_get_charptr(idpair.key)
 * 
 */
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":1623
 *         #bcf_hdr_sync(hdr)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_idpair_t *idpair
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1633
 *                 yield bcf_str_cache_get_charptr(idpair.key)
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_18get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_17get[] = "VariantHeaderMetadata.get(self, key, default=None)\nD.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.";
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_18get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 1633, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1633, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_17get(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_17get(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("get", 0);
  __Pyx_TraceCall("get", __pyx_f[0], 1633, 0, __PYX_ERR(0, 1633, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1635
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":1636
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 *             return self[key]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return default
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1636, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "pysam/libcbcf.pyx":1635
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":1637
 *         try:
 *             return self[key]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 1637, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":1638
 *             return self[key]
 *         except KeyError:
 *             return default             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_default);
      __pyx_r = __pyx_v_default;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":1635
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":1633
 *                 yield bcf_str_cache_get_charptr(idpair.key)
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1640
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         try:
 *             self[key]
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_20__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_20__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_19__contains__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_19__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("__contains__", 0);
  __Pyx_TraceCall("__contains__", __pyx_f[0], 1640, 0, __PYX_ERR(0, 1640, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1641
 * 
 *     def __contains__(self, key):
 *         try:             # <<<<<<<<<<<<<<
 *             self[key]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":1642
 *     def __contains__(self, key):
 *         try:
 *             self[key]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return False
 */
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1642, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pysam/libcbcf.pyx":1641
 * 
 *     def __contains__(self, key):
 *         try:             # <<<<<<<<<<<<<<
 *             self[key]
 *         except KeyError:
 */
    }

    /* "pysam/libcbcf.pyx":1646
 *             return False
 *         else:
 *             return True             # <<<<<<<<<<<<<<
 * 
 *     def iterkeys(self):
 */
    /*else:*/ {
      __pyx_r = 1;
      goto __pyx_L6_except_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":1643
 *         try:
 *             self[key]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return False
 *         else:
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 1643, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":1644
 *             self[key]
 *         except KeyError:
 *             return False             # <<<<<<<<<<<<<<
 *         else:
 *             return True
 */
      __pyx_r = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":1641
 * 
 *     def __contains__(self, key):
 *         try:             # <<<<<<<<<<<<<<
 *             self[key]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":1640
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         try:
 *             self[key]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1648
 *             return True
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_22iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_21iterkeys[] = "VariantHeaderMetadata.iterkeys(self)\nD.iterkeys() -> an iterator over the keys of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_22iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iterkeys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_21iterkeys(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_21iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("iterkeys", 0);
  __Pyx_TraceCall("iterkeys", __pyx_f[0], 1648, 0, __PYX_ERR(0, 1648, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1650
 *     def iterkeys(self):
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)             # <<<<<<<<<<<<<<
 * 
 *     def itervalues(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1650, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1648
 *             return True
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.iterkeys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_21VariantHeaderMetadata_25generator5(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":1652
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_24itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_23itervalues[] = "VariantHeaderMetadata.itervalues(self)\nD.itervalues() -> an iterator over the values of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_24itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_23itervalues(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_23itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_15_itervalues(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_15_itervalues, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1652, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_21VariantHeaderMetadata_25generator5, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_itervalues, __pyx_n_s_VariantHeaderMetadata_itervalues, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 1652, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.itervalues", __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_5pysam_7libcbcf_21VariantHeaderMetadata_25generator5(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __Pyx_TraceCall("itervalues", __pyx_f[0], 1652, 0, __PYX_ERR(0, 1652, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1652, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1654
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield self[key]
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1654, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1654, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1654, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1654, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1654, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1654, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1654, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":1655
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 *             yield self[key]             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1655, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1655, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1654
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield self[key]
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":1652
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("itervalues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_21VariantHeaderMetadata_28generator6(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":1657
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_27iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_26iteritems[] = "VariantHeaderMetadata.iteritems(self)\nD.iteritems() -> an iterator over the (key, value) items of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_27iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_26iteritems(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_26iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_16_iteritems(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_16_iteritems, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1657, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_21VariantHeaderMetadata_28generator6, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iteritems, __pyx_n_s_VariantHeaderMetadata_iteritems, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 1657, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.iteritems", __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_5pysam_7libcbcf_21VariantHeaderMetadata_28generator6(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __Pyx_TraceCall("iteritems", __pyx_f[0], 1657, 0, __PYX_ERR(0, 1657, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1657, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1659
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield (key, self[key])
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1659, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1659, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1659, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1659, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1659, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1659, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1659, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":1660
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 *             yield (key, self[key])             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1660, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1660, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_cur_scope->__pyx_v_key);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1660, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1659
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield (key, self[key])
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":1657
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("iteritems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1662
 *             yield (key, self[key])
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_30keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_29keys[] = "VariantHeaderMetadata.keys(self)\nD.keys() -> list of D's keys";
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_30keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_29keys(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_29keys(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("keys", 0);
  __Pyx_TraceCall("keys", __pyx_f[0], 1662, 0, __PYX_ERR(0, 1662, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1664
 *     def keys(self):
 *         """D.keys() -> list of D's keys"""
 *         return list(self)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_List(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1662
 *             yield (key, self[key])
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1666
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_32items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_31items[] = "VariantHeaderMetadata.items(self)\nD.items() -> list of D's (key, value) pairs, as 2-tuples";
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_32items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("items (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_31items(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_31items(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("items", 0);
  __Pyx_TraceCall("items", __pyx_f[0], 1666, 0, __PYX_ERR(0, 1666, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1668
 *     def items(self):
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_iteritems); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1668, __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, 1668, __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, 1668, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1668, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1666
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.items", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1670
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_34values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_33values[] = "VariantHeaderMetadata.values(self)\nD.values() -> list of D's values";
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_34values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("values (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_33values(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_33values(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("values", 0);
  __Pyx_TraceCall("values", __pyx_f[0], 1670, 0, __PYX_ERR(0, 1670, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1672
 *     def values(self):
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())             # <<<<<<<<<<<<<<
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itervalues); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1672, __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, 1672, __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, 1672, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1672, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1670
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":73
 * 
 * cdef class VariantHeaderMetadata(object):
 *     cdef readonly VariantHeader header             # <<<<<<<<<<<<<<
 *     cdef int32_t type
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_6header_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_6header_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_6header___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 73, 0, __PYX_ERR(1, 73, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __pyx_r = ((PyObject *)__pyx_v_self->header);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.header.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.header, self.type)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_36__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_35__reduce_cython__[] = "VariantHeaderMetadata.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_36__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_35__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_35__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.header, self.type)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_v_self->type); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->header));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->header));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.header, self.type)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":5
 *     state = (self.header, self.type)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.header is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.header, self.type)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.header is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_VariantHeaderMetadata, (type(self), 0xed5e66b, None), state
 */
  /*else*/ {
    __pyx_t_4 = (((PyObject *)__pyx_v_self->header) != Py_None);
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.header is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantHeaderMetadata, (type(self), 0xed5e66b, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":11
 *         use_setstate = self.header is not None
 *     if use_setstate:
 *         return __pyx_unpickle_VariantHeaderMetadata, (type(self), 0xed5e66b, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_VariantHeaderMetadata, (type(self), 0xed5e66b, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantHeaderMeta); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_248899179);
    __Pyx_GIVEREF(__pyx_int_248899179);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_248899179);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.header is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantHeaderMetadata, (type(self), 0xed5e66b, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_VariantHeaderMetadata, (type(self), 0xed5e66b, None), state
 *     else:
 *         return __pyx_unpickle_VariantHeaderMetadata, (type(self), 0xed5e66b, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantHeaderMetadata__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantHeaderMeta); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_248899179);
    __Pyx_GIVEREF(__pyx_int_248899179);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_248899179);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.header, self.type)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantHeaderMetadata, (type(self), 0xed5e66b, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantHeaderMetadata__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_38__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_37__setstate_cython__[] = "VariantHeaderMetadata.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_38__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_37__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_21VariantHeaderMetadata_37__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 14, 0, __PYX_ERR(2, 14, __pyx_L1_error));

  /* "(tree fragment)":15
 *         return __pyx_unpickle_VariantHeaderMetadata, (type(self), 0xed5e66b, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantHeaderMetadata__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderMetadata__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantHeaderMetadata, (type(self), 0xed5e66b, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantHeaderMetadata__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderMetadata.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1680
 * 
 * 
 * cdef VariantHeaderMetadata makeVariantHeaderMetadata(VariantHeader header, int32_t type):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_f_5pysam_7libcbcf_makeVariantHeaderMetadata(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header, int32_t __pyx_v_type) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v_meta = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("makeVariantHeaderMetadata", 0);
  __Pyx_TraceCall("makeVariantHeaderMetadata", __pyx_f[0], 1680, 0, __PYX_ERR(0, 1680, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1681
 * 
 * cdef VariantHeaderMetadata makeVariantHeaderMetadata(VariantHeader header, int32_t type):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_header)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1681, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1682
 * cdef VariantHeaderMetadata makeVariantHeaderMetadata(VariantHeader header, int32_t type):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantHeaderMetadata meta = VariantHeaderMetadata.__new__(VariantHeaderMetadata)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1682, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1681
 * 
 * cdef VariantHeaderMetadata makeVariantHeaderMetadata(VariantHeader header, int32_t type):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1684
 *         raise ValueError('invalid VariantHeader')
 * 
 *     cdef VariantHeaderMetadata meta = VariantHeaderMetadata.__new__(VariantHeaderMetadata)             # <<<<<<<<<<<<<<
 *     meta.header = header
 *     meta.type = type
 */
  __pyx_t_3 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantHeaderMetadata(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderMetadata), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1684, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_meta = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":1685
 * 
 *     cdef VariantHeaderMetadata meta = VariantHeaderMetadata.__new__(VariantHeaderMetadata)
 *     meta.header = header             # <<<<<<<<<<<<<<
 *     meta.type = type
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_header));
  __Pyx_GOTREF(__pyx_v_meta->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_meta->header));
  __pyx_v_meta->header = __pyx_v_header;

  /* "pysam/libcbcf.pyx":1686
 *     cdef VariantHeaderMetadata meta = VariantHeaderMetadata.__new__(VariantHeaderMetadata)
 *     meta.header = header
 *     meta.type = type             # <<<<<<<<<<<<<<
 * 
 *     return meta
 */
  __pyx_v_meta->type = __pyx_v_type;

  /* "pysam/libcbcf.pyx":1688
 *     meta.type = type
 * 
 *     return meta             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_meta));
  __pyx_r = __pyx_v_meta;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1680
 * 
 * 
 * cdef VariantHeaderMetadata makeVariantHeaderMetadata(VariantHeader header, int32_t type):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantHeaderMetadata", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_meta);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1693
 * cdef class VariantContig(object):
 *     """contig metadata from a :class:`VariantHeader`"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantContig_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantContig_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantContig___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantContig *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_13VariantContig___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 1693, 0, __PYX_ERR(0, 1693, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1694
 *     """contig metadata from a :class:`VariantHeader`"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1694, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 1694, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1693
 * cdef class VariantContig(object):
 *     """contig metadata from a :class:`VariantHeader`"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantContig.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1697
 * 
 *     @property
 *     def name(self):             # <<<<<<<<<<<<<<
 *         """contig name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_4name_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantContig_4name___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantContig *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_4name___get__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1697, 0, __PYX_ERR(0, 1697, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1699
 *     def name(self):
 *         """contig name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         return bcf_str_cache_get_charptr(hdr.id[BCF_DT_CTG][self.id].key)
 * 
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1700
 *         """contig name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         return bcf_str_cache_get_charptr(hdr.id[BCF_DT_CTG][self.id].key)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(((__pyx_v_hdr->id[BCF_DT_CTG])[__pyx_v_self->id]).key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1700, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1697
 * 
 *     @property
 *     def name(self):             # <<<<<<<<<<<<<<
 *         """contig name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantContig.name.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1703
 * 
 *     @property
 *     def id(self):             # <<<<<<<<<<<<<<
 *         """contig internal id number"""
 *         return self.id
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_2id_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_2id_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantContig_2id___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantContig *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_2id___get__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1703, 0, __PYX_ERR(0, 1703, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1705
 *     def id(self):
 *         """contig internal id number"""
 *         return self.id             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1705, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1703
 * 
 *     @property
 *     def id(self):             # <<<<<<<<<<<<<<
 *         """contig internal id number"""
 *         return self.id
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantContig.id.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1708
 * 
 *     @property
 *     def length(self):             # <<<<<<<<<<<<<<
 *         """contig length or None if not available"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_6length_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_6length_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantContig_6length___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantContig *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_6length___get__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  uint32_t __pyx_v_length;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1708, 0, __PYX_ERR(0, 1708, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1710
 *     def length(self):
 *         """contig length or None if not available"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef uint32_t length = hdr.id[BCF_DT_CTG][self.id].val.info[0]
 *         return length if length else None
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1711
 *         """contig length or None if not available"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef uint32_t length = hdr.id[BCF_DT_CTG][self.id].val.info[0]             # <<<<<<<<<<<<<<
 *         return length if length else None
 * 
 */
  __pyx_v_length = (((__pyx_v_hdr->id[BCF_DT_CTG])[__pyx_v_self->id]).val->info[0]);

  /* "pysam/libcbcf.pyx":1712
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef uint32_t length = hdr.id[BCF_DT_CTG][self.id].val.info[0]
 *         return length if length else None             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  if ((__pyx_v_length != 0)) {
    __pyx_t_3 = __Pyx_PyInt_From_uint32_t(__pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1712, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __pyx_t_3;
    __pyx_t_3 = 0;
  } else {
    __Pyx_INCREF(Py_None);
    __pyx_t_2 = Py_None;
  }
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1708
 * 
 *     @property
 *     def length(self):             # <<<<<<<<<<<<<<
 *         """contig length or None if not available"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantContig.length.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1715
 * 
 *     @property
 *     def header_record(self):             # <<<<<<<<<<<<<<
 *         """:class:`VariantHeaderRecord` associated with this :class:`VariantContig` object"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_13header_record_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_13header_record_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantContig_13header_record___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantContig *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_13header_record___get__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf_hrec_t *__pyx_v_hrec;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1715, 0, __PYX_ERR(0, 1715, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1717
 *     def header_record(self):
 *         """:class:`VariantHeaderRecord` associated with this :class:`VariantContig` object"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *hrec = hdr.id[BCF_DT_CTG][self.id].val.hrec[0]
 *         return makeVariantHeaderRecord(self.header, hrec)
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1718
 *         """:class:`VariantHeaderRecord` associated with this :class:`VariantContig` object"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_hrec_t *hrec = hdr.id[BCF_DT_CTG][self.id].val.hrec[0]             # <<<<<<<<<<<<<<
 *         return makeVariantHeaderRecord(self.header, hrec)
 * 
 */
  __pyx_v_hrec = (((__pyx_v_hdr->id[BCF_DT_CTG])[__pyx_v_self->id]).val->hrec[0]);

  /* "pysam/libcbcf.pyx":1719
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef bcf_hrec_t *hrec = hdr.id[BCF_DT_CTG][self.id].val.hrec[0]
 *         return makeVariantHeaderRecord(self.header, hrec)             # <<<<<<<<<<<<<<
 * 
 *     def remove_header(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((PyObject *)__pyx_v_self->header);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeaderRecord(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_2), __pyx_v_hrec)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1719, __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;

  /* "pysam/libcbcf.pyx":1715
 * 
 *     @property
 *     def header_record(self):             # <<<<<<<<<<<<<<
 *         """:class:`VariantHeaderRecord` associated with this :class:`VariantContig` object"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantContig.header_record.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1721
 *         return makeVariantHeaderRecord(self.header, hrec)
 * 
 *     def remove_header(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef const char *key = hdr.id[BCF_DT_CTG][self.id].key
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_3remove_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantContig_2remove_header[] = "VariantContig.remove_header(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_3remove_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_header (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantContig_2remove_header(((struct __pyx_obj_5pysam_7libcbcf_VariantContig *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_2remove_header(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  char const *__pyx_v_key;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  char const *__pyx_t_2;
  __Pyx_RefNannySetupContext("remove_header", 0);
  __Pyx_TraceCall("remove_header", __pyx_f[0], 1721, 0, __PYX_ERR(0, 1721, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1722
 * 
 *     def remove_header(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef const char *key = hdr.id[BCF_DT_CTG][self.id].key
 *         bcf_hdr_remove(hdr, BCF_HL_CTG, key)
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1723
 *     def remove_header(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef const char *key = hdr.id[BCF_DT_CTG][self.id].key             # <<<<<<<<<<<<<<
 *         bcf_hdr_remove(hdr, BCF_HL_CTG, key)
 * 
 */
  __pyx_t_2 = ((__pyx_v_hdr->id[BCF_DT_CTG])[__pyx_v_self->id]).key;
  __pyx_v_key = __pyx_t_2;

  /* "pysam/libcbcf.pyx":1724
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef const char *key = hdr.id[BCF_DT_CTG][self.id].key
 *         bcf_hdr_remove(hdr, BCF_HL_CTG, key)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  bcf_hdr_remove(__pyx_v_hdr, BCF_HL_CTG, __pyx_v_key);

  /* "pysam/libcbcf.pyx":1721
 *         return makeVariantHeaderRecord(self.header, hrec)
 * 
 *     def remove_header(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef const char *key = hdr.id[BCF_DT_CTG][self.id].key
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantContig.remove_header", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":62
 * 
 * cdef class VariantContig(object):
 *     cdef readonly VariantHeader header             # <<<<<<<<<<<<<<
 *     cdef int id
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_6header_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_6header_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantContig_6header___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantContig *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 62, 0, __PYX_ERR(1, 62, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __pyx_r = ((PyObject *)__pyx_v_self->header);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantContig.header.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.header, self.id)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantContig_4__reduce_cython__[] = "VariantContig.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantContig_4__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantContig *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_4__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.header, self.id)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->id); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->header));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->header));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.header, self.id)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":5
 *     state = (self.header, self.id)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.header is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.header, self.id)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.header is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_VariantContig, (type(self), 0xbe66ecb, None), state
 */
  /*else*/ {
    __pyx_t_4 = (((PyObject *)__pyx_v_self->header) != Py_None);
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.header is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantContig, (type(self), 0xbe66ecb, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":11
 *         use_setstate = self.header is not None
 *     if use_setstate:
 *         return __pyx_unpickle_VariantContig, (type(self), 0xbe66ecb, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_VariantContig, (type(self), 0xbe66ecb, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantContig); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_199651019);
    __Pyx_GIVEREF(__pyx_int_199651019);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_199651019);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.header is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantContig, (type(self), 0xbe66ecb, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_VariantContig, (type(self), 0xbe66ecb, None), state
 *     else:
 *         return __pyx_unpickle_VariantContig, (type(self), 0xbe66ecb, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantContig__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantContig); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_199651019);
    __Pyx_GIVEREF(__pyx_int_199651019);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_199651019);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.header, self.id)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantContig.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantContig, (type(self), 0xbe66ecb, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantContig__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantContig_6__setstate_cython__[] = "VariantContig.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantContig_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantContig_6__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantContig *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantContig_6__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 14, 0, __PYX_ERR(2, 14, __pyx_L1_error));

  /* "(tree fragment)":15
 *         return __pyx_unpickle_VariantContig, (type(self), 0xbe66ecb, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantContig__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantContig__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantContig, (type(self), 0xbe66ecb, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantContig__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantContig.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1727
 * 
 * 
 * cdef VariantContig makeVariantContig(VariantHeader header, int id):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_f_5pysam_7libcbcf_makeVariantContig(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header, int __pyx_v_id) {
  struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v_contig = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("makeVariantContig", 0);
  __Pyx_TraceCall("makeVariantContig", __pyx_f[0], 1727, 0, __PYX_ERR(0, 1727, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1728
 * 
 * cdef VariantContig makeVariantContig(VariantHeader header, int id):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_header)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1728, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1729
 * cdef VariantContig makeVariantContig(VariantHeader header, int id):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     if id < 0 or id >= header.ptr.n[BCF_DT_CTG]:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1729, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1729, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1728
 * 
 * cdef VariantContig makeVariantContig(VariantHeader header, int id):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1731
 *         raise ValueError('invalid VariantHeader')
 * 
 *     if id < 0 or id >= header.ptr.n[BCF_DT_CTG]:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid contig id')
 * 
 */
  __pyx_t_1 = ((__pyx_v_id < 0) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_id >= (__pyx_v_header->ptr->n[BCF_DT_CTG])) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1732
 * 
 *     if id < 0 or id >= header.ptr.n[BCF_DT_CTG]:
 *         raise ValueError('invalid contig id')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantContig contig = VariantContig.__new__(VariantContig)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1732, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1731
 *         raise ValueError('invalid VariantHeader')
 * 
 *     if id < 0 or id >= header.ptr.n[BCF_DT_CTG]:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid contig id')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1734
 *         raise ValueError('invalid contig id')
 * 
 *     cdef VariantContig contig = VariantContig.__new__(VariantContig)             # <<<<<<<<<<<<<<
 *     contig.header = header
 *     contig.id = id
 */
  __pyx_t_3 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantContig(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantContig), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1734, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_contig = ((struct __pyx_obj_5pysam_7libcbcf_VariantContig *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":1735
 * 
 *     cdef VariantContig contig = VariantContig.__new__(VariantContig)
 *     contig.header = header             # <<<<<<<<<<<<<<
 *     contig.id = id
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_header));
  __Pyx_GOTREF(__pyx_v_contig->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_contig->header));
  __pyx_v_contig->header = __pyx_v_header;

  /* "pysam/libcbcf.pyx":1736
 *     cdef VariantContig contig = VariantContig.__new__(VariantContig)
 *     contig.header = header
 *     contig.id = id             # <<<<<<<<<<<<<<
 * 
 *     return contig
 */
  __pyx_v_contig->id = __pyx_v_id;

  /* "pysam/libcbcf.pyx":1738
 *     contig.id = id
 * 
 *     return contig             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_contig));
  __pyx_r = __pyx_v_contig;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1727
 * 
 * 
 * cdef VariantContig makeVariantContig(VariantHeader header, int id):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantContig", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_contig);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1743
 * cdef class VariantHeaderContigs(object):
 *     """mapping from contig name or index to :class:`VariantContig` object."""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 1743, 0, __PYX_ERR(0, 1743, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1744
 *     """mapping from contig name or index to :class:`VariantContig` object."""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 1744, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1743
 * cdef class VariantHeaderContigs(object):
 *     """mapping from contig name or index to :class:`VariantContig` object."""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1746
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         assert kh_size(<vdict_t *>hdr.dict[BCF_DT_CTG]) == hdr.n[BCF_DT_CTG]
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_3__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_3__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_2__len__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  Py_ssize_t __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  __Pyx_RefNannySetupContext("__len__", 0);
  __Pyx_TraceCall("__len__", __pyx_f[0], 1746, 0, __PYX_ERR(0, 1746, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1747
 * 
 *     def __len__(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         assert kh_size(<vdict_t *>hdr.dict[BCF_DT_CTG]) == hdr.n[BCF_DT_CTG]
 *         return hdr.n[BCF_DT_CTG]
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1748
 *     def __len__(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         assert kh_size(<vdict_t *>hdr.dict[BCF_DT_CTG]) == hdr.n[BCF_DT_CTG]             # <<<<<<<<<<<<<<
 *         return hdr.n[BCF_DT_CTG]
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((kh_size(((vdict_t *)(__pyx_v_hdr->dict[BCF_DT_CTG]))) == (__pyx_v_hdr->n[BCF_DT_CTG])) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 1748, __pyx_L1_error)
    }
  }
  #endif

  /* "pysam/libcbcf.pyx":1749
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         assert kh_size(<vdict_t *>hdr.dict[BCF_DT_CTG]) == hdr.n[BCF_DT_CTG]
 *         return hdr.n[BCF_DT_CTG]             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
  __pyx_r = (__pyx_v_hdr->n[BCF_DT_CTG]);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1746
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         assert kh_size(<vdict_t *>hdr.dict[BCF_DT_CTG]) == hdr.n[BCF_DT_CTG]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1751
 *         return hdr.n[BCF_DT_CTG]
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         assert kh_size(<vdict_t *>hdr.dict[BCF_DT_CTG]) == hdr.n[BCF_DT_CTG]
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_5__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_5__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_4__bool__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  __Pyx_RefNannySetupContext("__bool__", 0);
  __Pyx_TraceCall("__bool__", __pyx_f[0], 1751, 0, __PYX_ERR(0, 1751, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1752
 * 
 *     def __bool__(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         assert kh_size(<vdict_t *>hdr.dict[BCF_DT_CTG]) == hdr.n[BCF_DT_CTG]
 *         return hdr.n[BCF_DT_CTG] != 0
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1753
 *     def __bool__(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         assert kh_size(<vdict_t *>hdr.dict[BCF_DT_CTG]) == hdr.n[BCF_DT_CTG]             # <<<<<<<<<<<<<<
 *         return hdr.n[BCF_DT_CTG] != 0
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((kh_size(((vdict_t *)(__pyx_v_hdr->dict[BCF_DT_CTG]))) == (__pyx_v_hdr->n[BCF_DT_CTG])) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 1753, __pyx_L1_error)
    }
  }
  #endif

  /* "pysam/libcbcf.pyx":1754
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         assert kh_size(<vdict_t *>hdr.dict[BCF_DT_CTG]) == hdr.n[BCF_DT_CTG]
 *         return hdr.n[BCF_DT_CTG] != 0             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key):
 */
  __pyx_r = ((__pyx_v_hdr->n[BCF_DT_CTG]) != 0);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1751
 *         return hdr.n[BCF_DT_CTG]
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         assert kh_size(<vdict_t *>hdr.dict[BCF_DT_CTG]) == hdr.n[BCF_DT_CTG]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1756
 *         return hdr.n[BCF_DT_CTG] != 0
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int index
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_6__getitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_index;
  vdict_t *__pyx_v_d;
  PyObject *__pyx_v_bkey = 0;
  khiter_t __pyx_v_k;
  int __pyx_v_id;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  char const *__pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_TraceCall("__getitem__", __pyx_f[0], 1756, 0, __PYX_ERR(0, 1756, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1757
 * 
 *     def __getitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef int index
 * 
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1760
 *         cdef int index
 * 
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             index = key
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:
 */
  __pyx_t_2 = PyInt_Check(__pyx_v_key); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":1761
 * 
 *         if isinstance(key, int):
 *             index = key             # <<<<<<<<<<<<<<
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:
 *                 raise IndexError('invalid contig index')
 */
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_key); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1761, __pyx_L1_error)
    __pyx_v_index = __pyx_t_4;

    /* "pysam/libcbcf.pyx":1762
 *         if isinstance(key, int):
 *             index = key
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:             # <<<<<<<<<<<<<<
 *                 raise IndexError('invalid contig index')
 *             return makeVariantContig(self.header, index)
 */
    __pyx_t_2 = ((__pyx_v_index < 0) != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_index >= (__pyx_v_hdr->n[BCF_DT_CTG])) != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;
    if (unlikely(__pyx_t_3)) {

      /* "pysam/libcbcf.pyx":1763
 *             index = key
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:
 *                 raise IndexError('invalid contig index')             # <<<<<<<<<<<<<<
 *             return makeVariantContig(self.header, index)
 * 
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1763, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 1763, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":1762
 *         if isinstance(key, int):
 *             index = key
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:             # <<<<<<<<<<<<<<
 *                 raise IndexError('invalid contig index')
 *             return makeVariantContig(self.header, index)
 */
    }

    /* "pysam/libcbcf.pyx":1764
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:
 *                 raise IndexError('invalid contig index')
 *             return makeVariantContig(self.header, index)             # <<<<<<<<<<<<<<
 * 
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_CTG]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = ((PyObject *)__pyx_v_self->header);
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_6 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantContig(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_5), __pyx_v_index)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":1760
 *         cdef int index
 * 
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             index = key
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:
 */
  }

  /* "pysam/libcbcf.pyx":1766
 *             return makeVariantContig(self.header, index)
 * 
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_CTG]             # <<<<<<<<<<<<<<
 *         cdef bytes bkey = force_bytes(key)
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 */
  __pyx_v_d = ((vdict_t *)(__pyx_v_hdr->dict[BCF_DT_CTG]));

  /* "pysam/libcbcf.pyx":1767
 * 
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_CTG]
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 * 
 */
  __pyx_t_6 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_bkey = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "pysam/libcbcf.pyx":1768
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_CTG]
 *         cdef bytes bkey = force_bytes(key)
 *         cdef khiter_t k = kh_get_vdict(d, bkey)             # <<<<<<<<<<<<<<
 * 
 *         if k == kh_end(d):
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 1768, __pyx_L1_error)
  }
  __pyx_t_7 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 1768, __pyx_L1_error)
  __pyx_v_k = kh_get_vdict(__pyx_v_d, __pyx_t_7);

  /* "pysam/libcbcf.pyx":1770
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 * 
 *         if k == kh_end(d):             # <<<<<<<<<<<<<<
 *             raise KeyError('invalid contig: {}'.format(key))
 * 
 */
  __pyx_t_3 = ((__pyx_v_k == kh_end(__pyx_v_d)) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":1771
 * 
 *         if k == kh_end(d):
 *             raise KeyError('invalid contig: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         cdef int id = kh_val_vdict(d, k).id
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_invalid_contig, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1771, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_key); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1771, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_key};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1771, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_key};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1771, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1771, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_key);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1771, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1771, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 1771, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1770
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 * 
 *         if k == kh_end(d):             # <<<<<<<<<<<<<<
 *             raise KeyError('invalid contig: {}'.format(key))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1773
 *             raise KeyError('invalid contig: {}'.format(key))
 * 
 *         cdef int id = kh_val_vdict(d, k).id             # <<<<<<<<<<<<<<
 * 
 *         return makeVariantContig(self.header, id)
 */
  __pyx_t_4 = kh_val(__pyx_v_d, __pyx_v_k).id;
  __pyx_v_id = __pyx_t_4;

  /* "pysam/libcbcf.pyx":1775
 *         cdef int id = kh_val_vdict(d, k).id
 * 
 *         return makeVariantContig(self.header, id)             # <<<<<<<<<<<<<<
 * 
 *     def remove_header(self, key):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = ((PyObject *)__pyx_v_self->header);
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_6 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantContig(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_5), __pyx_v_id)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1775, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1756
 *         return hdr.n[BCF_DT_CTG] != 0
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int index
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1777
 *         return makeVariantContig(self.header, id)
 * 
 *     def remove_header(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int index
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_9remove_header(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_8remove_header[] = "VariantHeaderContigs.remove_header(self, key)";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_9remove_header(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_header (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_8remove_header(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_8remove_header(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_index;
  char const *__pyx_v_ckey;
  vdict_t *__pyx_v_d;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  char const *__pyx_t_7;
  char const *__pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  char const *__pyx_t_12;
  __Pyx_RefNannySetupContext("remove_header", 0);
  __Pyx_TraceCall("remove_header", __pyx_f[0], 1777, 0, __PYX_ERR(0, 1777, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_key);

  /* "pysam/libcbcf.pyx":1778
 * 
 *     def remove_header(self, key):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef int index
 *         cdef const char *ckey
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1784
 *         cdef khiter_t k
 * 
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             index = key
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:
 */
  __pyx_t_2 = PyInt_Check(__pyx_v_key); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":1785
 * 
 *         if isinstance(key, int):
 *             index = key             # <<<<<<<<<<<<<<
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:
 *                 raise IndexError('invalid contig index')
 */
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_key); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1785, __pyx_L1_error)
    __pyx_v_index = __pyx_t_4;

    /* "pysam/libcbcf.pyx":1786
 *         if isinstance(key, int):
 *             index = key
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:             # <<<<<<<<<<<<<<
 *                 raise IndexError('invalid contig index')
 *             ckey = hdr.id[BCF_DT_CTG][self.id].key
 */
    __pyx_t_2 = ((__pyx_v_index < 0) != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_index >= (__pyx_v_hdr->n[BCF_DT_CTG])) != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;
    if (unlikely(__pyx_t_3)) {

      /* "pysam/libcbcf.pyx":1787
 *             index = key
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:
 *                 raise IndexError('invalid contig index')             # <<<<<<<<<<<<<<
 *             ckey = hdr.id[BCF_DT_CTG][self.id].key
 *         else:
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1787, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 1787, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":1786
 *         if isinstance(key, int):
 *             index = key
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:             # <<<<<<<<<<<<<<
 *                 raise IndexError('invalid contig index')
 *             ckey = hdr.id[BCF_DT_CTG][self.id].key
 */
    }

    /* "pysam/libcbcf.pyx":1788
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:
 *                 raise IndexError('invalid contig index')
 *             ckey = hdr.id[BCF_DT_CTG][self.id].key             # <<<<<<<<<<<<<<
 *         else:
 *             d = <vdict_t *>hdr.dict[BCF_DT_CTG]
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1788, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = ((__pyx_v_hdr->id[BCF_DT_CTG])[__pyx_t_6]).key;
    __pyx_v_ckey = __pyx_t_7;

    /* "pysam/libcbcf.pyx":1784
 *         cdef khiter_t k
 * 
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             index = key
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:
 */
    goto __pyx_L3;
  }

  /* "pysam/libcbcf.pyx":1790
 *             ckey = hdr.id[BCF_DT_CTG][self.id].key
 *         else:
 *             d = <vdict_t *>hdr.dict[BCF_DT_CTG]             # <<<<<<<<<<<<<<
 *             key = force_bytes(key)
 *             if kh_get_vdict(d, key) == kh_end(d):
 */
  /*else*/ {
    __pyx_v_d = ((vdict_t *)(__pyx_v_hdr->dict[BCF_DT_CTG]));

    /* "pysam/libcbcf.pyx":1791
 *         else:
 *             d = <vdict_t *>hdr.dict[BCF_DT_CTG]
 *             key = force_bytes(key)             # <<<<<<<<<<<<<<
 *             if kh_get_vdict(d, key) == kh_end(d):
 *                 raise KeyError('invalid contig: {}'.format(key))
 */
    __pyx_t_5 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1791, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_key, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "pysam/libcbcf.pyx":1792
 *             d = <vdict_t *>hdr.dict[BCF_DT_CTG]
 *             key = force_bytes(key)
 *             if kh_get_vdict(d, key) == kh_end(d):             # <<<<<<<<<<<<<<
 *                 raise KeyError('invalid contig: {}'.format(key))
 *             ckey = key
 */
    __pyx_t_8 = __Pyx_PyObject_AsString(__pyx_v_key); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 1792, __pyx_L1_error)
    __pyx_t_3 = ((kh_get_vdict(__pyx_v_d, __pyx_t_8) == kh_end(__pyx_v_d)) != 0);
    if (unlikely(__pyx_t_3)) {

      /* "pysam/libcbcf.pyx":1793
 *             key = force_bytes(key)
 *             if kh_get_vdict(d, key) == kh_end(d):
 *                 raise KeyError('invalid contig: {}'.format(key))             # <<<<<<<<<<<<<<
 *             ckey = key
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_invalid_contig, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1793, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_key); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1793, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1793, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_5);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1793, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_5);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1793, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_key);
          __Pyx_GIVEREF(__pyx_v_key);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_key);
          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1793, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1793, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 1793, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":1792
 *             d = <vdict_t *>hdr.dict[BCF_DT_CTG]
 *             key = force_bytes(key)
 *             if kh_get_vdict(d, key) == kh_end(d):             # <<<<<<<<<<<<<<
 *                 raise KeyError('invalid contig: {}'.format(key))
 *             ckey = key
 */
    }

    /* "pysam/libcbcf.pyx":1794
 *             if kh_get_vdict(d, key) == kh_end(d):
 *                 raise KeyError('invalid contig: {}'.format(key))
 *             ckey = key             # <<<<<<<<<<<<<<
 * 
 *         bcf_hdr_remove(hdr, BCF_HL_CTG, ckey)
 */
    __pyx_t_12 = __Pyx_PyObject_AsString(__pyx_v_key); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 1794, __pyx_L1_error)
    __pyx_v_ckey = __pyx_t_12;
  }
  __pyx_L3:;

  /* "pysam/libcbcf.pyx":1796
 *             ckey = key
 * 
 *         bcf_hdr_remove(hdr, BCF_HL_CTG, ckey)             # <<<<<<<<<<<<<<
 * 
 *     def clear_header(self):
 */
  bcf_hdr_remove(__pyx_v_hdr, BCF_HL_CTG, __pyx_v_ckey);

  /* "pysam/libcbcf.pyx":1777
 *         return makeVariantContig(self.header, id)
 * 
 *     def remove_header(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int index
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.remove_header", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1798
 *         bcf_hdr_remove(hdr, BCF_HL_CTG, ckey)
 * 
 *     def clear_header(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         bcf_hdr_remove(hdr, BCF_HL_CTG, NULL)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_11clear_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_10clear_header[] = "VariantHeaderContigs.clear_header(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_11clear_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear_header (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_10clear_header(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_10clear_header(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  __Pyx_RefNannySetupContext("clear_header", 0);
  __Pyx_TraceCall("clear_header", __pyx_f[0], 1798, 0, __PYX_ERR(0, 1798, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1799
 * 
 *     def clear_header(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         bcf_hdr_remove(hdr, BCF_HL_CTG, NULL)
 *         #bcf_hdr_sync(hdr)
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1800
 *     def clear_header(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         bcf_hdr_remove(hdr, BCF_HL_CTG, NULL)             # <<<<<<<<<<<<<<
 *         #bcf_hdr_sync(hdr)
 * 
 */
  bcf_hdr_remove(__pyx_v_hdr, BCF_HL_CTG, NULL);

  /* "pysam/libcbcf.pyx":1798
 *         bcf_hdr_remove(hdr, BCF_HL_CTG, ckey)
 * 
 *     def clear_header(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         bcf_hdr_remove(hdr, BCF_HL_CTG, NULL)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.clear_header", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_20VariantHeaderContigs_14generator7(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":1803
 *         #bcf_hdr_sync(hdr)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_CTG]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_13__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_13__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_12__iter__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_12__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__ *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__ *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_17___iter__(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_17___iter__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1803, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_20VariantHeaderContigs_14generator7, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_VariantHeaderContigs___iter, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 1803, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.__iter__", __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_5pysam_7libcbcf_20VariantHeaderContigs_14generator7(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__ *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hdr_t *__pyx_t_1;
  uint32_t __pyx_t_2;
  uint32_t __pyx_t_3;
  uint32_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 1803, 0, __PYX_ERR(0, 1803, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1803, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1804
 * 
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_CTG]
 *         cdef uint32_t n = kh_size(d)
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->header->ptr;
  __pyx_cur_scope->__pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1805
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_CTG]             # <<<<<<<<<<<<<<
 *         cdef uint32_t n = kh_size(d)
 * 
 */
  __pyx_cur_scope->__pyx_v_d = ((vdict_t *)(__pyx_cur_scope->__pyx_v_hdr->dict[BCF_DT_CTG]));

  /* "pysam/libcbcf.pyx":1806
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_CTG]
 *         cdef uint32_t n = kh_size(d)             # <<<<<<<<<<<<<<
 * 
 *         assert n == hdr.n[BCF_DT_CTG]
 */
  __pyx_cur_scope->__pyx_v_n = kh_size(__pyx_cur_scope->__pyx_v_d);

  /* "pysam/libcbcf.pyx":1808
 *         cdef uint32_t n = kh_size(d)
 * 
 *         assert n == hdr.n[BCF_DT_CTG]             # <<<<<<<<<<<<<<
 * 
 *         for i in range(n):
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_cur_scope->__pyx_v_n == (__pyx_cur_scope->__pyx_v_hdr->n[BCF_DT_CTG])) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 1808, __pyx_L1_error)
    }
  }
  #endif

  /* "pysam/libcbcf.pyx":1810
 *         assert n == hdr.n[BCF_DT_CTG]
 * 
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             yield bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, i))
 * 
 */
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_n;
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_4;

    /* "pysam/libcbcf.pyx":1811
 * 
 *         for i in range(n):
 *             yield bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, i))             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
    __pyx_t_5 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(bcf_hdr_id2name(__pyx_cur_scope->__pyx_v_hdr, __pyx_cur_scope->__pyx_v_i)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_4;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1811, __pyx_L1_error)
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":1803
 *         #bcf_hdr_sync(hdr)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_CTG]
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1813
 *             yield bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, i))
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_16get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_15get[] = "VariantHeaderContigs.get(self, key, default=None)\nD.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_16get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 1813, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1813, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_15get(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_15get(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("get", 0);
  __Pyx_TraceCall("get", __pyx_f[0], 1813, 0, __PYX_ERR(0, 1813, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1815
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":1816
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 *             return self[key]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return default
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1816, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "pysam/libcbcf.pyx":1815
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":1817
 *         try:
 *             return self[key]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 1817, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":1818
 *             return self[key]
 *         except KeyError:
 *             return default             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_default);
      __pyx_r = __pyx_v_default;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":1815
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":1813
 *             yield bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, i))
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1820
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         try:
 *             self[key]
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_18__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_18__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_17__contains__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_17__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("__contains__", 0);
  __Pyx_TraceCall("__contains__", __pyx_f[0], 1820, 0, __PYX_ERR(0, 1820, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1821
 * 
 *     def __contains__(self, key):
 *         try:             # <<<<<<<<<<<<<<
 *             self[key]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":1822
 *     def __contains__(self, key):
 *         try:
 *             self[key]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return False
 */
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1822, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pysam/libcbcf.pyx":1821
 * 
 *     def __contains__(self, key):
 *         try:             # <<<<<<<<<<<<<<
 *             self[key]
 *         except KeyError:
 */
    }

    /* "pysam/libcbcf.pyx":1826
 *             return False
 *         else:
 *             return True             # <<<<<<<<<<<<<<
 * 
 *     def iterkeys(self):
 */
    /*else:*/ {
      __pyx_r = 1;
      goto __pyx_L6_except_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":1823
 *         try:
 *             self[key]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return False
 *         else:
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 1823, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":1824
 *             self[key]
 *         except KeyError:
 *             return False             # <<<<<<<<<<<<<<
 *         else:
 *             return True
 */
      __pyx_r = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":1821
 * 
 *     def __contains__(self, key):
 *         try:             # <<<<<<<<<<<<<<
 *             self[key]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":1820
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         try:
 *             self[key]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1828
 *             return True
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_20iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_19iterkeys[] = "VariantHeaderContigs.iterkeys(self)\nD.iterkeys() -> an iterator over the keys of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_20iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iterkeys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_19iterkeys(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_19iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("iterkeys", 0);
  __Pyx_TraceCall("iterkeys", __pyx_f[0], 1828, 0, __PYX_ERR(0, 1828, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1830
 *     def iterkeys(self):
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)             # <<<<<<<<<<<<<<
 * 
 *     def itervalues(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1830, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1828
 *             return True
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.iterkeys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_20VariantHeaderContigs_23generator8(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":1832
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_22itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_21itervalues[] = "VariantHeaderContigs.itervalues(self)\nD.itervalues() -> an iterator over the values of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_22itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_21itervalues(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_21itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_18_itervalues(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_18_itervalues, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1832, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_20VariantHeaderContigs_23generator8, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_itervalues, __pyx_n_s_VariantHeaderContigs_itervalues, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 1832, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.itervalues", __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_5pysam_7libcbcf_20VariantHeaderContigs_23generator8(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __Pyx_TraceCall("itervalues", __pyx_f[0], 1832, 0, __PYX_ERR(0, 1832, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1832, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1834
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield self[key]
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1834, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1834, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1834, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1834, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1834, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1834, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":1835
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 *             yield self[key]             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1835, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1834
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield self[key]
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":1832
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("itervalues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_20VariantHeaderContigs_26generator9(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":1837
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_25iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_24iteritems[] = "VariantHeaderContigs.iteritems(self)\nD.iteritems() -> an iterator over the (key, value) items of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_25iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_24iteritems(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_24iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_19_iteritems(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_19_iteritems, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1837, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_20VariantHeaderContigs_26generator9, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iteritems, __pyx_n_s_VariantHeaderContigs_iteritems, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 1837, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.iteritems", __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_5pysam_7libcbcf_20VariantHeaderContigs_26generator9(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __Pyx_TraceCall("iteritems", __pyx_f[0], 1837, 0, __PYX_ERR(0, 1837, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1837, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1839
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield (key, self[key])
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1839, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1839, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1839, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1839, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1839, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1839, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1839, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":1840
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 *             yield (key, self[key])             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_cur_scope->__pyx_v_key);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1840, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1839
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield (key, self[key])
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":1837
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("iteritems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1842
 *             yield (key, self[key])
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_28keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_27keys[] = "VariantHeaderContigs.keys(self)\nD.keys() -> list of D's keys";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_28keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_27keys(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_27keys(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("keys", 0);
  __Pyx_TraceCall("keys", __pyx_f[0], 1842, 0, __PYX_ERR(0, 1842, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1844
 *     def keys(self):
 *         """D.keys() -> list of D's keys"""
 *         return list(self)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_List(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1844, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1842
 *             yield (key, self[key])
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1846
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_30items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_29items[] = "VariantHeaderContigs.items(self)\nD.items() -> list of D's (key, value) pairs, as 2-tuples";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_30items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("items (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_29items(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_29items(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("items", 0);
  __Pyx_TraceCall("items", __pyx_f[0], 1846, 0, __PYX_ERR(0, 1846, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1848
 *     def items(self):
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_iteritems); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1848, __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, 1848, __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, 1848, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1846
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.items", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1850
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_32values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_31values[] = "VariantHeaderContigs.values(self)\nD.values() -> list of D's values";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_32values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("values (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_31values(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_31values(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("values", 0);
  __Pyx_TraceCall("values", __pyx_f[0], 1850, 0, __PYX_ERR(0, 1850, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1852
 *     def values(self):
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())             # <<<<<<<<<<<<<<
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itervalues); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1852, __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, 1852, __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, 1852, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); 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_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1850
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1859
 *     #TODO: implement __richcmp__
 * 
 *     def add(self, id, **kwargs):             # <<<<<<<<<<<<<<
 *         """Add a new contig record"""
 *         if id in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_34add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_33add[] = "VariantHeaderContigs.add(self, id, **kwargs)\nAdd a new contig record";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_34add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_id = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (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_id,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_id)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "add") < 0)) __PYX_ERR(0, 1859, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_id = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1859, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_33add(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self), __pyx_v_id, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_33add(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, PyObject *__pyx_v_id, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_items = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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("add", 0);
  __Pyx_TraceCall("add", __pyx_f[0], 1859, 0, __PYX_ERR(0, 1859, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1861
 *     def add(self, id, **kwargs):
 *         """Add a new contig record"""
 *         if id in self:             # <<<<<<<<<<<<<<
 *             raise ValueError('Header already exists for contig {}'.format(id))
 * 
 */
  __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_id, ((PyObject *)__pyx_v_self), Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1861, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1862
 *         """Add a new contig record"""
 *         if id in self:
 *             raise ValueError('Header already exists for contig {}'.format(id))             # <<<<<<<<<<<<<<
 * 
 *         items = [('ID', id)]
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Header_already_exists_for_contig, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1862, __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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1862, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_id};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1862, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_id};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1862, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1862, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_INCREF(__pyx_v_id);
        __Pyx_GIVEREF(__pyx_v_id);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_id);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1862, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1862, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 1862, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1861
 *     def add(self, id, **kwargs):
 *         """Add a new contig record"""
 *         if id in self:             # <<<<<<<<<<<<<<
 *             raise ValueError('Header already exists for contig {}'.format(id))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1864
 *             raise ValueError('Header already exists for contig {}'.format(id))
 * 
 *         items = [('ID', id)]             # <<<<<<<<<<<<<<
 *         items += kwargs.items()
 *         self.header.add_meta('contig', items=items)
 */
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_n_s_ID);
  __Pyx_GIVEREF(__pyx_n_s_ID);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_ID);
  __Pyx_INCREF(__pyx_v_id);
  __Pyx_GIVEREF(__pyx_v_id);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_id);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_v_items = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":1865
 * 
 *         items = [('ID', id)]
 *         items += kwargs.items()             # <<<<<<<<<<<<<<
 *         self.header.add_meta('contig', items=items)
 * 
 */
  __pyx_t_3 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1865, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_items, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1865, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":1866
 *         items = [('ID', id)]
 *         items += kwargs.items()
 *         self.header.add_meta('contig', items=items)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->header), __pyx_n_s_add_meta); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1866, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1866, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_items, __pyx_v_items) < 0) __PYX_ERR(0, 1866, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__90, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1866, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "pysam/libcbcf.pyx":1859
 *     #TODO: implement __richcmp__
 * 
 *     def add(self, id, **kwargs):             # <<<<<<<<<<<<<<
 *         """Add a new contig record"""
 *         if id in self:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":54
 * 
 * cdef class VariantHeaderContigs(object):
 *     cdef readonly VariantHeader header             # <<<<<<<<<<<<<<
 * 
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_6header_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_6header_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_6header___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 54, 0, __PYX_ERR(1, 54, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __pyx_r = ((PyObject *)__pyx_v_self->header);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.header.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.header,)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_36__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_35__reduce_cython__[] = "VariantHeaderContigs.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_36__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_35__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_35__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.header,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->header));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->header));
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.header,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":5
 *     state = (self.header,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.header is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.header,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.header is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_VariantHeaderContigs, (type(self), 0x099fb99, None), state
 */
  /*else*/ {
    __pyx_t_3 = (((PyObject *)__pyx_v_self->header) != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.header is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantHeaderContigs, (type(self), 0x099fb99, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":11
 *         use_setstate = self.header is not None
 *     if use_setstate:
 *         return __pyx_unpickle_VariantHeaderContigs, (type(self), 0x099fb99, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_VariantHeaderContigs, (type(self), 0x099fb99, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantHeaderCont); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_10091417);
    __Pyx_GIVEREF(__pyx_int_10091417);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_10091417);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.header is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantHeaderContigs, (type(self), 0x099fb99, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_VariantHeaderContigs, (type(self), 0x099fb99, None), state
 *     else:
 *         return __pyx_unpickle_VariantHeaderContigs, (type(self), 0x099fb99, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantHeaderContigs__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantHeaderCont); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_10091417);
    __Pyx_GIVEREF(__pyx_int_10091417);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_10091417);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.header,)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantHeaderContigs, (type(self), 0x099fb99, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantHeaderContigs__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_38__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_37__setstate_cython__[] = "VariantHeaderContigs.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_38__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_37__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderContigs_37__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 14, 0, __PYX_ERR(2, 14, __pyx_L1_error));

  /* "(tree fragment)":15
 *         return __pyx_unpickle_VariantHeaderContigs, (type(self), 0x099fb99, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantHeaderContigs__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderContigs__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantHeaderContigs, (type(self), 0x099fb99, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantHeaderContigs__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderContigs.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1869
 * 
 * 
 * cdef VariantHeaderContigs makeVariantHeaderContigs(VariantHeader header):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_f_5pysam_7libcbcf_makeVariantHeaderContigs(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v_contigs = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("makeVariantHeaderContigs", 0);
  __Pyx_TraceCall("makeVariantHeaderContigs", __pyx_f[0], 1869, 0, __PYX_ERR(0, 1869, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1870
 * 
 * cdef VariantHeaderContigs makeVariantHeaderContigs(VariantHeader header):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_header)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1870, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1871
 * cdef VariantHeaderContigs makeVariantHeaderContigs(VariantHeader header):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantHeaderContigs contigs = VariantHeaderContigs.__new__(VariantHeaderContigs)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__91, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1871, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1871, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1870
 * 
 * cdef VariantHeaderContigs makeVariantHeaderContigs(VariantHeader header):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1873
 *         raise ValueError('invalid VariantHeader')
 * 
 *     cdef VariantHeaderContigs contigs = VariantHeaderContigs.__new__(VariantHeaderContigs)             # <<<<<<<<<<<<<<
 *     contigs.header = header
 * 
 */
  __pyx_t_3 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantHeaderContigs(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderContigs), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1873, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_contigs = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":1874
 * 
 *     cdef VariantHeaderContigs contigs = VariantHeaderContigs.__new__(VariantHeaderContigs)
 *     contigs.header = header             # <<<<<<<<<<<<<<
 * 
 *     return contigs
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_header));
  __Pyx_GOTREF(__pyx_v_contigs->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_contigs->header));
  __pyx_v_contigs->header = __pyx_v_header;

  /* "pysam/libcbcf.pyx":1876
 *     contigs.header = header
 * 
 *     return contigs             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_contigs));
  __pyx_r = __pyx_v_contigs;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1869
 * 
 * 
 * cdef VariantHeaderContigs makeVariantHeaderContigs(VariantHeader header):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantHeaderContigs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_contigs);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1881
 * cdef class VariantHeaderSamples(object):
 *     """sequence of sample names from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 1881, 0, __PYX_ERR(0, 1881, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1882
 *     """sequence of sample names from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1882, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 1882, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1881
 * cdef class VariantHeaderSamples(object):
 *     """sequence of sample names from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderSamples.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1884
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return bcf_hdr_nsamples(self.header.ptr)
 * 
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_3__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_3__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_2__len__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);
  __Pyx_TraceCall("__len__", __pyx_f[0], 1884, 0, __PYX_ERR(0, 1884, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1885
 * 
 *     def __len__(self):
 *         return bcf_hdr_nsamples(self.header.ptr)             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
  __pyx_r = bcf_hdr_nsamples(__pyx_v_self->header->ptr);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1884
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return bcf_hdr_nsamples(self.header.ptr)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderSamples.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1887
 *         return bcf_hdr_nsamples(self.header.ptr)
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         return bcf_hdr_nsamples(self.header.ptr) != 0
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_5__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_5__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_4__bool__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__", 0);
  __Pyx_TraceCall("__bool__", __pyx_f[0], 1887, 0, __PYX_ERR(0, 1887, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1888
 * 
 *     def __bool__(self):
 *         return bcf_hdr_nsamples(self.header.ptr) != 0             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, index):
 */
  __pyx_r = (bcf_hdr_nsamples(__pyx_v_self->header->ptr) != 0);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1887
 *         return bcf_hdr_nsamples(self.header.ptr)
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         return bcf_hdr_nsamples(self.header.ptr) != 0
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderSamples.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1890
 *         return bcf_hdr_nsamples(self.header.ptr) != 0
 * 
 *     def __getitem__(self, index):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int32_t n = bcf_hdr_nsamples(hdr)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_6__getitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)__pyx_v_self), ((PyObject *)__pyx_v_index));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self, PyObject *__pyx_v_index) {
  bcf_hdr_t *__pyx_v_hdr;
  int32_t __pyx_v_n;
  int32_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_TraceCall("__getitem__", __pyx_f[0], 1890, 0, __PYX_ERR(0, 1890, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1891
 * 
 *     def __getitem__(self, index):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef int32_t n = bcf_hdr_nsamples(hdr)
 *         cdef int32_t i = index
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1892
 *     def __getitem__(self, index):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int32_t n = bcf_hdr_nsamples(hdr)             # <<<<<<<<<<<<<<
 *         cdef int32_t i = index
 * 
 */
  __pyx_v_n = bcf_hdr_nsamples(__pyx_v_hdr);

  /* "pysam/libcbcf.pyx":1893
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int32_t n = bcf_hdr_nsamples(hdr)
 *         cdef int32_t i = index             # <<<<<<<<<<<<<<
 * 
 *         if i < 0 or i >= n:
 */
  __pyx_t_2 = __Pyx_PyInt_As_int32_t(__pyx_v_index); if (unlikely((__pyx_t_2 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1893, __pyx_L1_error)
  __pyx_v_i = __pyx_t_2;

  /* "pysam/libcbcf.pyx":1895
 *         cdef int32_t i = index
 * 
 *         if i < 0 or i >= n:             # <<<<<<<<<<<<<<
 *             raise IndexError('invalid sample index')
 * 
 */
  __pyx_t_4 = ((__pyx_v_i < 0) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_i >= __pyx_v_n) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":1896
 * 
 *         if i < 0 or i >= n:
 *             raise IndexError('invalid sample index')             # <<<<<<<<<<<<<<
 * 
 *         return charptr_to_str(hdr.samples[i])
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__93, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1896, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 1896, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1895
 *         cdef int32_t i = index
 * 
 *         if i < 0 or i >= n:             # <<<<<<<<<<<<<<
 *             raise IndexError('invalid sample index')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1898
 *             raise IndexError('invalid sample index')
 * 
 *         return charptr_to_str(hdr.samples[i])             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_v_hdr->samples[__pyx_v_i]), NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1898, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1890
 *         return bcf_hdr_nsamples(self.header.ptr) != 0
 * 
 *     def __getitem__(self, index):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int32_t n = bcf_hdr_nsamples(hdr)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderSamples.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_20VariantHeaderSamples_10generator10(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":1900
 *         return charptr_to_str(hdr.samples[i])
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int32_t i, n = bcf_hdr_nsamples(hdr)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_9__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_9__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_8__iter__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_8__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__ *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__ *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_20___iter__(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_20___iter__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1900, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_20VariantHeaderSamples_10generator10, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_VariantHeaderSamples___iter, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 1900, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderSamples.__iter__", __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_5pysam_7libcbcf_20VariantHeaderSamples_10generator10(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__ *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hdr_t *__pyx_t_1;
  int32_t __pyx_t_2;
  int32_t __pyx_t_3;
  int32_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 1900, 0, __PYX_ERR(0, 1900, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1900, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":1901
 * 
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef int32_t i, n = bcf_hdr_nsamples(hdr)
 * 
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->header->ptr;
  __pyx_cur_scope->__pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1902
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int32_t i, n = bcf_hdr_nsamples(hdr)             # <<<<<<<<<<<<<<
 * 
 *         for i in range(n):
 */
  __pyx_cur_scope->__pyx_v_n = bcf_hdr_nsamples(__pyx_cur_scope->__pyx_v_hdr);

  /* "pysam/libcbcf.pyx":1904
 *         cdef int32_t i, n = bcf_hdr_nsamples(hdr)
 * 
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             yield charptr_to_str(hdr.samples[i])
 * 
 */
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_n;
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_4;

    /* "pysam/libcbcf.pyx":1905
 * 
 *         for i in range(n):
 *             yield charptr_to_str(hdr.samples[i])             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
    __pyx_t_5 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_cur_scope->__pyx_v_hdr->samples[__pyx_cur_scope->__pyx_v_i]), NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1905, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_4;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1905, __pyx_L1_error)
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":1900
 *         return charptr_to_str(hdr.samples[i])
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int32_t i, n = bcf_hdr_nsamples(hdr)
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1907
 *             yield charptr_to_str(hdr.samples[i])
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_SAMPLE]
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_12__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_12__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_11__contains__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_11__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  vdict_t *__pyx_v_d;
  PyObject *__pyx_v_bkey = 0;
  khiter_t __pyx_v_k;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  char const *__pyx_t_3;
  __Pyx_RefNannySetupContext("__contains__", 0);
  __Pyx_TraceCall("__contains__", __pyx_f[0], 1907, 0, __PYX_ERR(0, 1907, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1908
 * 
 *     def __contains__(self, key):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_SAMPLE]
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":1909
 *     def __contains__(self, key):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_SAMPLE]             # <<<<<<<<<<<<<<
 *         cdef bytes bkey = force_bytes(key)
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 */
  __pyx_v_d = ((vdict_t *)(__pyx_v_hdr->dict[BCF_DT_SAMPLE]));

  /* "pysam/libcbcf.pyx":1910
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_SAMPLE]
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 * 
 */
  __pyx_t_2 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_bkey = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":1911
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_SAMPLE]
 *         cdef bytes bkey = force_bytes(key)
 *         cdef khiter_t k = kh_get_vdict(d, bkey)             # <<<<<<<<<<<<<<
 * 
 *         return k != kh_end(d)
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 1911, __pyx_L1_error)
  }
  __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 1911, __pyx_L1_error)
  __pyx_v_k = kh_get_vdict(__pyx_v_d, __pyx_t_3);

  /* "pysam/libcbcf.pyx":1913
 *         cdef khiter_t k = kh_get_vdict(d, bkey)
 * 
 *         return k != kh_end(d)             # <<<<<<<<<<<<<<
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 */
  __pyx_r = (__pyx_v_k != kh_end(__pyx_v_d));
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1907
 *             yield charptr_to_str(hdr.samples[i])
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef vdict_t *d = <vdict_t *>hdr.dict[BCF_DT_SAMPLE]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderSamples.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1920
 *     #TODO: implement __richcmp__
 * 
 *     def add(self, name):             # <<<<<<<<<<<<<<
 *         """Add a new sample"""
 *         self.header.add_sample(name)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_14add(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderSamples_13add[] = "VariantHeaderSamples.add(self, name)\nAdd a new sample";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_14add(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_13add(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)__pyx_v_self), ((PyObject *)__pyx_v_name));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_13add(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("add", 0);
  __Pyx_TraceCall("add", __pyx_f[0], 1920, 0, __PYX_ERR(0, 1920, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1922
 *     def add(self, name):
 *         """Add a new sample"""
 *         self.header.add_sample(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->header), __pyx_n_s_add_sample); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1922, __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_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1922, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_name};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1922, __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[2] = {__pyx_t_3, __pyx_v_name};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1922, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1922, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_name);
      __Pyx_GIVEREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_name);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1922, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":1920
 *     #TODO: implement __richcmp__
 * 
 *     def add(self, name):             # <<<<<<<<<<<<<<
 *         """Add a new sample"""
 *         self.header.add_sample(name)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderSamples.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":58
 * 
 * cdef class VariantHeaderSamples(object):
 *     cdef readonly VariantHeader header             # <<<<<<<<<<<<<<
 * 
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_6header_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_6header_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_6header___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 58, 0, __PYX_ERR(1, 58, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __pyx_r = ((PyObject *)__pyx_v_self->header);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderSamples.header.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.header,)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_16__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderSamples_15__reduce_cython__[] = "VariantHeaderSamples.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_16__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_15__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_15__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.header,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->header));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->header));
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.header,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":5
 *     state = (self.header,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.header is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.header,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.header is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_VariantHeaderSamples, (type(self), 0x099fb99, None), state
 */
  /*else*/ {
    __pyx_t_3 = (((PyObject *)__pyx_v_self->header) != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.header is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantHeaderSamples, (type(self), 0x099fb99, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":11
 *         use_setstate = self.header is not None
 *     if use_setstate:
 *         return __pyx_unpickle_VariantHeaderSamples, (type(self), 0x099fb99, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_VariantHeaderSamples, (type(self), 0x099fb99, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantHeaderSamp); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_10091417);
    __Pyx_GIVEREF(__pyx_int_10091417);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_10091417);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.header is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantHeaderSamples, (type(self), 0x099fb99, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_VariantHeaderSamples, (type(self), 0x099fb99, None), state
 *     else:
 *         return __pyx_unpickle_VariantHeaderSamples, (type(self), 0x099fb99, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantHeaderSamples__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantHeaderSamp); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_10091417);
    __Pyx_GIVEREF(__pyx_int_10091417);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_10091417);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.header,)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderSamples.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantHeaderSamples, (type(self), 0x099fb99, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantHeaderSamples__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_18__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantHeaderSamples_17__setstate_cython__[] = "VariantHeaderSamples.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_18__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_17__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantHeaderSamples_17__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 14, 0, __PYX_ERR(2, 14, __pyx_L1_error));

  /* "(tree fragment)":15
 *         return __pyx_unpickle_VariantHeaderSamples, (type(self), 0x099fb99, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantHeaderSamples__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderSamples__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantHeaderSamples, (type(self), 0x099fb99, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantHeaderSamples__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeaderSamples.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1925
 * 
 * 
 * cdef VariantHeaderSamples makeVariantHeaderSamples(VariantHeader header):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_f_5pysam_7libcbcf_makeVariantHeaderSamples(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v_samples = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("makeVariantHeaderSamples", 0);
  __Pyx_TraceCall("makeVariantHeaderSamples", __pyx_f[0], 1925, 0, __PYX_ERR(0, 1925, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1926
 * 
 * cdef VariantHeaderSamples makeVariantHeaderSamples(VariantHeader header):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_header)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1926, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1927
 * cdef VariantHeaderSamples makeVariantHeaderSamples(VariantHeader header):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantHeaderSamples samples = VariantHeaderSamples.__new__(VariantHeaderSamples)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__94, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1927, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1927, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1926
 * 
 * cdef VariantHeaderSamples makeVariantHeaderSamples(VariantHeader header):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1929
 *         raise ValueError('invalid VariantHeader')
 * 
 *     cdef VariantHeaderSamples samples = VariantHeaderSamples.__new__(VariantHeaderSamples)             # <<<<<<<<<<<<<<
 *     samples.header = header
 * 
 */
  __pyx_t_3 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantHeaderSamples(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderSamples), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1929, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_samples = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":1930
 * 
 *     cdef VariantHeaderSamples samples = VariantHeaderSamples.__new__(VariantHeaderSamples)
 *     samples.header = header             # <<<<<<<<<<<<<<
 * 
 *     return samples
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_header));
  __Pyx_GOTREF(__pyx_v_samples->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_samples->header));
  __pyx_v_samples->header = __pyx_v_header;

  /* "pysam/libcbcf.pyx":1932
 *     samples.header = header
 * 
 *     return samples             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_samples));
  __pyx_r = __pyx_v_samples;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1925
 * 
 * 
 * cdef VariantHeaderSamples makeVariantHeaderSamples(VariantHeader header):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantHeaderSamples", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_samples);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1942
 * 
 *     # See makeVariantHeader for C constructor
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.ptr = NULL
 * 
 */

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

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

static int __pyx_pf_5pysam_7libcbcf_13VariantHeader___cinit__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);
  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1942, 0, __PYX_ERR(0, 1942, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1943
 *     # See makeVariantHeader for C constructor
 *     def __cinit__(self):
 *         self.ptr = NULL             # <<<<<<<<<<<<<<
 * 
 *     # Python constructor
 */
  __pyx_v_self->ptr = NULL;

  /* "pysam/libcbcf.pyx":1942
 * 
 *     # See makeVariantHeader for C constructor
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.ptr = NULL
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1946
 * 
 *     # Python constructor
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.ptr = bcf_hdr_init(b'w')
 *         if not self.ptr:
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantHeader_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantHeader_3__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_5pysam_7libcbcf_13VariantHeader_2__init__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantHeader_2__init__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 1946, 0, __PYX_ERR(0, 1946, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1947
 *     # Python constructor
 *     def __init__(self):
 *         self.ptr = bcf_hdr_init(b'w')             # <<<<<<<<<<<<<<
 *         if not self.ptr:
 *             raise ValueError('cannot create VariantHeader')
 */
  __pyx_v_self->ptr = bcf_hdr_init(((char const *)"w"));

  /* "pysam/libcbcf.pyx":1948
 *     def __init__(self):
 *         self.ptr = bcf_hdr_init(b'w')
 *         if not self.ptr:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot create VariantHeader')
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_self->ptr != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":1949
 *         self.ptr = bcf_hdr_init(b'w')
 *         if not self.ptr:
 *             raise ValueError('cannot create VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__95, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1949, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 1949, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1948
 *     def __init__(self):
 *         self.ptr = bcf_hdr_init(b'w')
 *         if not self.ptr:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot create VariantHeader')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":1946
 * 
 *     # Python constructor
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.ptr = bcf_hdr_init(b'w')
 *         if not self.ptr:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1951
 *             raise ValueError('cannot create VariantHeader')
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.ptr:
 *             bcf_hdr_destroy(self.ptr)
 */

/* Python wrapper */
static void __pyx_pw_5pysam_7libcbcf_13VariantHeader_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5pysam_7libcbcf_13VariantHeader_5__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5pysam_7libcbcf_13VariantHeader_4__dealloc__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static void __pyx_pf_5pysam_7libcbcf_13VariantHeader_4__dealloc__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);
  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1951, 0, __PYX_ERR(0, 1951, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1952
 * 
 *     def __dealloc__(self):
 *         if self.ptr:             # <<<<<<<<<<<<<<
 *             bcf_hdr_destroy(self.ptr)
 *             self.ptr = NULL
 */
  __pyx_t_1 = (__pyx_v_self->ptr != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":1953
 *     def __dealloc__(self):
 *         if self.ptr:
 *             bcf_hdr_destroy(self.ptr)             # <<<<<<<<<<<<<<
 *             self.ptr = NULL
 * 
 */
    bcf_hdr_destroy(__pyx_v_self->ptr);

    /* "pysam/libcbcf.pyx":1954
 *         if self.ptr:
 *             bcf_hdr_destroy(self.ptr)
 *             self.ptr = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
    __pyx_v_self->ptr = NULL;

    /* "pysam/libcbcf.pyx":1952
 * 
 *     def __dealloc__(self):
 *         if self.ptr:             # <<<<<<<<<<<<<<
 *             bcf_hdr_destroy(self.ptr)
 *             self.ptr = NULL
 */
  }

  /* "pysam/libcbcf.pyx":1951
 *             raise ValueError('cannot create VariantHeader')
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.ptr:
 *             bcf_hdr_destroy(self.ptr)
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pysam.libcbcf.VariantHeader.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
}

/* "pysam/libcbcf.pyx":1956
 *             self.ptr = NULL
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         return self.ptr != NULL
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantHeader_7__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantHeader_7__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_6__bool__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantHeader_6__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__", 0);
  __Pyx_TraceCall("__bool__", __pyx_f[0], 1956, 0, __PYX_ERR(0, 1956, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1957
 * 
 *     def __bool__(self):
 *         return self.ptr != NULL             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  __pyx_r = (__pyx_v_self->ptr != NULL);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1956
 *             self.ptr = NULL
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         return self.ptr != NULL
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1959
 *         return self.ptr != NULL
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         return makeVariantHeader(bcf_hdr_dup(self.ptr))
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_9copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantHeader_8copy[] = "VariantHeader.copy(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_9copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_8copy(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_8copy(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("copy", 0);
  __Pyx_TraceCall("copy", __pyx_f[0], 1959, 0, __PYX_ERR(0, 1959, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1960
 * 
 *     def copy(self):
 *         return makeVariantHeader(bcf_hdr_dup(self.ptr))             # <<<<<<<<<<<<<<
 * 
 *     def merge(self, VariantHeader header):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeader(bcf_hdr_dup(__pyx_v_self->ptr))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1959
 *         return self.ptr != NULL
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         return makeVariantHeader(bcf_hdr_dup(self.ptr))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1962
 *         return makeVariantHeader(bcf_hdr_dup(self.ptr))
 * 
 *     def merge(self, VariantHeader header):             # <<<<<<<<<<<<<<
 *         if header is None:
 *             raise ValueError('header must not be None')
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_11merge(PyObject *__pyx_v_self, PyObject *__pyx_v_header); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantHeader_10merge[] = "VariantHeader.merge(self, VariantHeader header)";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_11merge(PyObject *__pyx_v_self, PyObject *__pyx_v_header) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("merge (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_header), __pyx_ptype_5pysam_7libcbcf_VariantHeader, 1, "header", 0))) __PYX_ERR(0, 1962, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_10merge(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self), ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_header));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_10merge(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("merge", 0);
  __Pyx_TraceCall("merge", __pyx_f[0], 1962, 0, __PYX_ERR(0, 1962, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1963
 * 
 *     def merge(self, VariantHeader header):
 *         if header is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('header must not be None')
 *         bcf_hdr_merge(self.ptr, header.ptr)
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_header) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":1964
 *     def merge(self, VariantHeader header):
 *         if header is None:
 *             raise ValueError('header must not be None')             # <<<<<<<<<<<<<<
 *         bcf_hdr_merge(self.ptr, header.ptr)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__96, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1964, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1964, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":1963
 * 
 *     def merge(self, VariantHeader header):
 *         if header is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('header must not be None')
 *         bcf_hdr_merge(self.ptr, header.ptr)
 */
  }

  /* "pysam/libcbcf.pyx":1965
 *         if header is None:
 *             raise ValueError('header must not be None')
 *         bcf_hdr_merge(self.ptr, header.ptr)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  (void)(bcf_hdr_merge(__pyx_v_self->ptr, __pyx_v_header->ptr));

  /* "pysam/libcbcf.pyx":1962
 *         return makeVariantHeader(bcf_hdr_dup(self.ptr))
 * 
 *     def merge(self, VariantHeader header):             # <<<<<<<<<<<<<<
 *         if header is None:
 *             raise ValueError('header must not be None')
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.merge", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1968
 * 
 *     @property
 *     def version(self):             # <<<<<<<<<<<<<<
 *         """VCF version"""
 *         return force_str(bcf_hdr_get_version(self.ptr))
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_7version_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_7version_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_7version___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_7version___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1968, 0, __PYX_ERR(0, 1968, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1970
 *     def version(self):
 *         """VCF version"""
 *         return force_str(bcf_hdr_get_version(self.ptr))             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBytes_FromString(bcf_hdr_get_version(__pyx_v_self->ptr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1970, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_5pysam_9libcutils_force_str(__pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1970, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1968
 * 
 *     @property
 *     def version(self):             # <<<<<<<<<<<<<<
 *         """VCF version"""
 *         return force_str(bcf_hdr_get_version(self.ptr))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.version.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1973
 * 
 *     @property
 *     def samples(self):             # <<<<<<<<<<<<<<
 *         """samples (:class:`VariantHeaderSamples`)"""
 *         return makeVariantHeaderSamples(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_7samples_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_7samples_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_7samples___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_7samples___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1973, 0, __PYX_ERR(0, 1973, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1975
 *     def samples(self):
 *         """samples (:class:`VariantHeaderSamples`)"""
 *         return makeVariantHeaderSamples(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeaderSamples(__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1975, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1973
 * 
 *     @property
 *     def samples(self):             # <<<<<<<<<<<<<<
 *         """samples (:class:`VariantHeaderSamples`)"""
 *         return makeVariantHeaderSamples(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.samples.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1978
 * 
 *     @property
 *     def records(self):             # <<<<<<<<<<<<<<
 *         """header records (:class:`VariantHeaderRecords`)"""
 *         return makeVariantHeaderRecords(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_7records_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_7records_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_7records___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_7records___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1978, 0, __PYX_ERR(0, 1978, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1980
 *     def records(self):
 *         """header records (:class:`VariantHeaderRecords`)"""
 *         return makeVariantHeaderRecords(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeaderRecords(__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1980, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1978
 * 
 *     @property
 *     def records(self):             # <<<<<<<<<<<<<<
 *         """header records (:class:`VariantHeaderRecords`)"""
 *         return makeVariantHeaderRecords(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.records.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1983
 * 
 *     @property
 *     def contigs(self):             # <<<<<<<<<<<<<<
 *         """contig information (:class:`VariantHeaderContigs`)"""
 *         return makeVariantHeaderContigs(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_7contigs_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_7contigs_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_7contigs___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_7contigs___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1983, 0, __PYX_ERR(0, 1983, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1985
 *     def contigs(self):
 *         """contig information (:class:`VariantHeaderContigs`)"""
 *         return makeVariantHeaderContigs(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeaderContigs(__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1983
 * 
 *     @property
 *     def contigs(self):             # <<<<<<<<<<<<<<
 *         """contig information (:class:`VariantHeaderContigs`)"""
 *         return makeVariantHeaderContigs(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.contigs.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1988
 * 
 *     @property
 *     def filters(self):             # <<<<<<<<<<<<<<
 *         """filter metadata (:class:`VariantHeaderMetadata`)"""
 *         return makeVariantHeaderMetadata(self, BCF_HL_FLT)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_7filters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_7filters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_7filters___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_7filters___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1988, 0, __PYX_ERR(0, 1988, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1990
 *     def filters(self):
 *         """filter metadata (:class:`VariantHeaderMetadata`)"""
 *         return makeVariantHeaderMetadata(self, BCF_HL_FLT)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeaderMetadata(__pyx_v_self, BCF_HL_FLT)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1990, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1988
 * 
 *     @property
 *     def filters(self):             # <<<<<<<<<<<<<<
 *         """filter metadata (:class:`VariantHeaderMetadata`)"""
 *         return makeVariantHeaderMetadata(self, BCF_HL_FLT)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.filters.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1993
 * 
 *     @property
 *     def info(self):             # <<<<<<<<<<<<<<
 *         """info metadata (:class:`VariantHeaderMetadata`)"""
 *         return makeVariantHeaderMetadata(self, BCF_HL_INFO)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_4info_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_4info_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_4info___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_4info___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1993, 0, __PYX_ERR(0, 1993, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":1995
 *     def info(self):
 *         """info metadata (:class:`VariantHeaderMetadata`)"""
 *         return makeVariantHeaderMetadata(self, BCF_HL_INFO)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeaderMetadata(__pyx_v_self, BCF_HL_INFO)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1995, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1993
 * 
 *     @property
 *     def info(self):             # <<<<<<<<<<<<<<
 *         """info metadata (:class:`VariantHeaderMetadata`)"""
 *         return makeVariantHeaderMetadata(self, BCF_HL_INFO)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.info.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":1998
 * 
 *     @property
 *     def formats(self):             # <<<<<<<<<<<<<<
 *         """format metadata (:class:`VariantHeaderMetadata`)"""
 *         return makeVariantHeaderMetadata(self, BCF_HL_FMT)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_7formats_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_7formats_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_7formats___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_7formats___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 1998, 0, __PYX_ERR(0, 1998, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2000
 *     def formats(self):
 *         """format metadata (:class:`VariantHeaderMetadata`)"""
 *         return makeVariantHeaderMetadata(self, BCF_HL_FMT)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeaderMetadata(__pyx_v_self, BCF_HL_FMT)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2000, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":1998
 * 
 *     @property
 *     def formats(self):             # <<<<<<<<<<<<<<
 *         """format metadata (:class:`VariantHeaderMetadata`)"""
 *         return makeVariantHeaderMetadata(self, BCF_HL_FMT)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.formats.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2003
 * 
 *     @property
 *     def alts(self):             # <<<<<<<<<<<<<<
 *         """alt metadata (:class:`dict` ID->record).
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_4alts_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_4alts_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_4alts___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_4alts___get__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  PyObject *__pyx_8genexpr5__pyx_v_record = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 2003, 0, __PYX_ERR(0, 2003, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2013
 *         at the time it is created.
 *         """
 *         return {record['ID']:record for record in self.records             # <<<<<<<<<<<<<<
 *                 if record.key.upper() == 'ALT' }
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2013, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_records); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2013, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2013, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2013, __pyx_L5_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2013, __pyx_L5_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2013, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2013, __pyx_L5_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2013, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_5(__pyx_t_3);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2013, __pyx_L5_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_record, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "pysam/libcbcf.pyx":2014
 *         """
 *         return {record['ID']:record for record in self.records
 *                 if record.key.upper() == 'ALT' }             # <<<<<<<<<<<<<<
 * 
 *     # only safe to do when opening an htsfile
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr5__pyx_v_record, __pyx_n_s_key); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2014, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_upper); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2014, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (__pyx_t_6) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2014, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2014, __pyx_L5_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_ALT, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 2014, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_8) {

        /* "pysam/libcbcf.pyx":2013
 *         at the time it is created.
 *         """
 *         return {record['ID']:record for record in self.records             # <<<<<<<<<<<<<<
 *                 if record.key.upper() == 'ALT' }
 * 
 */
        __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_8genexpr5__pyx_v_record, __pyx_n_s_ID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2013, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_t_2, (PyObject*)__pyx_8genexpr5__pyx_v_record))) __PYX_ERR(0, 2013, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "pysam/libcbcf.pyx":2014
 *         """
 *         return {record['ID']:record for record in self.records
 *                 if record.key.upper() == 'ALT' }             # <<<<<<<<<<<<<<
 * 
 *     # only safe to do when opening an htsfile
 */
      }

      /* "pysam/libcbcf.pyx":2013
 *         at the time it is created.
 *         """
 *         return {record['ID']:record for record in self.records             # <<<<<<<<<<<<<<
 *                 if record.key.upper() == 'ALT' }
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_record); __pyx_8genexpr5__pyx_v_record = 0;
    goto __pyx_L9_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_record); __pyx_8genexpr5__pyx_v_record = 0;
    goto __pyx_L1_error;
    __pyx_L9_exit_scope:;
  } /* exit inner scope */
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2003
 * 
 *     @property
 *     def alts(self):             # <<<<<<<<<<<<<<
 *         """alt metadata (:class:`dict` ID->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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.alts.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_record);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2017
 * 
 *     # only safe to do when opening an htsfile
 *     cdef _subset_samples(self, include_samples):             # <<<<<<<<<<<<<<
 *         keep_samples    = set(self.samples)
 *         include_samples = set(include_samples)
 */

static PyObject *__pyx_f_5pysam_7libcbcf_13VariantHeader__subset_samples(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, PyObject *__pyx_v_include_samples) {
  PyObject *__pyx_v_keep_samples = NULL;
  PyObject *__pyx_v_missing_samples = NULL;
  char *__pyx_v_keep;
  PyObject *__pyx_v_ret = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  char *__pyx_t_8;
  char *__pyx_t_9;
  __Pyx_RefNannySetupContext("_subset_samples", 0);
  __Pyx_TraceCall("_subset_samples", __pyx_f[0], 2017, 0, __PYX_ERR(0, 2017, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_include_samples);

  /* "pysam/libcbcf.pyx":2018
 *     # only safe to do when opening an htsfile
 *     cdef _subset_samples(self, include_samples):
 *         keep_samples    = set(self.samples)             # <<<<<<<<<<<<<<
 *         include_samples = set(include_samples)
 *         missing_samples = include_samples - keep_samples
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_samples); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySet_New(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_keep_samples = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":2019
 *     cdef _subset_samples(self, include_samples):
 *         keep_samples    = set(self.samples)
 *         include_samples = set(include_samples)             # <<<<<<<<<<<<<<
 *         missing_samples = include_samples - keep_samples
 *         keep_samples   &= include_samples
 */
  __pyx_t_2 = PySet_New(__pyx_v_include_samples); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2019, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_include_samples, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":2020
 *         keep_samples    = set(self.samples)
 *         include_samples = set(include_samples)
 *         missing_samples = include_samples - keep_samples             # <<<<<<<<<<<<<<
 *         keep_samples   &= include_samples
 * 
 */
  __pyx_t_2 = PyNumber_Subtract(__pyx_v_include_samples, __pyx_v_keep_samples); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2020, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_missing_samples = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":2021
 *         include_samples = set(include_samples)
 *         missing_samples = include_samples - keep_samples
 *         keep_samples   &= include_samples             # <<<<<<<<<<<<<<
 * 
 *         if missing_samples:
 */
  __pyx_t_2 = PyNumber_InPlaceAnd(__pyx_v_keep_samples, __pyx_v_include_samples); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_keep_samples, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":2023
 *         keep_samples   &= include_samples
 * 
 *         if missing_samples:             # <<<<<<<<<<<<<<
 *             # FIXME: add specialized exception with payload
 *             raise ValueError(
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_missing_samples); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2023, __pyx_L1_error)
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2026
 *             # FIXME: add specialized exception with payload
 *             raise ValueError(
 *                 'missing {:d} requested samples'.format(             # <<<<<<<<<<<<<<
 *                     len(missing_samples)))
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_missing_d_requested_samples, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "pysam/libcbcf.pyx":2027
 *             raise ValueError(
 *                 'missing {:d} requested samples'.format(
 *                     len(missing_samples)))             # <<<<<<<<<<<<<<
 * 
 *         keep_samples = force_bytes(','.join(keep_samples))
 */
    __pyx_t_4 = PyObject_Length(__pyx_v_missing_samples); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2027, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2027, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2026, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2026, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2026, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __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, 2026, __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_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2026, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":2025
 *         if missing_samples:
 *             # FIXME: add specialized exception with payload
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'missing {:d} requested samples'.format(
 *                     len(missing_samples)))
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2025, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 2025, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2023
 *         keep_samples   &= include_samples
 * 
 *         if missing_samples:             # <<<<<<<<<<<<<<
 *             # FIXME: add specialized exception with payload
 *             raise ValueError(
 */
  }

  /* "pysam/libcbcf.pyx":2029
 *                     len(missing_samples)))
 * 
 *         keep_samples = force_bytes(','.join(keep_samples))             # <<<<<<<<<<<<<<
 *         cdef char *keep = <char *>keep_samples if keep_samples else NULL
 *         cdef ret = bcf_hdr_set_samples(self.ptr, keep, 0)
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__2, __pyx_v_keep_samples); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2029, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2029, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_keep_samples, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":2030
 * 
 *         keep_samples = force_bytes(','.join(keep_samples))
 *         cdef char *keep = <char *>keep_samples if keep_samples else NULL             # <<<<<<<<<<<<<<
 *         cdef ret = bcf_hdr_set_samples(self.ptr, keep, 0)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_keep_samples); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2030, __pyx_L1_error)
  if (__pyx_t_3) {
    __pyx_t_9 = __Pyx_PyObject_AsWritableString(__pyx_v_keep_samples); if (unlikely((!__pyx_t_9) && PyErr_Occurred())) __PYX_ERR(0, 2030, __pyx_L1_error)
    __pyx_t_8 = ((char *)__pyx_t_9);
  } else {
    __pyx_t_8 = NULL;
  }
  __pyx_v_keep = __pyx_t_8;

  /* "pysam/libcbcf.pyx":2031
 *         keep_samples = force_bytes(','.join(keep_samples))
 *         cdef char *keep = <char *>keep_samples if keep_samples else NULL
 *         cdef ret = bcf_hdr_set_samples(self.ptr, keep, 0)             # <<<<<<<<<<<<<<
 * 
 *         if ret != 0:
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(bcf_hdr_set_samples(__pyx_v_self->ptr, __pyx_v_keep, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2031, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_ret = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":2033
 *         cdef ret = bcf_hdr_set_samples(self.ptr, keep, 0)
 * 
 *         if ret != 0:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'bcf_hdr_set_samples failed: ret = {}'.format(ret))
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_ret, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2033, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2033, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2035
 *         if ret != 0:
 *             raise ValueError(
 *                 'bcf_hdr_set_samples failed: ret = {}'.format(ret))             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_bcf_hdr_set_samples_failed_ret, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2035, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2035, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_ret};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2035, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_ret};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2035, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2035, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_INCREF(__pyx_v_ret);
        __Pyx_GIVEREF(__pyx_v_ret);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_ret);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2035, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":2034
 * 
 *         if ret != 0:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'bcf_hdr_set_samples failed: ret = {}'.format(ret))
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2034, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 2034, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2033
 *         cdef ret = bcf_hdr_set_samples(self.ptr, keep, 0)
 * 
 *         if ret != 0:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'bcf_hdr_set_samples failed: ret = {}'.format(ret))
 */
  }

  /* "pysam/libcbcf.pyx":2017
 * 
 *     # only safe to do when opening an htsfile
 *     cdef _subset_samples(self, include_samples):             # <<<<<<<<<<<<<<
 *         keep_samples    = set(self.samples)
 *         include_samples = set(include_samples)
 */

  /* 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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader._subset_samples", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_keep_samples);
  __Pyx_XDECREF(__pyx_v_missing_samples);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_include_samples);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2037
 *                 'bcf_hdr_set_samples failed: ret = {}'.format(ret))
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         cdef int hlen
 *         cdef char *hstr = bcf_hdr_fmt_text(self.ptr, 0, &hlen)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_13__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_13__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_12__str__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_12__str__(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  int __pyx_v_hlen;
  char *__pyx_v_hstr;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  char const *__pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("__str__", 0);
  __Pyx_TraceCall("__str__", __pyx_f[0], 2037, 0, __PYX_ERR(0, 2037, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2039
 *     def __str__(self):
 *         cdef int hlen
 *         cdef char *hstr = bcf_hdr_fmt_text(self.ptr, 0, &hlen)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_v_hstr = bcf_hdr_fmt_text(__pyx_v_self->ptr, 0, (&__pyx_v_hlen));

  /* "pysam/libcbcf.pyx":2041
 *         cdef char *hstr = bcf_hdr_fmt_text(self.ptr, 0, &hlen)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             return charptr_to_str_w_len(hstr, hlen)
 *         finally:
 */
  /*try:*/ {

    /* "pysam/libcbcf.pyx":2042
 * 
 *         try:
 *             return charptr_to_str_w_len(hstr, hlen)             # <<<<<<<<<<<<<<
 *         finally:
 *             free(hstr)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __pyx_f_5pysam_9libcutils_charptr_to_str_w_len(__pyx_v_hstr, __pyx_v_hlen, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2042, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L3_return;
  }

  /* "pysam/libcbcf.pyx":2044
 *             return charptr_to_str_w_len(hstr, hlen)
 *         finally:
 *             free(hstr)             # <<<<<<<<<<<<<<
 * 
 *     def new_record(self, contig=None, start=0, stop=0, alleles=None,
 */
  /*finally:*/ {
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0)) __Pyx_ErrFetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __pyx_t_2 = __pyx_lineno; __pyx_t_3 = __pyx_clineno; __pyx_t_4 = __pyx_filename;
      {
        free(__pyx_v_hstr);
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ErrRestore(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0;
      __pyx_lineno = __pyx_t_2; __pyx_clineno = __pyx_t_3; __pyx_filename = __pyx_t_4;
      goto __pyx_L1_error;
    }
    __pyx_L3_return: {
      __pyx_t_10 = __pyx_r;
      __pyx_r = 0;
      free(__pyx_v_hstr);
      __pyx_r = __pyx_t_10;
      __pyx_t_10 = 0;
      goto __pyx_L0;
    }
  }

  /* "pysam/libcbcf.pyx":2037
 *                 'bcf_hdr_set_samples failed: ret = {}'.format(ret))
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         cdef int hlen
 *         cdef char *hstr = bcf_hdr_fmt_text(self.ptr, 0, &hlen)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2046
 *             free(hstr)
 * 
 *     def new_record(self, contig=None, start=0, stop=0, alleles=None,             # <<<<<<<<<<<<<<
 *                          id=None, qual=None, filter=None, info=None, samples=None,
 *                          **kwargs):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_15new_record(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantHeader_14new_record[] = "VariantHeader.new_record(self, contig=None, start=0, stop=0, alleles=None, id=None, qual=None, filter=None, info=None, samples=None, **kwargs)\nCreate a new empty VariantRecord.\n\n        Arguments are currently experimental.  Use with caution and expect\n        changes in upcoming releases.\n\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_15new_record(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_contig = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  PyObject *__pyx_v_alleles = 0;
  PyObject *__pyx_v_id = 0;
  PyObject *__pyx_v_qual = 0;
  PyObject *__pyx_v_filter = 0;
  PyObject *__pyx_v_info = 0;
  PyObject *__pyx_v_samples = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("new_record (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_contig,&__pyx_n_s_start,&__pyx_n_s_stop,&__pyx_n_s_alleles,&__pyx_n_s_id,&__pyx_n_s_qual,&__pyx_n_s_filter,&__pyx_n_s_info,&__pyx_n_s_samples,0};
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)__pyx_int_0);
    values[2] = ((PyObject *)__pyx_int_0);
    values[3] = ((PyObject *)Py_None);

    /* "pysam/libcbcf.pyx":2047
 * 
 *     def new_record(self, contig=None, start=0, stop=0, alleles=None,
 *                          id=None, qual=None, filter=None, info=None, samples=None,             # <<<<<<<<<<<<<<
 *                          **kwargs):
 *         """Create a new empty VariantRecord.
 */
    values[4] = ((PyObject *)Py_None);
    values[5] = ((PyObject *)Py_None);
    values[6] = ((PyObject *)Py_None);
    values[7] = ((PyObject *)Py_None);
    values[8] = ((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  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_contig);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stop);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alleles);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_id);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_qual);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_filter);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_info);
          if (value) { values[7] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_samples);
          if (value) { values[8] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "new_record") < 0)) __PYX_ERR(0, 2046, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_contig = values[0];
    __pyx_v_start = values[1];
    __pyx_v_stop = values[2];
    __pyx_v_alleles = values[3];
    __pyx_v_id = values[4];
    __pyx_v_qual = values[5];
    __pyx_v_filter = values[6];
    __pyx_v_info = values[7];
    __pyx_v_samples = values[8];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("new_record", 0, 0, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2046, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.new_record", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_14new_record(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self), __pyx_v_contig, __pyx_v_start, __pyx_v_stop, __pyx_v_alleles, __pyx_v_id, __pyx_v_qual, __pyx_v_filter, __pyx_v_info, __pyx_v_samples, __pyx_v_kwargs);

  /* "pysam/libcbcf.pyx":2046
 *             free(hstr)
 * 
 *     def new_record(self, contig=None, start=0, stop=0, alleles=None,             # <<<<<<<<<<<<<<
 *                          id=None, qual=None, filter=None, info=None, samples=None,
 *                          **kwargs):
 */

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_14new_record(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_alleles, PyObject *__pyx_v_id, PyObject *__pyx_v_qual, PyObject *__pyx_v_filter, PyObject *__pyx_v_info, PyObject *__pyx_v_samples, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_rec = NULL;
  PyObject *__pyx_v_f = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_sample = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("new_record", 0);
  __Pyx_TraceCall("new_record", __pyx_f[0], 2046, 0, __PYX_ERR(0, 2046, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2055
 * 
 *         """
 *         rec = makeVariantRecord(self, bcf_init())             # <<<<<<<<<<<<<<
 * 
 *         if not rec:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantRecord(__pyx_v_self, bcf_init())); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_rec = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":2057
 *         rec = makeVariantRecord(self, bcf_init())
 * 
 *         if not rec:             # <<<<<<<<<<<<<<
 *             raise MemoryError('unable to allocate BCF record')
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_rec)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2057, __pyx_L1_error)
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2058
 * 
 *         if not rec:
 *             raise MemoryError('unable to allocate BCF record')             # <<<<<<<<<<<<<<
 * 
 *         rec.ptr.n_sample = bcf_hdr_nsamples(self.ptr)
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__97, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2058, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 2058, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2057
 *         rec = makeVariantRecord(self, bcf_init())
 * 
 *         if not rec:             # <<<<<<<<<<<<<<
 *             raise MemoryError('unable to allocate BCF record')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2060
 *             raise MemoryError('unable to allocate BCF record')
 * 
 *         rec.ptr.n_sample = bcf_hdr_nsamples(self.ptr)             # <<<<<<<<<<<<<<
 * 
 *         if contig is not None:
 */
  __pyx_v_rec->ptr->n_sample = bcf_hdr_nsamples(__pyx_v_self->ptr);

  /* "pysam/libcbcf.pyx":2062
 *         rec.ptr.n_sample = bcf_hdr_nsamples(self.ptr)
 * 
 *         if contig is not None:             # <<<<<<<<<<<<<<
 *             rec.contig  = contig
 *         if alleles is not None:
 */
  __pyx_t_3 = (__pyx_v_contig != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":2063
 * 
 *         if contig is not None:
 *             rec.contig  = contig             # <<<<<<<<<<<<<<
 *         if alleles is not None:
 *             rec.alleles = alleles
 */
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_contig, __pyx_v_contig) < 0) __PYX_ERR(0, 2063, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2062
 *         rec.ptr.n_sample = bcf_hdr_nsamples(self.ptr)
 * 
 *         if contig is not None:             # <<<<<<<<<<<<<<
 *             rec.contig  = contig
 *         if alleles is not None:
 */
  }

  /* "pysam/libcbcf.pyx":2064
 *         if contig is not None:
 *             rec.contig  = contig
 *         if alleles is not None:             # <<<<<<<<<<<<<<
 *             rec.alleles = alleles
 * 
 */
  __pyx_t_2 = (__pyx_v_alleles != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":2065
 *             rec.contig  = contig
 *         if alleles is not None:
 *             rec.alleles = alleles             # <<<<<<<<<<<<<<
 * 
 *         rec.start = start
 */
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_alleles, __pyx_v_alleles) < 0) __PYX_ERR(0, 2065, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2064
 *         if contig is not None:
 *             rec.contig  = contig
 *         if alleles is not None:             # <<<<<<<<<<<<<<
 *             rec.alleles = alleles
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2067
 *             rec.alleles = alleles
 * 
 *         rec.start = start             # <<<<<<<<<<<<<<
 *         rec.stop  = stop
 *         rec.id    = id
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_start, __pyx_v_start) < 0) __PYX_ERR(0, 2067, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2068
 * 
 *         rec.start = start
 *         rec.stop  = stop             # <<<<<<<<<<<<<<
 *         rec.id    = id
 *         rec.qual  = qual
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_stop, __pyx_v_stop) < 0) __PYX_ERR(0, 2068, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2069
 *         rec.start = start
 *         rec.stop  = stop
 *         rec.id    = id             # <<<<<<<<<<<<<<
 *         rec.qual  = qual
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_id, __pyx_v_id) < 0) __PYX_ERR(0, 2069, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2070
 *         rec.stop  = stop
 *         rec.id    = id
 *         rec.qual  = qual             # <<<<<<<<<<<<<<
 * 
 *         if filter is not None:
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_qual, __pyx_v_qual) < 0) __PYX_ERR(0, 2070, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2072
 *         rec.qual  = qual
 * 
 *         if filter is not None:             # <<<<<<<<<<<<<<
 *             if isinstance(filter, (list, tuple, VariantRecordFilter)):
 *                 for f in filter:
 */
  __pyx_t_3 = (__pyx_v_filter != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":2073
 * 
 *         if filter is not None:
 *             if isinstance(filter, (list, tuple, VariantRecordFilter)):             # <<<<<<<<<<<<<<
 *                 for f in filter:
 *                     rec.filter.add(f)
 */
    __pyx_t_3 = PyList_Check(__pyx_v_filter); 
    __pyx_t_4 = (__pyx_t_3 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_4 = PyTuple_Check(__pyx_v_filter); 
    __pyx_t_3 = (__pyx_t_4 != 0);
    if (!__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_filter, __pyx_ptype_5pysam_7libcbcf_VariantRecordFilter); 
    __pyx_t_4 = (__pyx_t_3 != 0);
    __pyx_t_2 = __pyx_t_4;
    __pyx_L8_bool_binop_done:;
    __pyx_t_4 = (__pyx_t_2 != 0);
    if (__pyx_t_4) {

      /* "pysam/libcbcf.pyx":2074
 *         if filter is not None:
 *             if isinstance(filter, (list, tuple, VariantRecordFilter)):
 *                 for f in filter:             # <<<<<<<<<<<<<<
 *                     rec.filter.add(f)
 *             else:
 */
      if (likely(PyList_CheckExact(__pyx_v_filter)) || PyTuple_CheckExact(__pyx_v_filter)) {
        __pyx_t_1 = __pyx_v_filter; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
        __pyx_t_6 = NULL;
      } else {
        __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_filter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2074, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2074, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_6)) {
          if (likely(PyList_CheckExact(__pyx_t_1))) {
            if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 2074, __pyx_L1_error)
            #else
            __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2074, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_7);
            #endif
          } else {
            if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 2074, __pyx_L1_error)
            #else
            __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2074, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_7);
            #endif
          }
        } else {
          __pyx_t_7 = __pyx_t_6(__pyx_t_1);
          if (unlikely(!__pyx_t_7)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 2074, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_XDECREF_SET(__pyx_v_f, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "pysam/libcbcf.pyx":2075
 *             if isinstance(filter, (list, tuple, VariantRecordFilter)):
 *                 for f in filter:
 *                     rec.filter.add(f)             # <<<<<<<<<<<<<<
 *             else:
 *                 rec.filter.add(filter)
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_filter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2075, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_add); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2075, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
          }
        }
        if (!__pyx_t_8) {
          __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_f); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2075, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_9)) {
            PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_f};
            __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2075, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_GOTREF(__pyx_t_7);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
            PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_f};
            __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2075, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_GOTREF(__pyx_t_7);
          } else
          #endif
          {
            __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2075, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
            __Pyx_INCREF(__pyx_v_f);
            __Pyx_GIVEREF(__pyx_v_f);
            PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_f);
            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2075, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "pysam/libcbcf.pyx":2074
 *         if filter is not None:
 *             if isinstance(filter, (list, tuple, VariantRecordFilter)):
 *                 for f in filter:             # <<<<<<<<<<<<<<
 *                     rec.filter.add(f)
 *             else:
 */
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pysam/libcbcf.pyx":2073
 * 
 *         if filter is not None:
 *             if isinstance(filter, (list, tuple, VariantRecordFilter)):             # <<<<<<<<<<<<<<
 *                 for f in filter:
 *                     rec.filter.add(f)
 */
      goto __pyx_L7;
    }

    /* "pysam/libcbcf.pyx":2077
 *                     rec.filter.add(f)
 *             else:
 *                 rec.filter.add(filter)             # <<<<<<<<<<<<<<
 * 
 *         if info:
 */
    /*else*/ {
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_filter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2077, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_add); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2077, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_7) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_filter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2077, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_filter};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2077, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_filter};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2077, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2077, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
          __Pyx_INCREF(__pyx_v_filter);
          __Pyx_GIVEREF(__pyx_v_filter);
          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_filter);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2077, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L7:;

    /* "pysam/libcbcf.pyx":2072
 *         rec.qual  = qual
 * 
 *         if filter is not None:             # <<<<<<<<<<<<<<
 *             if isinstance(filter, (list, tuple, VariantRecordFilter)):
 *                 for f in filter:
 */
  }

  /* "pysam/libcbcf.pyx":2079
 *                 rec.filter.add(filter)
 * 
 *         if info:             # <<<<<<<<<<<<<<
 *             rec.info.update(info)
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_info); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2079, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "pysam/libcbcf.pyx":2080
 * 
 *         if info:
 *             rec.info.update(info)             # <<<<<<<<<<<<<<
 * 
 *         if kwargs:
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2080, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_update); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2080, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2080, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_info};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2080, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_info};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2080, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2080, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_INCREF(__pyx_v_info);
        __Pyx_GIVEREF(__pyx_v_info);
        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_info);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2080, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":2079
 *                 rec.filter.add(filter)
 * 
 *         if info:             # <<<<<<<<<<<<<<
 *             rec.info.update(info)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2082
 *             rec.info.update(info)
 * 
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             if 'GT' in kwargs:
 *                 rec.samples[0]['GT'] = kwargs.pop('GT')
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2082, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "pysam/libcbcf.pyx":2083
 * 
 *         if kwargs:
 *             if 'GT' in kwargs:             # <<<<<<<<<<<<<<
 *                 rec.samples[0]['GT'] = kwargs.pop('GT')
 *             rec.samples[0].update(kwargs)
 */
    __pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_GT, __pyx_v_kwargs, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2083, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_4 != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":2084
 *         if kwargs:
 *             if 'GT' in kwargs:
 *                 rec.samples[0]['GT'] = kwargs.pop('GT')             # <<<<<<<<<<<<<<
 *             rec.samples[0].update(kwargs)
 * 
 */
      __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_GT, ((PyObject *)NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2084, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_samples); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2084, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_10, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2084, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(PyObject_SetItem(__pyx_t_7, __pyx_n_s_GT, __pyx_t_1) < 0)) __PYX_ERR(0, 2084, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pysam/libcbcf.pyx":2083
 * 
 *         if kwargs:
 *             if 'GT' in kwargs:             # <<<<<<<<<<<<<<
 *                 rec.samples[0]['GT'] = kwargs.pop('GT')
 *             rec.samples[0].update(kwargs)
 */
    }

    /* "pysam/libcbcf.pyx":2085
 *             if 'GT' in kwargs:
 *                 rec.samples[0]['GT'] = kwargs.pop('GT')
 *             rec.samples[0].update(kwargs)             # <<<<<<<<<<<<<<
 * 
 *         if samples:
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_samples); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2085, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_7, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2085, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2085, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2085, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_kwargs};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2085, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_kwargs};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2085, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2085, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_kwargs);
        __Pyx_GIVEREF(__pyx_v_kwargs);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_kwargs);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2085, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":2082
 *             rec.info.update(info)
 * 
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             if 'GT' in kwargs:
 *                 rec.samples[0]['GT'] = kwargs.pop('GT')
 */
  }

  /* "pysam/libcbcf.pyx":2087
 *             rec.samples[0].update(kwargs)
 * 
 *         if samples:             # <<<<<<<<<<<<<<
 *             for i, sample in enumerate(samples):
 *                 if 'GT' in sample:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_samples); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2087, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":2088
 * 
 *         if samples:
 *             for i, sample in enumerate(samples):             # <<<<<<<<<<<<<<
 *                 if 'GT' in sample:
 *                     rec.samples[i]['GT'] = sample.pop('GT')
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;
    if (likely(PyList_CheckExact(__pyx_v_samples)) || PyTuple_CheckExact(__pyx_v_samples)) {
      __pyx_t_7 = __pyx_v_samples; __Pyx_INCREF(__pyx_t_7); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_samples); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2088, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2088, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 2088, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_7, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2088, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 2088, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_7, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2088, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_6(__pyx_t_7);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2088, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_v_sample, __pyx_t_9);
      __pyx_t_9 = 0;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
      __pyx_t_9 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2088, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_1);
      __pyx_t_1 = __pyx_t_9;
      __pyx_t_9 = 0;

      /* "pysam/libcbcf.pyx":2089
 *         if samples:
 *             for i, sample in enumerate(samples):
 *                 if 'GT' in sample:             # <<<<<<<<<<<<<<
 *                     rec.samples[i]['GT'] = sample.pop('GT')
 *                 rec.samples[i].update(sample)
 */
      __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_GT, __pyx_v_sample, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2089, __pyx_L1_error)
      __pyx_t_4 = (__pyx_t_2 != 0);
      if (__pyx_t_4) {

        /* "pysam/libcbcf.pyx":2090
 *             for i, sample in enumerate(samples):
 *                 if 'GT' in sample:
 *                     rec.samples[i]['GT'] = sample.pop('GT')             # <<<<<<<<<<<<<<
 *                 rec.samples[i].update(sample)
 * 
 */
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_sample, __pyx_n_s_pop); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2090, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__98, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2090, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_samples); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2090, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_t_9, __pyx_v_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2090, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(PyObject_SetItem(__pyx_t_8, __pyx_n_s_GT, __pyx_t_10) < 0)) __PYX_ERR(0, 2090, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "pysam/libcbcf.pyx":2089
 *         if samples:
 *             for i, sample in enumerate(samples):
 *                 if 'GT' in sample:             # <<<<<<<<<<<<<<
 *                     rec.samples[i]['GT'] = sample.pop('GT')
 *                 rec.samples[i].update(sample)
 */
      }

      /* "pysam/libcbcf.pyx":2091
 *                 if 'GT' in sample:
 *                     rec.samples[i]['GT'] = sample.pop('GT')
 *                 rec.samples[i].update(sample)             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_rec), __pyx_n_s_samples); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2091, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_8, __pyx_v_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2091, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2091, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_sample); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2091, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_sample};
          __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2091, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_10);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_sample};
          __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2091, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_10);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2091, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
          __Pyx_INCREF(__pyx_v_sample);
          __Pyx_GIVEREF(__pyx_v_sample);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_sample);
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2091, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "pysam/libcbcf.pyx":2088
 * 
 *         if samples:
 *             for i, sample in enumerate(samples):             # <<<<<<<<<<<<<<
 *                 if 'GT' in sample:
 *                     rec.samples[i]['GT'] = sample.pop('GT')
 */
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":2087
 *             rec.samples[0].update(kwargs)
 * 
 *         if samples:             # <<<<<<<<<<<<<<
 *             for i, sample in enumerate(samples):
 *                 if 'GT' in sample:
 */
  }

  /* "pysam/libcbcf.pyx":2093
 *                 rec.samples[i].update(sample)
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 *     def add_record(self, VariantHeaderRecord record):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_rec));
  __pyx_r = ((PyObject *)__pyx_v_rec);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2046
 *             free(hstr)
 * 
 *     def new_record(self, contig=None, start=0, stop=0, alleles=None,             # <<<<<<<<<<<<<<
 *                          id=None, qual=None, filter=None, info=None, samples=None,
 *                          **kwargs):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.new_record", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rec);
  __Pyx_XDECREF(__pyx_v_f);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_sample);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2095
 *         return rec
 * 
 *     def add_record(self, VariantHeaderRecord record):             # <<<<<<<<<<<<<<
 *         """Add an existing :class:`VariantHeaderRecord` to this header"""
 *         if record is None:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_17add_record(PyObject *__pyx_v_self, PyObject *__pyx_v_record); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantHeader_16add_record[] = "VariantHeader.add_record(self, VariantHeaderRecord record)\nAdd an existing :class:`VariantHeaderRecord` to this header";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_17add_record(PyObject *__pyx_v_self, PyObject *__pyx_v_record) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_record (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_record), __pyx_ptype_5pysam_7libcbcf_VariantHeaderRecord, 1, "record", 0))) __PYX_ERR(0, 2095, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_16add_record(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self), ((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)__pyx_v_record));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_16add_record(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *__pyx_v_record) {
  bcf_hrec_t *__pyx_v_hrec;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("add_record", 0);
  __Pyx_TraceCall("add_record", __pyx_f[0], 2095, 0, __PYX_ERR(0, 2095, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2097
 *     def add_record(self, VariantHeaderRecord record):
 *         """Add an existing :class:`VariantHeaderRecord` to this header"""
 *         if record is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('record must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_record) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":2098
 *         """Add an existing :class:`VariantHeaderRecord` to this header"""
 *         if record is None:
 *             raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_hrec_t *hrec = bcf_hrec_dup(record.ptr)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__99, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2098, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2098, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2097
 *     def add_record(self, VariantHeaderRecord record):
 *         """Add an existing :class:`VariantHeaderRecord` to this header"""
 *         if record is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('record must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2100
 *             raise ValueError('record must not be None')
 * 
 *         cdef bcf_hrec_t *hrec = bcf_hrec_dup(record.ptr)             # <<<<<<<<<<<<<<
 * 
 *         bcf_hdr_add_hrec(self.ptr, hrec)
 */
  __pyx_v_hrec = bcf_hrec_dup(__pyx_v_record->ptr);

  /* "pysam/libcbcf.pyx":2102
 *         cdef bcf_hrec_t *hrec = bcf_hrec_dup(record.ptr)
 * 
 *         bcf_hdr_add_hrec(self.ptr, hrec)             # <<<<<<<<<<<<<<
 * 
 *         if self.ptr.dirty:
 */
  (void)(bcf_hdr_add_hrec(__pyx_v_self->ptr, __pyx_v_hrec));

  /* "pysam/libcbcf.pyx":2104
 *         bcf_hdr_add_hrec(self.ptr, hrec)
 * 
 *         if self.ptr.dirty:             # <<<<<<<<<<<<<<
 *             bcf_hdr_sync(self.ptr)
 * 
 */
  __pyx_t_2 = (__pyx_v_self->ptr->dirty != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":2105
 * 
 *         if self.ptr.dirty:
 *             bcf_hdr_sync(self.ptr)             # <<<<<<<<<<<<<<
 * 
 *     def add_line(self, line):
 */
    (void)(bcf_hdr_sync(__pyx_v_self->ptr));

    /* "pysam/libcbcf.pyx":2104
 *         bcf_hdr_add_hrec(self.ptr, hrec)
 * 
 *         if self.ptr.dirty:             # <<<<<<<<<<<<<<
 *             bcf_hdr_sync(self.ptr)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2095
 *         return rec
 * 
 *     def add_record(self, VariantHeaderRecord record):             # <<<<<<<<<<<<<<
 *         """Add an existing :class:`VariantHeaderRecord` to this header"""
 *         if record is None:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.add_record", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2107
 *             bcf_hdr_sync(self.ptr)
 * 
 *     def add_line(self, line):             # <<<<<<<<<<<<<<
 *         """Add a metadata line to this header"""
 *         bline = force_bytes(line)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_19add_line(PyObject *__pyx_v_self, PyObject *__pyx_v_line); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantHeader_18add_line[] = "VariantHeader.add_line(self, line)\nAdd a metadata line to this header";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_19add_line(PyObject *__pyx_v_self, PyObject *__pyx_v_line) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_line (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_18add_line(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self), ((PyObject *)__pyx_v_line));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_18add_line(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, PyObject *__pyx_v_line) {
  PyObject *__pyx_v_bline = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char const *__pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("add_line", 0);
  __Pyx_TraceCall("add_line", __pyx_f[0], 2107, 0, __PYX_ERR(0, 2107, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2109
 *     def add_line(self, line):
 *         """Add a metadata line to this header"""
 *         bline = force_bytes(line)             # <<<<<<<<<<<<<<
 *         if bcf_hdr_append(self.ptr, bline) < 0:
 *             raise ValueError('invalid header line')
 */
  __pyx_t_1 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_line, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bline = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":2110
 *         """Add a metadata line to this header"""
 *         bline = force_bytes(line)
 *         if bcf_hdr_append(self.ptr, bline) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('invalid header line')
 * 
 */
  if (unlikely(__pyx_v_bline == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2110, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_bline); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 2110, __pyx_L1_error)
  __pyx_t_3 = ((bcf_hdr_append(__pyx_v_self->ptr, __pyx_t_2) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2111
 *         bline = force_bytes(line)
 *         if bcf_hdr_append(self.ptr, bline) < 0:
 *             raise ValueError('invalid header line')             # <<<<<<<<<<<<<<
 * 
 *         if self.ptr.dirty:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__100, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2111, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 2111, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2110
 *         """Add a metadata line to this header"""
 *         bline = force_bytes(line)
 *         if bcf_hdr_append(self.ptr, bline) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('invalid header line')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2113
 *             raise ValueError('invalid header line')
 * 
 *         if self.ptr.dirty:             # <<<<<<<<<<<<<<
 *             bcf_hdr_sync(self.ptr)
 * 
 */
  __pyx_t_3 = (__pyx_v_self->ptr->dirty != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":2114
 * 
 *         if self.ptr.dirty:
 *             bcf_hdr_sync(self.ptr)             # <<<<<<<<<<<<<<
 * 
 *     def add_meta(self, key, value=None, items=None):
 */
    (void)(bcf_hdr_sync(__pyx_v_self->ptr));

    /* "pysam/libcbcf.pyx":2113
 *             raise ValueError('invalid header line')
 * 
 *         if self.ptr.dirty:             # <<<<<<<<<<<<<<
 *             bcf_hdr_sync(self.ptr)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2107
 *             bcf_hdr_sync(self.ptr)
 * 
 *     def add_line(self, line):             # <<<<<<<<<<<<<<
 *         """Add a metadata line to this header"""
 *         bline = force_bytes(line)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.add_line", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bline);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2116
 *             bcf_hdr_sync(self.ptr)
 * 
 *     def add_meta(self, key, value=None, items=None):             # <<<<<<<<<<<<<<
 *         """Add metadata to this header"""
 *         if not ((value is not None) ^ (items is not None)):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_21add_meta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantHeader_20add_meta[] = "VariantHeader.add_meta(self, key, value=None, items=None)\nAdd metadata to this header";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_21add_meta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_meta (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_value,&__pyx_n_s_items,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_value);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_meta") < 0)) __PYX_ERR(0, 2116, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_value = values[1];
    __pyx_v_items = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_meta", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2116, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.add_meta", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_20add_meta(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self), __pyx_v_key, __pyx_v_value, __pyx_v_items);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_20add_meta(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value, PyObject *__pyx_v_items) {
  bcf_hrec_t *__pyx_v_hrec;
  int __pyx_v_quoted;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  char const *__pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *(*__pyx_t_15)(PyObject *);
  char const *__pyx_t_16;
  Py_ssize_t __pyx_t_17;
  char const *__pyx_t_18;
  char const *__pyx_t_19;
  __Pyx_RefNannySetupContext("add_meta", 0);
  __Pyx_TraceCall("add_meta", __pyx_f[0], 2116, 0, __PYX_ERR(0, 2116, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_key);
  __Pyx_INCREF(__pyx_v_value);

  /* "pysam/libcbcf.pyx":2118
 *     def add_meta(self, key, value=None, items=None):
 *         """Add metadata to this header"""
 *         if not ((value is not None) ^ (items is not None)):             # <<<<<<<<<<<<<<
 *             raise ValueError('either value or items must be specified')
 * 
 */
  __pyx_t_1 = (__pyx_v_value != Py_None);
  __pyx_t_2 = (__pyx_v_items != Py_None);
  __pyx_t_3 = ((!((__pyx_t_1 ^ __pyx_t_2) != 0)) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2119
 *         """Add metadata to this header"""
 *         if not ((value is not None) ^ (items is not None)):
 *             raise ValueError('either value or items must be specified')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_hrec_t *hrec = <bcf_hrec_t*>calloc(1, sizeof(bcf_hrec_t))
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__101, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2119, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2119, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2118
 *     def add_meta(self, key, value=None, items=None):
 *         """Add metadata to this header"""
 *         if not ((value is not None) ^ (items is not None)):             # <<<<<<<<<<<<<<
 *             raise ValueError('either value or items must be specified')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2121
 *             raise ValueError('either value or items must be specified')
 * 
 *         cdef bcf_hrec_t *hrec = <bcf_hrec_t*>calloc(1, sizeof(bcf_hrec_t))             # <<<<<<<<<<<<<<
 *         cdef int quoted
 * 
 */
  __pyx_v_hrec = ((bcf_hrec_t *)calloc(1, (sizeof(bcf_hrec_t))));

  /* "pysam/libcbcf.pyx":2124
 *         cdef int quoted
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             key = force_bytes(key)
 *             hrec.key = strdup(key)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_7);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":2125
 * 
 *         try:
 *             key = force_bytes(key)             # <<<<<<<<<<<<<<
 *             hrec.key = strdup(key)
 * 
 */
      __pyx_t_4 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2125, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_key, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "pysam/libcbcf.pyx":2126
 *         try:
 *             key = force_bytes(key)
 *             hrec.key = strdup(key)             # <<<<<<<<<<<<<<
 * 
 *             if value is not None:
 */
      __pyx_t_8 = __Pyx_PyObject_AsString(__pyx_v_key); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 2126, __pyx_L4_error)
      __pyx_v_hrec->key = strdup(__pyx_t_8);

      /* "pysam/libcbcf.pyx":2128
 *             hrec.key = strdup(key)
 * 
 *             if value is not None:             # <<<<<<<<<<<<<<
 *                 hrec.value = strdup(force_bytes(value))
 *             else:
 */
      __pyx_t_3 = (__pyx_v_value != Py_None);
      __pyx_t_2 = (__pyx_t_3 != 0);
      if (__pyx_t_2) {

        /* "pysam/libcbcf.pyx":2129
 * 
 *             if value is not None:
 *                 hrec.value = strdup(force_bytes(value))             # <<<<<<<<<<<<<<
 *             else:
 *                 for key, value in items:
 */
        __pyx_t_4 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_value, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2129, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (unlikely(__pyx_t_4 == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
          __PYX_ERR(0, 2129, __pyx_L4_error)
        }
        __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 2129, __pyx_L4_error)
        __pyx_v_hrec->value = strdup(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "pysam/libcbcf.pyx":2128
 *             hrec.key = strdup(key)
 * 
 *             if value is not None:             # <<<<<<<<<<<<<<
 *                 hrec.value = strdup(force_bytes(value))
 *             else:
 */
        goto __pyx_L10;
      }

      /* "pysam/libcbcf.pyx":2131
 *                 hrec.value = strdup(force_bytes(value))
 *             else:
 *                 for key, value in items:             # <<<<<<<<<<<<<<
 *                     key = force_bytes(key)
 *                     bcf_hrec_add_key(hrec, key, <int>len(key))
 */
      /*else*/ {
        if (likely(PyList_CheckExact(__pyx_v_items)) || PyTuple_CheckExact(__pyx_v_items)) {
          __pyx_t_4 = __pyx_v_items; __Pyx_INCREF(__pyx_t_4); __pyx_t_9 = 0;
          __pyx_t_10 = NULL;
        } else {
          __pyx_t_9 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2131, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2131, __pyx_L4_error)
        }
        for (;;) {
          if (likely(!__pyx_t_10)) {
            if (likely(PyList_CheckExact(__pyx_t_4))) {
              if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_11 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 2131, __pyx_L4_error)
              #else
              __pyx_t_11 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2131, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_11);
              #endif
            } else {
              if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 2131, __pyx_L4_error)
              #else
              __pyx_t_11 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2131, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_11);
              #endif
            }
          } else {
            __pyx_t_11 = __pyx_t_10(__pyx_t_4);
            if (unlikely(!__pyx_t_11)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 2131, __pyx_L4_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_11);
          }
          if ((likely(PyTuple_CheckExact(__pyx_t_11))) || (PyList_CheckExact(__pyx_t_11))) {
            PyObject* sequence = __pyx_t_11;
            Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
            if (unlikely(size != 2)) {
              if (size > 2) __Pyx_RaiseTooManyValuesError(2);
              else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
              __PYX_ERR(0, 2131, __pyx_L4_error)
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            if (likely(PyTuple_CheckExact(sequence))) {
              __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
              __pyx_t_13 = PyTuple_GET_ITEM(sequence, 1); 
            } else {
              __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
              __pyx_t_13 = PyList_GET_ITEM(sequence, 1); 
            }
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_13);
            #else
            __pyx_t_12 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2131, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_13 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2131, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_13);
            #endif
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          } else {
            Py_ssize_t index = -1;
            __pyx_t_14 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2131, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __pyx_t_15 = Py_TYPE(__pyx_t_14)->tp_iternext;
            index = 0; __pyx_t_12 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_12)) goto __pyx_L13_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_12);
            index = 1; __pyx_t_13 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_13)) goto __pyx_L13_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_13);
            if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_14), 2) < 0) __PYX_ERR(0, 2131, __pyx_L4_error)
            __pyx_t_15 = NULL;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            goto __pyx_L14_unpacking_done;
            __pyx_L13_unpacking_failed:;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __pyx_t_15 = NULL;
            if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
            __PYX_ERR(0, 2131, __pyx_L4_error)
            __pyx_L14_unpacking_done:;
          }
          __Pyx_DECREF_SET(__pyx_v_key, __pyx_t_12);
          __pyx_t_12 = 0;
          __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_13);
          __pyx_t_13 = 0;

          /* "pysam/libcbcf.pyx":2132
 *             else:
 *                 for key, value in items:
 *                     key = force_bytes(key)             # <<<<<<<<<<<<<<
 *                     bcf_hrec_add_key(hrec, key, <int>len(key))
 * 
 */
          __pyx_t_11 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2132, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF_SET(__pyx_v_key, __pyx_t_11);
          __pyx_t_11 = 0;

          /* "pysam/libcbcf.pyx":2133
 *                 for key, value in items:
 *                     key = force_bytes(key)
 *                     bcf_hrec_add_key(hrec, key, <int>len(key))             # <<<<<<<<<<<<<<
 * 
 *                     value = force_bytes(str(value))
 */
          __pyx_t_16 = __Pyx_PyObject_AsString(__pyx_v_key); if (unlikely((!__pyx_t_16) && PyErr_Occurred())) __PYX_ERR(0, 2133, __pyx_L4_error)
          __pyx_t_17 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_17 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2133, __pyx_L4_error)
          bcf_hrec_add_key(__pyx_v_hrec, __pyx_t_16, ((int)__pyx_t_17));

          /* "pysam/libcbcf.pyx":2135
 *                     bcf_hrec_add_key(hrec, key, <int>len(key))
 * 
 *                     value = force_bytes(str(value))             # <<<<<<<<<<<<<<
 *                     quoted = strpbrk(value, ' ;,"\t<>') != NULL
 *                     bcf_hrec_set_val(hrec, hrec.nkeys-1, value, <int>len(value), quoted)
 */
          __pyx_t_11 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_value); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2135, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_13 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_t_11, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2135, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_13);
          __pyx_t_13 = 0;

          /* "pysam/libcbcf.pyx":2136
 * 
 *                     value = force_bytes(str(value))
 *                     quoted = strpbrk(value, ' ;,"\t<>') != NULL             # <<<<<<<<<<<<<<
 *                     bcf_hrec_set_val(hrec, hrec.nkeys-1, value, <int>len(value), quoted)
 *         except:
 */
          __pyx_t_18 = __Pyx_PyObject_AsString(__pyx_v_value); if (unlikely((!__pyx_t_18) && PyErr_Occurred())) __PYX_ERR(0, 2136, __pyx_L4_error)
          __pyx_v_quoted = (strpbrk(__pyx_t_18, ((char const *)" ;,\"\t<>")) != NULL);

          /* "pysam/libcbcf.pyx":2137
 *                     value = force_bytes(str(value))
 *                     quoted = strpbrk(value, ' ;,"\t<>') != NULL
 *                     bcf_hrec_set_val(hrec, hrec.nkeys-1, value, <int>len(value), quoted)             # <<<<<<<<<<<<<<
 *         except:
 *             bcf_hrec_destroy(hrec)
 */
          __pyx_t_19 = __Pyx_PyObject_AsString(__pyx_v_value); if (unlikely((!__pyx_t_19) && PyErr_Occurred())) __PYX_ERR(0, 2137, __pyx_L4_error)
          __pyx_t_17 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_17 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2137, __pyx_L4_error)
          bcf_hrec_set_val(__pyx_v_hrec, (__pyx_v_hrec->nkeys - 1), __pyx_t_19, ((int)__pyx_t_17), __pyx_v_quoted);

          /* "pysam/libcbcf.pyx":2131
 *                 hrec.value = strdup(force_bytes(value))
 *             else:
 *                 for key, value in items:             # <<<<<<<<<<<<<<
 *                     key = force_bytes(key)
 *                     bcf_hrec_add_key(hrec, key, <int>len(key))
 */
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_L10:;

      /* "pysam/libcbcf.pyx":2124
 *         cdef int quoted
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             key = force_bytes(key)
 *             hrec.key = strdup(key)
 */
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":2138
 *                     quoted = strpbrk(value, ' ;,"\t<>') != NULL
 *                     bcf_hrec_set_val(hrec, hrec.nkeys-1, value, <int>len(value), quoted)
 *         except:             # <<<<<<<<<<<<<<
 *             bcf_hrec_destroy(hrec)
 *             raise
 */
    /*except:*/ {
      __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.add_meta", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_13, &__pyx_t_11) < 0) __PYX_ERR(0, 2138, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_GOTREF(__pyx_t_11);

      /* "pysam/libcbcf.pyx":2139
 *                     bcf_hrec_set_val(hrec, hrec.nkeys-1, value, <int>len(value), quoted)
 *         except:
 *             bcf_hrec_destroy(hrec)             # <<<<<<<<<<<<<<
 *             raise
 * 
 */
      bcf_hrec_destroy(__pyx_v_hrec);

      /* "pysam/libcbcf.pyx":2140
 *         except:
 *             bcf_hrec_destroy(hrec)
 *             raise             # <<<<<<<<<<<<<<
 * 
 *         bcf_hdr_add_hrec(self.ptr, hrec)
 */
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_13, __pyx_t_11);
      __pyx_t_4 = 0; __pyx_t_13 = 0; __pyx_t_11 = 0; 
      __PYX_ERR(0, 2140, __pyx_L6_except_error)
    }
    __pyx_L6_except_error:;

    /* "pysam/libcbcf.pyx":2124
 *         cdef int quoted
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             key = force_bytes(key)
 *             hrec.key = strdup(key)
 */
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    goto __pyx_L1_error;
    __pyx_L9_try_end:;
  }

  /* "pysam/libcbcf.pyx":2142
 *             raise
 * 
 *         bcf_hdr_add_hrec(self.ptr, hrec)             # <<<<<<<<<<<<<<
 * 
 *         if self.ptr.dirty:
 */
  (void)(bcf_hdr_add_hrec(__pyx_v_self->ptr, __pyx_v_hrec));

  /* "pysam/libcbcf.pyx":2144
 *         bcf_hdr_add_hrec(self.ptr, hrec)
 * 
 *         if self.ptr.dirty:             # <<<<<<<<<<<<<<
 *             bcf_hdr_sync(self.ptr)
 * 
 */
  __pyx_t_2 = (__pyx_v_self->ptr->dirty != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":2145
 * 
 *         if self.ptr.dirty:
 *             bcf_hdr_sync(self.ptr)             # <<<<<<<<<<<<<<
 * 
 *     def add_sample(self, name):
 */
    (void)(bcf_hdr_sync(__pyx_v_self->ptr));

    /* "pysam/libcbcf.pyx":2144
 *         bcf_hdr_add_hrec(self.ptr, hrec)
 * 
 *         if self.ptr.dirty:             # <<<<<<<<<<<<<<
 *             bcf_hdr_sync(self.ptr)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2116
 *             bcf_hdr_sync(self.ptr)
 * 
 *     def add_meta(self, key, value=None, items=None):             # <<<<<<<<<<<<<<
 *         """Add metadata to this header"""
 *         if not ((value is not None) ^ (items is not None)):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.add_meta", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2147
 *             bcf_hdr_sync(self.ptr)
 * 
 *     def add_sample(self, name):             # <<<<<<<<<<<<<<
 *         """Add a new sample to this header"""
 *         bname = force_bytes(name)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_23add_sample(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantHeader_22add_sample[] = "VariantHeader.add_sample(self, name)\nAdd a new sample to this header";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_23add_sample(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_sample (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_22add_sample(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self), ((PyObject *)__pyx_v_name));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_22add_sample(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_v_bname = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char const *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("add_sample", 0);
  __Pyx_TraceCall("add_sample", __pyx_f[0], 2147, 0, __PYX_ERR(0, 2147, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2149
 *     def add_sample(self, name):
 *         """Add a new sample to this header"""
 *         bname = force_bytes(name)             # <<<<<<<<<<<<<<
 *         if bcf_hdr_add_sample(self.ptr, bname) < 0:
 *             raise ValueError('Duplicated sample name: {}'.format(name))
 */
  __pyx_t_1 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_name, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bname = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":2150
 *         """Add a new sample to this header"""
 *         bname = force_bytes(name)
 *         if bcf_hdr_add_sample(self.ptr, bname) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Duplicated sample name: {}'.format(name))
 *         if self.ptr.dirty:
 */
  if (unlikely(__pyx_v_bname == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2150, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_bname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 2150, __pyx_L1_error)
  __pyx_t_3 = ((bcf_hdr_add_sample(__pyx_v_self->ptr, __pyx_t_2) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2151
 *         bname = force_bytes(name)
 *         if bcf_hdr_add_sample(self.ptr, bname) < 0:
 *             raise ValueError('Duplicated sample name: {}'.format(name))             # <<<<<<<<<<<<<<
 *         if self.ptr.dirty:
 *             bcf_hdr_sync(self.ptr)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Duplicated_sample_name, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2151, __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_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2151, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_name};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2151, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_name};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2151, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2151, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_INCREF(__pyx_v_name);
        __Pyx_GIVEREF(__pyx_v_name);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_name);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2151, __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_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2151, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2151, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2150
 *         """Add a new sample to this header"""
 *         bname = force_bytes(name)
 *         if bcf_hdr_add_sample(self.ptr, bname) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Duplicated sample name: {}'.format(name))
 *         if self.ptr.dirty:
 */
  }

  /* "pysam/libcbcf.pyx":2152
 *         if bcf_hdr_add_sample(self.ptr, bname) < 0:
 *             raise ValueError('Duplicated sample name: {}'.format(name))
 *         if self.ptr.dirty:             # <<<<<<<<<<<<<<
 *             bcf_hdr_sync(self.ptr)
 * 
 */
  __pyx_t_3 = (__pyx_v_self->ptr->dirty != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":2153
 *             raise ValueError('Duplicated sample name: {}'.format(name))
 *         if self.ptr.dirty:
 *             bcf_hdr_sync(self.ptr)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    (void)(bcf_hdr_sync(__pyx_v_self->ptr));

    /* "pysam/libcbcf.pyx":2152
 *         if bcf_hdr_add_sample(self.ptr, bname) < 0:
 *             raise ValueError('Duplicated sample name: {}'.format(name))
 *         if self.ptr.dirty:             # <<<<<<<<<<<<<<
 *             bcf_hdr_sync(self.ptr)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2147
 *             bcf_hdr_sync(self.ptr)
 * 
 *     def add_sample(self, name):             # <<<<<<<<<<<<<<
 *         """Add a new sample to this header"""
 *         bname = force_bytes(name)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.add_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bname);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_25__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantHeader_24__reduce_cython__[] = "VariantHeader.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_25__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_24__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_24__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__102, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_27__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantHeader_26__setstate_cython__[] = "VariantHeader.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantHeader_27__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantHeader_26__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantHeader_26__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 3, 0, __PYX_ERR(2, 3, __pyx_L1_error));

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__103, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantHeader.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2156
 * 
 * 
 * cdef VariantHeader makeVariantHeader(bcf_hdr_t *hdr):             # <<<<<<<<<<<<<<
 *     if not hdr:
 *         raise ValueError('cannot create VariantHeader')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_f_5pysam_7libcbcf_makeVariantHeader(bcf_hdr_t *__pyx_v_hdr) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("makeVariantHeader", 0);
  __Pyx_TraceCall("makeVariantHeader", __pyx_f[0], 2156, 0, __PYX_ERR(0, 2156, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2157
 * 
 * cdef VariantHeader makeVariantHeader(bcf_hdr_t *hdr):
 *     if not hdr:             # <<<<<<<<<<<<<<
 *         raise ValueError('cannot create VariantHeader')
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_hdr != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":2158
 * cdef VariantHeader makeVariantHeader(bcf_hdr_t *hdr):
 *     if not hdr:
 *         raise ValueError('cannot create VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantHeader header = VariantHeader.__new__(VariantHeader)
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__104, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 2158, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2157
 * 
 * cdef VariantHeader makeVariantHeader(bcf_hdr_t *hdr):
 *     if not hdr:             # <<<<<<<<<<<<<<
 *         raise ValueError('cannot create VariantHeader')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2160
 *         raise ValueError('cannot create VariantHeader')
 * 
 *     cdef VariantHeader header = VariantHeader.__new__(VariantHeader)             # <<<<<<<<<<<<<<
 *     header.ptr = hdr
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantHeader(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeader), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2160, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_v_header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":2161
 * 
 *     cdef VariantHeader header = VariantHeader.__new__(VariantHeader)
 *     header.ptr = hdr             # <<<<<<<<<<<<<<
 * 
 *     return header
 */
  __pyx_v_header->ptr = __pyx_v_hdr;

  /* "pysam/libcbcf.pyx":2163
 *     header.ptr = hdr
 * 
 *     return header             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_header));
  __pyx_r = __pyx_v_header;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2156
 * 
 * 
 * cdef VariantHeader makeVariantHeader(bcf_hdr_t *hdr):             # <<<<<<<<<<<<<<
 *     if not hdr:
 *         raise ValueError('cannot create VariantHeader')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantHeader", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_header);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2166
 * 
 * 
 * cdef inline int bcf_header_get_info_id(bcf_hdr_t *hdr, key) except? -2:             # <<<<<<<<<<<<<<
 *     cdef vdict_t *d
 *     cdef khiter_t k
 */

static CYTHON_INLINE int __pyx_f_5pysam_7libcbcf_bcf_header_get_info_id(bcf_hdr_t *__pyx_v_hdr, PyObject *__pyx_v_key) {
  vdict_t *__pyx_v_d;
  khiter_t __pyx_v_k;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  char const *__pyx_t_4;
  __Pyx_RefNannySetupContext("bcf_header_get_info_id", 0);
  __Pyx_TraceCall("bcf_header_get_info_id", __pyx_f[0], 2166, 0, __PYX_ERR(0, 2166, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_key);

  /* "pysam/libcbcf.pyx":2171
 *     cdef int info_id
 * 
 *     if isinstance(key, str):             # <<<<<<<<<<<<<<
 *         key = force_bytes(key)
 * 
 */
  __pyx_t_1 = PyString_Check(__pyx_v_key); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":2172
 * 
 *     if isinstance(key, str):
 *         key = force_bytes(key)             # <<<<<<<<<<<<<<
 * 
 *     d = <vdict_t *>hdr.dict[BCF_DT_ID]
 */
    __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_key, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":2171
 *     cdef int info_id
 * 
 *     if isinstance(key, str):             # <<<<<<<<<<<<<<
 *         key = force_bytes(key)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2174
 *         key = force_bytes(key)
 * 
 *     d = <vdict_t *>hdr.dict[BCF_DT_ID]             # <<<<<<<<<<<<<<
 *     k = kh_get_vdict(d, key)
 * 
 */
  __pyx_v_d = ((vdict_t *)(__pyx_v_hdr->dict[BCF_DT_ID]));

  /* "pysam/libcbcf.pyx":2175
 * 
 *     d = <vdict_t *>hdr.dict[BCF_DT_ID]
 *     k = kh_get_vdict(d, key)             # <<<<<<<<<<<<<<
 * 
 *     if k == kh_end(d) or kh_val_vdict(d, k).info[BCF_HL_INFO] & 0xF == 0xF:
 */
  __pyx_t_4 = __Pyx_PyObject_AsString(__pyx_v_key); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 2175, __pyx_L1_error)
  __pyx_v_k = kh_get_vdict(__pyx_v_d, __pyx_t_4);

  /* "pysam/libcbcf.pyx":2177
 *     k = kh_get_vdict(d, key)
 * 
 *     if k == kh_end(d) or kh_val_vdict(d, k).info[BCF_HL_INFO] & 0xF == 0xF:             # <<<<<<<<<<<<<<
 *         return -1
 * 
 */
  __pyx_t_1 = ((__pyx_v_k == kh_end(__pyx_v_d)) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_1 = ((((kh_val(__pyx_v_d, __pyx_v_k).info[BCF_HL_INFO]) & 0xF) == 0xF) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":2178
 * 
 *     if k == kh_end(d) or kh_val_vdict(d, k).info[BCF_HL_INFO] & 0xF == 0xF:
 *         return -1             # <<<<<<<<<<<<<<
 * 
 *     return kh_val_vdict(d, k).id
 */
    __pyx_r = -1;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2177
 *     k = kh_get_vdict(d, key)
 * 
 *     if k == kh_end(d) or kh_val_vdict(d, k).info[BCF_HL_INFO] & 0xF == 0xF:             # <<<<<<<<<<<<<<
 *         return -1
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2180
 *         return -1
 * 
 *     return kh_val_vdict(d, k).id             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = kh_val(__pyx_v_d, __pyx_v_k).id;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2166
 * 
 * 
 * cdef inline int bcf_header_get_info_id(bcf_hdr_t *hdr, key) except? -2:             # <<<<<<<<<<<<<<
 *     cdef vdict_t *d
 *     cdef khiter_t k
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.bcf_header_get_info_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -2;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2191
 *     """Filters set on a :class:`VariantRecord` object, presented as a mapping from
 *        filter index or name to :class:`VariantMetadata` object"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 2191, 0, __PYX_ERR(0, 2191, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2192
 *        filter index or name to :class:`VariantMetadata` object"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__105, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2192, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 2192, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2191
 *     """Filters set on a :class:`VariantRecord` object, presented as a mapping from
 *        filter index or name to :class:`VariantMetadata` object"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2194
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.record.ptr.d.n_flt
 * 
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_3__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_3__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_2__len__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);
  __Pyx_TraceCall("__len__", __pyx_f[0], 2194, 0, __PYX_ERR(0, 2194, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2195
 * 
 *     def __len__(self):
 *         return self.record.ptr.d.n_flt             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
  __pyx_r = __pyx_v_self->record->ptr->d.n_flt;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2194
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.record.ptr.d.n_flt
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2197
 *         return self.record.ptr.d.n_flt
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         return self.record.ptr.d.n_flt != 0
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_5__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_5__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_4__bool__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__", 0);
  __Pyx_TraceCall("__bool__", __pyx_f[0], 2197, 0, __PYX_ERR(0, 2197, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2198
 * 
 *     def __bool__(self):
 *         return self.record.ptr.d.n_flt != 0             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key):
 */
  __pyx_r = (__pyx_v_self->record->ptr->d.n_flt != 0);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2197
 *         return self.record.ptr.d.n_flt
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         return self.record.ptr.d.n_flt != 0
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2200
 *         return self.record.ptr.d.n_flt != 0
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_6__getitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int __pyx_v_index;
  int __pyx_v_id;
  int __pyx_v_n;
  PyObject *__pyx_v_bkey = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  char const *__pyx_t_7;
  char *__pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_TraceCall("__getitem__", __pyx_f[0], 2200, 0, __PYX_ERR(0, 2200, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_key);

  /* "pysam/libcbcf.pyx":2201
 * 
 *     def __getitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int index, id
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2202
 *     def __getitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int index, id
 *         cdef int n = r.d.n_flt
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2204
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int index, id
 *         cdef int n = r.d.n_flt             # <<<<<<<<<<<<<<
 * 
 *         if isinstance(key, int):
 */
  __pyx_t_3 = __pyx_v_r->d.n_flt;
  __pyx_v_n = __pyx_t_3;

  /* "pysam/libcbcf.pyx":2206
 *         cdef int n = r.d.n_flt
 * 
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             index = key
 * 
 */
  __pyx_t_4 = PyInt_Check(__pyx_v_key); 
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pysam/libcbcf.pyx":2207
 * 
 *         if isinstance(key, int):
 *             index = key             # <<<<<<<<<<<<<<
 * 
 *             if index < 0 or index >= n:
 */
    __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_key); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2207, __pyx_L1_error)
    __pyx_v_index = __pyx_t_3;

    /* "pysam/libcbcf.pyx":2209
 *             index = key
 * 
 *             if index < 0 or index >= n:             # <<<<<<<<<<<<<<
 *                 raise IndexError('invalid filter index')
 * 
 */
    __pyx_t_4 = ((__pyx_v_index < 0) != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_4 = ((__pyx_v_index >= __pyx_v_n) != 0);
    __pyx_t_5 = __pyx_t_4;
    __pyx_L5_bool_binop_done:;
    if (unlikely(__pyx_t_5)) {

      /* "pysam/libcbcf.pyx":2210
 * 
 *             if index < 0 or index >= n:
 *                 raise IndexError('invalid filter index')             # <<<<<<<<<<<<<<
 * 
 *             id = r.d.flt[index]
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__106, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2210, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_ERR(0, 2210, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2209
 *             index = key
 * 
 *             if index < 0 or index >= n:             # <<<<<<<<<<<<<<
 *                 raise IndexError('invalid filter index')
 * 
 */
    }

    /* "pysam/libcbcf.pyx":2212
 *                 raise IndexError('invalid filter index')
 * 
 *             id = r.d.flt[index]             # <<<<<<<<<<<<<<
 *         else:
 *             if key == '.':
 */
    __pyx_v_id = (__pyx_v_r->d.flt[__pyx_v_index]);

    /* "pysam/libcbcf.pyx":2206
 *         cdef int n = r.d.n_flt
 * 
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             index = key
 * 
 */
    goto __pyx_L3;
  }

  /* "pysam/libcbcf.pyx":2214
 *             id = r.d.flt[index]
 *         else:
 *             if key == '.':             # <<<<<<<<<<<<<<
 *                 key = 'PASS'
 * 
 */
  /*else*/ {
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_key, __pyx_kp_s__71, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2214, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "pysam/libcbcf.pyx":2215
 *         else:
 *             if key == '.':
 *                 key = 'PASS'             # <<<<<<<<<<<<<<
 * 
 *             bkey = force_bytes(key)
 */
      __Pyx_INCREF(__pyx_n_s_PASS);
      __Pyx_DECREF_SET(__pyx_v_key, __pyx_n_s_PASS);

      /* "pysam/libcbcf.pyx":2214
 *             id = r.d.flt[index]
 *         else:
 *             if key == '.':             # <<<<<<<<<<<<<<
 *                 key = 'PASS'
 * 
 */
    }

    /* "pysam/libcbcf.pyx":2217
 *                 key = 'PASS'
 * 
 *             bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *             id = bcf_hdr_id2int(hdr, BCF_DT_ID, bkey)
 * 
 */
    __pyx_t_6 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2217, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_bkey = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "pysam/libcbcf.pyx":2218
 * 
 *             bkey = force_bytes(key)
 *             id = bcf_hdr_id2int(hdr, BCF_DT_ID, bkey)             # <<<<<<<<<<<<<<
 * 
 *             if not check_header_id(hdr, BCF_HL_FLT, id) or not bcf_has_filter(hdr, r, bkey):
 */
    if (unlikely(__pyx_v_bkey == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 2218, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 2218, __pyx_L1_error)
    __pyx_v_id = bcf_hdr_id2int(__pyx_v_hdr, BCF_DT_ID, __pyx_t_7);

    /* "pysam/libcbcf.pyx":2220
 *             id = bcf_hdr_id2int(hdr, BCF_DT_ID, bkey)
 * 
 *             if not check_header_id(hdr, BCF_HL_FLT, id) or not bcf_has_filter(hdr, r, bkey):             # <<<<<<<<<<<<<<
 *                 raise KeyError('Invalid filter: {}'.format(key))
 * 
 */
    __pyx_t_4 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, BCF_HL_FLT, __pyx_v_id) != 0)) != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L9_bool_binop_done;
    }
    if (unlikely(__pyx_v_bkey == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 2220, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyBytes_AsWritableString(__pyx_v_bkey); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 2220, __pyx_L1_error)
    __pyx_t_4 = ((!(bcf_has_filter(__pyx_v_hdr, __pyx_v_r, __pyx_t_8) != 0)) != 0);
    __pyx_t_5 = __pyx_t_4;
    __pyx_L9_bool_binop_done:;
    if (unlikely(__pyx_t_5)) {

      /* "pysam/libcbcf.pyx":2221
 * 
 *             if not check_header_id(hdr, BCF_HL_FLT, id) or not bcf_has_filter(hdr, r, bkey):
 *                 raise KeyError('Invalid filter: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         return makeVariantMetadata(self.record.header, BCF_HL_FLT, id)
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Invalid_filter, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2221, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_key); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2221, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2221, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2221, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2221, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_key);
          __Pyx_GIVEREF(__pyx_v_key);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_key);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2221, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2221, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 2221, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2220
 *             id = bcf_hdr_id2int(hdr, BCF_DT_ID, bkey)
 * 
 *             if not check_header_id(hdr, BCF_HL_FLT, id) or not bcf_has_filter(hdr, r, bkey):             # <<<<<<<<<<<<<<
 *                 raise KeyError('Invalid filter: {}'.format(key))
 * 
 */
    }
  }
  __pyx_L3:;

  /* "pysam/libcbcf.pyx":2223
 *                 raise KeyError('Invalid filter: {}'.format(key))
 * 
 *         return makeVariantMetadata(self.record.header, BCF_HL_FLT, id)             # <<<<<<<<<<<<<<
 * 
 *     def add(self, key):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_9 = ((PyObject *)__pyx_v_self->record->header);
  __Pyx_INCREF(__pyx_t_9);
  __pyx_t_6 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantMetadata(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_9), BCF_HL_FLT, __pyx_v_id)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2200
 *         return self.record.ptr.d.n_flt != 0
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2225
 *         return makeVariantMetadata(self.record.header, BCF_HL_FLT, id)
 * 
 *     def add(self, key):             # <<<<<<<<<<<<<<
 *         """Add a new filter"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_9add(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_8add[] = "VariantRecordFilter.add(self, key)\nAdd a new filter";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_9add(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_8add(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_8add(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int __pyx_v_id;
  PyObject *__pyx_v_bkey = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  char const *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("add", 0);
  __Pyx_TraceCall("add", __pyx_f[0], 2225, 0, __PYX_ERR(0, 2225, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_key);

  /* "pysam/libcbcf.pyx":2227
 *     def add(self, key):
 *         """Add a new filter"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int id
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2228
 *         """Add a new filter"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int id
 * 
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2231
 *         cdef int id
 * 
 *         if key == '.':             # <<<<<<<<<<<<<<
 *             key = 'PASS'
 * 
 */
  __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_v_key, __pyx_kp_s__71, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2231, __pyx_L1_error)
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":2232
 * 
 *         if key == '.':
 *             key = 'PASS'             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
    __Pyx_INCREF(__pyx_n_s_PASS);
    __Pyx_DECREF_SET(__pyx_v_key, __pyx_n_s_PASS);

    /* "pysam/libcbcf.pyx":2231
 *         cdef int id
 * 
 *         if key == '.':             # <<<<<<<<<<<<<<
 *             key = 'PASS'
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2234
 *             key = 'PASS'
 * 
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *         id = bcf_hdr_id2int(hdr, BCF_DT_ID, bkey)
 * 
 */
  __pyx_t_4 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2234, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_bkey = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":2235
 * 
 *         cdef bytes bkey = force_bytes(key)
 *         id = bcf_hdr_id2int(hdr, BCF_DT_ID, bkey)             # <<<<<<<<<<<<<<
 * 
 *         if not check_header_id(hdr, BCF_HL_FLT, id):
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2235, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 2235, __pyx_L1_error)
  __pyx_v_id = bcf_hdr_id2int(__pyx_v_hdr, BCF_DT_ID, __pyx_t_5);

  /* "pysam/libcbcf.pyx":2237
 *         id = bcf_hdr_id2int(hdr, BCF_DT_ID, bkey)
 * 
 *         if not check_header_id(hdr, BCF_HL_FLT, id):             # <<<<<<<<<<<<<<
 *             raise KeyError('Invalid filter: {}'.format(key))
 * 
 */
  __pyx_t_3 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, BCF_HL_FLT, __pyx_v_id) != 0)) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2238
 * 
 *         if not check_header_id(hdr, BCF_HL_FLT, id):
 *             raise KeyError('Invalid filter: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         bcf_add_filter(hdr, r, id)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Invalid_filter, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2238, __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_7, __pyx_v_key};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2238, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 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_7, __pyx_v_key};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2238, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2238, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_key);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2238, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(0, 2238, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2237
 *         id = bcf_hdr_id2int(hdr, BCF_DT_ID, bkey)
 * 
 *         if not check_header_id(hdr, BCF_HL_FLT, id):             # <<<<<<<<<<<<<<
 *             raise KeyError('Invalid filter: {}'.format(key))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2240
 *             raise KeyError('Invalid filter: {}'.format(key))
 * 
 *         bcf_add_filter(hdr, r, id)             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, key):
 */
  (void)(bcf_add_filter(__pyx_v_hdr, __pyx_v_r, __pyx_v_id));

  /* "pysam/libcbcf.pyx":2225
 *         return makeVariantMetadata(self.record.header, BCF_HL_FLT, id)
 * 
 *     def add(self, key):             # <<<<<<<<<<<<<<
 *         """Add a new filter"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2242
 *         bcf_add_filter(hdr, r, id)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_11__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_11__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_10__delitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_10__delitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int __pyx_v_index;
  int __pyx_v_id;
  int __pyx_v_n;
  PyObject *__pyx_v_bkey = NULL;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  char const *__pyx_t_7;
  char *__pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("__delitem__", 0);
  __Pyx_TraceCall("__delitem__", __pyx_f[0], 2242, 0, __PYX_ERR(0, 2242, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_key);

  /* "pysam/libcbcf.pyx":2243
 * 
 *     def __delitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int index, id
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2244
 *     def __delitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int index, id
 *         cdef int n = r.d.n_flt
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2246
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int index, id
 *         cdef int n = r.d.n_flt             # <<<<<<<<<<<<<<
 * 
 *         if isinstance(key, int):
 */
  __pyx_t_3 = __pyx_v_r->d.n_flt;
  __pyx_v_n = __pyx_t_3;

  /* "pysam/libcbcf.pyx":2248
 *         cdef int n = r.d.n_flt
 * 
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             index = key
 * 
 */
  __pyx_t_4 = PyInt_Check(__pyx_v_key); 
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pysam/libcbcf.pyx":2249
 * 
 *         if isinstance(key, int):
 *             index = key             # <<<<<<<<<<<<<<
 * 
 *             if index < 0 or index >= n:
 */
    __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_key); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2249, __pyx_L1_error)
    __pyx_v_index = __pyx_t_3;

    /* "pysam/libcbcf.pyx":2251
 *             index = key
 * 
 *             if index < 0 or index >= n:             # <<<<<<<<<<<<<<
 *                 raise IndexError('invalid filter index')
 * 
 */
    __pyx_t_4 = ((__pyx_v_index < 0) != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_4 = ((__pyx_v_index >= __pyx_v_n) != 0);
    __pyx_t_5 = __pyx_t_4;
    __pyx_L5_bool_binop_done:;
    if (unlikely(__pyx_t_5)) {

      /* "pysam/libcbcf.pyx":2252
 * 
 *             if index < 0 or index >= n:
 *                 raise IndexError('invalid filter index')             # <<<<<<<<<<<<<<
 * 
 *             id = r.d.flt[index]
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__107, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2252, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_ERR(0, 2252, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2251
 *             index = key
 * 
 *             if index < 0 or index >= n:             # <<<<<<<<<<<<<<
 *                 raise IndexError('invalid filter index')
 * 
 */
    }

    /* "pysam/libcbcf.pyx":2254
 *                 raise IndexError('invalid filter index')
 * 
 *             id = r.d.flt[index]             # <<<<<<<<<<<<<<
 *         else:
 *             if key == '.':
 */
    __pyx_v_id = (__pyx_v_r->d.flt[__pyx_v_index]);

    /* "pysam/libcbcf.pyx":2248
 *         cdef int n = r.d.n_flt
 * 
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             index = key
 * 
 */
    goto __pyx_L3;
  }

  /* "pysam/libcbcf.pyx":2256
 *             id = r.d.flt[index]
 *         else:
 *             if key == '.':             # <<<<<<<<<<<<<<
 *                 key = 'PASS'
 * 
 */
  /*else*/ {
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_key, __pyx_kp_s__71, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2256, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "pysam/libcbcf.pyx":2257
 *         else:
 *             if key == '.':
 *                 key = 'PASS'             # <<<<<<<<<<<<<<
 * 
 *             bkey = force_bytes(key)
 */
      __Pyx_INCREF(__pyx_n_s_PASS);
      __Pyx_DECREF_SET(__pyx_v_key, __pyx_n_s_PASS);

      /* "pysam/libcbcf.pyx":2256
 *             id = r.d.flt[index]
 *         else:
 *             if key == '.':             # <<<<<<<<<<<<<<
 *                 key = 'PASS'
 * 
 */
    }

    /* "pysam/libcbcf.pyx":2259
 *                 key = 'PASS'
 * 
 *             bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *             id = bcf_hdr_id2int(hdr, BCF_DT_ID, bkey)
 * 
 */
    __pyx_t_6 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2259, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_bkey = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "pysam/libcbcf.pyx":2260
 * 
 *             bkey = force_bytes(key)
 *             id = bcf_hdr_id2int(hdr, BCF_DT_ID, bkey)             # <<<<<<<<<<<<<<
 * 
 *             if not check_header_id(hdr, BCF_HL_FLT, id) or not bcf_has_filter(hdr, r, bkey):
 */
    if (unlikely(__pyx_v_bkey == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 2260, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 2260, __pyx_L1_error)
    __pyx_v_id = bcf_hdr_id2int(__pyx_v_hdr, BCF_DT_ID, __pyx_t_7);

    /* "pysam/libcbcf.pyx":2262
 *             id = bcf_hdr_id2int(hdr, BCF_DT_ID, bkey)
 * 
 *             if not check_header_id(hdr, BCF_HL_FLT, id) or not bcf_has_filter(hdr, r, bkey):             # <<<<<<<<<<<<<<
 *                 raise KeyError('Invalid filter: {}'.format(key))
 * 
 */
    __pyx_t_4 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, BCF_HL_FLT, __pyx_v_id) != 0)) != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L9_bool_binop_done;
    }
    if (unlikely(__pyx_v_bkey == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 2262, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyBytes_AsWritableString(__pyx_v_bkey); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 2262, __pyx_L1_error)
    __pyx_t_4 = ((!(bcf_has_filter(__pyx_v_hdr, __pyx_v_r, __pyx_t_8) != 0)) != 0);
    __pyx_t_5 = __pyx_t_4;
    __pyx_L9_bool_binop_done:;
    if (unlikely(__pyx_t_5)) {

      /* "pysam/libcbcf.pyx":2263
 * 
 *             if not check_header_id(hdr, BCF_HL_FLT, id) or not bcf_has_filter(hdr, r, bkey):
 *                 raise KeyError('Invalid filter: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         bcf_remove_filter(hdr, r, id, 0)
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Invalid_filter, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2263, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_key); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2263, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2263, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2263, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2263, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_key);
          __Pyx_GIVEREF(__pyx_v_key);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_key);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2263, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2263, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 2263, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2262
 *             id = bcf_hdr_id2int(hdr, BCF_DT_ID, bkey)
 * 
 *             if not check_header_id(hdr, BCF_HL_FLT, id) or not bcf_has_filter(hdr, r, bkey):             # <<<<<<<<<<<<<<
 *                 raise KeyError('Invalid filter: {}'.format(key))
 * 
 */
    }
  }
  __pyx_L3:;

  /* "pysam/libcbcf.pyx":2265
 *                 raise KeyError('Invalid filter: {}'.format(key))
 * 
 *         bcf_remove_filter(hdr, r, id, 0)             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
  (void)(bcf_remove_filter(__pyx_v_hdr, __pyx_v_r, __pyx_v_id, 0));

  /* "pysam/libcbcf.pyx":2242
 *         bcf_add_filter(hdr, r, id)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.__delitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2267
 *         bcf_remove_filter(hdr, r, id, 0)
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         """Clear all filters"""
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_13clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_12clear[] = "VariantRecordFilter.clear(self)\nClear all filters";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_13clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_12clear(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_12clear(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self) {
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf1_t *__pyx_t_1;
  __Pyx_RefNannySetupContext("clear", 0);
  __Pyx_TraceCall("clear", __pyx_f[0], 2267, 0, __PYX_ERR(0, 2267, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2269
 *     def clear(self):
 *         """Clear all filters"""
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         r.d.shared_dirty |= BCF1_DIRTY_FLT
 *         r.d.n_flt = 0
 */
  __pyx_t_1 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2270
 *         """Clear all filters"""
 *         cdef bcf1_t *r = self.record.ptr
 *         r.d.shared_dirty |= BCF1_DIRTY_FLT             # <<<<<<<<<<<<<<
 *         r.d.n_flt = 0
 * 
 */
  __pyx_v_r->d.shared_dirty = (__pyx_v_r->d.shared_dirty | BCF1_DIRTY_FLT);

  /* "pysam/libcbcf.pyx":2271
 *         cdef bcf1_t *r = self.record.ptr
 *         r.d.shared_dirty |= BCF1_DIRTY_FLT
 *         r.d.n_flt = 0             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_v_r->d.n_flt = 0;

  /* "pysam/libcbcf.pyx":2267
 *         bcf_remove_filter(hdr, r, id, 0)
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         """Clear all filters"""
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.clear", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantRecordFilter_16generator11(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":2273
 *         r.d.n_flt = 0
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_15__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_15__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_14__iter__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_14__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__ *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__ *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_21___iter__(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_21___iter__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2273, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantRecordFilter_16generator11, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_VariantRecordFilter___iter, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 2273, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.__iter__", __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_5pysam_7libcbcf_19VariantRecordFilter_16generator11(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__ *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 2273, 0, __PYX_ERR(0, 2273, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2273, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2274
 * 
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int i
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->record->header->ptr;
  __pyx_cur_scope->__pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2275
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int i
 * 
 */
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self->record->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2278
 *         cdef int i
 * 
 *         for i in range(r.d.n_flt):             # <<<<<<<<<<<<<<
 *             yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, r.d.flt[i]))
 * 
 */
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_r->d.n_flt;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_5;

    /* "pysam/libcbcf.pyx":2279
 * 
 *         for i in range(r.d.n_flt):
 *             yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, r.d.flt[i]))             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
    __pyx_t_6 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(bcf_hdr_int2id(__pyx_cur_scope->__pyx_v_hdr, BCF_DT_ID, (__pyx_cur_scope->__pyx_v_r->d.flt[__pyx_cur_scope->__pyx_v_i]))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2279, __pyx_L1_error)
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":2273
 *         r.d.n_flt = 0
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2281
 *             yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, r.d.flt[i]))
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_18get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_17get[] = "VariantRecordFilter.get(self, key, default=None)\nD.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_18get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 2281, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2281, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_17get(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_17get(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("get", 0);
  __Pyx_TraceCall("get", __pyx_f[0], 2281, 0, __PYX_ERR(0, 2281, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2283
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":2284
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 *             return self[key]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return default
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2284, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "pysam/libcbcf.pyx":2283
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":2285
 *         try:
 *             return self[key]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 2285, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":2286
 *             return self[key]
 *         except KeyError:
 *             return default             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_default);
      __pyx_r = __pyx_v_default;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":2283
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":2281
 *             yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, r.d.flt[i]))
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2288
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_20__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_20__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_19__contains__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_19__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_bkey = 0;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  char *__pyx_t_4;
  __Pyx_RefNannySetupContext("__contains__", 0);
  __Pyx_TraceCall("__contains__", __pyx_f[0], 2288, 0, __PYX_ERR(0, 2288, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2289
 * 
 *     def __contains__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2290
 *     def __contains__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bytes bkey = force_bytes(key)
 *         return bcf_has_filter(hdr, r, bkey) == 1
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2291
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *         return bcf_has_filter(hdr, r, bkey) == 1
 * 
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_bkey = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":2292
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bytes bkey = force_bytes(key)
 *         return bcf_has_filter(hdr, r, bkey) == 1             # <<<<<<<<<<<<<<
 * 
 *     def iterkeys(self):
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2292, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_PyBytes_AsWritableString(__pyx_v_bkey); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 2292, __pyx_L1_error)
  __pyx_r = (bcf_has_filter(__pyx_v_hdr, __pyx_v_r, __pyx_t_4) == 1);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2288
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2294
 *         return bcf_has_filter(hdr, r, bkey) == 1
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_22iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_21iterkeys[] = "VariantRecordFilter.iterkeys(self)\nD.iterkeys() -> an iterator over the keys of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_22iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iterkeys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_21iterkeys(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_21iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("iterkeys", 0);
  __Pyx_TraceCall("iterkeys", __pyx_f[0], 2294, 0, __PYX_ERR(0, 2294, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2296
 *     def iterkeys(self):
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)             # <<<<<<<<<<<<<<
 * 
 *     def itervalues(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2294
 *         return bcf_has_filter(hdr, r, bkey) == 1
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.iterkeys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantRecordFilter_25generator12(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":2298
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_24itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_23itervalues[] = "VariantRecordFilter.itervalues(self)\nD.itervalues() -> an iterator over the values of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_24itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_23itervalues(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_23itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_22_itervalues(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_22_itervalues, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2298, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantRecordFilter_25generator12, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_itervalues, __pyx_n_s_VariantRecordFilter_itervalues, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 2298, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.itervalues", __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_5pysam_7libcbcf_19VariantRecordFilter_25generator12(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __Pyx_TraceCall("itervalues", __pyx_f[0], 2298, 0, __PYX_ERR(0, 2298, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2298, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2300
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield self[key]
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2300, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2300, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2300, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2300, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2300, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2300, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":2301
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 *             yield self[key]             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2301, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2300
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield self[key]
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":2298
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("itervalues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantRecordFilter_28generator13(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":2303
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_27iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_26iteritems[] = "VariantRecordFilter.iteritems(self)\nD.iteritems() -> an iterator over the (key, value) items of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_27iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_26iteritems(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_26iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_23_iteritems(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_23_iteritems, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2303, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantRecordFilter_28generator13, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iteritems, __pyx_n_s_VariantRecordFilter_iteritems, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 2303, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.iteritems", __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_5pysam_7libcbcf_19VariantRecordFilter_28generator13(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __Pyx_TraceCall("iteritems", __pyx_f[0], 2303, 0, __PYX_ERR(0, 2303, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2303, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2305
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield (key, self[key])
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2305, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2305, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2305, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2305, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2305, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2305, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2305, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":2306
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 *             yield (key, self[key])             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2306, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2306, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_cur_scope->__pyx_v_key);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2306, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2305
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield (key, self[key])
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":2303
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("iteritems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2308
 *             yield (key, self[key])
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_30keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_29keys[] = "VariantRecordFilter.keys(self)\nD.keys() -> list of D's keys";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_30keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_29keys(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_29keys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("keys", 0);
  __Pyx_TraceCall("keys", __pyx_f[0], 2308, 0, __PYX_ERR(0, 2308, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2310
 *     def keys(self):
 *         """D.keys() -> list of D's keys"""
 *         return list(self)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_List(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2308
 *             yield (key, self[key])
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2312
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_32items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_31items[] = "VariantRecordFilter.items(self)\nD.items() -> list of D's (key, value) pairs, as 2-tuples";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_32items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("items (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_31items(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_31items(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("items", 0);
  __Pyx_TraceCall("items", __pyx_f[0], 2312, 0, __PYX_ERR(0, 2312, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2314
 *     def items(self):
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_iteritems); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2314, __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, 2314, __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, 2314, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2314, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2312
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.items", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2316
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_34values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_33values[] = "VariantRecordFilter.values(self)\nD.values() -> list of D's values";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_34values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("values (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_33values(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_33values(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("values", 0);
  __Pyx_TraceCall("values", __pyx_f[0], 2316, 0, __PYX_ERR(0, 2316, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2318
 *     def values(self):
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(VariantRecordFilter self not None, VariantRecordFilter other not None, int op):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itervalues); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2318, __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, 2318, __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, 2318, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2316
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2320
 *         return list(self.itervalues())
 * 
 *     def __richcmp__(VariantRecordFilter self not None, VariantRecordFilter other not None, int op):             # <<<<<<<<<<<<<<
 *         if op != 2 and op != 3:
 *             return NotImplemented
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_36__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_36__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  if (unlikely(((PyObject *)__pyx_v_self) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "self"); __PYX_ERR(0, 2320, __pyx_L1_error)
  }
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5pysam_7libcbcf_VariantRecordFilter, 0, "other", 0))) __PYX_ERR(0, 2320, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_35__richcmp__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self), ((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_other), ((int)__pyx_v_op));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_35__richcmp__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_other, int __pyx_v_op) {
  bcf1_t *__pyx_v_s;
  bcf1_t *__pyx_v_o;
  int __pyx_v_cmp;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__richcmp__", 0);
  __Pyx_TraceCall("__richcmp__", __pyx_f[0], 2320, 0, __PYX_ERR(0, 2320, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2321
 * 
 *     def __richcmp__(VariantRecordFilter self not None, VariantRecordFilter other not None, int op):
 *         if op != 2 and op != 3:             # <<<<<<<<<<<<<<
 *             return NotImplemented
 * 
 */
  switch (__pyx_v_op) {
    case 2:
    case 3:
    __pyx_t_1 = 0;
    break;
    default:
    __pyx_t_1 = 1;
    break;
  }
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":2322
 *     def __richcmp__(VariantRecordFilter self not None, VariantRecordFilter other not None, int op):
 *         if op != 2 and op != 3:
 *             return NotImplemented             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf1_t *s = self.record.ptr
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2321
 * 
 *     def __richcmp__(VariantRecordFilter self not None, VariantRecordFilter other not None, int op):
 *         if op != 2 and op != 3:             # <<<<<<<<<<<<<<
 *             return NotImplemented
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2324
 *             return NotImplemented
 * 
 *         cdef bcf1_t *s = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *o = other.record.ptr
 * 
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_s = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2325
 * 
 *         cdef bcf1_t *s = self.record.ptr
 *         cdef bcf1_t *o = other.record.ptr             # <<<<<<<<<<<<<<
 * 
 *         cdef bint cmp = (s.d.n_flt == o.d.n_flt and list(self) == list(other))
 */
  __pyx_t_2 = __pyx_v_other->record->ptr;
  __pyx_v_o = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2327
 *         cdef bcf1_t *o = other.record.ptr
 * 
 *         cdef bint cmp = (s.d.n_flt == o.d.n_flt and list(self) == list(other))             # <<<<<<<<<<<<<<
 * 
 *         if op == 3:
 */
  __pyx_t_3 = ((__pyx_v_s->d.n_flt == __pyx_v_o->d.n_flt) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = PySequence_List(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PySequence_List(((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2327, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2327, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  __pyx_v_cmp = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2329
 *         cdef bint cmp = (s.d.n_flt == o.d.n_flt and list(self) == list(other))
 * 
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             cmp = not cmp
 * 
 */
  __pyx_t_1 = ((__pyx_v_op == 3) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":2330
 * 
 *         if op == 3:
 *             cmp = not cmp             # <<<<<<<<<<<<<<
 * 
 *         return cmp
 */
    __pyx_v_cmp = (!(__pyx_v_cmp != 0));

    /* "pysam/libcbcf.pyx":2329
 *         cdef bint cmp = (s.d.n_flt == o.d.n_flt and list(self) == list(other))
 * 
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             cmp = not cmp
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2332
 *             cmp = not cmp
 * 
 *         return cmp             # <<<<<<<<<<<<<<
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_v_cmp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2320
 *         return list(self.itervalues())
 * 
 *     def __richcmp__(VariantRecordFilter self not None, VariantRecordFilter other not None, int op):             # <<<<<<<<<<<<<<
 *         if op != 2 and op != 3:
 *             return NotImplemented
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.record,)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_38__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_37__reduce_cython__[] = "VariantRecordFilter.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_38__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_37__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_37__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.record,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->record));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->record));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->record));
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.record,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":5
 *     state = (self.record,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.record is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.record,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.record is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_VariantRecordFilter, (type(self), 0xde17f0f, None), state
 */
  /*else*/ {
    __pyx_t_3 = (((PyObject *)__pyx_v_self->record) != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.record is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantRecordFilter, (type(self), 0xde17f0f, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":11
 *         use_setstate = self.record is not None
 *     if use_setstate:
 *         return __pyx_unpickle_VariantRecordFilter, (type(self), 0xde17f0f, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_VariantRecordFilter, (type(self), 0xde17f0f, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantRecordFilt); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_232881935);
    __Pyx_GIVEREF(__pyx_int_232881935);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_232881935);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.record is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantRecordFilter, (type(self), 0xde17f0f, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_VariantRecordFilter, (type(self), 0xde17f0f, None), state
 *     else:
 *         return __pyx_unpickle_VariantRecordFilter, (type(self), 0xde17f0f, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantRecordFilter__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantRecordFilt); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_232881935);
    __Pyx_GIVEREF(__pyx_int_232881935);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_232881935);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.record,)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantRecordFilter, (type(self), 0xde17f0f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantRecordFilter__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_40__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_39__setstate_cython__[] = "VariantRecordFilter.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_40__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_39__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFilter_39__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 14, 0, __PYX_ERR(2, 14, __pyx_L1_error));

  /* "(tree fragment)":15
 *         return __pyx_unpickle_VariantRecordFilter, (type(self), 0xde17f0f, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantRecordFilter__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordFilter__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantRecordFilter, (type(self), 0xde17f0f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantRecordFilter__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFilter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2340
 * 
 * 
 * cdef VariantRecordFilter makeVariantRecordFilter(VariantRecord record):             # <<<<<<<<<<<<<<
 *     if not record:
 *         raise ValueError('invalid VariantRecord')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_f_5pysam_7libcbcf_makeVariantRecordFilter(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v_filter = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("makeVariantRecordFilter", 0);
  __Pyx_TraceCall("makeVariantRecordFilter", __pyx_f[0], 2340, 0, __PYX_ERR(0, 2340, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2341
 * 
 * cdef VariantRecordFilter makeVariantRecordFilter(VariantRecord record):
 *     if not record:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantRecord')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_record)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2341, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":2342
 * cdef VariantRecordFilter makeVariantRecordFilter(VariantRecord record):
 *     if not record:
 *         raise ValueError('invalid VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantRecordFilter filter = VariantRecordFilter.__new__(VariantRecordFilter)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__108, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2342, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2342, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2341
 * 
 * cdef VariantRecordFilter makeVariantRecordFilter(VariantRecord record):
 *     if not record:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2344
 *         raise ValueError('invalid VariantRecord')
 * 
 *     cdef VariantRecordFilter filter = VariantRecordFilter.__new__(VariantRecordFilter)             # <<<<<<<<<<<<<<
 *     filter.record = record
 * 
 */
  __pyx_t_3 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantRecordFilter(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordFilter), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2344, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_filter = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":2345
 * 
 *     cdef VariantRecordFilter filter = VariantRecordFilter.__new__(VariantRecordFilter)
 *     filter.record = record             # <<<<<<<<<<<<<<
 * 
 *     return filter
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_record));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_record));
  __Pyx_GOTREF(__pyx_v_filter->record);
  __Pyx_DECREF(((PyObject *)__pyx_v_filter->record));
  __pyx_v_filter->record = __pyx_v_record;

  /* "pysam/libcbcf.pyx":2347
 *     filter.record = record
 * 
 *     return filter             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_filter));
  __pyx_r = __pyx_v_filter;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2340
 * 
 * 
 * cdef VariantRecordFilter makeVariantRecordFilter(VariantRecord record):             # <<<<<<<<<<<<<<
 *     if not record:
 *         raise ValueError('invalid VariantRecord')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantRecordFilter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_filter);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2353
 *     """Format data present for each sample in a :class:`VariantRecord` object,
 *        presented as mapping from format name to :class:`VariantMetadata` object."""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 2353, 0, __PYX_ERR(0, 2353, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2354
 *        presented as mapping from format name to :class:`VariantMetadata` object."""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__109, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 2354, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2353
 *     """Format data present for each sample in a :class:`VariantRecord` object,
 *        presented as mapping from format name to :class:`VariantMetadata` object."""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2356
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_3__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_3__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_2__len__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self) {
  CYTHON_UNUSED bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int __pyx_v_i;
  int __pyx_v_n;
  Py_ssize_t __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  uint32_t __pyx_t_3;
  uint32_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__len__", 0);
  __Pyx_TraceCall("__len__", __pyx_f[0], 2356, 0, __PYX_ERR(0, 2356, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2357
 * 
 *     def __len__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int i, n = 0
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2358
 *     def __len__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int i, n = 0
 * 
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2359
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int i, n = 0             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_fmt):
 */
  __pyx_v_n = 0;

  /* "pysam/libcbcf.pyx":2361
 *         cdef int i, n = 0
 * 
 *         for i in range(r.n_fmt):             # <<<<<<<<<<<<<<
 *             if r.d.fmt[i].p:
 *                 n += 1
 */
  __pyx_t_3 = __pyx_v_r->n_fmt;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "pysam/libcbcf.pyx":2362
 * 
 *         for i in range(r.n_fmt):
 *             if r.d.fmt[i].p:             # <<<<<<<<<<<<<<
 *                 n += 1
 *         return n
 */
    __pyx_t_6 = ((__pyx_v_r->d.fmt[__pyx_v_i]).p != 0);
    if (__pyx_t_6) {

      /* "pysam/libcbcf.pyx":2363
 *         for i in range(r.n_fmt):
 *             if r.d.fmt[i].p:
 *                 n += 1             # <<<<<<<<<<<<<<
 *         return n
 * 
 */
      __pyx_v_n = (__pyx_v_n + 1);

      /* "pysam/libcbcf.pyx":2362
 * 
 *         for i in range(r.n_fmt):
 *             if r.d.fmt[i].p:             # <<<<<<<<<<<<<<
 *                 n += 1
 *         return n
 */
    }
  }

  /* "pysam/libcbcf.pyx":2364
 *             if r.d.fmt[i].p:
 *                 n += 1
 *         return n             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
  __pyx_r = __pyx_v_n;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2356
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2366
 *         return n
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_5__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_5__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_4__bool__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self) {
  CYTHON_UNUSED bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int __pyx_v_i;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  uint32_t __pyx_t_3;
  uint32_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__bool__", 0);
  __Pyx_TraceCall("__bool__", __pyx_f[0], 2366, 0, __PYX_ERR(0, 2366, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2367
 * 
 *     def __bool__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int i
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2368
 *     def __bool__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int i
 * 
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2371
 *         cdef int i
 * 
 *         for i in range(r.n_fmt):             # <<<<<<<<<<<<<<
 *             if r.d.fmt[i].p:
 *                 return True
 */
  __pyx_t_3 = __pyx_v_r->n_fmt;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "pysam/libcbcf.pyx":2372
 * 
 *         for i in range(r.n_fmt):
 *             if r.d.fmt[i].p:             # <<<<<<<<<<<<<<
 *                 return True
 *         return False
 */
    __pyx_t_6 = ((__pyx_v_r->d.fmt[__pyx_v_i]).p != 0);
    if (__pyx_t_6) {

      /* "pysam/libcbcf.pyx":2373
 *         for i in range(r.n_fmt):
 *             if r.d.fmt[i].p:
 *                 return True             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
      __pyx_r = 1;
      goto __pyx_L0;

      /* "pysam/libcbcf.pyx":2372
 * 
 *         for i in range(r.n_fmt):
 *             if r.d.fmt[i].p:             # <<<<<<<<<<<<<<
 *                 return True
 *         return False
 */
    }
  }

  /* "pysam/libcbcf.pyx":2374
 *             if r.d.fmt[i].p:
 *                 return True
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2366
 *         return n
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2376
 *         return False
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_6__getitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_bkey = 0;
  bcf_fmt_t *__pyx_v_fmt;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  char const *__pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_TraceCall("__getitem__", __pyx_f[0], 2376, 0, __PYX_ERR(0, 2376, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2377
 * 
 *     def __getitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 * 
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2378
 *     def __getitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2380
 *         cdef bcf1_t *r = self.record.ptr
 * 
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_bkey = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":2381
 * 
 *         cdef bytes bkey = force_bytes(key)
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)             # <<<<<<<<<<<<<<
 * 
 *         if not fmt or not fmt.p:
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2381, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 2381, __pyx_L1_error)
  __pyx_v_fmt = bcf_get_fmt(__pyx_v_hdr, __pyx_v_r, __pyx_t_4);

  /* "pysam/libcbcf.pyx":2383
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 *         if not fmt or not fmt.p:             # <<<<<<<<<<<<<<
 *             raise KeyError('unknown format: {}'.format(key))
 * 
 */
  __pyx_t_6 = ((!(__pyx_v_fmt != 0)) != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_5 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = ((!(__pyx_v_fmt->p != 0)) != 0);
  __pyx_t_5 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_5)) {

    /* "pysam/libcbcf.pyx":2384
 * 
 *         if not fmt or not fmt.p:
 *             raise KeyError('unknown format: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         return makeVariantMetadata(self.record.header, BCF_HL_FMT, fmt.id)
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_unknown_format, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2384, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2384, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_key};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2384, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_key};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2384, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2384, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_key);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2384, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2384, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __PYX_ERR(0, 2384, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2383
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 *         if not fmt or not fmt.p:             # <<<<<<<<<<<<<<
 *             raise KeyError('unknown format: {}'.format(key))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2386
 *             raise KeyError('unknown format: {}'.format(key))
 * 
 *         return makeVariantMetadata(self.record.header, BCF_HL_FMT, fmt.id)             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, key):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = ((PyObject *)__pyx_v_self->record->header);
  __Pyx_INCREF(__pyx_t_7);
  __pyx_t_3 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantMetadata(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_7), BCF_HL_FMT, __pyx_v_fmt->id)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2376
 *         return False
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2388
 *         return makeVariantMetadata(self.record.header, BCF_HL_FMT, fmt.id)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_9__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_9__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_8__delitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_8__delitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_bkey = 0;
  bcf_fmt_t *__pyx_v_fmt;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  char const *__pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  char const *__pyx_t_10;
  __Pyx_RefNannySetupContext("__delitem__", 0);
  __Pyx_TraceCall("__delitem__", __pyx_f[0], 2388, 0, __PYX_ERR(0, 2388, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2389
 * 
 *     def __delitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 * 
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2390
 *     def __delitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2392
 *         cdef bcf1_t *r = self.record.ptr
 * 
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_bkey = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":2393
 * 
 *         cdef bytes bkey = force_bytes(key)
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)             # <<<<<<<<<<<<<<
 * 
 *         if not fmt or not fmt.p:
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2393, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 2393, __pyx_L1_error)
  __pyx_v_fmt = bcf_get_fmt(__pyx_v_hdr, __pyx_v_r, __pyx_t_4);

  /* "pysam/libcbcf.pyx":2395
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 *         if not fmt or not fmt.p:             # <<<<<<<<<<<<<<
 *             raise KeyError('unknown format: {}'.format(key))
 * 
 */
  __pyx_t_6 = ((!(__pyx_v_fmt != 0)) != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_5 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = ((!(__pyx_v_fmt->p != 0)) != 0);
  __pyx_t_5 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_5)) {

    /* "pysam/libcbcf.pyx":2396
 * 
 *         if not fmt or not fmt.p:
 *             raise KeyError('unknown format: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         if bcf_update_format(hdr, r, bkey, fmt.p, 0, fmt.type) < 0:
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_unknown_format, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2396, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2396, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_key};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2396, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_key};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2396, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2396, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_key);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2396, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2396, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __PYX_ERR(0, 2396, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2395
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 * 
 *         if not fmt or not fmt.p:             # <<<<<<<<<<<<<<
 *             raise KeyError('unknown format: {}'.format(key))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2398
 *             raise KeyError('unknown format: {}'.format(key))
 * 
 *         if bcf_update_format(hdr, r, bkey, fmt.p, 0, fmt.type) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Unable to delete FORMAT')
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2398, __pyx_L1_error)
  }
  __pyx_t_10 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) __PYX_ERR(0, 2398, __pyx_L1_error)
  __pyx_t_5 = ((bcf_update_format(__pyx_v_hdr, __pyx_v_r, __pyx_t_10, __pyx_v_fmt->p, 0, __pyx_v_fmt->type) < 0) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "pysam/libcbcf.pyx":2399
 * 
 *         if bcf_update_format(hdr, r, bkey, fmt.p, 0, fmt.type) < 0:
 *             raise ValueError('Unable to delete FORMAT')             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__110, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __PYX_ERR(0, 2399, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2398
 *             raise KeyError('unknown format: {}'.format(key))
 * 
 *         if bcf_update_format(hdr, r, bkey, fmt.p, 0, fmt.type) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Unable to delete FORMAT')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2388
 *         return makeVariantMetadata(self.record.header, BCF_HL_FMT, fmt.id)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.__delitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2401
 *             raise ValueError('Unable to delete FORMAT')
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         """Clear all formats for all samples within the associated
 *            :class:`VariantRecord` instance"""
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_11clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_10clear[] = "VariantRecordFormat.clear(self)\nClear all formats for all samples within the associated\n           :class:`VariantRecord` instance";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_11clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_10clear(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_10clear(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  bcf_fmt_t *__pyx_v_fmt;
  char const *__pyx_v_key;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("clear", 0);
  __Pyx_TraceCall("clear", __pyx_f[0], 2401, 0, __PYX_ERR(0, 2401, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2404
 *         """Clear all formats for all samples within the associated
 *            :class:`VariantRecord` instance"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bcf_fmt_t *fmt
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2405
 *            :class:`VariantRecord` instance"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_fmt_t *fmt
 *         cdef const char *key
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2410
 *         cdef int i
 * 
 *         for i in reversed(range(r.n_fmt)):             # <<<<<<<<<<<<<<
 *             fmt = &r.d.fmt[i]
 *             if fmt.p:
 */
  for (__pyx_t_3 = __pyx_v_r->n_fmt-1; __pyx_t_3 >= 0; __pyx_t_3-=1) {
    __pyx_v_i = __pyx_t_3;

    /* "pysam/libcbcf.pyx":2411
 * 
 *         for i in reversed(range(r.n_fmt)):
 *             fmt = &r.d.fmt[i]             # <<<<<<<<<<<<<<
 *             if fmt.p:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id)
 */
    __pyx_v_fmt = (&(__pyx_v_r->d.fmt[__pyx_v_i]));

    /* "pysam/libcbcf.pyx":2412
 *         for i in reversed(range(r.n_fmt)):
 *             fmt = &r.d.fmt[i]
 *             if fmt.p:             # <<<<<<<<<<<<<<
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id)
 *                 if bcf_update_format(hdr, r, key, fmt.p, 0, fmt.type) < 0:
 */
    __pyx_t_4 = (__pyx_v_fmt->p != 0);
    if (__pyx_t_4) {

      /* "pysam/libcbcf.pyx":2413
 *             fmt = &r.d.fmt[i]
 *             if fmt.p:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id)             # <<<<<<<<<<<<<<
 *                 if bcf_update_format(hdr, r, key, fmt.p, 0, fmt.type) < 0:
 *                     raise ValueError('Unable to delete FORMAT')
 */
      __pyx_v_key = bcf_hdr_int2id(__pyx_v_hdr, BCF_DT_ID, __pyx_v_fmt->id);

      /* "pysam/libcbcf.pyx":2414
 *             if fmt.p:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id)
 *                 if bcf_update_format(hdr, r, key, fmt.p, 0, fmt.type) < 0:             # <<<<<<<<<<<<<<
 *                     raise ValueError('Unable to delete FORMAT')
 * 
 */
      __pyx_t_4 = ((bcf_update_format(__pyx_v_hdr, __pyx_v_r, __pyx_v_key, __pyx_v_fmt->p, 0, __pyx_v_fmt->type) < 0) != 0);
      if (unlikely(__pyx_t_4)) {

        /* "pysam/libcbcf.pyx":2415
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id)
 *                 if bcf_update_format(hdr, r, key, fmt.p, 0, fmt.type) < 0:
 *                     raise ValueError('Unable to delete FORMAT')             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__111, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2415, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __PYX_ERR(0, 2415, __pyx_L1_error)

        /* "pysam/libcbcf.pyx":2414
 *             if fmt.p:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id)
 *                 if bcf_update_format(hdr, r, key, fmt.p, 0, fmt.type) < 0:             # <<<<<<<<<<<<<<
 *                     raise ValueError('Unable to delete FORMAT')
 * 
 */
      }

      /* "pysam/libcbcf.pyx":2412
 *         for i in reversed(range(r.n_fmt)):
 *             fmt = &r.d.fmt[i]
 *             if fmt.p:             # <<<<<<<<<<<<<<
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id)
 *                 if bcf_update_format(hdr, r, key, fmt.p, 0, fmt.type) < 0:
 */
    }
  }

  /* "pysam/libcbcf.pyx":2401
 *             raise ValueError('Unable to delete FORMAT')
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         """Clear all formats for all samples within the associated
 *            :class:`VariantRecord` instance"""
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.clear", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantRecordFormat_14generator14(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":2417
 *                     raise ValueError('Unable to delete FORMAT')
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_13__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_13__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_12__iter__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_12__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__ *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__ *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_24___iter__(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_24___iter__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2417, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantRecordFormat_14generator14, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_VariantRecordFormat___iter, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 2417, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.__iter__", __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_5pysam_7libcbcf_19VariantRecordFormat_14generator14(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__ *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  uint32_t __pyx_t_3;
  uint32_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 2417, 0, __PYX_ERR(0, 2417, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L7_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2417, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2418
 * 
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bcf_fmt_t *fmt
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->record->header->ptr;
  __pyx_cur_scope->__pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2419
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_fmt_t *fmt
 *         cdef int i
 */
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self->record->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2423
 *         cdef int i
 * 
 *         for i in range(r.n_fmt):             # <<<<<<<<<<<<<<
 *             fmt = &r.d.fmt[i]
 *             if fmt.p:
 */
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_r->n_fmt;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_5;

    /* "pysam/libcbcf.pyx":2424
 * 
 *         for i in range(r.n_fmt):
 *             fmt = &r.d.fmt[i]             # <<<<<<<<<<<<<<
 *             if fmt.p:
 *                 yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 */
    __pyx_cur_scope->__pyx_v_fmt = (&(__pyx_cur_scope->__pyx_v_r->d.fmt[__pyx_cur_scope->__pyx_v_i]));

    /* "pysam/libcbcf.pyx":2425
 *         for i in range(r.n_fmt):
 *             fmt = &r.d.fmt[i]
 *             if fmt.p:             # <<<<<<<<<<<<<<
 *                 yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 */
    __pyx_t_6 = (__pyx_cur_scope->__pyx_v_fmt->p != 0);
    if (__pyx_t_6) {

      /* "pysam/libcbcf.pyx":2426
 *             fmt = &r.d.fmt[i]
 *             if fmt.p:
 *                 yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
      __pyx_t_7 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(bcf_hdr_int2id(__pyx_cur_scope->__pyx_v_hdr, BCF_DT_ID, __pyx_cur_scope->__pyx_v_fmt->id)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2426, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_r = __pyx_t_7;
      __pyx_t_7 = 0;
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_TraceReturn(__pyx_r, 0);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L7_resume_from_yield:;
      __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
      __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2426, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2425
 *         for i in range(r.n_fmt):
 *             fmt = &r.d.fmt[i]
 *             if fmt.p:             # <<<<<<<<<<<<<<
 *                 yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 */
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":2417
 *                     raise ValueError('Unable to delete FORMAT')
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2428
 *                 yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_16get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_15get[] = "VariantRecordFormat.get(self, key, default=None)\nD.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_16get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 2428, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2428, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_15get(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_15get(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("get", 0);
  __Pyx_TraceCall("get", __pyx_f[0], 2428, 0, __PYX_ERR(0, 2428, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2430
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":2431
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 *             return self[key]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return default
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2431, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "pysam/libcbcf.pyx":2430
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":2432
 *         try:
 *             return self[key]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 2432, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":2433
 *             return self[key]
 *         except KeyError:
 *             return default             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_default);
      __pyx_r = __pyx_v_default;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":2430
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":2428
 *                 yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2435
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_18__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_18__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_17__contains__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_17__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_bkey = 0;
  bcf_fmt_t *__pyx_v_fmt;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  char const *__pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__contains__", 0);
  __Pyx_TraceCall("__contains__", __pyx_f[0], 2435, 0, __PYX_ERR(0, 2435, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2436
 * 
 *     def __contains__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2437
 *     def __contains__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bytes bkey = force_bytes(key)
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2438
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 *         return fmt != NULL and fmt.p != NULL
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_bkey = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":2439
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bytes bkey = force_bytes(key)
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)             # <<<<<<<<<<<<<<
 *         return fmt != NULL and fmt.p != NULL
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2439, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 2439, __pyx_L1_error)
  __pyx_v_fmt = bcf_get_fmt(__pyx_v_hdr, __pyx_v_r, __pyx_t_4);

  /* "pysam/libcbcf.pyx":2440
 *         cdef bytes bkey = force_bytes(key)
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 *         return fmt != NULL and fmt.p != NULL             # <<<<<<<<<<<<<<
 * 
 *     def iterkeys(self):
 */
  __pyx_t_6 = (__pyx_v_fmt != NULL);
  if (__pyx_t_6) {
  } else {
    __pyx_t_5 = __pyx_t_6;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_6 = (__pyx_v_fmt->p != NULL);
  __pyx_t_5 = __pyx_t_6;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_5;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2435
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2442
 *         return fmt != NULL and fmt.p != NULL
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_20iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_19iterkeys[] = "VariantRecordFormat.iterkeys(self)\nD.iterkeys() -> an iterator over the keys of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_20iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iterkeys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_19iterkeys(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_19iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("iterkeys", 0);
  __Pyx_TraceCall("iterkeys", __pyx_f[0], 2442, 0, __PYX_ERR(0, 2442, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2444
 *     def iterkeys(self):
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)             # <<<<<<<<<<<<<<
 * 
 *     def itervalues(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2442
 *         return fmt != NULL and fmt.p != NULL
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.iterkeys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantRecordFormat_23generator15(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":2446
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_22itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_21itervalues[] = "VariantRecordFormat.itervalues(self)\nD.itervalues() -> an iterator over the values of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_22itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_21itervalues(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_21itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_25_itervalues(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_25_itervalues, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2446, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantRecordFormat_23generator15, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_itervalues, __pyx_n_s_VariantRecordFormat_itervalues, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 2446, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.itervalues", __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_5pysam_7libcbcf_19VariantRecordFormat_23generator15(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __Pyx_TraceCall("itervalues", __pyx_f[0], 2446, 0, __PYX_ERR(0, 2446, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2446, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2448
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield self[key]
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2448, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2448, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2448, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2448, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2448, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2448, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2448, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":2449
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 *             yield self[key]             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2449, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2448
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield self[key]
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":2446
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("itervalues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantRecordFormat_26generator16(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":2451
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_25iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_24iteritems[] = "VariantRecordFormat.iteritems(self)\nD.iteritems() -> an iterator over the (key, value) items of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_25iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_24iteritems(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_24iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_26_iteritems(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_26_iteritems, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2451, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantRecordFormat_26generator16, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iteritems, __pyx_n_s_VariantRecordFormat_iteritems, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 2451, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.iteritems", __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_5pysam_7libcbcf_19VariantRecordFormat_26generator16(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __Pyx_TraceCall("iteritems", __pyx_f[0], 2451, 0, __PYX_ERR(0, 2451, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2451, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2453
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield (key, self[key])
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2453, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2453, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2453, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2453, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2453, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2453, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2453, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":2454
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 *             yield (key, self[key])             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2454, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2454, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_cur_scope->__pyx_v_key);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2454, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2453
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield (key, self[key])
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":2451
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("iteritems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2456
 *             yield (key, self[key])
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_28keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_27keys[] = "VariantRecordFormat.keys(self)\nD.keys() -> list of D's keys";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_28keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_27keys(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_27keys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("keys", 0);
  __Pyx_TraceCall("keys", __pyx_f[0], 2456, 0, __PYX_ERR(0, 2456, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2458
 *     def keys(self):
 *         """D.keys() -> list of D's keys"""
 *         return list(self)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_List(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2456
 *             yield (key, self[key])
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2460
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_30items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_29items[] = "VariantRecordFormat.items(self)\nD.items() -> list of D's (key, value) pairs, as 2-tuples";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_30items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("items (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_29items(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_29items(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("items", 0);
  __Pyx_TraceCall("items", __pyx_f[0], 2460, 0, __PYX_ERR(0, 2460, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2462
 *     def items(self):
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_iteritems); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2462, __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, 2462, __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, 2462, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2462, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2460
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.items", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2464
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_32values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_31values[] = "VariantRecordFormat.values(self)\nD.values() -> list of D's values";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_32values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("values (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_31values(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_31values(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("values", 0);
  __Pyx_TraceCall("values", __pyx_f[0], 2464, 0, __PYX_ERR(0, 2464, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2466
 *     def values(self):
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())             # <<<<<<<<<<<<<<
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itervalues); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2466, __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, 2466, __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, 2466, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2464
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.record,)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_34__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_33__reduce_cython__[] = "VariantRecordFormat.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_34__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_33__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_33__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.record,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->record));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->record));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->record));
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.record,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":5
 *     state = (self.record,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.record is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.record,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.record is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_VariantRecordFormat, (type(self), 0xde17f0f, None), state
 */
  /*else*/ {
    __pyx_t_3 = (((PyObject *)__pyx_v_self->record) != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.record is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantRecordFormat, (type(self), 0xde17f0f, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":11
 *         use_setstate = self.record is not None
 *     if use_setstate:
 *         return __pyx_unpickle_VariantRecordFormat, (type(self), 0xde17f0f, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_VariantRecordFormat, (type(self), 0xde17f0f, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantRecordForm); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_232881935);
    __Pyx_GIVEREF(__pyx_int_232881935);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_232881935);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.record is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantRecordFormat, (type(self), 0xde17f0f, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_VariantRecordFormat, (type(self), 0xde17f0f, None), state
 *     else:
 *         return __pyx_unpickle_VariantRecordFormat, (type(self), 0xde17f0f, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantRecordFormat__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantRecordForm); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_232881935);
    __Pyx_GIVEREF(__pyx_int_232881935);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_232881935);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.record,)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantRecordFormat, (type(self), 0xde17f0f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantRecordFormat__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_36__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_35__setstate_cython__[] = "VariantRecordFormat.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_36__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_35__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordFormat_35__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 14, 0, __PYX_ERR(2, 14, __pyx_L1_error));

  /* "(tree fragment)":15
 *         return __pyx_unpickle_VariantRecordFormat, (type(self), 0xde17f0f, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantRecordFormat__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordFormat__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantRecordFormat, (type(self), 0xde17f0f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantRecordFormat__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordFormat.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2474
 * 
 * 
 * cdef VariantRecordFormat makeVariantRecordFormat(VariantRecord record):             # <<<<<<<<<<<<<<
 *     if not record:
 *         raise ValueError('invalid VariantRecord')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_f_5pysam_7libcbcf_makeVariantRecordFormat(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v_format = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("makeVariantRecordFormat", 0);
  __Pyx_TraceCall("makeVariantRecordFormat", __pyx_f[0], 2474, 0, __PYX_ERR(0, 2474, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2475
 * 
 * cdef VariantRecordFormat makeVariantRecordFormat(VariantRecord record):
 *     if not record:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantRecord')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_record)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2475, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":2476
 * cdef VariantRecordFormat makeVariantRecordFormat(VariantRecord record):
 *     if not record:
 *         raise ValueError('invalid VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantRecordFormat format = VariantRecordFormat.__new__(VariantRecordFormat)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__112, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2476, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2476, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2475
 * 
 * cdef VariantRecordFormat makeVariantRecordFormat(VariantRecord record):
 *     if not record:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2478
 *         raise ValueError('invalid VariantRecord')
 * 
 *     cdef VariantRecordFormat format = VariantRecordFormat.__new__(VariantRecordFormat)             # <<<<<<<<<<<<<<
 *     format.record = record
 * 
 */
  __pyx_t_3 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantRecordFormat(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordFormat), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2478, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_format = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":2479
 * 
 *     cdef VariantRecordFormat format = VariantRecordFormat.__new__(VariantRecordFormat)
 *     format.record = record             # <<<<<<<<<<<<<<
 * 
 *     return format
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_record));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_record));
  __Pyx_GOTREF(__pyx_v_format->record);
  __Pyx_DECREF(((PyObject *)__pyx_v_format->record));
  __pyx_v_format->record = __pyx_v_record;

  /* "pysam/libcbcf.pyx":2481
 *     format.record = record
 * 
 *     return format             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_format));
  __pyx_r = __pyx_v_format;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2474
 * 
 * 
 * cdef VariantRecordFormat makeVariantRecordFormat(VariantRecord record):             # <<<<<<<<<<<<<<
 *     if not record:
 *         raise ValueError('invalid VariantRecord')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantRecordFormat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_format);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2489
 *        mapping from info metadata name to value."""
 * 
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 2489, 0, __PYX_ERR(0, 2489, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2490
 * 
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__113, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 2490, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2489
 *        mapping from info metadata name to value."""
 * 
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2492
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_3__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_3__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_2__len__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  bcf_info_t *__pyx_v_info;
  char const *__pyx_v_key;
  int __pyx_v_i;
  int __pyx_v_count;
  Py_ssize_t __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  uint32_t __pyx_t_5;
  uint32_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("__len__", 0);
  __Pyx_TraceCall("__len__", __pyx_f[0], 2492, 0, __PYX_ERR(0, 2492, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2493
 * 
 *     def __len__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bcf_info_t *info
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2494
 *     def __len__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_info_t *info
 *         cdef const char *key
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2497
 *         cdef bcf_info_t *info
 *         cdef const char *key
 *         cdef int i, count = 0             # <<<<<<<<<<<<<<
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 */
  __pyx_v_count = 0;

  /* "pysam/libcbcf.pyx":2499
 *         cdef int i, count = 0
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2500
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_info):
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__114, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2500, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2500, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2499
 *         cdef int i, count = 0
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2502
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         for i in range(r.n_info):             # <<<<<<<<<<<<<<
 *             info = &r.d.info[i]
 *             key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 */
  __pyx_t_5 = __pyx_v_r->n_info;
  __pyx_t_6 = __pyx_t_5;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "pysam/libcbcf.pyx":2503
 * 
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]             # <<<<<<<<<<<<<<
 *             key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *             if info != NULL and info.vptr != NULL and strcmp(key, b'END') != 0:
 */
    __pyx_v_info = (&(__pyx_v_r->d.info[__pyx_v_i]));

    /* "pysam/libcbcf.pyx":2504
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]
 *             key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)             # <<<<<<<<<<<<<<
 *             if info != NULL and info.vptr != NULL and strcmp(key, b'END') != 0:
 *                 count += 1
 */
    __pyx_v_key = bcf_hdr_int2id(__pyx_v_hdr, BCF_DT_ID, __pyx_v_info->key);

    /* "pysam/libcbcf.pyx":2505
 *             info = &r.d.info[i]
 *             key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *             if info != NULL and info.vptr != NULL and strcmp(key, b'END') != 0:             # <<<<<<<<<<<<<<
 *                 count += 1
 * 
 */
    __pyx_t_8 = ((__pyx_v_info != NULL) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_3 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_info->vptr != NULL) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_3 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_8 = ((strcmp(__pyx_v_key, ((char const *)"END")) != 0) != 0);
    __pyx_t_3 = __pyx_t_8;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_3) {

      /* "pysam/libcbcf.pyx":2506
 *             key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *             if info != NULL and info.vptr != NULL and strcmp(key, b'END') != 0:
 *                 count += 1             # <<<<<<<<<<<<<<
 * 
 *         return count
 */
      __pyx_v_count = (__pyx_v_count + 1);

      /* "pysam/libcbcf.pyx":2505
 *             info = &r.d.info[i]
 *             key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *             if info != NULL and info.vptr != NULL and strcmp(key, b'END') != 0:             # <<<<<<<<<<<<<<
 *                 count += 1
 * 
 */
    }
  }

  /* "pysam/libcbcf.pyx":2508
 *                 count += 1
 * 
 *         return count             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
  __pyx_r = __pyx_v_count;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2492
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2510
 *         return count
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_5__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_5__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_4__bool__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  bcf_info_t *__pyx_v_info;
  char const *__pyx_v_key;
  int __pyx_v_i;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  uint32_t __pyx_t_5;
  uint32_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("__bool__", 0);
  __Pyx_TraceCall("__bool__", __pyx_f[0], 2510, 0, __PYX_ERR(0, 2510, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2511
 * 
 *     def __bool__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bcf_info_t *info
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2512
 *     def __bool__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_info_t *info
 *         cdef const char *key
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2517
 *         cdef int i
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2518
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_info):
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__115, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2518, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2517
 *         cdef int i
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2520
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         for i in range(r.n_info):             # <<<<<<<<<<<<<<
 *             info = &r.d.info[i]
 *             key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 */
  __pyx_t_5 = __pyx_v_r->n_info;
  __pyx_t_6 = __pyx_t_5;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "pysam/libcbcf.pyx":2521
 * 
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]             # <<<<<<<<<<<<<<
 *             key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *             if info != NULL and info.vptr != NULL and strcmp(key, b'END') != 0:
 */
    __pyx_v_info = (&(__pyx_v_r->d.info[__pyx_v_i]));

    /* "pysam/libcbcf.pyx":2522
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]
 *             key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)             # <<<<<<<<<<<<<<
 *             if info != NULL and info.vptr != NULL and strcmp(key, b'END') != 0:
 *                 return True
 */
    __pyx_v_key = bcf_hdr_int2id(__pyx_v_hdr, BCF_DT_ID, __pyx_v_info->key);

    /* "pysam/libcbcf.pyx":2523
 *             info = &r.d.info[i]
 *             key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *             if info != NULL and info.vptr != NULL and strcmp(key, b'END') != 0:             # <<<<<<<<<<<<<<
 *                 return True
 * 
 */
    __pyx_t_8 = ((__pyx_v_info != NULL) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_3 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_info->vptr != NULL) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_3 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_8 = ((strcmp(__pyx_v_key, ((char const *)"END")) != 0) != 0);
    __pyx_t_3 = __pyx_t_8;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_3) {

      /* "pysam/libcbcf.pyx":2524
 *             key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *             if info != NULL and info.vptr != NULL and strcmp(key, b'END') != 0:
 *                 return True             # <<<<<<<<<<<<<<
 * 
 *         return False
 */
      __pyx_r = 1;
      goto __pyx_L0;

      /* "pysam/libcbcf.pyx":2523
 *             info = &r.d.info[i]
 *             key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *             if info != NULL and info.vptr != NULL and strcmp(key, b'END') != 0:             # <<<<<<<<<<<<<<
 *                 return True
 * 
 */
    }
  }

  /* "pysam/libcbcf.pyx":2526
 *                 return True
 * 
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2510
 *         return count
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2528
 *         return False
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_6__getitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_bkey = 0;
  bcf_info_t *__pyx_v_info;
  int __pyx_v_info_id;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  char const *__pyx_t_5;
  char const *__pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_TraceCall("__getitem__", __pyx_f[0], 2528, 0, __PYX_ERR(0, 2528, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2529
 * 
 *     def __getitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 * 
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2530
 *     def __getitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2532
 *         cdef bcf1_t *r = self.record.ptr
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2533
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__116, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2533, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2533, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2532
 *         cdef bcf1_t *r = self.record.ptr
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2535
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 * 
 *         if strcmp(bkey, b'END') == 0:
 */
  __pyx_t_4 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_bkey = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":2537
 *         cdef bytes bkey = force_bytes(key)
 * 
 *         if strcmp(bkey, b'END') == 0:             # <<<<<<<<<<<<<<
 *             raise KeyError('END is a reserved attribute; access is via record.stop')
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2537, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 2537, __pyx_L1_error)
  __pyx_t_3 = ((strcmp(__pyx_t_5, ((char const *)"END")) == 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2538
 * 
 *         if strcmp(bkey, b'END') == 0:
 *             raise KeyError('END is a reserved attribute; access is via record.stop')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_tuple__117, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2538, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2538, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2537
 *         cdef bytes bkey = force_bytes(key)
 * 
 *         if strcmp(bkey, b'END') == 0:             # <<<<<<<<<<<<<<
 *             raise KeyError('END is a reserved attribute; access is via record.stop')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2540
 *             raise KeyError('END is a reserved attribute; access is via record.stop')
 * 
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)             # <<<<<<<<<<<<<<
 * 
 *         # Cannot stop here if info == NULL, since flags must return False
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2540, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 2540, __pyx_L1_error)
  __pyx_v_info = bcf_get_info(__pyx_v_hdr, __pyx_v_r, __pyx_t_6);

  /* "pysam/libcbcf.pyx":2543
 * 
 *         # Cannot stop here if info == NULL, since flags must return False
 *         cdef int info_id = bcf_header_get_info_id(hdr, bkey) if not info else info.key             # <<<<<<<<<<<<<<
 * 
 *         if info_id < 0:
 */
  if (((!(__pyx_v_info != 0)) != 0)) {
    __pyx_t_8 = __pyx_f_5pysam_7libcbcf_bcf_header_get_info_id(__pyx_v_hdr, __pyx_v_bkey); if (unlikely(__pyx_t_8 == ((int)-2) && PyErr_Occurred())) __PYX_ERR(0, 2543, __pyx_L1_error)
    __pyx_t_7 = __pyx_t_8;
  } else {
    __pyx_t_7 = __pyx_v_info->key;
  }
  __pyx_v_info_id = __pyx_t_7;

  /* "pysam/libcbcf.pyx":2545
 *         cdef int info_id = bcf_header_get_info_id(hdr, bkey) if not info else info.key
 * 
 *         if info_id < 0:             # <<<<<<<<<<<<<<
 *             raise KeyError('Unknown INFO field: {}'.format(key))
 * 
 */
  __pyx_t_3 = ((__pyx_v_info_id < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2546
 * 
 *         if info_id < 0:
 *             raise KeyError('Unknown INFO field: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unknown_INFO_field, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2546, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2546, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2546, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2546, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2546, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_key);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2546, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2546, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 2546, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2545
 *         cdef int info_id = bcf_header_get_info_id(hdr, bkey) if not info else info.key
 * 
 *         if info_id < 0:             # <<<<<<<<<<<<<<
 *             raise KeyError('Unknown INFO field: {}'.format(key))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2548
 *             raise KeyError('Unknown INFO field: {}'.format(key))
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header')
 * 
 */
  __pyx_t_3 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, BCF_HL_INFO, __pyx_v_info_id) != 0)) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2549
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):
 *             raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *         # Handle type=Flag values
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__118, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 2549, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2548
 *             raise KeyError('Unknown INFO field: {}'.format(key))
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2552
 * 
 *         # Handle type=Flag values
 *         if bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id) == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *             return info != NULL and info.vptr != NULL
 * 
 */
  __pyx_t_3 = ((bcf_hdr_id2type(__pyx_v_hdr, BCF_HL_INFO, __pyx_v_info_id) == BCF_HT_FLAG) != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":2553
 *         # Handle type=Flag values
 *         if bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id) == BCF_HT_FLAG:
 *             return info != NULL and info.vptr != NULL             # <<<<<<<<<<<<<<
 * 
 *         if not info or not info.vptr:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = (__pyx_v_info != NULL);
    if (__pyx_t_3) {
    } else {
      __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2553, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_3 = (__pyx_v_info->vptr != NULL);
    __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2553, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = __pyx_t_4;
    __pyx_t_4 = 0;
    __pyx_L8_bool_binop_done:;
    __pyx_r = __pyx_t_9;
    __pyx_t_9 = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2552
 * 
 *         # Handle type=Flag values
 *         if bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id) == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *             return info != NULL and info.vptr != NULL
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2555
 *             return info != NULL and info.vptr != NULL
 * 
 *         if not info or not info.vptr:             # <<<<<<<<<<<<<<
 *             raise KeyError('Invalid INFO field: {}'.format(key))
 * 
 */
  __pyx_t_12 = ((!(__pyx_v_info != 0)) != 0);
  if (!__pyx_t_12) {
  } else {
    __pyx_t_3 = __pyx_t_12;
    goto __pyx_L11_bool_binop_done;
  }
  __pyx_t_12 = ((!(__pyx_v_info->vptr != 0)) != 0);
  __pyx_t_3 = __pyx_t_12;
  __pyx_L11_bool_binop_done:;
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2556
 * 
 *         if not info or not info.vptr:
 *             raise KeyError('Invalid INFO field: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         return bcf_info_get_value(self.record, info)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Invalid_INFO_field, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_key); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2556, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_key};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2556, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_key};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2556, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_key);
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2556, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2555
 *             return info != NULL and info.vptr != NULL
 * 
 *         if not info or not info.vptr:             # <<<<<<<<<<<<<<
 *             raise KeyError('Invalid INFO field: {}'.format(key))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2558
 *             raise KeyError('Invalid INFO field: {}'.format(key))
 * 
 *         return bcf_info_get_value(self.record, info)             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, key, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = ((PyObject *)__pyx_v_self->record);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_9 = __pyx_f_5pysam_7libcbcf_bcf_info_get_value(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_4), __pyx_v_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2528
 *         return False
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2560
 *         return bcf_info_get_value(self.record, info)
 * 
 *     def __setitem__(self, key, value):             # <<<<<<<<<<<<<<
 *         cdef bytes bkey = force_bytes(key)
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_8__setitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self), ((PyObject *)__pyx_v_key), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_8__setitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_bkey = 0;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char const *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__setitem__", 0);
  __Pyx_TraceCall("__setitem__", __pyx_f[0], 2560, 0, __PYX_ERR(0, 2560, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2561
 * 
 *     def __setitem__(self, key, value):
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 * 
 *         if strcmp(bkey, b'END') == 0:
 */
  __pyx_t_1 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bkey = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":2563
 *         cdef bytes bkey = force_bytes(key)
 * 
 *         if strcmp(bkey, b'END') == 0:             # <<<<<<<<<<<<<<
 *             raise KeyError('END is a reserved attribute; access is via record.stop')
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2563, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 2563, __pyx_L1_error)
  __pyx_t_3 = ((strcmp(__pyx_t_2, ((char const *)"END")) == 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2564
 * 
 *         if strcmp(bkey, b'END') == 0:
 *             raise KeyError('END is a reserved attribute; access is via record.stop')             # <<<<<<<<<<<<<<
 * 
 *         if bcf_unpack(self.record.ptr, BCF_UN_INFO) < 0:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_tuple__119, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 2564, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2563
 *         cdef bytes bkey = force_bytes(key)
 * 
 *         if strcmp(bkey, b'END') == 0:             # <<<<<<<<<<<<<<
 *             raise KeyError('END is a reserved attribute; access is via record.stop')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2566
 *             raise KeyError('END is a reserved attribute; access is via record.stop')
 * 
 *         if bcf_unpack(self.record.ptr, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_v_self->record->ptr, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2567
 * 
 *         if bcf_unpack(self.record.ptr, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         bcf_info_set_value(self.record, key, value)
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__120, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2567, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 2567, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2566
 *             raise KeyError('END is a reserved attribute; access is via record.stop')
 * 
 *         if bcf_unpack(self.record.ptr, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2569
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         bcf_info_set_value(self.record, key, value)             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, key):
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->record);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = __pyx_f_5pysam_7libcbcf_bcf_info_set_value(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_1), __pyx_v_key, __pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":2560
 *         return bcf_info_get_value(self.record, info)
 * 
 *     def __setitem__(self, key, value):             # <<<<<<<<<<<<<<
 *         cdef bytes bkey = force_bytes(key)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2571
 *         bcf_info_set_value(self.record, key, value)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_11__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_11__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_10__delitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_10__delitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_bkey = 0;
  bcf_info_t *__pyx_v_info;
  int __pyx_v_info_id;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  char const *__pyx_t_4;
  int __pyx_t_5;
  char const *__pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  char const *__pyx_t_13;
  __Pyx_RefNannySetupContext("__delitem__", 0);
  __Pyx_TraceCall("__delitem__", __pyx_f[0], 2571, 0, __PYX_ERR(0, 2571, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2572
 * 
 *     def __delitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 * 
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2573
 *     def __delitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2575
 *         cdef bcf1_t *r = self.record.ptr
 * 
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *         if strcmp(bkey, b'END') == 0:
 *             raise KeyError('END is a reserved attribute; access is via record.stop')
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_bkey = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":2576
 * 
 *         cdef bytes bkey = force_bytes(key)
 *         if strcmp(bkey, b'END') == 0:             # <<<<<<<<<<<<<<
 *             raise KeyError('END is a reserved attribute; access is via record.stop')
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2576, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 2576, __pyx_L1_error)
  __pyx_t_5 = ((strcmp(__pyx_t_4, ((char const *)"END")) == 0) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "pysam/libcbcf.pyx":2577
 *         cdef bytes bkey = force_bytes(key)
 *         if strcmp(bkey, b'END') == 0:
 *             raise KeyError('END is a reserved attribute; access is via record.stop')             # <<<<<<<<<<<<<<
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_tuple__121, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2577, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2577, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2576
 * 
 *         cdef bytes bkey = force_bytes(key)
 *         if strcmp(bkey, b'END') == 0:             # <<<<<<<<<<<<<<
 *             raise KeyError('END is a reserved attribute; access is via record.stop')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2579
 *             raise KeyError('END is a reserved attribute; access is via record.stop')
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_5 = ((bcf_unpack(__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "pysam/libcbcf.pyx":2580
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__122, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2580, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2579
 *             raise KeyError('END is a reserved attribute; access is via record.stop')
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2582
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)             # <<<<<<<<<<<<<<
 * 
 *         # Cannot stop here if info == NULL, since flags must return False
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2582, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 2582, __pyx_L1_error)
  __pyx_v_info = bcf_get_info(__pyx_v_hdr, __pyx_v_r, __pyx_t_6);

  /* "pysam/libcbcf.pyx":2585
 * 
 *         # Cannot stop here if info == NULL, since flags must return False
 *         cdef int info_id = bcf_header_get_info_id(hdr, bkey) if not info else info.key             # <<<<<<<<<<<<<<
 * 
 *         if info_id < 0:
 */
  if (((!(__pyx_v_info != 0)) != 0)) {
    __pyx_t_8 = __pyx_f_5pysam_7libcbcf_bcf_header_get_info_id(__pyx_v_hdr, __pyx_v_bkey); if (unlikely(__pyx_t_8 == ((int)-2) && PyErr_Occurred())) __PYX_ERR(0, 2585, __pyx_L1_error)
    __pyx_t_7 = __pyx_t_8;
  } else {
    __pyx_t_7 = __pyx_v_info->key;
  }
  __pyx_v_info_id = __pyx_t_7;

  /* "pysam/libcbcf.pyx":2587
 *         cdef int info_id = bcf_header_get_info_id(hdr, bkey) if not info else info.key
 * 
 *         if info_id < 0:             # <<<<<<<<<<<<<<
 *             raise KeyError('Unknown INFO field: {}'.format(key))
 * 
 */
  __pyx_t_5 = ((__pyx_v_info_id < 0) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "pysam/libcbcf.pyx":2588
 * 
 *         if info_id < 0:
 *             raise KeyError('Unknown INFO field: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unknown_INFO_field, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2588, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2588, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2588, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2588, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_key);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2588, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 2588, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2587
 *         cdef int info_id = bcf_header_get_info_id(hdr, bkey) if not info else info.key
 * 
 *         if info_id < 0:             # <<<<<<<<<<<<<<
 *             raise KeyError('Unknown INFO field: {}'.format(key))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2590
 *             raise KeyError('Unknown INFO field: {}'.format(key))
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header')
 * 
 */
  __pyx_t_5 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, BCF_HL_INFO, __pyx_v_info_id) != 0)) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "pysam/libcbcf.pyx":2591
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):
 *             raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *         # Handle flags
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__123, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2591, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 2591, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2590
 *             raise KeyError('Unknown INFO field: {}'.format(key))
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2594
 * 
 *         # Handle flags
 *         if bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id) == BCF_HT_FLAG and (not info or not info.vptr):             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_12 = ((bcf_hdr_id2type(__pyx_v_hdr, BCF_HL_INFO, __pyx_v_info_id) == BCF_HT_FLAG) != 0);
  if (__pyx_t_12) {
  } else {
    __pyx_t_5 = __pyx_t_12;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_12 = ((!(__pyx_v_info != 0)) != 0);
  if (!__pyx_t_12) {
  } else {
    __pyx_t_5 = __pyx_t_12;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_12 = ((!(__pyx_v_info->vptr != 0)) != 0);
  __pyx_t_5 = __pyx_t_12;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_5) {

    /* "pysam/libcbcf.pyx":2595
 *         # Handle flags
 *         if bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id) == BCF_HT_FLAG and (not info or not info.vptr):
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if not info or not info.vptr:
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2594
 * 
 *         # Handle flags
 *         if bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id) == BCF_HT_FLAG and (not info or not info.vptr):             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2597
 *             return
 * 
 *         if not info or not info.vptr:             # <<<<<<<<<<<<<<
 *             raise KeyError('Unknown INFO field: {}'.format(key))
 * 
 */
  __pyx_t_12 = ((!(__pyx_v_info != 0)) != 0);
  if (!__pyx_t_12) {
  } else {
    __pyx_t_5 = __pyx_t_12;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_12 = ((!(__pyx_v_info->vptr != 0)) != 0);
  __pyx_t_5 = __pyx_t_12;
  __pyx_L12_bool_binop_done:;
  if (unlikely(__pyx_t_5)) {

    /* "pysam/libcbcf.pyx":2598
 * 
 *         if not info or not info.vptr:
 *             raise KeyError('Unknown INFO field: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         if bcf_update_info(hdr, r, bkey, NULL, 0, info.type) < 0:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unknown_INFO_field, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_key); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2598, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_key};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2598, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_key};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2598, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2598, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_key);
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2598, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2598, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2597
 *             return
 * 
 *         if not info or not info.vptr:             # <<<<<<<<<<<<<<
 *             raise KeyError('Unknown INFO field: {}'.format(key))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2600
 *             raise KeyError('Unknown INFO field: {}'.format(key))
 * 
 *         if bcf_update_info(hdr, r, bkey, NULL, 0, info.type) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Unable to delete INFO')
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2600, __pyx_L1_error)
  }
  __pyx_t_13 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(0, 2600, __pyx_L1_error)
  __pyx_t_5 = ((bcf_update_info(__pyx_v_hdr, __pyx_v_r, __pyx_t_13, NULL, 0, __pyx_v_info->type) < 0) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "pysam/libcbcf.pyx":2601
 * 
 *         if bcf_update_info(hdr, r, bkey, NULL, 0, info.type) < 0:
 *             raise ValueError('Unable to delete INFO')             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__124, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2601, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2600
 *             raise KeyError('Unknown INFO field: {}'.format(key))
 * 
 *         if bcf_update_info(hdr, r, bkey, NULL, 0, info.type) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Unable to delete INFO')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2571
 *         bcf_info_set_value(self.record, key, value)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.__delitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2603
 *             raise ValueError('Unable to delete INFO')
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         """Clear all info data"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_13clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_12clear[] = "VariantRecordInfo.clear(self)\nClear all info data";
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_13clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_12clear(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_12clear(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  bcf_info_t *__pyx_v_info;
  char const *__pyx_v_key;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  uint32_t __pyx_t_5;
  uint32_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("clear", 0);
  __Pyx_TraceCall("clear", __pyx_f[0], 2603, 0, __PYX_ERR(0, 2603, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2605
 *     def clear(self):
 *         """Clear all info data"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bcf_info_t *info
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2606
 *         """Clear all info data"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_info_t *info
 *         cdef const char *key
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2611
 *         cdef int i
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2612
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_info):
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__125, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2612, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2612, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2611
 *         cdef int i
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2614
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         for i in range(r.n_info):             # <<<<<<<<<<<<<<
 *             info = &r.d.info[i]
 *             if info and info.vptr:
 */
  __pyx_t_5 = __pyx_v_r->n_info;
  __pyx_t_6 = __pyx_t_5;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "pysam/libcbcf.pyx":2615
 * 
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]             # <<<<<<<<<<<<<<
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 */
    __pyx_v_info = (&(__pyx_v_r->d.info[__pyx_v_i]));

    /* "pysam/libcbcf.pyx":2616
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]
 *             if info and info.vptr:             # <<<<<<<<<<<<<<
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') == 0:
 */
    __pyx_t_8 = (__pyx_v_info != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_3 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_info->vptr != 0);
    __pyx_t_3 = __pyx_t_8;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_3) {

      /* "pysam/libcbcf.pyx":2617
 *             info = &r.d.info[i]
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)             # <<<<<<<<<<<<<<
 *                 if strcmp(key, b'END') == 0:
 *                     continue
 */
      __pyx_v_key = bcf_hdr_int2id(__pyx_v_hdr, BCF_DT_ID, __pyx_v_info->key);

      /* "pysam/libcbcf.pyx":2618
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') == 0:             # <<<<<<<<<<<<<<
 *                     continue
 *                 if bcf_update_info(hdr, r, key, NULL, 0, info.type) < 0:
 */
      __pyx_t_3 = ((strcmp(__pyx_v_key, ((char const *)"END")) == 0) != 0);
      if (__pyx_t_3) {

        /* "pysam/libcbcf.pyx":2619
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') == 0:
 *                     continue             # <<<<<<<<<<<<<<
 *                 if bcf_update_info(hdr, r, key, NULL, 0, info.type) < 0:
 *                     raise ValueError('Unable to delete INFO')
 */
        goto __pyx_L4_continue;

        /* "pysam/libcbcf.pyx":2618
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') == 0:             # <<<<<<<<<<<<<<
 *                     continue
 *                 if bcf_update_info(hdr, r, key, NULL, 0, info.type) < 0:
 */
      }

      /* "pysam/libcbcf.pyx":2620
 *                 if strcmp(key, b'END') == 0:
 *                     continue
 *                 if bcf_update_info(hdr, r, key, NULL, 0, info.type) < 0:             # <<<<<<<<<<<<<<
 *                     raise ValueError('Unable to delete INFO')
 * 
 */
      __pyx_t_3 = ((bcf_update_info(__pyx_v_hdr, __pyx_v_r, __pyx_v_key, NULL, 0, __pyx_v_info->type) < 0) != 0);
      if (unlikely(__pyx_t_3)) {

        /* "pysam/libcbcf.pyx":2621
 *                     continue
 *                 if bcf_update_info(hdr, r, key, NULL, 0, info.type) < 0:
 *                     raise ValueError('Unable to delete INFO')             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__126, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2621, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 2621, __pyx_L1_error)

        /* "pysam/libcbcf.pyx":2620
 *                 if strcmp(key, b'END') == 0:
 *                     continue
 *                 if bcf_update_info(hdr, r, key, NULL, 0, info.type) < 0:             # <<<<<<<<<<<<<<
 *                     raise ValueError('Unable to delete INFO')
 * 
 */
      }

      /* "pysam/libcbcf.pyx":2616
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]
 *             if info and info.vptr:             # <<<<<<<<<<<<<<
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') == 0:
 */
    }
    __pyx_L4_continue:;
  }

  /* "pysam/libcbcf.pyx":2603
 *             raise ValueError('Unable to delete INFO')
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         """Clear all info data"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.clear", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_17VariantRecordInfo_16generator17(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":2623
 *                     raise ValueError('Unable to delete INFO')
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_15__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_15__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_14__iter__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_14__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__ *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__ *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_27___iter__(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_27___iter__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2623, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_17VariantRecordInfo_16generator17, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_VariantRecordInfo___iter, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 2623, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.__iter__", __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_5pysam_7libcbcf_17VariantRecordInfo_16generator17(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__ *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  uint32_t __pyx_t_5;
  uint32_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 2623, 0, __PYX_ERR(0, 2623, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L11_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2623, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2624
 * 
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bcf_info_t *info
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->record->header->ptr;
  __pyx_cur_scope->__pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2625
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_info_t *info
 *         cdef const char *key
 */
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self->record->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2630
 *         cdef int i
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_cur_scope->__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2631
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_info):
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__127, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2631, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2630
 *         cdef int i
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2633
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         for i in range(r.n_info):             # <<<<<<<<<<<<<<
 *             info = &r.d.info[i]
 *             if info and info.vptr:
 */
  __pyx_t_5 = __pyx_cur_scope->__pyx_v_r->n_info;
  __pyx_t_6 = __pyx_t_5;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_7;

    /* "pysam/libcbcf.pyx":2634
 * 
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]             # <<<<<<<<<<<<<<
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 */
    __pyx_cur_scope->__pyx_v_info = (&(__pyx_cur_scope->__pyx_v_r->d.info[__pyx_cur_scope->__pyx_v_i]));

    /* "pysam/libcbcf.pyx":2635
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]
 *             if info and info.vptr:             # <<<<<<<<<<<<<<
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:
 */
    __pyx_t_8 = (__pyx_cur_scope->__pyx_v_info != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_3 = __pyx_t_8;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_cur_scope->__pyx_v_info->vptr != 0);
    __pyx_t_3 = __pyx_t_8;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_3) {

      /* "pysam/libcbcf.pyx":2636
 *             info = &r.d.info[i]
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)             # <<<<<<<<<<<<<<
 *                 if strcmp(key, b'END') != 0:
 *                     yield bcf_str_cache_get_charptr(key)
 */
      __pyx_cur_scope->__pyx_v_key = bcf_hdr_int2id(__pyx_cur_scope->__pyx_v_hdr, BCF_DT_ID, __pyx_cur_scope->__pyx_v_info->key);

      /* "pysam/libcbcf.pyx":2637
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:             # <<<<<<<<<<<<<<
 *                     yield bcf_str_cache_get_charptr(key)
 * 
 */
      __pyx_t_3 = ((strcmp(__pyx_cur_scope->__pyx_v_key, ((char const *)"END")) != 0) != 0);
      if (__pyx_t_3) {

        /* "pysam/libcbcf.pyx":2638
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:
 *                     yield bcf_str_cache_get_charptr(key)             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
        __pyx_t_4 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(__pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2638, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_r = __pyx_t_4;
        __pyx_t_4 = 0;
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_5;
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_TraceReturn(__pyx_r, 0);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, yielding value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L11_resume_from_yield:;
        __pyx_t_5 = __pyx_cur_scope->__pyx_t_0;
        __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
        __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2638, __pyx_L1_error)

        /* "pysam/libcbcf.pyx":2637
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:             # <<<<<<<<<<<<<<
 *                     yield bcf_str_cache_get_charptr(key)
 * 
 */
      }

      /* "pysam/libcbcf.pyx":2635
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]
 *             if info and info.vptr:             # <<<<<<<<<<<<<<
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:
 */
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":2623
 *                     raise ValueError('Unable to delete INFO')
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2640
 *                     yield bcf_str_cache_get_charptr(key)
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_18get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_17get[] = "VariantRecordInfo.get(self, key, default=None)\nD.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.";
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_18get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 2640, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2640, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_17get(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_17get(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_bkey = 0;
  bcf_info_t *__pyx_v_info;
  int __pyx_v_info_id;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  char const *__pyx_t_5;
  char const *__pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("get", 0);
  __Pyx_TraceCall("get", __pyx_f[0], 2640, 0, __PYX_ERR(0, 2640, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2642
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 * 
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2643
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2645
 *         cdef bcf1_t *r = self.record.ptr
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2646
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__128, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2646, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2646, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2645
 *         cdef bcf1_t *r = self.record.ptr
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2648
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 * 
 *         if strcmp(bkey, b'END') == 0:
 */
  __pyx_t_4 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2648, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_bkey = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":2650
 *         cdef bytes bkey = force_bytes(key)
 * 
 *         if strcmp(bkey, b'END') == 0:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2650, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 2650, __pyx_L1_error)
  __pyx_t_3 = ((strcmp(__pyx_t_5, ((char const *)"END")) == 0) != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":2651
 * 
 *         if strcmp(bkey, b'END') == 0:
 *             return default             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_default);
    __pyx_r = __pyx_v_default;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2650
 *         cdef bytes bkey = force_bytes(key)
 * 
 *         if strcmp(bkey, b'END') == 0:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2653
 *             return default
 * 
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)             # <<<<<<<<<<<<<<
 * 
 *         # Cannot stop here if info == NULL, since flags must return False
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2653, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 2653, __pyx_L1_error)
  __pyx_v_info = bcf_get_info(__pyx_v_hdr, __pyx_v_r, __pyx_t_6);

  /* "pysam/libcbcf.pyx":2656
 * 
 *         # Cannot stop here if info == NULL, since flags must return False
 *         cdef int info_id = bcf_header_get_info_id(hdr, bkey) if not info else info.key             # <<<<<<<<<<<<<<
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):
 */
  if (((!(__pyx_v_info != 0)) != 0)) {
    __pyx_t_8 = __pyx_f_5pysam_7libcbcf_bcf_header_get_info_id(__pyx_v_hdr, __pyx_v_bkey); if (unlikely(__pyx_t_8 == ((int)-2) && PyErr_Occurred())) __PYX_ERR(0, 2656, __pyx_L1_error)
    __pyx_t_7 = __pyx_t_8;
  } else {
    __pyx_t_7 = __pyx_v_info->key;
  }
  __pyx_v_info_id = __pyx_t_7;

  /* "pysam/libcbcf.pyx":2658
 *         cdef int info_id = bcf_header_get_info_id(hdr, bkey) if not info else info.key
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header')
 * 
 */
  __pyx_t_3 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, BCF_HL_INFO, __pyx_v_info_id) != 0)) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2659
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):
 *             raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *         # Handle flags
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__129, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2659, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2659, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2658
 *         cdef int info_id = bcf_header_get_info_id(hdr, bkey) if not info else info.key
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2662
 * 
 *         # Handle flags
 *         if bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id) == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *             return info != NULL and info.vptr != NULL
 * 
 */
  __pyx_t_3 = ((bcf_hdr_id2type(__pyx_v_hdr, BCF_HL_INFO, __pyx_v_info_id) == BCF_HT_FLAG) != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":2663
 *         # Handle flags
 *         if bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id) == BCF_HT_FLAG:
 *             return info != NULL and info.vptr != NULL             # <<<<<<<<<<<<<<
 * 
 *         if not info or not info.vptr:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = (__pyx_v_info != NULL);
    if (__pyx_t_3) {
    } else {
      __pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2663, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_4 = __pyx_t_9;
      __pyx_t_9 = 0;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_3 = (__pyx_v_info->vptr != NULL);
    __pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2663, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = __pyx_t_9;
    __pyx_t_9 = 0;
    __pyx_L7_bool_binop_done:;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2662
 * 
 *         # Handle flags
 *         if bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id) == BCF_HT_FLAG:             # <<<<<<<<<<<<<<
 *             return info != NULL and info.vptr != NULL
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2665
 *             return info != NULL and info.vptr != NULL
 * 
 *         if not info or not info.vptr:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
  __pyx_t_10 = ((!(__pyx_v_info != 0)) != 0);
  if (!__pyx_t_10) {
  } else {
    __pyx_t_3 = __pyx_t_10;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_10 = ((!(__pyx_v_info->vptr != 0)) != 0);
  __pyx_t_3 = __pyx_t_10;
  __pyx_L10_bool_binop_done:;
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":2666
 * 
 *         if not info or not info.vptr:
 *             return default             # <<<<<<<<<<<<<<
 * 
 *         return bcf_info_get_value(self.record, info)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_default);
    __pyx_r = __pyx_v_default;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2665
 *             return info != NULL and info.vptr != NULL
 * 
 *         if not info or not info.vptr:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2668
 *             return default
 * 
 *         return bcf_info_get_value(self.record, info)             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = ((PyObject *)__pyx_v_self->record);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_9 = __pyx_f_5pysam_7libcbcf_bcf_info_get_value(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_4), __pyx_v_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2668, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2640
 *                     yield bcf_str_cache_get_charptr(key)
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2670
 *         return bcf_info_get_value(self.record, info)
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_20__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_20__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_19__contains__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_19__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_bkey = 0;
  bcf_info_t *__pyx_v_info;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  char const *__pyx_t_5;
  char const *__pyx_t_6;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__contains__", 0);
  __Pyx_TraceCall("__contains__", __pyx_f[0], 2670, 0, __PYX_ERR(0, 2670, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2671
 * 
 *     def __contains__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 * 
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2672
 *     def __contains__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2674
 *         cdef bcf1_t *r = self.record.ptr
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2675
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__130, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2675, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2675, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2674
 *         cdef bcf1_t *r = self.record.ptr
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2677
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 * 
 *         if strcmp(bkey, b'END') == 0:
 */
  __pyx_t_4 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2677, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_bkey = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":2679
 *         cdef bytes bkey = force_bytes(key)
 * 
 *         if strcmp(bkey, b'END') == 0:             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2679, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 2679, __pyx_L1_error)
  __pyx_t_3 = ((strcmp(__pyx_t_5, ((char const *)"END")) == 0) != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":2680
 * 
 *         if strcmp(bkey, b'END') == 0:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2679
 *         cdef bytes bkey = force_bytes(key)
 * 
 *         if strcmp(bkey, b'END') == 0:             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2682
 *             return False
 * 
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)             # <<<<<<<<<<<<<<
 * 
 *         return info != NULL and info.vptr != NULL
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2682, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 2682, __pyx_L1_error)
  __pyx_v_info = bcf_get_info(__pyx_v_hdr, __pyx_v_r, __pyx_t_6);

  /* "pysam/libcbcf.pyx":2684
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 * 
 *         return info != NULL and info.vptr != NULL             # <<<<<<<<<<<<<<
 * 
 *     def iterkeys(self):
 */
  __pyx_t_3 = (__pyx_v_info != NULL);
  if (__pyx_t_3) {
  } else {
    __pyx_t_7 = __pyx_t_3;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_info->vptr != NULL);
  __pyx_t_7 = __pyx_t_3;
  __pyx_L5_bool_binop_done:;
  __pyx_r = __pyx_t_7;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2670
 *         return bcf_info_get_value(self.record, info)
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2686
 *         return info != NULL and info.vptr != NULL
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_22iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_21iterkeys[] = "VariantRecordInfo.iterkeys(self)\nD.iterkeys() -> an iterator over the keys of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_22iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iterkeys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_21iterkeys(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_21iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("iterkeys", 0);
  __Pyx_TraceCall("iterkeys", __pyx_f[0], 2686, 0, __PYX_ERR(0, 2686, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2688
 *     def iterkeys(self):
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)             # <<<<<<<<<<<<<<
 * 
 *     def itervalues(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2686
 *         return info != NULL and info.vptr != NULL
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.iterkeys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_17VariantRecordInfo_25generator18(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":2690
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_24itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_23itervalues[] = "VariantRecordInfo.itervalues(self)\nD.itervalues() -> an iterator over the values of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_24itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_23itervalues(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_23itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_28_itervalues(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_28_itervalues, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2690, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_17VariantRecordInfo_25generator18, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_itervalues, __pyx_n_s_VariantRecordInfo_itervalues, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 2690, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.itervalues", __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_5pysam_7libcbcf_17VariantRecordInfo_25generator18(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  uint32_t __pyx_t_5;
  uint32_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __Pyx_TraceCall("itervalues", __pyx_f[0], 2690, 0, __PYX_ERR(0, 2690, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L11_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2690, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2692
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bcf_info_t *info
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->record->header->ptr;
  __pyx_cur_scope->__pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2693
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_info_t *info
 *         cdef const char *key
 */
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self->record->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2698
 *         cdef int i
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_cur_scope->__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2699
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_info):
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__131, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2699, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2699, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2698
 *         cdef int i
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2701
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         for i in range(r.n_info):             # <<<<<<<<<<<<<<
 *             info = &r.d.info[i]
 *             if info and info.vptr:
 */
  __pyx_t_5 = __pyx_cur_scope->__pyx_v_r->n_info;
  __pyx_t_6 = __pyx_t_5;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_7;

    /* "pysam/libcbcf.pyx":2702
 * 
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]             # <<<<<<<<<<<<<<
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 */
    __pyx_cur_scope->__pyx_v_info = (&(__pyx_cur_scope->__pyx_v_r->d.info[__pyx_cur_scope->__pyx_v_i]));

    /* "pysam/libcbcf.pyx":2703
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]
 *             if info and info.vptr:             # <<<<<<<<<<<<<<
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:
 */
    __pyx_t_8 = (__pyx_cur_scope->__pyx_v_info != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_3 = __pyx_t_8;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_cur_scope->__pyx_v_info->vptr != 0);
    __pyx_t_3 = __pyx_t_8;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_3) {

      /* "pysam/libcbcf.pyx":2704
 *             info = &r.d.info[i]
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)             # <<<<<<<<<<<<<<
 *                 if strcmp(key, b'END') != 0:
 *                     yield bcf_info_get_value(self.record, info)
 */
      __pyx_cur_scope->__pyx_v_key = bcf_hdr_int2id(__pyx_cur_scope->__pyx_v_hdr, BCF_DT_ID, __pyx_cur_scope->__pyx_v_info->key);

      /* "pysam/libcbcf.pyx":2705
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:             # <<<<<<<<<<<<<<
 *                     yield bcf_info_get_value(self.record, info)
 * 
 */
      __pyx_t_3 = ((strcmp(__pyx_cur_scope->__pyx_v_key, ((char const *)"END")) != 0) != 0);
      if (__pyx_t_3) {

        /* "pysam/libcbcf.pyx":2706
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:
 *                     yield bcf_info_get_value(self.record, info)             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
        __pyx_t_4 = ((PyObject *)__pyx_cur_scope->__pyx_v_self->record);
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_9 = __pyx_f_5pysam_7libcbcf_bcf_info_get_value(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_4), __pyx_cur_scope->__pyx_v_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2706, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_r = __pyx_t_9;
        __pyx_t_9 = 0;
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_5;
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_TraceReturn(__pyx_r, 0);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, yielding value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L11_resume_from_yield:;
        __pyx_t_5 = __pyx_cur_scope->__pyx_t_0;
        __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
        __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2706, __pyx_L1_error)

        /* "pysam/libcbcf.pyx":2705
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:             # <<<<<<<<<<<<<<
 *                     yield bcf_info_get_value(self.record, info)
 * 
 */
      }

      /* "pysam/libcbcf.pyx":2703
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]
 *             if info and info.vptr:             # <<<<<<<<<<<<<<
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:
 */
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":2690
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("itervalues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_17VariantRecordInfo_28generator19(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":2708
 *                     yield bcf_info_get_value(self.record, info)
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_27iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_26iteritems[] = "VariantRecordInfo.iteritems(self)\nD.iteritems() -> an iterator over the (key, value) items of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_27iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_26iteritems(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_26iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_29_iteritems(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_29_iteritems, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2708, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_17VariantRecordInfo_28generator19, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iteritems, __pyx_n_s_VariantRecordInfo_iteritems, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 2708, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.iteritems", __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_5pysam_7libcbcf_17VariantRecordInfo_28generator19(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  uint32_t __pyx_t_5;
  uint32_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __Pyx_TraceCall("iteritems", __pyx_f[0], 2708, 0, __PYX_ERR(0, 2708, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L11_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2708, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2710
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bcf_info_t *info
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->record->header->ptr;
  __pyx_cur_scope->__pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2711
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_info_t *info
 *         cdef const char *key
 */
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self->record->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2716
 *         cdef int i
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_cur_scope->__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2717
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_info):
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__132, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2717, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2717, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2716
 *         cdef int i
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2719
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         for i in range(r.n_info):             # <<<<<<<<<<<<<<
 *             info = &r.d.info[i]
 *             if info and info.vptr:
 */
  __pyx_t_5 = __pyx_cur_scope->__pyx_v_r->n_info;
  __pyx_t_6 = __pyx_t_5;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_7;

    /* "pysam/libcbcf.pyx":2720
 * 
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]             # <<<<<<<<<<<<<<
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 */
    __pyx_cur_scope->__pyx_v_info = (&(__pyx_cur_scope->__pyx_v_r->d.info[__pyx_cur_scope->__pyx_v_i]));

    /* "pysam/libcbcf.pyx":2721
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]
 *             if info and info.vptr:             # <<<<<<<<<<<<<<
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:
 */
    __pyx_t_8 = (__pyx_cur_scope->__pyx_v_info != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_3 = __pyx_t_8;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_cur_scope->__pyx_v_info->vptr != 0);
    __pyx_t_3 = __pyx_t_8;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_3) {

      /* "pysam/libcbcf.pyx":2722
 *             info = &r.d.info[i]
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)             # <<<<<<<<<<<<<<
 *                 if strcmp(key, b'END') != 0:
 *                     value = bcf_info_get_value(self.record, info)
 */
      __pyx_cur_scope->__pyx_v_key = bcf_hdr_int2id(__pyx_cur_scope->__pyx_v_hdr, BCF_DT_ID, __pyx_cur_scope->__pyx_v_info->key);

      /* "pysam/libcbcf.pyx":2723
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:             # <<<<<<<<<<<<<<
 *                     value = bcf_info_get_value(self.record, info)
 *                     yield bcf_str_cache_get_charptr(key), value
 */
      __pyx_t_3 = ((strcmp(__pyx_cur_scope->__pyx_v_key, ((char const *)"END")) != 0) != 0);
      if (__pyx_t_3) {

        /* "pysam/libcbcf.pyx":2724
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:
 *                     value = bcf_info_get_value(self.record, info)             # <<<<<<<<<<<<<<
 *                     yield bcf_str_cache_get_charptr(key), value
 * 
 */
        __pyx_t_4 = ((PyObject *)__pyx_cur_scope->__pyx_v_self->record);
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_9 = __pyx_f_5pysam_7libcbcf_bcf_info_get_value(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_4), __pyx_cur_scope->__pyx_v_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2724, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_value);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_value, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_9 = 0;

        /* "pysam/libcbcf.pyx":2725
 *                 if strcmp(key, b'END') != 0:
 *                     value = bcf_info_get_value(self.record, info)
 *                     yield bcf_str_cache_get_charptr(key), value             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
        __pyx_t_9 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(__pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2725, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2725, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_9);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_value);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_value);
        PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_cur_scope->__pyx_v_value);
        __pyx_t_9 = 0;
        __pyx_r = __pyx_t_4;
        __pyx_t_4 = 0;
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_5;
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_TraceReturn(__pyx_r, 0);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, yielding value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L11_resume_from_yield:;
        __pyx_t_5 = __pyx_cur_scope->__pyx_t_0;
        __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
        __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2725, __pyx_L1_error)

        /* "pysam/libcbcf.pyx":2723
 *             if info and info.vptr:
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:             # <<<<<<<<<<<<<<
 *                     value = bcf_info_get_value(self.record, info)
 *                     yield bcf_str_cache_get_charptr(key), value
 */
      }

      /* "pysam/libcbcf.pyx":2721
 *         for i in range(r.n_info):
 *             info = &r.d.info[i]
 *             if info and info.vptr:             # <<<<<<<<<<<<<<
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, info.key)
 *                 if strcmp(key, b'END') != 0:
 */
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":2708
 *                     yield bcf_info_get_value(self.record, info)
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("iteritems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2727
 *                     yield bcf_str_cache_get_charptr(key), value
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_30keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_29keys[] = "VariantRecordInfo.keys(self)\nD.keys() -> list of D's keys";
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_30keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_29keys(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_29keys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("keys", 0);
  __Pyx_TraceCall("keys", __pyx_f[0], 2727, 0, __PYX_ERR(0, 2727, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2729
 *     def keys(self):
 *         """D.keys() -> list of D's keys"""
 *         return list(self)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_List(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2727
 *                     yield bcf_str_cache_get_charptr(key), value
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2731
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_32items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_31items[] = "VariantRecordInfo.items(self)\nD.items() -> list of D's (key, value) pairs, as 2-tuples";
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_32items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("items (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_31items(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_31items(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("items", 0);
  __Pyx_TraceCall("items", __pyx_f[0], 2731, 0, __PYX_ERR(0, 2731, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2733
 *     def items(self):
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_iteritems); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2733, __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, 2733, __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, 2733, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2733, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2731
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.items", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2735
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_34values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_33values[] = "VariantRecordInfo.values(self)\nD.values() -> list of D's values";
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_34values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("values (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_33values(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_33values(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("values", 0);
  __Pyx_TraceCall("values", __pyx_f[0], 2735, 0, __PYX_ERR(0, 2735, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2737
 *     def values(self):
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())             # <<<<<<<<<<<<<<
 * 
 *     def update(self, items=None, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itervalues); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2737, __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, 2737, __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, 2737, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2737, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2735
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2739
 *         return list(self.itervalues())
 * 
 *     def update(self, items=None, **kwargs):             # <<<<<<<<<<<<<<
 *         """D.update([E, ]**F) -> None.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_36update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_35update[] = "VariantRecordInfo.update(self, items=None, **kwargs)\nD.update([E, ]**F) -> None.\n\n        Update D from dict/iterable E and F.\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_36update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update (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_items,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "update") < 0)) __PYX_ERR(0, 2739, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("update", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2739, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_35update(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self), __pyx_v_items, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_35update(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("update", 0);
  __Pyx_TraceCall("update", __pyx_f[0], 2739, 0, __PYX_ERR(0, 2739, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2744
 *         Update D from dict/iterable E and F.
 *         """
 *         for k, v in items.items():             # <<<<<<<<<<<<<<
 *             if k != 'END':
 *                 self[k] = v
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2744, __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, 2744, __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, 2744, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2744, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2744, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2744, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2744, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2744, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2744, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2744, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 2744, __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, 2744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 2744, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 2744, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pysam/libcbcf.pyx":2745
 *         """
 *         for k, v in items.items():
 *             if k != 'END':             # <<<<<<<<<<<<<<
 *                 self[k] = v
 * 
 */
    __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_k, __pyx_n_s_END, Py_NE)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 2745, __pyx_L1_error)
    if (__pyx_t_9) {

      /* "pysam/libcbcf.pyx":2746
 *         for k, v in items.items():
 *             if k != 'END':
 *                 self[k] = v             # <<<<<<<<<<<<<<
 * 
 *         if kwargs:
 */
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_k, __pyx_v_v) < 0)) __PYX_ERR(0, 2746, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2745
 *         """
 *         for k, v in items.items():
 *             if k != 'END':             # <<<<<<<<<<<<<<
 *                 self[k] = v
 * 
 */
    }

    /* "pysam/libcbcf.pyx":2744
 *         Update D from dict/iterable E and F.
 *         """
 *         for k, v in items.items():             # <<<<<<<<<<<<<<
 *             if k != 'END':
 *                 self[k] = v
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":2748
 *                 self[k] = v
 * 
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             kwargs.pop('END', None)
 *             for k, v in kwargs.items():
 */
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 2748, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "pysam/libcbcf.pyx":2749
 * 
 *         if kwargs:
 *             kwargs.pop('END', None)             # <<<<<<<<<<<<<<
 *             for k, v in kwargs.items():
 *                 self[k] = v
 */
    __pyx_t_2 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_END, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pysam/libcbcf.pyx":2750
 *         if kwargs:
 *             kwargs.pop('END', None)
 *             for k, v in kwargs.items():             # <<<<<<<<<<<<<<
 *                 self[k] = v
 * 
 */
    __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2750, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2750, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2750, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2750, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2750, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2750, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2750, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 2750, __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_3 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2750, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2750, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2750, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 2750, __pyx_L1_error)
        __pyx_t_8 = NULL;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L12_unpacking_done;
        __pyx_L11_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_8 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 2750, __pyx_L1_error)
        __pyx_L12_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":2751
 *             kwargs.pop('END', None)
 *             for k, v in kwargs.items():
 *                 self[k] = v             # <<<<<<<<<<<<<<
 * 
 *     def pop(self, key, default=_nothing):
 */
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_k, __pyx_v_v) < 0)) __PYX_ERR(0, 2751, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2750
 *         if kwargs:
 *             kwargs.pop('END', None)
 *             for k, v in kwargs.items():             # <<<<<<<<<<<<<<
 *                 self[k] = v
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":2748
 *                 self[k] = v
 * 
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             kwargs.pop('END', None)
 *             for k, v in kwargs.items():
 */
  }

  /* "pysam/libcbcf.pyx":2739
 *         return list(self.itervalues())
 * 
 *     def update(self, items=None, **kwargs):             # <<<<<<<<<<<<<<
 *         """D.update([E, ]**F) -> None.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2753
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_38pop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_37pop[] = "VariantRecordInfo.pop(self, key, default=_nothing)";
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_38pop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pop (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k__133;
    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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "pop") < 0)) __PYX_ERR(0, 2753, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("pop", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2753, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_37pop(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_37pop(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_bkey = 0;
  bcf_info_t *__pyx_v_info;
  int __pyx_v_info_id;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  char const *__pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  char const *__pyx_t_12;
  __Pyx_RefNannySetupContext("pop", 0);
  __Pyx_TraceCall("pop", __pyx_f[0], 2753, 0, __PYX_ERR(0, 2753, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2754
 * 
 *     def pop(self, key, default=_nothing):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 * 
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2755
 *     def pop(self, key, default=_nothing):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2757
 *         cdef bcf1_t *r = self.record.ptr
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_v_r, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2758
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__134, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2758, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2758, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2757
 *         cdef bcf1_t *r = self.record.ptr
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2760
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 * 
 */
  __pyx_t_4 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2760, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_bkey = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":2761
 * 
 *         cdef bytes bkey = force_bytes(key)
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)             # <<<<<<<<<<<<<<
 * 
 *         # Cannot stop here if info == NULL, since flags must return False
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2761, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 2761, __pyx_L1_error)
  __pyx_v_info = bcf_get_info(__pyx_v_hdr, __pyx_v_r, __pyx_t_5);

  /* "pysam/libcbcf.pyx":2764
 * 
 *         # Cannot stop here if info == NULL, since flags must return False
 *         cdef int info_id = bcf_header_get_info_id(hdr, bkey) if not info else info.key             # <<<<<<<<<<<<<<
 * 
 *         if info_id < 0:
 */
  if (((!(__pyx_v_info != 0)) != 0)) {
    __pyx_t_7 = __pyx_f_5pysam_7libcbcf_bcf_header_get_info_id(__pyx_v_hdr, __pyx_v_bkey); if (unlikely(__pyx_t_7 == ((int)-2) && PyErr_Occurred())) __PYX_ERR(0, 2764, __pyx_L1_error)
    __pyx_t_6 = __pyx_t_7;
  } else {
    __pyx_t_6 = __pyx_v_info->key;
  }
  __pyx_v_info_id = __pyx_t_6;

  /* "pysam/libcbcf.pyx":2766
 *         cdef int info_id = bcf_header_get_info_id(hdr, bkey) if not info else info.key
 * 
 *         if info_id < 0:             # <<<<<<<<<<<<<<
 *             if default is _nothing:
 *                 raise KeyError('Unknown INFO field: {}'.format(key))
 */
  __pyx_t_3 = ((__pyx_v_info_id < 0) != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":2767
 * 
 *         if info_id < 0:
 *             if default is _nothing:             # <<<<<<<<<<<<<<
 *                 raise KeyError('Unknown INFO field: {}'.format(key))
 *             return default
 */
    __pyx_t_3 = (__pyx_v_default == __pyx_v_5pysam_7libcbcf__nothing);
    __pyx_t_8 = (__pyx_t_3 != 0);
    if (unlikely(__pyx_t_8)) {

      /* "pysam/libcbcf.pyx":2768
 *         if info_id < 0:
 *             if default is _nothing:
 *                 raise KeyError('Unknown INFO field: {}'.format(key))             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unknown_INFO_field, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2768, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2768, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2768, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_4);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2768, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_4);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2768, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_key);
          __Pyx_GIVEREF(__pyx_v_key);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_key);
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2768, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2768, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 2768, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2767
 * 
 *         if info_id < 0:
 *             if default is _nothing:             # <<<<<<<<<<<<<<
 *                 raise KeyError('Unknown INFO field: {}'.format(key))
 *             return default
 */
    }

    /* "pysam/libcbcf.pyx":2769
 *             if default is _nothing:
 *                 raise KeyError('Unknown INFO field: {}'.format(key))
 *             return default             # <<<<<<<<<<<<<<
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_default);
    __pyx_r = __pyx_v_default;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2766
 *         cdef int info_id = bcf_header_get_info_id(hdr, bkey) if not info else info.key
 * 
 *         if info_id < 0:             # <<<<<<<<<<<<<<
 *             if default is _nothing:
 *                 raise KeyError('Unknown INFO field: {}'.format(key))
 */
  }

  /* "pysam/libcbcf.pyx":2771
 *             return default
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header')
 * 
 */
  __pyx_t_8 = ((!(__pyx_f_5pysam_7libcbcf_check_header_id(__pyx_v_hdr, BCF_HL_INFO, __pyx_v_info_id) != 0)) != 0);
  if (unlikely(__pyx_t_8)) {

    /* "pysam/libcbcf.pyx":2772
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):
 *             raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *         # Handle flags
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__135, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 2772, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2771
 *             return default
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2775
 * 
 *         # Handle flags
 *         if bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id) == BCF_HT_FLAG and (not info or not info.vptr):             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_3 = ((bcf_hdr_id2type(__pyx_v_hdr, BCF_HL_INFO, __pyx_v_info_id) == BCF_HT_FLAG) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_8 = __pyx_t_3;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_3 = ((!(__pyx_v_info != 0)) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_8 = __pyx_t_3;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_3 = ((!(__pyx_v_info->vptr != 0)) != 0);
  __pyx_t_8 = __pyx_t_3;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_8) {

    /* "pysam/libcbcf.pyx":2776
 *         # Handle flags
 *         if bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id) == BCF_HT_FLAG and (not info or not info.vptr):
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if not info or not info.vptr:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2775
 * 
 *         # Handle flags
 *         if bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id) == BCF_HT_FLAG and (not info or not info.vptr):             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2778
 *             return
 * 
 *         if not info or not info.vptr:             # <<<<<<<<<<<<<<
 *             if default is _nothing:
 *                 raise KeyError('Unknown INFO field: {}'.format(key))
 */
  __pyx_t_3 = ((!(__pyx_v_info != 0)) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_8 = __pyx_t_3;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_3 = ((!(__pyx_v_info->vptr != 0)) != 0);
  __pyx_t_8 = __pyx_t_3;
  __pyx_L12_bool_binop_done:;
  if (__pyx_t_8) {

    /* "pysam/libcbcf.pyx":2779
 * 
 *         if not info or not info.vptr:
 *             if default is _nothing:             # <<<<<<<<<<<<<<
 *                 raise KeyError('Unknown INFO field: {}'.format(key))
 *             return default
 */
    __pyx_t_8 = (__pyx_v_default == __pyx_v_5pysam_7libcbcf__nothing);
    __pyx_t_3 = (__pyx_t_8 != 0);
    if (unlikely(__pyx_t_3)) {

      /* "pysam/libcbcf.pyx":2780
 *         if not info or not info.vptr:
 *             if default is _nothing:
 *                 raise KeyError('Unknown INFO field: {}'.format(key))             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unknown_INFO_field, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2780, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_11) {
        __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_key); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2780, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_key};
          __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2780, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_9);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_key};
          __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2780, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_9);
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2780, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL;
          __Pyx_INCREF(__pyx_v_key);
          __Pyx_GIVEREF(__pyx_v_key);
          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_key);
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2780, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2780, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 2780, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2779
 * 
 *         if not info or not info.vptr:
 *             if default is _nothing:             # <<<<<<<<<<<<<<
 *                 raise KeyError('Unknown INFO field: {}'.format(key))
 *             return default
 */
    }

    /* "pysam/libcbcf.pyx":2781
 *             if default is _nothing:
 *                 raise KeyError('Unknown INFO field: {}'.format(key))
 *             return default             # <<<<<<<<<<<<<<
 * 
 *         value = bcf_info_get_value(self.record, info)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_default);
    __pyx_r = __pyx_v_default;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2778
 *             return
 * 
 *         if not info or not info.vptr:             # <<<<<<<<<<<<<<
 *             if default is _nothing:
 *                 raise KeyError('Unknown INFO field: {}'.format(key))
 */
  }

  /* "pysam/libcbcf.pyx":2783
 *             return default
 * 
 *         value = bcf_info_get_value(self.record, info)             # <<<<<<<<<<<<<<
 * 
 *         if bcf_update_info(hdr, r, bkey, NULL, 0, info.type) < 0:
 */
  __pyx_t_4 = ((PyObject *)__pyx_v_self->record);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_9 = __pyx_f_5pysam_7libcbcf_bcf_info_get_value(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_4), __pyx_v_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_value = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "pysam/libcbcf.pyx":2785
 *         value = bcf_info_get_value(self.record, info)
 * 
 *         if bcf_update_info(hdr, r, bkey, NULL, 0, info.type) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Unable to delete INFO')
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 2785, __pyx_L1_error)
  }
  __pyx_t_12 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 2785, __pyx_L1_error)
  __pyx_t_3 = ((bcf_update_info(__pyx_v_hdr, __pyx_v_r, __pyx_t_12, NULL, 0, __pyx_v_info->type) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":2786
 * 
 *         if bcf_update_info(hdr, r, bkey, NULL, 0, info.type) < 0:
 *             raise ValueError('Unable to delete INFO')             # <<<<<<<<<<<<<<
 * 
 *         return value
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__136, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 2786, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2785
 *         value = bcf_info_get_value(self.record, info)
 * 
 *         if bcf_update_info(hdr, r, bkey, NULL, 0, info.type) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Unable to delete INFO')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2788
 *             raise ValueError('Unable to delete INFO')
 * 
 *         return value             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(VariantRecordInfo self not None, VariantRecordInfo other not None, int op):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_value);
  __pyx_r = __pyx_v_value;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2753
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2790
 *         return value
 * 
 *     def __richcmp__(VariantRecordInfo self not None, VariantRecordInfo other not None, int op):             # <<<<<<<<<<<<<<
 *         if op != 2 and op != 3:
 *             return NotImplemented
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_40__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_40__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  if (unlikely(((PyObject *)__pyx_v_self) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "self"); __PYX_ERR(0, 2790, __pyx_L1_error)
  }
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5pysam_7libcbcf_VariantRecordInfo, 0, "other", 0))) __PYX_ERR(0, 2790, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_39__richcmp__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self), ((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_other), ((int)__pyx_v_op));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_39__richcmp__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_other, int __pyx_v_op) {
  CYTHON_UNUSED bcf1_t *__pyx_v_s;
  CYTHON_UNUSED bcf1_t *__pyx_v_o;
  int __pyx_v_cmp;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  bcf1_t *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__richcmp__", 0);
  __Pyx_TraceCall("__richcmp__", __pyx_f[0], 2790, 0, __PYX_ERR(0, 2790, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2791
 * 
 *     def __richcmp__(VariantRecordInfo self not None, VariantRecordInfo other not None, int op):
 *         if op != 2 and op != 3:             # <<<<<<<<<<<<<<
 *             return NotImplemented
 * 
 */
  switch (__pyx_v_op) {
    case 2:
    case 3:
    __pyx_t_1 = 0;
    break;
    default:
    __pyx_t_1 = 1;
    break;
  }
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":2792
 *     def __richcmp__(VariantRecordInfo self not None, VariantRecordInfo other not None, int op):
 *         if op != 2 and op != 3:
 *             return NotImplemented             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf1_t *s = self.record.ptr
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2791
 * 
 *     def __richcmp__(VariantRecordInfo self not None, VariantRecordInfo other not None, int op):
 *         if op != 2 and op != 3:             # <<<<<<<<<<<<<<
 *             return NotImplemented
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2794
 *             return NotImplemented
 * 
 *         cdef bcf1_t *s = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *o = other.record.ptr
 * 
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_s = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2795
 * 
 *         cdef bcf1_t *s = self.record.ptr
 *         cdef bcf1_t *o = other.record.ptr             # <<<<<<<<<<<<<<
 * 
 *         # Cannot use n_info as shortcut logic, since null values may remain
 */
  __pyx_t_2 = __pyx_v_other->record->ptr;
  __pyx_v_o = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2798
 * 
 *         # Cannot use n_info as shortcut logic, since null values may remain
 *         cdef bint cmp = dict(self) == dict(other)             # <<<<<<<<<<<<<<
 * 
 *         if op == 3:
 */
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyDict_Type)), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyDict_Type)), ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2798, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2798, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_cmp = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2800
 *         cdef bint cmp = dict(self) == dict(other)
 * 
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             cmp = not cmp
 * 
 */
  __pyx_t_1 = ((__pyx_v_op == 3) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":2801
 * 
 *         if op == 3:
 *             cmp = not cmp             # <<<<<<<<<<<<<<
 * 
 *         return cmp
 */
    __pyx_v_cmp = (!(__pyx_v_cmp != 0));

    /* "pysam/libcbcf.pyx":2800
 *         cdef bint cmp = dict(self) == dict(other)
 * 
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             cmp = not cmp
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2803
 *             cmp = not cmp
 * 
 *         return cmp             # <<<<<<<<<<<<<<
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_cmp); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2790
 *         return value
 * 
 *     def __richcmp__(VariantRecordInfo self not None, VariantRecordInfo other not None, int op):             # <<<<<<<<<<<<<<
 *         if op != 2 and op != 3:
 *             return NotImplemented
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.record,)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_42__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_41__reduce_cython__[] = "VariantRecordInfo.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_42__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_41__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_41__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.record,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->record));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->record));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->record));
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.record,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":5
 *     state = (self.record,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.record is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.record,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.record is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_VariantRecordInfo, (type(self), 0xde17f0f, None), state
 */
  /*else*/ {
    __pyx_t_3 = (((PyObject *)__pyx_v_self->record) != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.record is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantRecordInfo, (type(self), 0xde17f0f, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":11
 *         use_setstate = self.record is not None
 *     if use_setstate:
 *         return __pyx_unpickle_VariantRecordInfo, (type(self), 0xde17f0f, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_VariantRecordInfo, (type(self), 0xde17f0f, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantRecordInfo); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_232881935);
    __Pyx_GIVEREF(__pyx_int_232881935);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_232881935);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.record is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantRecordInfo, (type(self), 0xde17f0f, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_VariantRecordInfo, (type(self), 0xde17f0f, None), state
 *     else:
 *         return __pyx_unpickle_VariantRecordInfo, (type(self), 0xde17f0f, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantRecordInfo__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantRecordInfo); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_232881935);
    __Pyx_GIVEREF(__pyx_int_232881935);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_232881935);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.record,)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantRecordInfo, (type(self), 0xde17f0f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantRecordInfo__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_44__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_43__setstate_cython__[] = "VariantRecordInfo.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_44__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_43__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_17VariantRecordInfo_43__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 14, 0, __PYX_ERR(2, 14, __pyx_L1_error));

  /* "(tree fragment)":15
 *         return __pyx_unpickle_VariantRecordInfo, (type(self), 0xde17f0f, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantRecordInfo__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordInfo__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantRecordInfo, (type(self), 0xde17f0f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantRecordInfo__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordInfo.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2809
 * 
 * 
 * cdef VariantRecordInfo makeVariantRecordInfo(VariantRecord record):             # <<<<<<<<<<<<<<
 *     if not record:
 *         raise ValueError('invalid VariantRecord')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_f_5pysam_7libcbcf_makeVariantRecordInfo(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v_info = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("makeVariantRecordInfo", 0);
  __Pyx_TraceCall("makeVariantRecordInfo", __pyx_f[0], 2809, 0, __PYX_ERR(0, 2809, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2810
 * 
 * cdef VariantRecordInfo makeVariantRecordInfo(VariantRecord record):
 *     if not record:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantRecord')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_record)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2810, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":2811
 * cdef VariantRecordInfo makeVariantRecordInfo(VariantRecord record):
 *     if not record:
 *         raise ValueError('invalid VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantRecordInfo info = VariantRecordInfo.__new__(VariantRecordInfo)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__137, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2811, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2810
 * 
 * cdef VariantRecordInfo makeVariantRecordInfo(VariantRecord record):
 *     if not record:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2813
 *         raise ValueError('invalid VariantRecord')
 * 
 *     cdef VariantRecordInfo info = VariantRecordInfo.__new__(VariantRecordInfo)             # <<<<<<<<<<<<<<
 *     info.record = record
 * 
 */
  __pyx_t_3 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantRecordInfo(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordInfo), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2813, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_info = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":2814
 * 
 *     cdef VariantRecordInfo info = VariantRecordInfo.__new__(VariantRecordInfo)
 *     info.record = record             # <<<<<<<<<<<<<<
 * 
 *     return info
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_record));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_record));
  __Pyx_GOTREF(__pyx_v_info->record);
  __Pyx_DECREF(((PyObject *)__pyx_v_info->record));
  __pyx_v_info->record = __pyx_v_record;

  /* "pysam/libcbcf.pyx":2816
 *     info.record = record
 * 
 *     return info             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_info));
  __pyx_r = __pyx_v_info;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2809
 * 
 * 
 * cdef VariantRecordInfo makeVariantRecordInfo(VariantRecord record):             # <<<<<<<<<<<<<<
 *     if not record:
 *         raise ValueError('invalid VariantRecord')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantRecordInfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_info);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2821
 * cdef class VariantRecordSamples(object):
 *     """mapping from sample index or name to :class:`VariantRecordSample` object."""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 2821, 0, __PYX_ERR(0, 2821, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2822
 *     """mapping from sample index or name to :class:`VariantRecordSample` object."""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__138, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2822, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 2822, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2821
 * cdef class VariantRecordSamples(object):
 *     """mapping from sample index or name to :class:`VariantRecordSample` object."""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2824
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.record.ptr.n_sample  # bcf_hdr_nsamples(self.record.header.ptr)
 * 
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_3__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_3__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_2__len__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);
  __Pyx_TraceCall("__len__", __pyx_f[0], 2824, 0, __PYX_ERR(0, 2824, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2825
 * 
 *     def __len__(self):
 *         return self.record.ptr.n_sample  # bcf_hdr_nsamples(self.record.header.ptr)             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
  __pyx_r = __pyx_v_self->record->ptr->n_sample;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2824
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.record.ptr.n_sample  # bcf_hdr_nsamples(self.record.header.ptr)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2827
 *         return self.record.ptr.n_sample  # bcf_hdr_nsamples(self.record.header.ptr)
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         return self.record.ptr.n_sample != 0  # bcf_hdr_nsamples(self.record.header.ptr) != 0
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_5__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_5__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_4__bool__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__", 0);
  __Pyx_TraceCall("__bool__", __pyx_f[0], 2827, 0, __PYX_ERR(0, 2827, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2828
 * 
 *     def __bool__(self):
 *         return self.record.ptr.n_sample != 0  # bcf_hdr_nsamples(self.record.header.ptr) != 0             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key):
 */
  __pyx_r = (__pyx_v_self->record->ptr->n_sample != 0);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2827
 *         return self.record.ptr.n_sample  # bcf_hdr_nsamples(self.record.header.ptr)
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         return self.record.ptr.n_sample != 0  # bcf_hdr_nsamples(self.record.header.ptr) != 0
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2830
 *         return self.record.ptr.n_sample != 0  # bcf_hdr_nsamples(self.record.header.ptr) != 0
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_6__getitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  CYTHON_UNUSED bcf1_t *__pyx_v_r;
  int __pyx_v_n;
  int __pyx_v_sample_index;
  PyObject *__pyx_v_bkey = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  uint32_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  char const *__pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_TraceCall("__getitem__", __pyx_f[0], 2830, 0, __PYX_ERR(0, 2830, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2831
 * 
 *     def __getitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int n = self.record.ptr.n_sample
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2832
 *     def __getitem__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int n = self.record.ptr.n_sample
 *         cdef int sample_index
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2833
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int n = self.record.ptr.n_sample             # <<<<<<<<<<<<<<
 *         cdef int sample_index
 *         cdef vdict_t *d
 */
  __pyx_t_3 = __pyx_v_self->record->ptr->n_sample;
  __pyx_v_n = __pyx_t_3;

  /* "pysam/libcbcf.pyx":2838
 *         cdef khiter_t k
 * 
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             sample_index = key
 *         else:
 */
  __pyx_t_4 = PyInt_Check(__pyx_v_key); 
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pysam/libcbcf.pyx":2839
 * 
 *         if isinstance(key, int):
 *             sample_index = key             # <<<<<<<<<<<<<<
 *         else:
 *             bkey = force_bytes(key)
 */
    __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_key); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2839, __pyx_L1_error)
    __pyx_v_sample_index = __pyx_t_6;

    /* "pysam/libcbcf.pyx":2838
 *         cdef khiter_t k
 * 
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             sample_index = key
 *         else:
 */
    goto __pyx_L3;
  }

  /* "pysam/libcbcf.pyx":2841
 *             sample_index = key
 *         else:
 *             bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *             sample_index = bcf_hdr_id2int(hdr, BCF_DT_SAMPLE, bkey)
 *             if sample_index < 0:
 */
  /*else*/ {
    __pyx_t_7 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2841, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_v_bkey = ((PyObject*)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "pysam/libcbcf.pyx":2842
 *         else:
 *             bkey = force_bytes(key)
 *             sample_index = bcf_hdr_id2int(hdr, BCF_DT_SAMPLE, bkey)             # <<<<<<<<<<<<<<
 *             if sample_index < 0:
 *                 raise KeyError('invalid sample name: {}'.format(key))
 */
    if (unlikely(__pyx_v_bkey == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 2842, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 2842, __pyx_L1_error)
    __pyx_v_sample_index = bcf_hdr_id2int(__pyx_v_hdr, BCF_DT_SAMPLE, __pyx_t_8);

    /* "pysam/libcbcf.pyx":2843
 *             bkey = force_bytes(key)
 *             sample_index = bcf_hdr_id2int(hdr, BCF_DT_SAMPLE, bkey)
 *             if sample_index < 0:             # <<<<<<<<<<<<<<
 *                 raise KeyError('invalid sample name: {}'.format(key))
 * 
 */
    __pyx_t_5 = ((__pyx_v_sample_index < 0) != 0);
    if (unlikely(__pyx_t_5)) {

      /* "pysam/libcbcf.pyx":2844
 *             sample_index = bcf_hdr_id2int(hdr, BCF_DT_SAMPLE, bkey)
 *             if sample_index < 0:
 *                 raise KeyError('invalid sample name: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         if sample_index < 0 or sample_index >= n:
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_invalid_sample_name, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2844, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_key); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2844, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2844, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2844, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2844, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_key);
          __Pyx_GIVEREF(__pyx_v_key);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_key);
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2844, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2844, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 2844, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2843
 *             bkey = force_bytes(key)
 *             sample_index = bcf_hdr_id2int(hdr, BCF_DT_SAMPLE, bkey)
 *             if sample_index < 0:             # <<<<<<<<<<<<<<
 *                 raise KeyError('invalid sample name: {}'.format(key))
 * 
 */
    }
  }
  __pyx_L3:;

  /* "pysam/libcbcf.pyx":2846
 *                 raise KeyError('invalid sample name: {}'.format(key))
 * 
 *         if sample_index < 0 or sample_index >= n:             # <<<<<<<<<<<<<<
 *             raise IndexError('invalid sample index')
 * 
 */
  __pyx_t_4 = ((__pyx_v_sample_index < 0) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_5 = __pyx_t_4;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_sample_index >= __pyx_v_n) != 0);
  __pyx_t_5 = __pyx_t_4;
  __pyx_L6_bool_binop_done:;
  if (unlikely(__pyx_t_5)) {

    /* "pysam/libcbcf.pyx":2847
 * 
 *         if sample_index < 0 or sample_index >= n:
 *             raise IndexError('invalid sample index')             # <<<<<<<<<<<<<<
 * 
 *         return makeVariantRecordSample(self.record, sample_index)
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__139, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2847, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 2847, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2846
 *                 raise KeyError('invalid sample name: {}'.format(key))
 * 
 *         if sample_index < 0 or sample_index >= n:             # <<<<<<<<<<<<<<
 *             raise IndexError('invalid sample index')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2849
 *             raise IndexError('invalid sample index')
 * 
 *         return makeVariantRecordSample(self.record, sample_index)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_9 = ((PyObject *)__pyx_v_self->record);
  __Pyx_INCREF(__pyx_t_9);
  __pyx_t_7 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantRecordSample(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_9), __pyx_v_sample_index)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2830
 *         return self.record.ptr.n_sample != 0  # bcf_hdr_nsamples(self.record.header.ptr) != 0
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_20VariantRecordSamples_10generator20(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":2851
 *         return makeVariantRecordSample(self.record, sample_index)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_9__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_9__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_8__iter__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_8__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__ *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__ *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_30___iter__(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_30___iter__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2851, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_20VariantRecordSamples_10generator20, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_VariantRecordSamples___iter, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 2851, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.__iter__", __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_5pysam_7libcbcf_20VariantRecordSamples_10generator20(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__ *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  uint32_t __pyx_t_3;
  int32_t __pyx_t_4;
  int32_t __pyx_t_5;
  int32_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 2851, 0, __PYX_ERR(0, 2851, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2851, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2852
 * 
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int32_t i, n = self.record.ptr.n_sample
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->record->header->ptr;
  __pyx_cur_scope->__pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2853
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int32_t i, n = self.record.ptr.n_sample
 * 
 */
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self->record->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2854
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int32_t i, n = self.record.ptr.n_sample             # <<<<<<<<<<<<<<
 * 
 *         for i in range(n):
 */
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_self->record->ptr->n_sample;
  __pyx_cur_scope->__pyx_v_n = __pyx_t_3;

  /* "pysam/libcbcf.pyx":2856
 *         cdef int32_t i, n = self.record.ptr.n_sample
 * 
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             yield charptr_to_str(hdr.samples[i])
 * 
 */
  __pyx_t_4 = __pyx_cur_scope->__pyx_v_n;
  __pyx_t_5 = __pyx_t_4;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_6;

    /* "pysam/libcbcf.pyx":2857
 * 
 *         for i in range(n):
 *             yield charptr_to_str(hdr.samples[i])             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
    __pyx_t_7 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_cur_scope->__pyx_v_hdr->samples[__pyx_cur_scope->__pyx_v_i]), NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2857, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
    __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2857, __pyx_L1_error)
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":2851
 *         return makeVariantRecordSample(self.record, sample_index)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2859
 *             yield charptr_to_str(hdr.samples[i])
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_12get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_11get[] = "VariantRecordSamples.get(self, key, default=None)\nD.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_12get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 2859, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2859, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_11get(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_11get(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("get", 0);
  __Pyx_TraceCall("get", __pyx_f[0], 2859, 0, __PYX_ERR(0, 2859, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2861
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":2862
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 *             return self[key]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return default
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2862, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "pysam/libcbcf.pyx":2861
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":2863
 *         try:
 *             return self[key]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 2863, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":2864
 *             return self[key]
 *         except KeyError:
 *             return default             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_default);
      __pyx_r = __pyx_v_default;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":2861
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":2859
 *             yield charptr_to_str(hdr.samples[i])
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2866
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_14__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_14__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_13__contains__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_13__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  CYTHON_UNUSED bcf1_t *__pyx_v_r;
  int __pyx_v_n;
  int __pyx_v_sample_index;
  PyObject *__pyx_v_bkey = NULL;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  uint32_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  char const *__pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("__contains__", 0);
  __Pyx_TraceCall("__contains__", __pyx_f[0], 2866, 0, __PYX_ERR(0, 2866, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2867
 * 
 *     def __contains__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int n = self.record.ptr.n_sample
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2868
 *     def __contains__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int n = self.record.ptr.n_sample
 *         cdef int sample_index
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2869
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int n = self.record.ptr.n_sample             # <<<<<<<<<<<<<<
 *         cdef int sample_index
 *         cdef vdict_t *d
 */
  __pyx_t_3 = __pyx_v_self->record->ptr->n_sample;
  __pyx_v_n = __pyx_t_3;

  /* "pysam/libcbcf.pyx":2874
 *         cdef khiter_t k
 * 
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             sample_index = key
 *         else:
 */
  __pyx_t_4 = PyInt_Check(__pyx_v_key); 
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pysam/libcbcf.pyx":2875
 * 
 *         if isinstance(key, int):
 *             sample_index = key             # <<<<<<<<<<<<<<
 *         else:
 *             bkey = force_bytes(key)
 */
    __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_key); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2875, __pyx_L1_error)
    __pyx_v_sample_index = __pyx_t_6;

    /* "pysam/libcbcf.pyx":2874
 *         cdef khiter_t k
 * 
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             sample_index = key
 *         else:
 */
    goto __pyx_L3;
  }

  /* "pysam/libcbcf.pyx":2877
 *             sample_index = key
 *         else:
 *             bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *             sample_index = bcf_hdr_id2int(hdr, BCF_DT_SAMPLE, bkey)
 *             if sample_index < 0:
 */
  /*else*/ {
    __pyx_t_7 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2877, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_v_bkey = ((PyObject*)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "pysam/libcbcf.pyx":2878
 *         else:
 *             bkey = force_bytes(key)
 *             sample_index = bcf_hdr_id2int(hdr, BCF_DT_SAMPLE, bkey)             # <<<<<<<<<<<<<<
 *             if sample_index < 0:
 *                 raise KeyError('invalid sample name: {}'.format(key))
 */
    if (unlikely(__pyx_v_bkey == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 2878, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 2878, __pyx_L1_error)
    __pyx_v_sample_index = bcf_hdr_id2int(__pyx_v_hdr, BCF_DT_SAMPLE, __pyx_t_8);

    /* "pysam/libcbcf.pyx":2879
 *             bkey = force_bytes(key)
 *             sample_index = bcf_hdr_id2int(hdr, BCF_DT_SAMPLE, bkey)
 *             if sample_index < 0:             # <<<<<<<<<<<<<<
 *                 raise KeyError('invalid sample name: {}'.format(key))
 * 
 */
    __pyx_t_5 = ((__pyx_v_sample_index < 0) != 0);
    if (unlikely(__pyx_t_5)) {

      /* "pysam/libcbcf.pyx":2880
 *             sample_index = bcf_hdr_id2int(hdr, BCF_DT_SAMPLE, bkey)
 *             if sample_index < 0:
 *                 raise KeyError('invalid sample name: {}'.format(key))             # <<<<<<<<<<<<<<
 * 
 *         return 0 <= sample_index < n
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_invalid_sample_name, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2880, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_key); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2880, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2880, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_key};
          __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2880, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2880, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_key);
          __Pyx_GIVEREF(__pyx_v_key);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_key);
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2880, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2880, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 2880, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2879
 *             bkey = force_bytes(key)
 *             sample_index = bcf_hdr_id2int(hdr, BCF_DT_SAMPLE, bkey)
 *             if sample_index < 0:             # <<<<<<<<<<<<<<
 *                 raise KeyError('invalid sample name: {}'.format(key))
 * 
 */
    }
  }
  __pyx_L3:;

  /* "pysam/libcbcf.pyx":2882
 *                 raise KeyError('invalid sample name: {}'.format(key))
 * 
 *         return 0 <= sample_index < n             # <<<<<<<<<<<<<<
 * 
 *     def iterkeys(self):
 */
  __pyx_t_5 = (0 <= __pyx_v_sample_index);
  if (__pyx_t_5) {
    __pyx_t_5 = (__pyx_v_sample_index < __pyx_v_n);
  }
  __pyx_r = __pyx_t_5;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2866
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2884
 *         return 0 <= sample_index < n
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_16iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_15iterkeys[] = "VariantRecordSamples.iterkeys(self)\nD.iterkeys() -> an iterator over the keys of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_16iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iterkeys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_15iterkeys(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_15iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("iterkeys", 0);
  __Pyx_TraceCall("iterkeys", __pyx_f[0], 2884, 0, __PYX_ERR(0, 2884, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2886
 *     def iterkeys(self):
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)             # <<<<<<<<<<<<<<
 * 
 *     def itervalues(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2884
 *         return 0 <= sample_index < n
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.iterkeys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_20VariantRecordSamples_19generator21(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":2888
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_18itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_17itervalues[] = "VariantRecordSamples.itervalues(self)\nD.itervalues() -> an iterator over the values of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_18itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_17itervalues(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_17itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_31_itervalues(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_31_itervalues, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2888, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_20VariantRecordSamples_19generator21, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_itervalues, __pyx_n_s_VariantRecordSamples_itervalues, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 2888, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.itervalues", __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_5pysam_7libcbcf_20VariantRecordSamples_19generator21(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  uint32_t __pyx_t_3;
  int32_t __pyx_t_4;
  int32_t __pyx_t_5;
  int32_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __Pyx_TraceCall("itervalues", __pyx_f[0], 2888, 0, __PYX_ERR(0, 2888, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2888, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2890
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int32_t i, n = self.record.ptr.n_sample
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->record->header->ptr;
  __pyx_cur_scope->__pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2891
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int32_t i, n = self.record.ptr.n_sample
 * 
 */
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self->record->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2892
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int32_t i, n = self.record.ptr.n_sample             # <<<<<<<<<<<<<<
 * 
 *         for i in range(n):
 */
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_self->record->ptr->n_sample;
  __pyx_cur_scope->__pyx_v_n = __pyx_t_3;

  /* "pysam/libcbcf.pyx":2894
 *         cdef int32_t i, n = self.record.ptr.n_sample
 * 
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             yield makeVariantRecordSample(self.record, i)
 * 
 */
  __pyx_t_4 = __pyx_cur_scope->__pyx_v_n;
  __pyx_t_5 = __pyx_t_4;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_6;

    /* "pysam/libcbcf.pyx":2895
 * 
 *         for i in range(n):
 *             yield makeVariantRecordSample(self.record, i)             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
    __pyx_t_7 = ((PyObject *)__pyx_cur_scope->__pyx_v_self->record);
    __Pyx_INCREF(__pyx_t_7);
    __pyx_t_8 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantRecordSample(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_7), __pyx_cur_scope->__pyx_v_i)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2895, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_r = __pyx_t_8;
    __pyx_t_8 = 0;
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
    __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2895, __pyx_L1_error)
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":2888
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("itervalues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_20VariantRecordSamples_22generator22(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":2897
 *             yield makeVariantRecordSample(self.record, i)
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_21iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_20iteritems[] = "VariantRecordSamples.iteritems(self)\nD.iteritems() -> an iterator over the (key, value) items of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_21iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_20iteritems(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_20iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_32_iteritems(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_32_iteritems, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2897, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_20VariantRecordSamples_22generator22, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iteritems, __pyx_n_s_VariantRecordSamples_iteritems, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 2897, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.iteritems", __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_5pysam_7libcbcf_20VariantRecordSamples_22generator22(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  uint32_t __pyx_t_3;
  int32_t __pyx_t_4;
  int32_t __pyx_t_5;
  int32_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __Pyx_TraceCall("iteritems", __pyx_f[0], 2897, 0, __PYX_ERR(0, 2897, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2897, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2899
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int32_t i, n = self.record.ptr.n_sample
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->record->header->ptr;
  __pyx_cur_scope->__pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2900
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int32_t i, n = self.record.ptr.n_sample
 * 
 */
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self->record->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2901
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int32_t i, n = self.record.ptr.n_sample             # <<<<<<<<<<<<<<
 * 
 *         for i in range(n):
 */
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_self->record->ptr->n_sample;
  __pyx_cur_scope->__pyx_v_n = __pyx_t_3;

  /* "pysam/libcbcf.pyx":2903
 *         cdef int32_t i, n = self.record.ptr.n_sample
 * 
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             yield (charptr_to_str(hdr.samples[i]), makeVariantRecordSample(self.record, i))
 * 
 */
  __pyx_t_4 = __pyx_cur_scope->__pyx_v_n;
  __pyx_t_5 = __pyx_t_4;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_6;

    /* "pysam/libcbcf.pyx":2904
 * 
 *         for i in range(n):
 *             yield (charptr_to_str(hdr.samples[i]), makeVariantRecordSample(self.record, i))             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
    __pyx_t_7 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_cur_scope->__pyx_v_hdr->samples[__pyx_cur_scope->__pyx_v_i]), NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2904, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = ((PyObject *)__pyx_cur_scope->__pyx_v_self->record);
    __Pyx_INCREF(__pyx_t_8);
    __pyx_t_9 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantRecordSample(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_8), __pyx_cur_scope->__pyx_v_i)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2904, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2904, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_9);
    __pyx_t_7 = 0;
    __pyx_t_9 = 0;
    __pyx_r = __pyx_t_8;
    __pyx_t_8 = 0;
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
    __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2904, __pyx_L1_error)
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":2897
 *             yield makeVariantRecordSample(self.record, i)
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("iteritems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2906
 *             yield (charptr_to_str(hdr.samples[i]), makeVariantRecordSample(self.record, i))
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_24keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_23keys[] = "VariantRecordSamples.keys(self)\nD.keys() -> list of D's keys";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_24keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_23keys(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_23keys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("keys", 0);
  __Pyx_TraceCall("keys", __pyx_f[0], 2906, 0, __PYX_ERR(0, 2906, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2908
 *     def keys(self):
 *         """D.keys() -> list of D's keys"""
 *         return list(self)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_List(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2906
 *             yield (charptr_to_str(hdr.samples[i]), makeVariantRecordSample(self.record, i))
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2910
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_26items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_25items[] = "VariantRecordSamples.items(self)\nD.items() -> list of D's (key, value) pairs, as 2-tuples";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_26items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("items (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_25items(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_25items(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("items", 0);
  __Pyx_TraceCall("items", __pyx_f[0], 2910, 0, __PYX_ERR(0, 2910, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2912
 *     def items(self):
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_iteritems); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2912, __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, 2912, __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, 2912, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2910
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.items", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2914
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_28values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_27values[] = "VariantRecordSamples.values(self)\nD.values() -> list of D's values";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_28values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("values (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_27values(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_27values(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("values", 0);
  __Pyx_TraceCall("values", __pyx_f[0], 2914, 0, __PYX_ERR(0, 2914, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2916
 *     def values(self):
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())             # <<<<<<<<<<<<<<
 * 
 *     def update(self, items=None, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itervalues); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2916, __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, 2916, __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, 2916, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2916, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2914
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2918
 *         return list(self.itervalues())
 * 
 *     def update(self, items=None, **kwargs):             # <<<<<<<<<<<<<<
 *         """D.update([E, ]**F) -> None.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_30update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_29update[] = "VariantRecordSamples.update(self, items=None, **kwargs)\nD.update([E, ]**F) -> None.\n\n        Update D from dict/iterable E and F.\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_30update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update (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_items,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "update") < 0)) __PYX_ERR(0, 2918, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("update", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2918, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_29update(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self), __pyx_v_items, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_29update(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("update", 0);
  __Pyx_TraceCall("update", __pyx_f[0], 2918, 0, __PYX_ERR(0, 2918, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2923
 *         Update D from dict/iterable E and F.
 *         """
 *         for k, v in items.items():             # <<<<<<<<<<<<<<
 *             self[k] = v
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2923, __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, 2923, __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, 2923, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2923, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2923, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2923, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2923, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2923, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2923, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2923, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 2923, __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, 2923, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2923, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2923, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 2923, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 2923, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pysam/libcbcf.pyx":2924
 *         """
 *         for k, v in items.items():
 *             self[k] = v             # <<<<<<<<<<<<<<
 * 
 *         if kwargs:
 */
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_k, __pyx_v_v) < 0)) __PYX_ERR(0, 2924, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2923
 *         Update D from dict/iterable E and F.
 *         """
 *         for k, v in items.items():             # <<<<<<<<<<<<<<
 *             self[k] = v
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":2926
 *             self[k] = v
 * 
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             for k, v in kwargs.items():
 *                 self[k] = v
 */
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 2926, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "pysam/libcbcf.pyx":2927
 * 
 *         if kwargs:
 *             for k, v in kwargs.items():             # <<<<<<<<<<<<<<
 *                 self[k] = v
 * 
 */
    __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2927, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2927, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2927, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2927, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2927, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2927, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2927, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2927, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 2927, __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_3 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2927, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2927, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2927, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L10_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L10_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 2927, __pyx_L1_error)
        __pyx_t_8 = NULL;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L11_unpacking_done;
        __pyx_L10_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, 2927, __pyx_L1_error)
        __pyx_L11_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":2928
 *         if kwargs:
 *             for k, v in kwargs.items():
 *                 self[k] = v             # <<<<<<<<<<<<<<
 * 
 *     def pop(self, key, default=_nothing):
 */
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_k, __pyx_v_v) < 0)) __PYX_ERR(0, 2928, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2927
 * 
 *         if kwargs:
 *             for k, v in kwargs.items():             # <<<<<<<<<<<<<<
 *                 self[k] = v
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":2926
 *             self[k] = v
 * 
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             for k, v in kwargs.items():
 *                 self[k] = v
 */
  }

  /* "pysam/libcbcf.pyx":2918
 *         return list(self.itervalues())
 * 
 *     def update(self, items=None, **kwargs):             # <<<<<<<<<<<<<<
 *         """D.update([E, ]**F) -> None.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2930
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         try:
 *             value = self[key]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_32pop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_31pop[] = "VariantRecordSamples.pop(self, key, default=_nothing)";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_32pop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pop (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k__140;
    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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "pop") < 0)) __PYX_ERR(0, 2930, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("pop", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2930, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_31pop(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_31pop(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("pop", 0);
  __Pyx_TraceCall("pop", __pyx_f[0], 2930, 0, __PYX_ERR(0, 2930, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2931
 * 
 *     def pop(self, key, default=_nothing):
 *         try:             # <<<<<<<<<<<<<<
 *             value = self[key]
 *             del self[key]
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":2932
 *     def pop(self, key, default=_nothing):
 *         try:
 *             value = self[key]             # <<<<<<<<<<<<<<
 *             del self[key]
 *             return value
 */
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2932, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_value = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "pysam/libcbcf.pyx":2933
 *         try:
 *             value = self[key]
 *             del self[key]             # <<<<<<<<<<<<<<
 *             return value
 *         except KeyError:
 */
      if (unlikely(PyObject_DelItem(((PyObject *)__pyx_v_self), __pyx_v_key) < 0)) __PYX_ERR(0, 2933, __pyx_L3_error)

      /* "pysam/libcbcf.pyx":2934
 *             value = self[key]
 *             del self[key]
 *             return value             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             if default is not _nothing:
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_value);
      __pyx_r = __pyx_v_value;
      goto __pyx_L7_try_return;

      /* "pysam/libcbcf.pyx":2931
 * 
 *     def pop(self, key, default=_nothing):
 *         try:             # <<<<<<<<<<<<<<
 *             value = self[key]
 *             del self[key]
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":2935
 *             del self[key]
 *             return value
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             if default is not _nothing:
 *                 return default
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 2935, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":2936
 *             return value
 *         except KeyError:
 *             if default is not _nothing:             # <<<<<<<<<<<<<<
 *                 return default
 *             raise
 */
      __pyx_t_8 = (__pyx_v_default != __pyx_v_5pysam_7libcbcf__nothing);
      __pyx_t_9 = (__pyx_t_8 != 0);
      if (__pyx_t_9) {

        /* "pysam/libcbcf.pyx":2937
 *         except KeyError:
 *             if default is not _nothing:
 *                 return default             # <<<<<<<<<<<<<<
 *             raise
 * 
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_v_default);
        __pyx_r = __pyx_v_default;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L6_except_return;

        /* "pysam/libcbcf.pyx":2936
 *             return value
 *         except KeyError:
 *             if default is not _nothing:             # <<<<<<<<<<<<<<
 *                 return default
 *             raise
 */
      }

      /* "pysam/libcbcf.pyx":2938
 *             if default is not _nothing:
 *                 return default
 *             raise             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(VariantRecordSamples self not None, VariantRecordSamples other not None, int op):
 */
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_6, __pyx_t_7);
      __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; 
      __PYX_ERR(0, 2938, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":2931
 * 
 *     def pop(self, key, default=_nothing):
 *         try:             # <<<<<<<<<<<<<<
 *             value = self[key]
 *             del self[key]
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":2930
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         try:
 *             value = self[key]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2940
 *             raise
 * 
 *     def __richcmp__(VariantRecordSamples self not None, VariantRecordSamples other not None, int op):             # <<<<<<<<<<<<<<
 *         if op != 2 and op != 3:
 *             return NotImplemented
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_34__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_34__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  if (unlikely(((PyObject *)__pyx_v_self) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "self"); __PYX_ERR(0, 2940, __pyx_L1_error)
  }
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5pysam_7libcbcf_VariantRecordSamples, 0, "other", 0))) __PYX_ERR(0, 2940, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_33__richcmp__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self), ((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_other), ((int)__pyx_v_op));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_33__richcmp__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_other, int __pyx_v_op) {
  bcf1_t *__pyx_v_s;
  bcf1_t *__pyx_v_o;
  int __pyx_v_cmp;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("__richcmp__", 0);
  __Pyx_TraceCall("__richcmp__", __pyx_f[0], 2940, 0, __PYX_ERR(0, 2940, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2941
 * 
 *     def __richcmp__(VariantRecordSamples self not None, VariantRecordSamples other not None, int op):
 *         if op != 2 and op != 3:             # <<<<<<<<<<<<<<
 *             return NotImplemented
 * 
 */
  switch (__pyx_v_op) {
    case 2:
    case 3:
    __pyx_t_1 = 0;
    break;
    default:
    __pyx_t_1 = 1;
    break;
  }
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":2942
 *     def __richcmp__(VariantRecordSamples self not None, VariantRecordSamples other not None, int op):
 *         if op != 2 and op != 3:
 *             return NotImplemented             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf1_t *s = self.record.ptr
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":2941
 * 
 *     def __richcmp__(VariantRecordSamples self not None, VariantRecordSamples other not None, int op):
 *         if op != 2 and op != 3:             # <<<<<<<<<<<<<<
 *             return NotImplemented
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2944
 *             return NotImplemented
 * 
 *         cdef bcf1_t *s = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *o = other.record.ptr
 * 
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_s = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2945
 * 
 *         cdef bcf1_t *s = self.record.ptr
 *         cdef bcf1_t *o = other.record.ptr             # <<<<<<<<<<<<<<
 * 
 *         cdef bint cmp = (s.n_sample == o.n_sample and self.values() == other.values())
 */
  __pyx_t_2 = __pyx_v_other->record->ptr;
  __pyx_v_o = __pyx_t_2;

  /* "pysam/libcbcf.pyx":2947
 *         cdef bcf1_t *o = other.record.ptr
 * 
 *         cdef bint cmp = (s.n_sample == o.n_sample and self.values() == other.values())             # <<<<<<<<<<<<<<
 * 
 *         if op == 3:
 */
  __pyx_t_3 = ((__pyx_v_s->n_sample == __pyx_v_o->n_sample) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_values); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2947, __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, 2947, __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, 2947, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_values); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2947, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (__pyx_t_7) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2947, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else {
    __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2947, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2947, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2947, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  __pyx_v_cmp = __pyx_t_1;

  /* "pysam/libcbcf.pyx":2949
 *         cdef bint cmp = (s.n_sample == o.n_sample and self.values() == other.values())
 * 
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             cmp = not cmp
 * 
 */
  __pyx_t_1 = ((__pyx_v_op == 3) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":2950
 * 
 *         if op == 3:
 *             cmp = not cmp             # <<<<<<<<<<<<<<
 * 
 *         return cmp
 */
    __pyx_v_cmp = (!(__pyx_v_cmp != 0));

    /* "pysam/libcbcf.pyx":2949
 *         cdef bint cmp = (s.n_sample == o.n_sample and self.values() == other.values())
 * 
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             cmp = not cmp
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2952
 *             cmp = not cmp
 * 
 *         return cmp             # <<<<<<<<<<<<<<
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_v_cmp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2952, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2940
 *             raise
 * 
 *     def __richcmp__(VariantRecordSamples self not None, VariantRecordSamples other not None, int op):             # <<<<<<<<<<<<<<
 *         if op != 2 and op != 3:
 *             return NotImplemented
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.record,)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_36__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_35__reduce_cython__[] = "VariantRecordSamples.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_36__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_35__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_35__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.record,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->record));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->record));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->record));
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.record,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":5
 *     state = (self.record,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.record is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.record,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.record is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_VariantRecordSamples, (type(self), 0xde17f0f, None), state
 */
  /*else*/ {
    __pyx_t_3 = (((PyObject *)__pyx_v_self->record) != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.record is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantRecordSamples, (type(self), 0xde17f0f, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":11
 *         use_setstate = self.record is not None
 *     if use_setstate:
 *         return __pyx_unpickle_VariantRecordSamples, (type(self), 0xde17f0f, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_VariantRecordSamples, (type(self), 0xde17f0f, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantRecordSamp); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_232881935);
    __Pyx_GIVEREF(__pyx_int_232881935);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_232881935);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.record is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantRecordSamples, (type(self), 0xde17f0f, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_VariantRecordSamples, (type(self), 0xde17f0f, None), state
 *     else:
 *         return __pyx_unpickle_VariantRecordSamples, (type(self), 0xde17f0f, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantRecordSamples__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantRecordSamp); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_232881935);
    __Pyx_GIVEREF(__pyx_int_232881935);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_232881935);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.record,)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantRecordSamples, (type(self), 0xde17f0f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantRecordSamples__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_38__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_37__setstate_cython__[] = "VariantRecordSamples.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_38__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_37__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20VariantRecordSamples_37__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 14, 0, __PYX_ERR(2, 14, __pyx_L1_error));

  /* "(tree fragment)":15
 *         return __pyx_unpickle_VariantRecordSamples, (type(self), 0xde17f0f, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantRecordSamples__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordSamples__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantRecordSamples, (type(self), 0xde17f0f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantRecordSamples__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSamples.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2958
 * 
 * 
 * cdef VariantRecordSamples makeVariantRecordSamples(VariantRecord record):             # <<<<<<<<<<<<<<
 *     if not record:
 *         raise ValueError('invalid VariantRecord')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_f_5pysam_7libcbcf_makeVariantRecordSamples(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v_samples = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("makeVariantRecordSamples", 0);
  __Pyx_TraceCall("makeVariantRecordSamples", __pyx_f[0], 2958, 0, __PYX_ERR(0, 2958, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2959
 * 
 * cdef VariantRecordSamples makeVariantRecordSamples(VariantRecord record):
 *     if not record:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantRecord')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_record)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2959, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":2960
 * cdef VariantRecordSamples makeVariantRecordSamples(VariantRecord record):
 *     if not record:
 *         raise ValueError('invalid VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantRecordSamples samples = VariantRecordSamples.__new__(
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__141, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2960, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2960, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2959
 * 
 * cdef VariantRecordSamples makeVariantRecordSamples(VariantRecord record):
 *     if not record:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2962
 *         raise ValueError('invalid VariantRecord')
 * 
 *     cdef VariantRecordSamples samples = VariantRecordSamples.__new__(             # <<<<<<<<<<<<<<
 *         VariantRecordSamples)
 *     samples.record = record
 */
  __pyx_t_3 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantRecordSamples(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordSamples), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2962, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_samples = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":2964
 *     cdef VariantRecordSamples samples = VariantRecordSamples.__new__(
 *         VariantRecordSamples)
 *     samples.record = record             # <<<<<<<<<<<<<<
 * 
 *     return samples
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_record));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_record));
  __Pyx_GOTREF(__pyx_v_samples->record);
  __Pyx_DECREF(((PyObject *)__pyx_v_samples->record));
  __pyx_v_samples->record = __pyx_v_record;

  /* "pysam/libcbcf.pyx":2966
 *     samples.record = record
 * 
 *     return samples             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_samples));
  __pyx_r = __pyx_v_samples;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2958
 * 
 * 
 * cdef VariantRecordSamples makeVariantRecordSamples(VariantRecord record):             # <<<<<<<<<<<<<<
 *     if not record:
 *         raise ValueError('invalid VariantRecord')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantRecordSamples", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_samples);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2971
 * cdef class VariantRecord(object):
 *     """Variant record"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 2971, 0, __PYX_ERR(0, 2971, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2972
 *     """Variant record"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__142, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2972, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 2972, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":2971
 * cdef class VariantRecord(object):
 *     """Variant record"""
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2974
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.ptr:
 *             bcf_destroy1(self.ptr)
 */

/* Python wrapper */
static void __pyx_pw_5pysam_7libcbcf_13VariantRecord_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5pysam_7libcbcf_13VariantRecord_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5pysam_7libcbcf_13VariantRecord_2__dealloc__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static void __pyx_pf_5pysam_7libcbcf_13VariantRecord_2__dealloc__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);
  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 2974, 0, __PYX_ERR(0, 2974, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2975
 * 
 *     def __dealloc__(self):
 *         if self.ptr:             # <<<<<<<<<<<<<<
 *             bcf_destroy1(self.ptr)
 *             self.ptr = NULL
 */
  __pyx_t_1 = (__pyx_v_self->ptr != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":2976
 *     def __dealloc__(self):
 *         if self.ptr:
 *             bcf_destroy1(self.ptr)             # <<<<<<<<<<<<<<
 *             self.ptr = NULL
 * 
 */
    bcf_destroy1(__pyx_v_self->ptr);

    /* "pysam/libcbcf.pyx":2977
 *         if self.ptr:
 *             bcf_destroy1(self.ptr)
 *             self.ptr = NULL             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
    __pyx_v_self->ptr = NULL;

    /* "pysam/libcbcf.pyx":2975
 * 
 *     def __dealloc__(self):
 *         if self.ptr:             # <<<<<<<<<<<<<<
 *             bcf_destroy1(self.ptr)
 *             self.ptr = NULL
 */
  }

  /* "pysam/libcbcf.pyx":2974
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.ptr:
 *             bcf_destroy1(self.ptr)
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pysam.libcbcf.VariantRecord.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
}

/* "pysam/libcbcf.pyx":2979
 *             self.ptr = NULL
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         """return a copy of this VariantRecord object"""
 *         return makeVariantRecord(self.header, bcf_dup(self.ptr))
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_5copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantRecord_4copy[] = "VariantRecord.copy(self)\nreturn a copy of this VariantRecord object";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_5copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_4copy(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_4copy(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("copy", 0);
  __Pyx_TraceCall("copy", __pyx_f[0], 2979, 0, __PYX_ERR(0, 2979, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2981
 *     def copy(self):
 *         """return a copy of this VariantRecord object"""
 *         return makeVariantRecord(self.header, bcf_dup(self.ptr))             # <<<<<<<<<<<<<<
 * 
 *     def translate(self, VariantHeader dst_header):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_v_self->header);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantRecord(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_1), bcf_dup(__pyx_v_self->ptr))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2981, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2979
 *             self.ptr = NULL
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         """return a copy of this VariantRecord object"""
 *         return makeVariantRecord(self.header, bcf_dup(self.ptr))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2983
 *         return makeVariantRecord(self.header, bcf_dup(self.ptr))
 * 
 *     def translate(self, VariantHeader dst_header):             # <<<<<<<<<<<<<<
 *         if dst_header is None:
 *             raise ValueError('dst_header must not be None')
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_7translate(PyObject *__pyx_v_self, PyObject *__pyx_v_dst_header); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantRecord_6translate[] = "VariantRecord.translate(self, VariantHeader dst_header)";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_7translate(PyObject *__pyx_v_self, PyObject *__pyx_v_dst_header) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("translate (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dst_header), __pyx_ptype_5pysam_7libcbcf_VariantHeader, 1, "dst_header", 0))) __PYX_ERR(0, 2983, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_6translate(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_v_dst_header));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_6translate(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_dst_header) {
  bcf_hdr_t *__pyx_v_src_hdr;
  bcf_hdr_t *__pyx_v_dst_hdr;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  bcf_hdr_t *__pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("translate", 0);
  __Pyx_TraceCall("translate", __pyx_f[0], 2983, 0, __PYX_ERR(0, 2983, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":2984
 * 
 *     def translate(self, VariantHeader dst_header):
 *         if dst_header is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('dst_header must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_dst_header) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":2985
 *     def translate(self, VariantHeader dst_header):
 *         if dst_header is None:
 *             raise ValueError('dst_header must not be None')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_hdr_t *src_hdr = self.header.ptr
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__143, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2985, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2985, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":2984
 * 
 *     def translate(self, VariantHeader dst_header):
 *         if dst_header is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('dst_header must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":2987
 *             raise ValueError('dst_header must not be None')
 * 
 *         cdef bcf_hdr_t *src_hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *dst_hdr = dst_header.ptr
 * 
 */
  __pyx_t_4 = __pyx_v_self->header->ptr;
  __pyx_v_src_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":2988
 * 
 *         cdef bcf_hdr_t *src_hdr = self.header.ptr
 *         cdef bcf_hdr_t *dst_hdr = dst_header.ptr             # <<<<<<<<<<<<<<
 * 
 *         if src_hdr != dst_hdr:
 */
  __pyx_t_4 = __pyx_v_dst_header->ptr;
  __pyx_v_dst_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":2990
 *         cdef bcf_hdr_t *dst_hdr = dst_header.ptr
 * 
 *         if src_hdr != dst_hdr:             # <<<<<<<<<<<<<<
 *             if self.ptr.n_sample != bcf_hdr_nsamples(dst_hdr):
 *                 msg = 'Cannot translate record.  Number of samples does not match header ({} vs {})'
 */
  __pyx_t_2 = ((__pyx_v_src_hdr != __pyx_v_dst_hdr) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":2991
 * 
 *         if src_hdr != dst_hdr:
 *             if self.ptr.n_sample != bcf_hdr_nsamples(dst_hdr):             # <<<<<<<<<<<<<<
 *                 msg = 'Cannot translate record.  Number of samples does not match header ({} vs {})'
 *                 raise ValueError(msg.format(self.ptr.n_sample, bcf_hdr_nsamples(dst_hdr)))
 */
    __pyx_t_2 = ((__pyx_v_self->ptr->n_sample != bcf_hdr_nsamples(__pyx_v_dst_hdr)) != 0);
    if (unlikely(__pyx_t_2)) {

      /* "pysam/libcbcf.pyx":2992
 *         if src_hdr != dst_hdr:
 *             if self.ptr.n_sample != bcf_hdr_nsamples(dst_hdr):
 *                 msg = 'Cannot translate record.  Number of samples does not match header ({} vs {})'             # <<<<<<<<<<<<<<
 *                 raise ValueError(msg.format(self.ptr.n_sample, bcf_hdr_nsamples(dst_hdr)))
 * 
 */
      __Pyx_INCREF(__pyx_kp_s_Cannot_translate_record_Number_o);
      __pyx_v_msg = __pyx_kp_s_Cannot_translate_record_Number_o;

      /* "pysam/libcbcf.pyx":2993
 *             if self.ptr.n_sample != bcf_hdr_nsamples(dst_hdr):
 *                 msg = 'Cannot translate record.  Number of samples does not match header ({} vs {})'
 *                 raise ValueError(msg.format(self.ptr.n_sample, bcf_hdr_nsamples(dst_hdr)))             # <<<<<<<<<<<<<<
 * 
 *             bcf_translate(dst_hdr, src_hdr, self.ptr)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2993, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyInt_From_uint32_t(__pyx_v_self->ptr->n_sample); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2993, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyInt_From_int32_t(bcf_hdr_nsamples(__pyx_v_dst_hdr)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2993, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_7};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2993, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_7};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2993, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2993, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (__pyx_t_8) {
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7);
        __pyx_t_6 = 0;
        __pyx_t_7 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2993, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2993, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 2993, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":2991
 * 
 *         if src_hdr != dst_hdr:
 *             if self.ptr.n_sample != bcf_hdr_nsamples(dst_hdr):             # <<<<<<<<<<<<<<
 *                 msg = 'Cannot translate record.  Number of samples does not match header ({} vs {})'
 *                 raise ValueError(msg.format(self.ptr.n_sample, bcf_hdr_nsamples(dst_hdr)))
 */
    }

    /* "pysam/libcbcf.pyx":2995
 *                 raise ValueError(msg.format(self.ptr.n_sample, bcf_hdr_nsamples(dst_hdr)))
 * 
 *             bcf_translate(dst_hdr, src_hdr, self.ptr)             # <<<<<<<<<<<<<<
 *             self.header = dst_header
 * 
 */
    (void)(bcf_translate(__pyx_v_dst_hdr, __pyx_v_src_hdr, __pyx_v_self->ptr));

    /* "pysam/libcbcf.pyx":2996
 * 
 *             bcf_translate(dst_hdr, src_hdr, self.ptr)
 *             self.header = dst_header             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_dst_header));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dst_header));
    __Pyx_GOTREF(__pyx_v_self->header);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->header));
    __pyx_v_self->header = __pyx_v_dst_header;

    /* "pysam/libcbcf.pyx":2990
 *         cdef bcf_hdr_t *dst_hdr = dst_header.ptr
 * 
 *         if src_hdr != dst_hdr:             # <<<<<<<<<<<<<<
 *             if self.ptr.n_sample != bcf_hdr_nsamples(dst_hdr):
 *                 msg = 'Cannot translate record.  Number of samples does not match header ({} vs {})'
 */
  }

  /* "pysam/libcbcf.pyx":2983
 *         return makeVariantRecord(self.header, bcf_dup(self.ptr))
 * 
 *     def translate(self, VariantHeader dst_header):             # <<<<<<<<<<<<<<
 *         if dst_header is None:
 *             raise ValueError('dst_header must not be None')
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.translate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":2999
 * 
 *     @property
 *     def rid(self):             # <<<<<<<<<<<<<<
 *         """internal reference id number"""
 *         return self.ptr.rid
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_3rid_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_3rid_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_3rid___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_3rid___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 2999, 0, __PYX_ERR(0, 2999, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3001
 *     def rid(self):
 *         """internal reference id number"""
 *         return self.ptr.rid             # <<<<<<<<<<<<<<
 * 
 *     @rid.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_v_self->ptr->rid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":2999
 * 
 *     @property
 *     def rid(self):             # <<<<<<<<<<<<<<
 *         """internal reference id number"""
 *         return self.ptr.rid
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.rid.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3004
 * 
 *     @rid.setter
 *     def rid(self, value):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int r = value
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_3rid_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_3rid_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_3rid_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_3rid_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value) {
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_r;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3004, 0, __PYX_ERR(0, 3004, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3005
 *     @rid.setter
 *     def rid(self, value):
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef int r = value
 *         if r < 0 or r >= hdr.n[BCF_DT_CTG] or not hdr.id[BCF_DT_CTG][r].val:
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3006
 *     def rid(self, value):
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int r = value             # <<<<<<<<<<<<<<
 *         if r < 0 or r >= hdr.n[BCF_DT_CTG] or not hdr.id[BCF_DT_CTG][r].val:
 *             raise ValueError('invalid reference id')
 */
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3006, __pyx_L1_error)
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":3007
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int r = value
 *         if r < 0 or r >= hdr.n[BCF_DT_CTG] or not hdr.id[BCF_DT_CTG][r].val:             # <<<<<<<<<<<<<<
 *             raise ValueError('invalid reference id')
 *         self.ptr.rid = r
 */
  __pyx_t_4 = ((__pyx_v_r < 0) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_r >= (__pyx_v_hdr->n[BCF_DT_CTG])) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = ((!(((__pyx_v_hdr->id[BCF_DT_CTG])[__pyx_v_r]).val != 0)) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":3008
 *         cdef int r = value
 *         if r < 0 or r >= hdr.n[BCF_DT_CTG] or not hdr.id[BCF_DT_CTG][r].val:
 *             raise ValueError('invalid reference id')             # <<<<<<<<<<<<<<
 *         self.ptr.rid = r
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__144, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3008, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 3008, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3007
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int r = value
 *         if r < 0 or r >= hdr.n[BCF_DT_CTG] or not hdr.id[BCF_DT_CTG][r].val:             # <<<<<<<<<<<<<<
 *             raise ValueError('invalid reference id')
 *         self.ptr.rid = r
 */
  }

  /* "pysam/libcbcf.pyx":3009
 *         if r < 0 or r >= hdr.n[BCF_DT_CTG] or not hdr.id[BCF_DT_CTG][r].val:
 *             raise ValueError('invalid reference id')
 *         self.ptr.rid = r             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_v_self->ptr->rid = __pyx_v_r;

  /* "pysam/libcbcf.pyx":3004
 * 
 *     @rid.setter
 *     def rid(self, value):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int r = value
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.rid.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3012
 * 
 *     @property
 *     def chrom(self):             # <<<<<<<<<<<<<<
 *         """chromosome/contig name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_5chrom_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_5chrom_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_5chrom___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_5chrom___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_rid;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3012, 0, __PYX_ERR(0, 3012, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3014
 *     def chrom(self):
 *         """chromosome/contig name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef int rid = self.ptr.rid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3015
 *         """chromosome/contig name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int rid = self.ptr.rid             # <<<<<<<<<<<<<<
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 *             raise ValueError('Invalid header')
 */
  __pyx_t_2 = __pyx_v_self->ptr->rid;
  __pyx_v_rid = __pyx_t_2;

  /* "pysam/libcbcf.pyx":3016
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int rid = self.ptr.rid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header')
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 */
  __pyx_t_4 = ((__pyx_v_rid < 0) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_rid >= (__pyx_v_hdr->n[BCF_DT_CTG])) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":3017
 *         cdef int rid = self.ptr.rid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 *             raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__145, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3017, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 3017, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3016
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int rid = self.ptr.rid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header')
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 */
  }

  /* "pysam/libcbcf.pyx":3018
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 *             raise ValueError('Invalid header')
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))             # <<<<<<<<<<<<<<
 * 
 *     @chrom.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(bcf_hdr_id2name(__pyx_v_hdr, __pyx_v_rid)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3012
 * 
 *     @property
 *     def chrom(self):             # <<<<<<<<<<<<<<
 *         """chromosome/contig name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.chrom.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3021
 * 
 *     @chrom.setter
 *     def chrom(self, value):             # <<<<<<<<<<<<<<
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]
 *         bchrom = force_bytes(value)
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_5chrom_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_5chrom_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_5chrom_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_5chrom_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value) {
  vdict_t *__pyx_v_d;
  PyObject *__pyx_v_bchrom = NULL;
  khint_t __pyx_v_k;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char const *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3021, 0, __PYX_ERR(0, 3021, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3022
 *     @chrom.setter
 *     def chrom(self, value):
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]             # <<<<<<<<<<<<<<
 *         bchrom = force_bytes(value)
 *         cdef khint_t k = kh_get_vdict(d, bchrom)
 */
  __pyx_v_d = ((vdict_t *)(__pyx_v_self->header->ptr->dict[BCF_DT_CTG]));

  /* "pysam/libcbcf.pyx":3023
 *     def chrom(self, value):
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]
 *         bchrom = force_bytes(value)             # <<<<<<<<<<<<<<
 *         cdef khint_t k = kh_get_vdict(d, bchrom)
 *         if k == kh_end(d):
 */
  __pyx_t_1 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_value, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3023, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bchrom = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":3024
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]
 *         bchrom = force_bytes(value)
 *         cdef khint_t k = kh_get_vdict(d, bchrom)             # <<<<<<<<<<<<<<
 *         if k == kh_end(d):
 *             raise ValueError('Invalid chromosome/contig')
 */
  if (unlikely(__pyx_v_bchrom == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 3024, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_bchrom); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 3024, __pyx_L1_error)
  __pyx_v_k = kh_get_vdict(__pyx_v_d, __pyx_t_2);

  /* "pysam/libcbcf.pyx":3025
 *         bchrom = force_bytes(value)
 *         cdef khint_t k = kh_get_vdict(d, bchrom)
 *         if k == kh_end(d):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid chromosome/contig')
 *         self.ptr.rid = kh_val_vdict(d, k).id
 */
  __pyx_t_3 = ((__pyx_v_k == kh_end(__pyx_v_d)) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":3026
 *         cdef khint_t k = kh_get_vdict(d, bchrom)
 *         if k == kh_end(d):
 *             raise ValueError('Invalid chromosome/contig')             # <<<<<<<<<<<<<<
 *         self.ptr.rid = kh_val_vdict(d, k).id
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__146, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 3026, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3025
 *         bchrom = force_bytes(value)
 *         cdef khint_t k = kh_get_vdict(d, bchrom)
 *         if k == kh_end(d):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid chromosome/contig')
 *         self.ptr.rid = kh_val_vdict(d, k).id
 */
  }

  /* "pysam/libcbcf.pyx":3027
 *         if k == kh_end(d):
 *             raise ValueError('Invalid chromosome/contig')
 *         self.ptr.rid = kh_val_vdict(d, k).id             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_4 = kh_val(__pyx_v_d, __pyx_v_k).id;
  __pyx_v_self->ptr->rid = __pyx_t_4;

  /* "pysam/libcbcf.pyx":3021
 * 
 *     @chrom.setter
 *     def chrom(self, value):             # <<<<<<<<<<<<<<
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]
 *         bchrom = force_bytes(value)
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.chrom.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bchrom);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3030
 * 
 *     @property
 *     def contig(self):             # <<<<<<<<<<<<<<
 *         """chromosome/contig name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_6contig_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_6contig_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_6contig___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_6contig___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_rid;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3030, 0, __PYX_ERR(0, 3030, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3032
 *     def contig(self):
 *         """chromosome/contig name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef int rid = self.ptr.rid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 */
  __pyx_t_1 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3033
 *         """chromosome/contig name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int rid = self.ptr.rid             # <<<<<<<<<<<<<<
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 *             raise ValueError('Invalid header')
 */
  __pyx_t_2 = __pyx_v_self->ptr->rid;
  __pyx_v_rid = __pyx_t_2;

  /* "pysam/libcbcf.pyx":3034
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int rid = self.ptr.rid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header')
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 */
  __pyx_t_4 = ((__pyx_v_rid < 0) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_rid >= (__pyx_v_hdr->n[BCF_DT_CTG])) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":3035
 *         cdef int rid = self.ptr.rid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 *             raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__147, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3035, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 3035, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3034
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int rid = self.ptr.rid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid header')
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 */
  }

  /* "pysam/libcbcf.pyx":3036
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 *             raise ValueError('Invalid header')
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))             # <<<<<<<<<<<<<<
 * 
 *     @contig.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(bcf_hdr_id2name(__pyx_v_hdr, __pyx_v_rid)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3036, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3030
 * 
 *     @property
 *     def contig(self):             # <<<<<<<<<<<<<<
 *         """chromosome/contig name"""
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.contig.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3039
 * 
 *     @contig.setter
 *     def contig(self, value):             # <<<<<<<<<<<<<<
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]
 *         bchrom = force_bytes(value)
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_6contig_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_6contig_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_6contig_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_6contig_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value) {
  vdict_t *__pyx_v_d;
  PyObject *__pyx_v_bchrom = NULL;
  khint_t __pyx_v_k;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char const *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3039, 0, __PYX_ERR(0, 3039, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3040
 *     @contig.setter
 *     def contig(self, value):
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]             # <<<<<<<<<<<<<<
 *         bchrom = force_bytes(value)
 *         cdef khint_t k = kh_get_vdict(d, bchrom)
 */
  __pyx_v_d = ((vdict_t *)(__pyx_v_self->header->ptr->dict[BCF_DT_CTG]));

  /* "pysam/libcbcf.pyx":3041
 *     def contig(self, value):
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]
 *         bchrom = force_bytes(value)             # <<<<<<<<<<<<<<
 *         cdef khint_t k = kh_get_vdict(d, bchrom)
 *         if k == kh_end(d):
 */
  __pyx_t_1 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_value, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3041, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bchrom = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":3042
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]
 *         bchrom = force_bytes(value)
 *         cdef khint_t k = kh_get_vdict(d, bchrom)             # <<<<<<<<<<<<<<
 *         if k == kh_end(d):
 *             raise ValueError('Invalid chromosome/contig')
 */
  if (unlikely(__pyx_v_bchrom == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 3042, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_bchrom); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 3042, __pyx_L1_error)
  __pyx_v_k = kh_get_vdict(__pyx_v_d, __pyx_t_2);

  /* "pysam/libcbcf.pyx":3043
 *         bchrom = force_bytes(value)
 *         cdef khint_t k = kh_get_vdict(d, bchrom)
 *         if k == kh_end(d):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid chromosome/contig')
 *         self.ptr.rid = kh_val_vdict(d, k).id
 */
  __pyx_t_3 = ((__pyx_v_k == kh_end(__pyx_v_d)) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":3044
 *         cdef khint_t k = kh_get_vdict(d, bchrom)
 *         if k == kh_end(d):
 *             raise ValueError('Invalid chromosome/contig')             # <<<<<<<<<<<<<<
 *         self.ptr.rid = kh_val_vdict(d, k).id
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__148, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3044, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 3044, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3043
 *         bchrom = force_bytes(value)
 *         cdef khint_t k = kh_get_vdict(d, bchrom)
 *         if k == kh_end(d):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid chromosome/contig')
 *         self.ptr.rid = kh_val_vdict(d, k).id
 */
  }

  /* "pysam/libcbcf.pyx":3045
 *         if k == kh_end(d):
 *             raise ValueError('Invalid chromosome/contig')
 *         self.ptr.rid = kh_val_vdict(d, k).id             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_4 = kh_val(__pyx_v_d, __pyx_v_k).id;
  __pyx_v_self->ptr->rid = __pyx_t_4;

  /* "pysam/libcbcf.pyx":3039
 * 
 *     @contig.setter
 *     def contig(self, value):             # <<<<<<<<<<<<<<
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]
 *         bchrom = force_bytes(value)
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.contig.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bchrom);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3048
 * 
 *     @property
 *     def pos(self):             # <<<<<<<<<<<<<<
 *         """record start position on chrom/contig (1-based inclusive)"""
 *         return self.ptr.pos + 1
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_3pos_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_3pos_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_3pos___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_3pos___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3048, 0, __PYX_ERR(0, 3048, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3050
 *     def pos(self):
 *         """record start position on chrom/contig (1-based inclusive)"""
 *         return self.ptr.pos + 1             # <<<<<<<<<<<<<<
 * 
 *     @pos.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_self->ptr->pos + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3050, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3048
 * 
 *     @property
 *     def pos(self):             # <<<<<<<<<<<<<<
 *         """record start position on chrom/contig (1-based inclusive)"""
 *         return self.ptr.pos + 1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.pos.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3053
 * 
 *     @pos.setter
 *     def pos(self, value):             # <<<<<<<<<<<<<<
 *         cdef int p = value
 *         if p < 1:
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_3pos_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_3pos_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_3pos_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_3pos_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_v_p;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3053, 0, __PYX_ERR(0, 3053, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3054
 *     @pos.setter
 *     def pos(self, value):
 *         cdef int p = value             # <<<<<<<<<<<<<<
 *         if p < 1:
 *             raise ValueError('Position must be positive')
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3054, __pyx_L1_error)
  __pyx_v_p = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3055
 *     def pos(self, value):
 *         cdef int p = value
 *         if p < 1:             # <<<<<<<<<<<<<<
 *             raise ValueError('Position must be positive')
 *         self.ptr.pos = p - 1
 */
  __pyx_t_2 = ((__pyx_v_p < 1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3056
 *         cdef int p = value
 *         if p < 1:
 *             raise ValueError('Position must be positive')             # <<<<<<<<<<<<<<
 *         self.ptr.pos = p - 1
 *         bcf_sync_end(self)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__149, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3056, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3056, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3055
 *     def pos(self, value):
 *         cdef int p = value
 *         if p < 1:             # <<<<<<<<<<<<<<
 *             raise ValueError('Position must be positive')
 *         self.ptr.pos = p - 1
 */
  }

  /* "pysam/libcbcf.pyx":3057
 *         if p < 1:
 *             raise ValueError('Position must be positive')
 *         self.ptr.pos = p - 1             # <<<<<<<<<<<<<<
 *         bcf_sync_end(self)
 * 
 */
  __pyx_v_self->ptr->pos = (__pyx_v_p - 1);

  /* "pysam/libcbcf.pyx":3058
 *             raise ValueError('Position must be positive')
 *         self.ptr.pos = p - 1
 *         bcf_sync_end(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_sync_end(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3058, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3053
 * 
 *     @pos.setter
 *     def pos(self, value):             # <<<<<<<<<<<<<<
 *         cdef int p = value
 *         if p < 1:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.pos.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3061
 * 
 *     @property
 *     def start(self):             # <<<<<<<<<<<<<<
 *         """record start position on chrom/contig (0-based inclusive)"""
 *         return self.ptr.pos
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_5start_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_5start_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_5start___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_5start___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3061, 0, __PYX_ERR(0, 3061, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3063
 *     def start(self):
 *         """record start position on chrom/contig (0-based inclusive)"""
 *         return self.ptr.pos             # <<<<<<<<<<<<<<
 * 
 *     @start.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_v_self->ptr->pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3063, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3061
 * 
 *     @property
 *     def start(self):             # <<<<<<<<<<<<<<
 *         """record start position on chrom/contig (0-based inclusive)"""
 *         return self.ptr.pos
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.start.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3066
 * 
 *     @start.setter
 *     def start(self, value):             # <<<<<<<<<<<<<<
 *         cdef int s = value
 *         if s < 0:
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_5start_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_5start_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_5start_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_5start_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_v_s;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3066, 0, __PYX_ERR(0, 3066, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3067
 *     @start.setter
 *     def start(self, value):
 *         cdef int s = value             # <<<<<<<<<<<<<<
 *         if s < 0:
 *             raise ValueError('Start coordinate must be non-negative')
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3067, __pyx_L1_error)
  __pyx_v_s = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3068
 *     def start(self, value):
 *         cdef int s = value
 *         if s < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Start coordinate must be non-negative')
 *         self.ptr.pos = s
 */
  __pyx_t_2 = ((__pyx_v_s < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3069
 *         cdef int s = value
 *         if s < 0:
 *             raise ValueError('Start coordinate must be non-negative')             # <<<<<<<<<<<<<<
 *         self.ptr.pos = s
 *         bcf_sync_end(self)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__150, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3069, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3069, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3068
 *     def start(self, value):
 *         cdef int s = value
 *         if s < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Start coordinate must be non-negative')
 *         self.ptr.pos = s
 */
  }

  /* "pysam/libcbcf.pyx":3070
 *         if s < 0:
 *             raise ValueError('Start coordinate must be non-negative')
 *         self.ptr.pos = s             # <<<<<<<<<<<<<<
 *         bcf_sync_end(self)
 * 
 */
  __pyx_v_self->ptr->pos = __pyx_v_s;

  /* "pysam/libcbcf.pyx":3071
 *             raise ValueError('Start coordinate must be non-negative')
 *         self.ptr.pos = s
 *         bcf_sync_end(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_sync_end(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3071, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3066
 * 
 *     @start.setter
 *     def start(self, value):             # <<<<<<<<<<<<<<
 *         cdef int s = value
 *         if s < 0:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.start.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3074
 * 
 *     @property
 *     def stop(self):             # <<<<<<<<<<<<<<
 *         """record stop position on chrom/contig (0-based exclusive)"""
 *         return self.ptr.pos + self.ptr.rlen
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_4stop_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_4stop_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_4stop___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_4stop___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3074, 0, __PYX_ERR(0, 3074, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3076
 *     def stop(self):
 *         """record stop position on chrom/contig (0-based exclusive)"""
 *         return self.ptr.pos + self.ptr.rlen             # <<<<<<<<<<<<<<
 * 
 *     @stop.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int32_t((__pyx_v_self->ptr->pos + __pyx_v_self->ptr->rlen)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3076, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3074
 * 
 *     @property
 *     def stop(self):             # <<<<<<<<<<<<<<
 *         """record stop position on chrom/contig (0-based exclusive)"""
 *         return self.ptr.pos + self.ptr.rlen
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.stop.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3079
 * 
 *     @stop.setter
 *     def stop(self, value):             # <<<<<<<<<<<<<<
 *         cdef int s = value
 *         if s < 0:
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_4stop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_4stop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_4stop_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_4stop_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_v_s;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3079, 0, __PYX_ERR(0, 3079, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3080
 *     @stop.setter
 *     def stop(self, value):
 *         cdef int s = value             # <<<<<<<<<<<<<<
 *         if s < 0:
 *             raise ValueError('Stop coordinate must be non-negative')
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3080, __pyx_L1_error)
  __pyx_v_s = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3081
 *     def stop(self, value):
 *         cdef int s = value
 *         if s < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Stop coordinate must be non-negative')
 *         self.ptr.rlen = s - self.ptr.pos
 */
  __pyx_t_2 = ((__pyx_v_s < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3082
 *         cdef int s = value
 *         if s < 0:
 *             raise ValueError('Stop coordinate must be non-negative')             # <<<<<<<<<<<<<<
 *         self.ptr.rlen = s - self.ptr.pos
 *         bcf_sync_end(self)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__151, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3082, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3082, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3081
 *     def stop(self, value):
 *         cdef int s = value
 *         if s < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Stop coordinate must be non-negative')
 *         self.ptr.rlen = s - self.ptr.pos
 */
  }

  /* "pysam/libcbcf.pyx":3083
 *         if s < 0:
 *             raise ValueError('Stop coordinate must be non-negative')
 *         self.ptr.rlen = s - self.ptr.pos             # <<<<<<<<<<<<<<
 *         bcf_sync_end(self)
 * 
 */
  __pyx_v_self->ptr->rlen = (__pyx_v_s - __pyx_v_self->ptr->pos);

  /* "pysam/libcbcf.pyx":3084
 *             raise ValueError('Stop coordinate must be non-negative')
 *         self.ptr.rlen = s - self.ptr.pos
 *         bcf_sync_end(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_sync_end(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3084, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3079
 * 
 *     @stop.setter
 *     def stop(self, value):             # <<<<<<<<<<<<<<
 *         cdef int s = value
 *         if s < 0:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.stop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3087
 * 
 *     @property
 *     def rlen(self):             # <<<<<<<<<<<<<<
 *         """record length on chrom/contig (aka rec.stop - rec.start)"""
 *         return self.ptr.rlen
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_4rlen_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_4rlen_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_4rlen___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_4rlen___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3087, 0, __PYX_ERR(0, 3087, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3089
 *     def rlen(self):
 *         """record length on chrom/contig (aka rec.stop - rec.start)"""
 *         return self.ptr.rlen             # <<<<<<<<<<<<<<
 * 
 *     @rlen.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_v_self->ptr->rlen); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3087
 * 
 *     @property
 *     def rlen(self):             # <<<<<<<<<<<<<<
 *         """record length on chrom/contig (aka rec.stop - rec.start)"""
 *         return self.ptr.rlen
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.rlen.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3092
 * 
 *     @rlen.setter
 *     def rlen(self, value):             # <<<<<<<<<<<<<<
 *         cdef int r = value
 *         self.ptr.rlen = r
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_4rlen_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_4rlen_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_4rlen_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_4rlen_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_v_r;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3092, 0, __PYX_ERR(0, 3092, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3093
 *     @rlen.setter
 *     def rlen(self, value):
 *         cdef int r = value             # <<<<<<<<<<<<<<
 *         self.ptr.rlen = r
 *         bcf_sync_end(self)
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3093, __pyx_L1_error)
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3094
 *     def rlen(self, value):
 *         cdef int r = value
 *         self.ptr.rlen = r             # <<<<<<<<<<<<<<
 *         bcf_sync_end(self)
 * 
 */
  __pyx_v_self->ptr->rlen = __pyx_v_r;

  /* "pysam/libcbcf.pyx":3095
 *         cdef int r = value
 *         self.ptr.rlen = r
 *         bcf_sync_end(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_2 = __pyx_f_5pysam_7libcbcf_bcf_sync_end(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3095, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":3092
 * 
 *     @rlen.setter
 *     def rlen(self, value):             # <<<<<<<<<<<<<<
 *         cdef int r = value
 *         self.ptr.rlen = r
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.rlen.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3098
 * 
 *     @property
 *     def qual(self):             # <<<<<<<<<<<<<<
 *         """phred scaled quality score or None if not available"""
 *         return self.ptr.qual if not bcf_float_is_missing(self.ptr.qual) else None
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_4qual_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_4qual_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_4qual___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_4qual___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3098, 0, __PYX_ERR(0, 3098, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3100
 *     def qual(self):
 *         """phred scaled quality score or None if not available"""
 *         return self.ptr.qual if not bcf_float_is_missing(self.ptr.qual) else None             # <<<<<<<<<<<<<<
 * 
 *     @qual.setter
 */
  __Pyx_XDECREF(__pyx_r);
  if (((!(bcf_float_is_missing(__pyx_v_self->ptr->qual) != 0)) != 0)) {
    __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->ptr->qual); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3100, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __pyx_t_2;
    __pyx_t_2 = 0;
  } else {
    __Pyx_INCREF(Py_None);
    __pyx_t_1 = Py_None;
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3098
 * 
 *     @property
 *     def qual(self):             # <<<<<<<<<<<<<<
 *         """phred scaled quality score or None if not available"""
 *         return self.ptr.qual if not bcf_float_is_missing(self.ptr.qual) else None
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.qual.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3103
 * 
 *     @qual.setter
 *     def qual(self, value):             # <<<<<<<<<<<<<<
 *         if value is not None:
 *             self.ptr.qual = value
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_4qual_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_4qual_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_4qual_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_4qual_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  float __pyx_t_3;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3103, 0, __PYX_ERR(0, 3103, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3104
 *     @qual.setter
 *     def qual(self, value):
 *         if value is not None:             # <<<<<<<<<<<<<<
 *             self.ptr.qual = value
 *         else:
 */
  __pyx_t_1 = (__pyx_v_value != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":3105
 *     def qual(self, value):
 *         if value is not None:
 *             self.ptr.qual = value             # <<<<<<<<<<<<<<
 *         else:
 *             bcf_float_set(&self.ptr.qual, bcf_float_missing)
 */
    __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_value); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 3105, __pyx_L1_error)
    __pyx_v_self->ptr->qual = __pyx_t_3;

    /* "pysam/libcbcf.pyx":3104
 *     @qual.setter
 *     def qual(self, value):
 *         if value is not None:             # <<<<<<<<<<<<<<
 *             self.ptr.qual = value
 *         else:
 */
    goto __pyx_L3;
  }

  /* "pysam/libcbcf.pyx":3107
 *             self.ptr.qual = value
 *         else:
 *             bcf_float_set(&self.ptr.qual, bcf_float_missing)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    bcf_float_set((&__pyx_v_self->ptr->qual), bcf_float_missing);
  }
  __pyx_L3:;

  /* "pysam/libcbcf.pyx":3103
 * 
 *     @qual.setter
 *     def qual(self, value):             # <<<<<<<<<<<<<<
 *         if value is not None:
 *             self.ptr.qual = value
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.qual.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3119
 * 
 *     @property
 *     def id(self):             # <<<<<<<<<<<<<<
 *         """record identifier or None if not available"""
 *         cdef bcf1_t *r = self.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_2id_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_2id_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_2id___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_2id___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf1_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3119, 0, __PYX_ERR(0, 3119, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3121
 *     def id(self):
 *         """record identifier or None if not available"""
 *         cdef bcf1_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3122
 *         """record identifier or None if not available"""
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         return bcf_str_cache_get_charptr(r.d.id) if r.d.id != b'.' else None
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_STR) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3123
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         return bcf_str_cache_get_charptr(r.d.id) if r.d.id != b'.' else None
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__152, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3123, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3122
 *         """record identifier or None if not available"""
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         return bcf_str_cache_get_charptr(r.d.id) if r.d.id != b'.' else None
 */
  }

  /* "pysam/libcbcf.pyx":3124
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 *         return bcf_str_cache_get_charptr(r.d.id) if r.d.id != b'.' else None             # <<<<<<<<<<<<<<
 * 
 *     @id.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_r->d.id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_t_4, __pyx_kp_b__71, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3124, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {
    __pyx_t_4 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(__pyx_v_r->d.id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3124, __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_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3119
 * 
 *     @property
 *     def id(self):             # <<<<<<<<<<<<<<
 *         """record identifier or None if not available"""
 *         cdef bcf1_t *r = self.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.id.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3127
 * 
 *     @id.setter
 *     def id(self, value):             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_2id_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_2id_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_2id_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_2id_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value) {
  bcf1_t *__pyx_v_r;
  char *__pyx_v_idstr;
  PyObject *__pyx_v_bid = NULL;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf1_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  char *__pyx_t_5;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3127, 0, __PYX_ERR(0, 3127, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3128
 *     @id.setter
 *     def id(self, value):
 *         cdef bcf1_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3129
 *     def id(self, value):
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         cdef char *idstr = NULL
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_STR) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3130
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         cdef char *idstr = NULL
 *         if value is not None:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__153, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3130, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3129
 *     def id(self, value):
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         cdef char *idstr = NULL
 */
  }

  /* "pysam/libcbcf.pyx":3131
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 *         cdef char *idstr = NULL             # <<<<<<<<<<<<<<
 *         if value is not None:
 *             bid = force_bytes(value)
 */
  __pyx_v_idstr = NULL;

  /* "pysam/libcbcf.pyx":3132
 *             raise ValueError('Error unpacking VariantRecord')
 *         cdef char *idstr = NULL
 *         if value is not None:             # <<<<<<<<<<<<<<
 *             bid = force_bytes(value)
 *             idstr = bid
 */
  __pyx_t_2 = (__pyx_v_value != Py_None);
  __pyx_t_4 = (__pyx_t_2 != 0);
  if (__pyx_t_4) {

    /* "pysam/libcbcf.pyx":3133
 *         cdef char *idstr = NULL
 *         if value is not None:
 *             bid = force_bytes(value)             # <<<<<<<<<<<<<<
 *             idstr = bid
 *         if bcf_update_id(self.header.ptr, self.ptr, idstr) < 0:
 */
    __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_value, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_bid = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":3134
 *         if value is not None:
 *             bid = force_bytes(value)
 *             idstr = bid             # <<<<<<<<<<<<<<
 *         if bcf_update_id(self.header.ptr, self.ptr, idstr) < 0:
 *             raise ValueError('Error updating id')
 */
    if (unlikely(__pyx_v_bid == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 3134, __pyx_L1_error)
    }
    __pyx_t_5 = __Pyx_PyBytes_AsWritableString(__pyx_v_bid); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 3134, __pyx_L1_error)
    __pyx_v_idstr = __pyx_t_5;

    /* "pysam/libcbcf.pyx":3132
 *             raise ValueError('Error unpacking VariantRecord')
 *         cdef char *idstr = NULL
 *         if value is not None:             # <<<<<<<<<<<<<<
 *             bid = force_bytes(value)
 *             idstr = bid
 */
  }

  /* "pysam/libcbcf.pyx":3135
 *             bid = force_bytes(value)
 *             idstr = bid
 *         if bcf_update_id(self.header.ptr, self.ptr, idstr) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error updating id')
 * 
 */
  __pyx_t_4 = ((bcf_update_id(__pyx_v_self->header->ptr, __pyx_v_self->ptr, __pyx_v_idstr) < 0) != 0);
  if (unlikely(__pyx_t_4)) {

    /* "pysam/libcbcf.pyx":3136
 *             idstr = bid
 *         if bcf_update_id(self.header.ptr, self.ptr, idstr) < 0:
 *             raise ValueError('Error updating id')             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__154, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3136, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3136, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3135
 *             bid = force_bytes(value)
 *             idstr = bid
 *         if bcf_update_id(self.header.ptr, self.ptr, idstr) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error updating id')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3127
 * 
 *     @id.setter
 *     def id(self, value):             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.id.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bid);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3139
 * 
 *     @property
 *     def ref(self):             # <<<<<<<<<<<<<<
 *         """reference allele"""
 *         cdef bcf1_t *r = self.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_3ref_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_3ref___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_3ref___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf1_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3139, 0, __PYX_ERR(0, 3139, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3141
 *     def ref(self):
 *         """reference allele"""
 *         cdef bcf1_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3142
 *         """reference allele"""
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         return charptr_to_str(r.d.allele[0]) if r.d.allele else None
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_STR) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3143
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         return charptr_to_str(r.d.allele[0]) if r.d.allele else None
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__155, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3143, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3143, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3142
 *         """reference allele"""
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         return charptr_to_str(r.d.allele[0]) if r.d.allele else None
 */
  }

  /* "pysam/libcbcf.pyx":3144
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 *         return charptr_to_str(r.d.allele[0]) if r.d.allele else None             # <<<<<<<<<<<<<<
 * 
 *     @ref.setter
 */
  __Pyx_XDECREF(__pyx_r);
  if ((__pyx_v_r->d.allele != 0)) {
    __pyx_t_4 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_v_r->d.allele[0]), NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3144, __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_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3139
 * 
 *     @property
 *     def ref(self):             # <<<<<<<<<<<<<<
 *         """reference allele"""
 *         cdef bcf1_t *r = self.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.ref.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3147
 * 
 *     @ref.setter
 *     def ref(self, value):             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_3ref_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_3ref_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value) {
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_alleles = NULL;
  uint32_t __pyx_v_i;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf1_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  uint32_t __pyx_t_5;
  uint32_t __pyx_t_6;
  uint32_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3147, 0, __PYX_ERR(0, 3147, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_value);

  /* "pysam/libcbcf.pyx":3148
 *     @ref.setter
 *     def ref(self, value):
 *         cdef bcf1_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3149
 *     def ref(self, value):
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         #FIXME: Set alleles directly -- this is stupid
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_STR) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3150
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         #FIXME: Set alleles directly -- this is stupid
 *         if not value:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__156, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3150, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3149
 *     def ref(self, value):
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         #FIXME: Set alleles directly -- this is stupid
 */
  }

  /* "pysam/libcbcf.pyx":3152
 *             raise ValueError('Error unpacking VariantRecord')
 *         #FIXME: Set alleles directly -- this is stupid
 *         if not value:             # <<<<<<<<<<<<<<
 *             raise ValueError('ref allele must not be null')
 *         value = force_bytes(value)
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3152, __pyx_L1_error)
  __pyx_t_4 = ((!__pyx_t_2) != 0);
  if (unlikely(__pyx_t_4)) {

    /* "pysam/libcbcf.pyx":3153
 *         #FIXME: Set alleles directly -- this is stupid
 *         if not value:
 *             raise ValueError('ref allele must not be null')             # <<<<<<<<<<<<<<
 *         value = force_bytes(value)
 *         if r.d.allele and r.n_allele:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__157, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3153, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3152
 *             raise ValueError('Error unpacking VariantRecord')
 *         #FIXME: Set alleles directly -- this is stupid
 *         if not value:             # <<<<<<<<<<<<<<
 *             raise ValueError('ref allele must not be null')
 *         value = force_bytes(value)
 */
  }

  /* "pysam/libcbcf.pyx":3154
 *         if not value:
 *             raise ValueError('ref allele must not be null')
 *         value = force_bytes(value)             # <<<<<<<<<<<<<<
 *         if r.d.allele and r.n_allele:
 *             alleles = [r.d.allele[i] for i in range(r.n_allele)]
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_value, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3154, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3155
 *             raise ValueError('ref allele must not be null')
 *         value = force_bytes(value)
 *         if r.d.allele and r.n_allele:             # <<<<<<<<<<<<<<
 *             alleles = [r.d.allele[i] for i in range(r.n_allele)]
 *             alleles[0] = value
 */
  __pyx_t_2 = (__pyx_v_r->d.allele != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_4 = __pyx_t_2;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_r->n_allele != 0);
  __pyx_t_4 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_4) {

    /* "pysam/libcbcf.pyx":3156
 *         value = force_bytes(value)
 *         if r.d.allele and r.n_allele:
 *             alleles = [r.d.allele[i] for i in range(r.n_allele)]             # <<<<<<<<<<<<<<
 *             alleles[0] = value
 *         else:
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __pyx_v_r->n_allele;
    __pyx_t_6 = __pyx_t_5;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_i = __pyx_t_7;
      __pyx_t_8 = __Pyx_PyBytes_FromString((__pyx_v_r->d.allele[__pyx_v_i])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 3156, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __pyx_v_alleles = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":3157
 *         if r.d.allele and r.n_allele:
 *             alleles = [r.d.allele[i] for i in range(r.n_allele)]
 *             alleles[0] = value             # <<<<<<<<<<<<<<
 *         else:
 *             alleles = [value, '<NON_REF>']
 */
    if (unlikely(__Pyx_SetItemInt(__pyx_v_alleles, 0, __pyx_v_value, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 3157, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3155
 *             raise ValueError('ref allele must not be null')
 *         value = force_bytes(value)
 *         if r.d.allele and r.n_allele:             # <<<<<<<<<<<<<<
 *             alleles = [r.d.allele[i] for i in range(r.n_allele)]
 *             alleles[0] = value
 */
    goto __pyx_L5;
  }

  /* "pysam/libcbcf.pyx":3159
 *             alleles[0] = value
 *         else:
 *             alleles = [value, '<NON_REF>']             # <<<<<<<<<<<<<<
 *         self.alleles = alleles
 *         bcf_sync_end(self)
 */
  /*else*/ {
    __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_value);
    __Pyx_INCREF(__pyx_kp_s_NON_REF);
    __Pyx_GIVEREF(__pyx_kp_s_NON_REF);
    PyList_SET_ITEM(__pyx_t_3, 1, __pyx_kp_s_NON_REF);
    __pyx_v_alleles = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L5:;

  /* "pysam/libcbcf.pyx":3160
 *         else:
 *             alleles = [value, '<NON_REF>']
 *         self.alleles = alleles             # <<<<<<<<<<<<<<
 *         bcf_sync_end(self)
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_alleles, __pyx_v_alleles) < 0) __PYX_ERR(0, 3160, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":3161
 *             alleles = [value, '<NON_REF>']
 *         self.alleles = alleles
 *         bcf_sync_end(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_3 = __pyx_f_5pysam_7libcbcf_bcf_sync_end(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3147
 * 
 *     @ref.setter
 *     def ref(self, value):             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_alleles);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3164
 * 
 *     @property
 *     def alleles(self):             # <<<<<<<<<<<<<<
 *         """tuple of reference allele followed by alt alleles"""
 *         cdef bcf1_t *r = self.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_7alleles_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_7alleles_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_7alleles___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_7alleles___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_res = 0;
  uint32_t __pyx_v_i;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf1_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  uint32_t __pyx_t_4;
  uint32_t __pyx_t_5;
  uint32_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3164, 0, __PYX_ERR(0, 3164, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3166
 *     def alleles(self):
 *         """tuple of reference allele followed by alt alleles"""
 *         cdef bcf1_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3167
 *         """tuple of reference allele followed by alt alleles"""
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         if not r.d.allele:
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_STR) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3168
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         if not r.d.allele:
 *             return None
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__158, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3168, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3168, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3167
 *         """tuple of reference allele followed by alt alleles"""
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         if not r.d.allele:
 */
  }

  /* "pysam/libcbcf.pyx":3169
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 *         if not r.d.allele:             # <<<<<<<<<<<<<<
 *             return None
 *         cdef tuple res = PyTuple_New(r.n_allele)
 */
  __pyx_t_2 = ((!(__pyx_v_r->d.allele != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":3170
 *             raise ValueError('Error unpacking VariantRecord')
 *         if not r.d.allele:
 *             return None             # <<<<<<<<<<<<<<
 *         cdef tuple res = PyTuple_New(r.n_allele)
 *         for i in range(r.n_allele):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":3169
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 *         if not r.d.allele:             # <<<<<<<<<<<<<<
 *             return None
 *         cdef tuple res = PyTuple_New(r.n_allele)
 */
  }

  /* "pysam/libcbcf.pyx":3171
 *         if not r.d.allele:
 *             return None
 *         cdef tuple res = PyTuple_New(r.n_allele)             # <<<<<<<<<<<<<<
 *         for i in range(r.n_allele):
 *             a = charptr_to_str(r.d.allele[i])
 */
  __pyx_t_3 = PyTuple_New(__pyx_v_r->n_allele); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_res = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3172
 *             return None
 *         cdef tuple res = PyTuple_New(r.n_allele)
 *         for i in range(r.n_allele):             # <<<<<<<<<<<<<<
 *             a = charptr_to_str(r.d.allele[i])
 *             PyTuple_SET_ITEM(res, i, a)
 */
  __pyx_t_4 = __pyx_v_r->n_allele;
  __pyx_t_5 = __pyx_t_4;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
    __pyx_v_i = __pyx_t_6;

    /* "pysam/libcbcf.pyx":3173
 *         cdef tuple res = PyTuple_New(r.n_allele)
 *         for i in range(r.n_allele):
 *             a = charptr_to_str(r.d.allele[i])             # <<<<<<<<<<<<<<
 *             PyTuple_SET_ITEM(res, i, a)
 *             Py_INCREF(a)
 */
    __pyx_t_3 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_v_r->d.allele[__pyx_v_i]), NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":3174
 *         for i in range(r.n_allele):
 *             a = charptr_to_str(r.d.allele[i])
 *             PyTuple_SET_ITEM(res, i, a)             # <<<<<<<<<<<<<<
 *             Py_INCREF(a)
 *         return res
 */
    PyTuple_SET_ITEM(__pyx_v_res, __pyx_v_i, __pyx_v_a);

    /* "pysam/libcbcf.pyx":3175
 *             a = charptr_to_str(r.d.allele[i])
 *             PyTuple_SET_ITEM(res, i, a)
 *             Py_INCREF(a)             # <<<<<<<<<<<<<<
 *         return res
 * 
 */
    Py_INCREF(__pyx_v_a);
  }

  /* "pysam/libcbcf.pyx":3176
 *             PyTuple_SET_ITEM(res, i, a)
 *             Py_INCREF(a)
 *         return res             # <<<<<<<<<<<<<<
 * 
 *     @alleles.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_res);
  __pyx_r = __pyx_v_res;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3164
 * 
 *     @property
 *     def alleles(self):             # <<<<<<<<<<<<<<
 *         """tuple of reference allele followed by alt alleles"""
 *         cdef bcf1_t *r = self.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.alleles.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3179
 * 
 *     @alleles.setter
 *     def alleles(self, values):             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.ptr
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_7alleles_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_values); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_7alleles_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_values) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_7alleles_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v_values));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_7alleles_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_values) {
  bcf1_t *__pyx_v_r;
  int __pyx_v_rlen;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_v = NULL;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf1_t *__pyx_t_1;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  char const *__pyx_t_10;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3179, 0, __PYX_ERR(0, 3179, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_values);

  /* "pysam/libcbcf.pyx":3180
 *     @alleles.setter
 *     def alleles(self, values):
 *         cdef bcf1_t *r = self.ptr             # <<<<<<<<<<<<<<
 * 
 *         # Cache rlen of symbolic alleles before call to bcf_update_alleles_str
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3183
 * 
 *         # Cache rlen of symbolic alleles before call to bcf_update_alleles_str
 *         cdef int rlen = r.rlen             # <<<<<<<<<<<<<<
 * 
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 */
  __pyx_t_2 = __pyx_v_r->rlen;
  __pyx_v_rlen = __pyx_t_2;

  /* "pysam/libcbcf.pyx":3185
 *         cdef int rlen = r.rlen
 * 
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_v_r, BCF_UN_STR) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":3186
 * 
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         values = [force_bytes(v) for v in values]
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__159, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 3186, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3185
 *         cdef int rlen = r.rlen
 * 
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3188
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         values = [force_bytes(v) for v in values]             # <<<<<<<<<<<<<<
 * 
 *         if len(values) < 2:
 */
  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (likely(PyList_CheckExact(__pyx_v_values)) || PyTuple_CheckExact(__pyx_v_values)) {
    __pyx_t_5 = __pyx_v_values; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3188, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3188, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 3188, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3188, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 3188, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3188, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      }
    } else {
      __pyx_t_8 = __pyx_t_7(__pyx_t_5);
      if (unlikely(!__pyx_t_8)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3188, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_v, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3188, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 3188, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_values, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":3190
 *         values = [force_bytes(v) for v in values]
 * 
 *         if len(values) < 2:             # <<<<<<<<<<<<<<
 *             raise ValueError('must set at least 2 alleles')
 * 
 */
  __pyx_t_6 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3190, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_6 < 2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":3191
 * 
 *         if len(values) < 2:
 *             raise ValueError('must set at least 2 alleles')             # <<<<<<<<<<<<<<
 * 
 *         if b'' in values:
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__160, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3191, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 3191, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3190
 *         values = [force_bytes(v) for v in values]
 * 
 *         if len(values) < 2:             # <<<<<<<<<<<<<<
 *             raise ValueError('must set at least 2 alleles')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3193
 *             raise ValueError('must set at least 2 alleles')
 * 
 *         if b'' in values:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot set null allele')
 * 
 */
  __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_kp_b__15, __pyx_v_values, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3193, __pyx_L1_error)
  __pyx_t_9 = (__pyx_t_3 != 0);
  if (unlikely(__pyx_t_9)) {

    /* "pysam/libcbcf.pyx":3194
 * 
 *         if b'' in values:
 *             raise ValueError('cannot set null allele')             # <<<<<<<<<<<<<<
 * 
 *         value = b','.join(values)
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__161, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3194, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 3194, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3193
 *             raise ValueError('must set at least 2 alleles')
 * 
 *         if b'' in values:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot set null allele')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3196
 *             raise ValueError('cannot set null allele')
 * 
 *         value = b','.join(values)             # <<<<<<<<<<<<<<
 * 
 *         if bcf_update_alleles_str(self.header.ptr, r, value) < 0:
 */
  __pyx_t_4 = __Pyx_PyBytes_Join(__pyx_kp_b__2, __pyx_v_values); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_value = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":3198
 *         value = b','.join(values)
 * 
 *         if bcf_update_alleles_str(self.header.ptr, r, value) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error updating alleles')
 * 
 */
  __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_value); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) __PYX_ERR(0, 3198, __pyx_L1_error)
  __pyx_t_9 = ((bcf_update_alleles_str(__pyx_v_self->header->ptr, __pyx_v_r, __pyx_t_10) < 0) != 0);
  if (unlikely(__pyx_t_9)) {

    /* "pysam/libcbcf.pyx":3199
 * 
 *         if bcf_update_alleles_str(self.header.ptr, r, value) < 0:
 *             raise ValueError('Error updating alleles')             # <<<<<<<<<<<<<<
 * 
 *         # Reset rlen if alternate allele isn't symbolic, otherwise used cached
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__162, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3199, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 3199, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3198
 *         value = b','.join(values)
 * 
 *         if bcf_update_alleles_str(self.header.ptr, r, value) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error updating alleles')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3202
 * 
 *         # Reset rlen if alternate allele isn't symbolic, otherwise used cached
 *         if has_symbolic_allele(self):             # <<<<<<<<<<<<<<
 *             self.ptr.rlen = rlen
 *         else:
 */
  __pyx_t_9 = (__pyx_f_5pysam_7libcbcf_has_symbolic_allele(__pyx_v_self) != 0);
  if (__pyx_t_9) {

    /* "pysam/libcbcf.pyx":3203
 *         # Reset rlen if alternate allele isn't symbolic, otherwise used cached
 *         if has_symbolic_allele(self):
 *             self.ptr.rlen = rlen             # <<<<<<<<<<<<<<
 *         else:
 *             self.ptr.rlen = len(values[0])
 */
    __pyx_v_self->ptr->rlen = __pyx_v_rlen;

    /* "pysam/libcbcf.pyx":3202
 * 
 *         # Reset rlen if alternate allele isn't symbolic, otherwise used cached
 *         if has_symbolic_allele(self):             # <<<<<<<<<<<<<<
 *             self.ptr.rlen = rlen
 *         else:
 */
    goto __pyx_L9;
  }

  /* "pysam/libcbcf.pyx":3205
 *             self.ptr.rlen = rlen
 *         else:
 *             self.ptr.rlen = len(values[0])             # <<<<<<<<<<<<<<
 *         bcf_sync_end(self)
 * 
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_values, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3205, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_self->ptr->rlen = __pyx_t_6;
  }
  __pyx_L9:;

  /* "pysam/libcbcf.pyx":3206
 *         else:
 *             self.ptr.rlen = len(values[0])
 *         bcf_sync_end(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_4 = __pyx_f_5pysam_7libcbcf_bcf_sync_end(__pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":3179
 * 
 *     @alleles.setter
 *     def alleles(self, values):             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.ptr
 * 
 */

  /* 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_8);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.alleles.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3209
 * 
 *     @property
 *     def alts(self):             # <<<<<<<<<<<<<<
 *         """tuple of alt alleles"""
 *         cdef bcf1_t *r = self.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_4alts_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_4alts_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_4alts___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_4alts___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_res = 0;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf1_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  Py_ssize_t __pyx_t_8;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3209, 0, __PYX_ERR(0, 3209, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3211
 *     def alts(self):
 *         """tuple of alt alleles"""
 *         cdef bcf1_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3212
 *         """tuple of alt alleles"""
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         if r.n_allele < 2 or not r.d.allele:
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_STR) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3213
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         if r.n_allele < 2 or not r.d.allele:
 *             return None
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__163, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3213, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3213, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3212
 *         """tuple of alt alleles"""
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         if r.n_allele < 2 or not r.d.allele:
 */
  }

  /* "pysam/libcbcf.pyx":3214
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 *         if r.n_allele < 2 or not r.d.allele:             # <<<<<<<<<<<<<<
 *             return None
 *         cdef tuple res = PyTuple_New(r.n_allele - 1)
 */
  __pyx_t_4 = ((__pyx_v_r->n_allele < 2) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = ((!(__pyx_v_r->d.allele != 0)) != 0);
  __pyx_t_2 = __pyx_t_4;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":3215
 *             raise ValueError('Error unpacking VariantRecord')
 *         if r.n_allele < 2 or not r.d.allele:
 *             return None             # <<<<<<<<<<<<<<
 *         cdef tuple res = PyTuple_New(r.n_allele - 1)
 *         for i in range(1, r.n_allele):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":3214
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 *         if r.n_allele < 2 or not r.d.allele:             # <<<<<<<<<<<<<<
 *             return None
 *         cdef tuple res = PyTuple_New(r.n_allele - 1)
 */
  }

  /* "pysam/libcbcf.pyx":3216
 *         if r.n_allele < 2 or not r.d.allele:
 *             return None
 *         cdef tuple res = PyTuple_New(r.n_allele - 1)             # <<<<<<<<<<<<<<
 *         for i in range(1, r.n_allele):
 *             a = charptr_to_str(r.d.allele[i])
 */
  __pyx_t_3 = PyTuple_New((__pyx_v_r->n_allele - 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_res = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3217
 *             return None
 *         cdef tuple res = PyTuple_New(r.n_allele - 1)
 *         for i in range(1, r.n_allele):             # <<<<<<<<<<<<<<
 *             a = charptr_to_str(r.d.allele[i])
 *             PyTuple_SET_ITEM(res, i - 1, a)
 */
  __pyx_t_3 = __Pyx_PyInt_From_uint32_t(__pyx_v_r->n_allele); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3217, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3217, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 3217, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3217, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 3217, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3217, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_7(__pyx_t_5);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3217, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":3218
 *         cdef tuple res = PyTuple_New(r.n_allele - 1)
 *         for i in range(1, r.n_allele):
 *             a = charptr_to_str(r.d.allele[i])             # <<<<<<<<<<<<<<
 *             PyTuple_SET_ITEM(res, i - 1, a)
 *             Py_INCREF(a)
 */
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3218, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_v_r->d.allele[__pyx_t_8]), NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3218, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":3219
 *         for i in range(1, r.n_allele):
 *             a = charptr_to_str(r.d.allele[i])
 *             PyTuple_SET_ITEM(res, i - 1, a)             # <<<<<<<<<<<<<<
 *             Py_INCREF(a)
 *         return res
 */
    __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3219, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3219, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    PyTuple_SET_ITEM(__pyx_v_res, __pyx_t_8, __pyx_v_a);

    /* "pysam/libcbcf.pyx":3220
 *             a = charptr_to_str(r.d.allele[i])
 *             PyTuple_SET_ITEM(res, i - 1, a)
 *             Py_INCREF(a)             # <<<<<<<<<<<<<<
 *         return res
 * 
 */
    Py_INCREF(__pyx_v_a);

    /* "pysam/libcbcf.pyx":3217
 *             return None
 *         cdef tuple res = PyTuple_New(r.n_allele - 1)
 *         for i in range(1, r.n_allele):             # <<<<<<<<<<<<<<
 *             a = charptr_to_str(r.d.allele[i])
 *             PyTuple_SET_ITEM(res, i - 1, a)
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pysam/libcbcf.pyx":3221
 *             PyTuple_SET_ITEM(res, i - 1, a)
 *             Py_INCREF(a)
 *         return res             # <<<<<<<<<<<<<<
 * 
 *     @alts.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_res);
  __pyx_r = __pyx_v_res;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3209
 * 
 *     @property
 *     def alts(self):             # <<<<<<<<<<<<<<
 *         """tuple of alt alleles"""
 *         cdef bcf1_t *r = self.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.alts.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3224
 * 
 *     @alts.setter
 *     def alts(self, value):             # <<<<<<<<<<<<<<
 *         #FIXME: Set alleles directly -- this is stupid
 *         cdef bcf1_t *r = self.ptr
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_4alts_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13VariantRecord_4alts_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_4alts_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_13VariantRecord_4alts_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, PyObject *__pyx_v_value) {
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_ref = NULL;
  PyObject *__pyx_v_v = NULL;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf1_t *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3224, 0, __PYX_ERR(0, 3224, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_value);

  /* "pysam/libcbcf.pyx":3226
 *     def alts(self, value):
 *         #FIXME: Set alleles directly -- this is stupid
 *         cdef bcf1_t *r = self.ptr             # <<<<<<<<<<<<<<
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 */
  __pyx_t_1 = __pyx_v_self->ptr;
  __pyx_v_r = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3227
 *         #FIXME: Set alleles directly -- this is stupid
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         value = [force_bytes(v) for v in value]
 */
  __pyx_t_2 = ((bcf_unpack(__pyx_v_r, BCF_UN_STR) < 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3228
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         value = [force_bytes(v) for v in value]
 *         if b'' in value:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__164, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3228, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3228, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3227
 *         #FIXME: Set alleles directly -- this is stupid
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         value = [force_bytes(v) for v in value]
 */
  }

  /* "pysam/libcbcf.pyx":3229
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 *         value = [force_bytes(v) for v in value]             # <<<<<<<<<<<<<<
 *         if b'' in value:
 *             raise ValueError('cannot set null alt allele')
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (likely(PyList_CheckExact(__pyx_v_value)) || PyTuple_CheckExact(__pyx_v_value)) {
    __pyx_t_4 = __pyx_v_value; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3229, __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, 3229, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 3229, __pyx_L1_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3229, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 3229, __pyx_L1_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3229, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      }
    } else {
      __pyx_t_7 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_7)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3229, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_7);
    }
    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_7 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_v, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 3229, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3230
 *             raise ValueError('Error unpacking VariantRecord')
 *         value = [force_bytes(v) for v in value]
 *         if b'' in value:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot set null alt allele')
 *         ref  = [r.d.allele[0] if r.d.allele and r.n_allele else b'.']
 */
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_kp_b__15, __pyx_v_value, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3230, __pyx_L1_error)
  __pyx_t_8 = (__pyx_t_2 != 0);
  if (unlikely(__pyx_t_8)) {

    /* "pysam/libcbcf.pyx":3231
 *         value = [force_bytes(v) for v in value]
 *         if b'' in value:
 *             raise ValueError('cannot set null alt allele')             # <<<<<<<<<<<<<<
 *         ref  = [r.d.allele[0] if r.d.allele and r.n_allele else b'.']
 *         self.alleles = ref + value
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__165, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3231, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3231, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3230
 *             raise ValueError('Error unpacking VariantRecord')
 *         value = [force_bytes(v) for v in value]
 *         if b'' in value:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot set null alt allele')
 *         ref  = [r.d.allele[0] if r.d.allele and r.n_allele else b'.']
 */
  }

  /* "pysam/libcbcf.pyx":3232
 *         if b'' in value:
 *             raise ValueError('cannot set null alt allele')
 *         ref  = [r.d.allele[0] if r.d.allele and r.n_allele else b'.']             # <<<<<<<<<<<<<<
 *         self.alleles = ref + value
 * 
 */
  __pyx_t_2 = (__pyx_v_r->d.allele != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_8 = __pyx_t_2;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_r->n_allele != 0);
  __pyx_t_8 = __pyx_t_2;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_8) {
    __pyx_t_4 = __Pyx_PyBytes_FromString((__pyx_v_r->d.allele[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3232, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __pyx_t_4;
    __pyx_t_4 = 0;
  } else {
    __Pyx_INCREF(__pyx_kp_b__71);
    __pyx_t_3 = __pyx_kp_b__71;
  }
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3232, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_ref = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":3233
 *             raise ValueError('cannot set null alt allele')
 *         ref  = [r.d.allele[0] if r.d.allele and r.n_allele else b'.']
 *         self.alleles = ref + value             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_4 = PyNumber_Add(__pyx_v_ref, __pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_alleles, __pyx_t_4) < 0) __PYX_ERR(0, 3233, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":3224
 * 
 *     @alts.setter
 *     def alts(self, value):             # <<<<<<<<<<<<<<
 *         #FIXME: Set alleles directly -- this is stupid
 *         cdef bcf1_t *r = self.ptr
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.alts.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ref);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3236
 * 
 *     @property
 *     def filter(self):             # <<<<<<<<<<<<<<
 *         """filter information (see :class:`VariantRecordFilter`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_FLT) < 0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_6filter_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_6filter_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_6filter___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_6filter___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3236, 0, __PYX_ERR(0, 3236, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3238
 *     def filter(self):
 *         """filter information (see :class:`VariantRecordFilter`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_FLT) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         return makeVariantRecordFilter(self)
 */
  __pyx_t_1 = ((bcf_unpack(__pyx_v_self->ptr, BCF_UN_FLT) < 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3239
 *         """filter information (see :class:`VariantRecordFilter`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_FLT) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         return makeVariantRecordFilter(self)
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__166, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3239, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 3239, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3238
 *     def filter(self):
 *         """filter information (see :class:`VariantRecordFilter`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_FLT) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         return makeVariantRecordFilter(self)
 */
  }

  /* "pysam/libcbcf.pyx":3240
 *         if bcf_unpack(self.ptr, BCF_UN_FLT) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 *         return makeVariantRecordFilter(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantRecordFilter(__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3236
 * 
 *     @property
 *     def filter(self):             # <<<<<<<<<<<<<<
 *         """filter information (see :class:`VariantRecordFilter`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_FLT) < 0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.filter.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3243
 * 
 *     @property
 *     def info(self):             # <<<<<<<<<<<<<<
 *         """info data (see :class:`VariantRecordInfo`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_INFO) < 0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_4info_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_4info_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_4info___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_4info___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3243, 0, __PYX_ERR(0, 3243, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3245
 *     def info(self):
 *         """info data (see :class:`VariantRecordInfo`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         return makeVariantRecordInfo(self)
 */
  __pyx_t_1 = ((bcf_unpack(__pyx_v_self->ptr, BCF_UN_INFO) < 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3246
 *         """info data (see :class:`VariantRecordInfo`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         return makeVariantRecordInfo(self)
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__167, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3246, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 3246, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3245
 *     def info(self):
 *         """info data (see :class:`VariantRecordInfo`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_INFO) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         return makeVariantRecordInfo(self)
 */
  }

  /* "pysam/libcbcf.pyx":3247
 *         if bcf_unpack(self.ptr, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 *         return makeVariantRecordInfo(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantRecordInfo(__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3243
 * 
 *     @property
 *     def info(self):             # <<<<<<<<<<<<<<
 *         """info data (see :class:`VariantRecordInfo`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_INFO) < 0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.info.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3250
 * 
 *     @property
 *     def format(self):             # <<<<<<<<<<<<<<
 *         """sample format metadata (see :class:`VariantRecordFormat`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_FMT) < 0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_6format_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_6format_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_6format___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_6format___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3250, 0, __PYX_ERR(0, 3250, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3252
 *     def format(self):
 *         """sample format metadata (see :class:`VariantRecordFormat`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_FMT) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         return makeVariantRecordFormat(self)
 */
  __pyx_t_1 = ((bcf_unpack(__pyx_v_self->ptr, BCF_UN_FMT) < 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3253
 *         """sample format metadata (see :class:`VariantRecordFormat`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_FMT) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         return makeVariantRecordFormat(self)
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__168, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3253, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 3253, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3252
 *     def format(self):
 *         """sample format metadata (see :class:`VariantRecordFormat`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_FMT) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         return makeVariantRecordFormat(self)
 */
  }

  /* "pysam/libcbcf.pyx":3254
 *         if bcf_unpack(self.ptr, BCF_UN_FMT) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 *         return makeVariantRecordFormat(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantRecordFormat(__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3250
 * 
 *     @property
 *     def format(self):             # <<<<<<<<<<<<<<
 *         """sample format metadata (see :class:`VariantRecordFormat`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_FMT) < 0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.format.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3257
 * 
 *     @property
 *     def samples(self):             # <<<<<<<<<<<<<<
 *         """sample data (see :class:`VariantRecordSamples`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_ALL) < 0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_7samples_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_7samples_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_7samples___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_7samples___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3257, 0, __PYX_ERR(0, 3257, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3259
 *     def samples(self):
 *         """sample data (see :class:`VariantRecordSamples`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         return makeVariantRecordSamples(self)
 */
  __pyx_t_1 = ((bcf_unpack(__pyx_v_self->ptr, BCF_UN_ALL) < 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3260
 *         """sample data (see :class:`VariantRecordSamples`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_ALL) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         return makeVariantRecordSamples(self)
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__169, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3260, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 3260, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3259
 *     def samples(self):
 *         """sample data (see :class:`VariantRecordSamples`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_ALL) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 *         return makeVariantRecordSamples(self)
 */
  }

  /* "pysam/libcbcf.pyx":3261
 *         if bcf_unpack(self.ptr, BCF_UN_ALL) < 0:
 *             raise ValueError('Error unpacking VariantRecord')
 *         return makeVariantRecordSamples(self)             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(VariantRecord self not None, VariantRecord other not None, int op):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantRecordSamples(__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3257
 * 
 *     @property
 *     def samples(self):             # <<<<<<<<<<<<<<
 *         """sample data (see :class:`VariantRecordSamples`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_ALL) < 0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.samples.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3263
 *         return makeVariantRecordSamples(self)
 * 
 *     def __richcmp__(VariantRecord self not None, VariantRecord other not None, int op):             # <<<<<<<<<<<<<<
 *         if op != 2 and op != 3:
 *             return NotImplemented
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_9__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_9__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  if (unlikely(((PyObject *)__pyx_v_self) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "self"); __PYX_ERR(0, 3263, __pyx_L1_error)
  }
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5pysam_7libcbcf_VariantRecord, 0, "other", 0))) __PYX_ERR(0, 3263, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_8__richcmp__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_other), ((int)__pyx_v_op));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_8__richcmp__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_other, int __pyx_v_op) {
  bcf1_t *__pyx_v_s;
  bcf1_t *__pyx_v_o;
  int __pyx_v_cmp;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("__richcmp__", 0);
  __Pyx_TraceCall("__richcmp__", __pyx_f[0], 3263, 0, __PYX_ERR(0, 3263, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3264
 * 
 *     def __richcmp__(VariantRecord self not None, VariantRecord other not None, int op):
 *         if op != 2 and op != 3:             # <<<<<<<<<<<<<<
 *             return NotImplemented
 * 
 */
  switch (__pyx_v_op) {
    case 2:
    case 3:
    __pyx_t_1 = 0;
    break;
    default:
    __pyx_t_1 = 1;
    break;
  }
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3265
 *     def __richcmp__(VariantRecord self not None, VariantRecord other not None, int op):
 *         if op != 2 and op != 3:
 *             return NotImplemented             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf1_t *s = self.ptr
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":3264
 * 
 *     def __richcmp__(VariantRecord self not None, VariantRecord other not None, int op):
 *         if op != 2 and op != 3:             # <<<<<<<<<<<<<<
 *             return NotImplemented
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3267
 *             return NotImplemented
 * 
 *         cdef bcf1_t *s = self.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *o = other.ptr
 * 
 */
  __pyx_t_2 = __pyx_v_self->ptr;
  __pyx_v_s = __pyx_t_2;

  /* "pysam/libcbcf.pyx":3268
 * 
 *         cdef bcf1_t *s = self.ptr
 *         cdef bcf1_t *o = other.ptr             # <<<<<<<<<<<<<<
 * 
 *         cdef bint cmp = self is other or (
 */
  __pyx_t_2 = __pyx_v_other->ptr;
  __pyx_v_o = __pyx_t_2;

  /* "pysam/libcbcf.pyx":3270
 *         cdef bcf1_t *o = other.ptr
 * 
 *         cdef bint cmp = self is other or (             # <<<<<<<<<<<<<<
 *                              s.pos        == o.pos
 *                         and  s.rlen       == o.rlen
 */
  __pyx_t_3 = (__pyx_v_self == __pyx_v_other);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pysam/libcbcf.pyx":3271
 * 
 *         cdef bint cmp = self is other or (
 *                              s.pos        == o.pos             # <<<<<<<<<<<<<<
 *                         and  s.rlen       == o.rlen
 *                         and ((bcf_float_is_missing(s.qual) and bcf_float_is_missing(o.qual))
 */
  __pyx_t_4 = ((__pyx_v_s->pos == __pyx_v_o->pos) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pysam/libcbcf.pyx":3272
 *         cdef bint cmp = self is other or (
 *                              s.pos        == o.pos
 *                         and  s.rlen       == o.rlen             # <<<<<<<<<<<<<<
 *                         and ((bcf_float_is_missing(s.qual) and bcf_float_is_missing(o.qual))
 *                           or s.qual       == o.qual)
 */
  __pyx_t_4 = ((__pyx_v_s->rlen == __pyx_v_o->rlen) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pysam/libcbcf.pyx":3273
 *                              s.pos        == o.pos
 *                         and  s.rlen       == o.rlen
 *                         and ((bcf_float_is_missing(s.qual) and bcf_float_is_missing(o.qual))             # <<<<<<<<<<<<<<
 *                           or s.qual       == o.qual)
 *                         and  s.n_sample   == o.n_sample
 */
  __pyx_t_4 = (bcf_float_is_missing(__pyx_v_s->qual) != 0);
  if (!__pyx_t_4) {
    goto __pyx_L9_next_or;
  } else {
  }
  __pyx_t_4 = (bcf_float_is_missing(__pyx_v_o->qual) != 0);
  if (!__pyx_t_4) {
  } else {
    goto __pyx_L8_next_and;
  }
  __pyx_L9_next_or:;

  /* "pysam/libcbcf.pyx":3274
 *                         and  s.rlen       == o.rlen
 *                         and ((bcf_float_is_missing(s.qual) and bcf_float_is_missing(o.qual))
 *                           or s.qual       == o.qual)             # <<<<<<<<<<<<<<
 *                         and  s.n_sample   == o.n_sample
 *                         and  s.n_allele   == o.n_allele
 */
  __pyx_t_4 = ((__pyx_v_s->qual == __pyx_v_o->qual) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_L8_next_and:;

  /* "pysam/libcbcf.pyx":3275
 *                         and ((bcf_float_is_missing(s.qual) and bcf_float_is_missing(o.qual))
 *                           or s.qual       == o.qual)
 *                         and  s.n_sample   == o.n_sample             # <<<<<<<<<<<<<<
 *                         and  s.n_allele   == o.n_allele
 *                         and  self.contig  == other.contig
 */
  __pyx_t_4 = ((__pyx_v_s->n_sample == __pyx_v_o->n_sample) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pysam/libcbcf.pyx":3276
 *                           or s.qual       == o.qual)
 *                         and  s.n_sample   == o.n_sample
 *                         and  s.n_allele   == o.n_allele             # <<<<<<<<<<<<<<
 *                         and  self.contig  == other.contig
 *                         and  self.alleles == other.alleles
 */
  __pyx_t_4 = ((__pyx_v_s->n_allele == __pyx_v_o->n_allele) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pysam/libcbcf.pyx":3277
 *                         and  s.n_sample   == o.n_sample
 *                         and  s.n_allele   == o.n_allele
 *                         and  self.contig  == other.contig             # <<<<<<<<<<<<<<
 *                         and  self.alleles == other.alleles
 *                         and  self.id      == other.id
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contig); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_contig); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyObject_RichCompare(__pyx_t_5, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3277, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3277, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pysam/libcbcf.pyx":3278
 *                         and  s.n_allele   == o.n_allele
 *                         and  self.contig  == other.contig
 *                         and  self.alleles == other.alleles             # <<<<<<<<<<<<<<
 *                         and  self.id      == other.id
 *                         and  self.info    == other.info
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_alleles); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_alleles); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_7, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3278, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3278, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pysam/libcbcf.pyx":3279
 *                         and  self.contig  == other.contig
 *                         and  self.alleles == other.alleles
 *                         and  self.id      == other.id             # <<<<<<<<<<<<<<
 *                         and  self.info    == other.info
 *                         and  self.filter  == other.filter
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3279, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3279, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyObject_RichCompare(__pyx_t_5, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3279, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3279, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pysam/libcbcf.pyx":3280
 *                         and  self.alleles == other.alleles
 *                         and  self.id      == other.id
 *                         and  self.info    == other.info             # <<<<<<<<<<<<<<
 *                         and  self.filter  == other.filter
 *                         and  self.samples == other.samples)
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_7, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3280, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3280, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pysam/libcbcf.pyx":3281
 *                         and  self.id      == other.id
 *                         and  self.info    == other.info
 *                         and  self.filter  == other.filter             # <<<<<<<<<<<<<<
 *                         and  self.samples == other.samples)
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_filter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_filter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyObject_RichCompare(__pyx_t_5, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3281, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3281, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pysam/libcbcf.pyx":3282
 *                         and  self.info    == other.info
 *                         and  self.filter  == other.filter
 *                         and  self.samples == other.samples)             # <<<<<<<<<<<<<<
 * 
 *         if op == 3:
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_samples); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_samples); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_7, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3282, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3282, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_1 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  __pyx_v_cmp = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3284
 *                         and  self.samples == other.samples)
 * 
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             cmp = not cmp
 * 
 */
  __pyx_t_1 = ((__pyx_v_op == 3) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3285
 * 
 *         if op == 3:
 *             cmp = not cmp             # <<<<<<<<<<<<<<
 * 
 *         return cmp
 */
    __pyx_v_cmp = (!(__pyx_v_cmp != 0));

    /* "pysam/libcbcf.pyx":3284
 *                         and  self.samples == other.samples)
 * 
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             cmp = not cmp
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3287
 *             cmp = not cmp
 * 
 *         return cmp             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_cmp); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3263
 *         return makeVariantRecordSamples(self)
 * 
 *     def __richcmp__(VariantRecord self not None, VariantRecord other not None, int op):             # <<<<<<<<<<<<<<
 *         if op != 2 and op != 3:
 *             return NotImplemented
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3289
 *         return cmp
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         cdef kstring_t line
 *         cdef char c
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_11__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_11__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_10__str__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_10__str__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  kstring_t __pyx_v_line;
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__str__", 0);
  __Pyx_TraceCall("__str__", __pyx_f[0], 3289, 0, __PYX_ERR(0, 3289, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3293
 *         cdef char c
 * 
 *         line.l = line.m = 0             # <<<<<<<<<<<<<<
 *         line.s = NULL
 * 
 */
  __pyx_v_line.l = 0;
  __pyx_v_line.m = 0;

  /* "pysam/libcbcf.pyx":3294
 * 
 *         line.l = line.m = 0
 *         line.s = NULL             # <<<<<<<<<<<<<<
 * 
 *         if vcf_format(self.header.ptr, self.ptr, &line) < 0:
 */
  __pyx_v_line.s = NULL;

  /* "pysam/libcbcf.pyx":3296
 *         line.s = NULL
 * 
 *         if vcf_format(self.header.ptr, self.ptr, &line) < 0:             # <<<<<<<<<<<<<<
 *             if line.m:
 *                 free(line.s)
 */
  __pyx_t_1 = ((vcf_format(__pyx_v_self->header->ptr, __pyx_v_self->ptr, (&__pyx_v_line)) < 0) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3297
 * 
 *         if vcf_format(self.header.ptr, self.ptr, &line) < 0:
 *             if line.m:             # <<<<<<<<<<<<<<
 *                 free(line.s)
 *             raise ValueError('vcf_format failed')
 */
    __pyx_t_1 = (__pyx_v_line.m != 0);
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":3298
 *         if vcf_format(self.header.ptr, self.ptr, &line) < 0:
 *             if line.m:
 *                 free(line.s)             # <<<<<<<<<<<<<<
 *             raise ValueError('vcf_format failed')
 * 
 */
      free(__pyx_v_line.s);

      /* "pysam/libcbcf.pyx":3297
 * 
 *         if vcf_format(self.header.ptr, self.ptr, &line) < 0:
 *             if line.m:             # <<<<<<<<<<<<<<
 *                 free(line.s)
 *             raise ValueError('vcf_format failed')
 */
    }

    /* "pysam/libcbcf.pyx":3299
 *             if line.m:
 *                 free(line.s)
 *             raise ValueError('vcf_format failed')             # <<<<<<<<<<<<<<
 * 
 *         # Strip CR/LF?
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__170, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 3299, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3296
 *         line.s = NULL
 * 
 *         if vcf_format(self.header.ptr, self.ptr, &line) < 0:             # <<<<<<<<<<<<<<
 *             if line.m:
 *                 free(line.s)
 */
  }

  /* "pysam/libcbcf.pyx":3308
 *         #    line.l -= 1
 * 
 *         ret = charptr_to_str_w_len(line.s, line.l)             # <<<<<<<<<<<<<<
 * 
 *         if line.m:
 */
  __pyx_t_2 = __pyx_f_5pysam_9libcutils_charptr_to_str_w_len(__pyx_v_line.s, __pyx_v_line.l, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_ret = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":3310
 *         ret = charptr_to_str_w_len(line.s, line.l)
 * 
 *         if line.m:             # <<<<<<<<<<<<<<
 *             free(line.s)
 * 
 */
  __pyx_t_1 = (__pyx_v_line.m != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3311
 * 
 *         if line.m:
 *             free(line.s)             # <<<<<<<<<<<<<<
 * 
 *         return ret
 */
    free(__pyx_v_line.s);

    /* "pysam/libcbcf.pyx":3310
 *         ret = charptr_to_str_w_len(line.s, line.l)
 * 
 *         if line.m:             # <<<<<<<<<<<<<<
 *             free(line.s)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3313
 *             free(line.s)
 * 
 *         return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3289
 *         return cmp
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         cdef kstring_t line
 *         cdef char c
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":78
 * 
 * cdef class VariantRecord(object):
 *     cdef readonly VariantHeader header             # <<<<<<<<<<<<<<
 *     cdef bcf1_t *ptr
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_6header_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_6header_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_6header___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 78, 0, __PYX_ERR(1, 78, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __pyx_r = ((PyObject *)__pyx_v_self->header);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.header.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantRecord_12__reduce_cython__[] = "VariantRecord.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_12__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_12__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__171, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13VariantRecord_14__setstate_cython__[] = "VariantRecord.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_13VariantRecord_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13VariantRecord_14__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13VariantRecord_14__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 3, 0, __PYX_ERR(2, 3, __pyx_L1_error));

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__172, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecord.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3316
 * 
 * 
 * cdef VariantRecord makeVariantRecord(VariantHeader header, bcf1_t *r):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_f_5pysam_7libcbcf_makeVariantRecord(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header, bcf1_t *__pyx_v_r) {
  PyObject *__pyx_v_msg = NULL;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("makeVariantRecord", 0);
  __Pyx_TraceCall("makeVariantRecord", __pyx_f[0], 3316, 0, __PYX_ERR(0, 3316, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3317
 * 
 * cdef VariantRecord makeVariantRecord(VariantHeader header, bcf1_t *r):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_header)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3317, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3318
 * cdef VariantRecord makeVariantRecord(VariantHeader header, bcf1_t *r):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     if not r:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__173, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3318, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3318, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3317
 * 
 * cdef VariantRecord makeVariantRecord(VariantHeader header, bcf1_t *r):
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3320
 *         raise ValueError('invalid VariantHeader')
 * 
 *     if not r:             # <<<<<<<<<<<<<<
 *         raise ValueError('cannot create VariantRecord')
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_r != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3321
 * 
 *     if not r:
 *         raise ValueError('cannot create VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     if r.errcode:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__174, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3321, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3321, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3320
 *         raise ValueError('invalid VariantHeader')
 * 
 *     if not r:             # <<<<<<<<<<<<<<
 *         raise ValueError('cannot create VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3323
 *         raise ValueError('cannot create VariantRecord')
 * 
 *     if r.errcode:             # <<<<<<<<<<<<<<
 *         msg = []
 *         #if r.errcode & BCF_ERR_CTG_UNDEF:
 */
  __pyx_t_2 = (__pyx_v_r->errcode != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":3324
 * 
 *     if r.errcode:
 *         msg = []             # <<<<<<<<<<<<<<
 *         #if r.errcode & BCF_ERR_CTG_UNDEF:
 *         #    msg.append('undefined contig')
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3324, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_msg = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":3329
 *         #if r.errcode & BCF_ERR_TAG_UNDEF:
 *         #    msg.append('undefined tag')
 *         if r.errcode & BCF_ERR_NCOLS:             # <<<<<<<<<<<<<<
 *             msg.append('invalid number of columns')
 *         if r.errcode & BCF_ERR_LIMITS:
 */
    __pyx_t_2 = ((__pyx_v_r->errcode & BCF_ERR_NCOLS) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":3330
 *         #    msg.append('undefined tag')
 *         if r.errcode & BCF_ERR_NCOLS:
 *             msg.append('invalid number of columns')             # <<<<<<<<<<<<<<
 *         if r.errcode & BCF_ERR_LIMITS:
 *             msg.append('limits violated')
 */
      __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_msg, __pyx_kp_s_invalid_number_of_columns); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 3330, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3329
 *         #if r.errcode & BCF_ERR_TAG_UNDEF:
 *         #    msg.append('undefined tag')
 *         if r.errcode & BCF_ERR_NCOLS:             # <<<<<<<<<<<<<<
 *             msg.append('invalid number of columns')
 *         if r.errcode & BCF_ERR_LIMITS:
 */
    }

    /* "pysam/libcbcf.pyx":3331
 *         if r.errcode & BCF_ERR_NCOLS:
 *             msg.append('invalid number of columns')
 *         if r.errcode & BCF_ERR_LIMITS:             # <<<<<<<<<<<<<<
 *             msg.append('limits violated')
 *         if r.errcode & BCF_ERR_CHAR:
 */
    __pyx_t_2 = ((__pyx_v_r->errcode & BCF_ERR_LIMITS) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":3332
 *             msg.append('invalid number of columns')
 *         if r.errcode & BCF_ERR_LIMITS:
 *             msg.append('limits violated')             # <<<<<<<<<<<<<<
 *         if r.errcode & BCF_ERR_CHAR:
 *             msg.append('invalid character found')
 */
      __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_msg, __pyx_kp_s_limits_violated); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 3332, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3331
 *         if r.errcode & BCF_ERR_NCOLS:
 *             msg.append('invalid number of columns')
 *         if r.errcode & BCF_ERR_LIMITS:             # <<<<<<<<<<<<<<
 *             msg.append('limits violated')
 *         if r.errcode & BCF_ERR_CHAR:
 */
    }

    /* "pysam/libcbcf.pyx":3333
 *         if r.errcode & BCF_ERR_LIMITS:
 *             msg.append('limits violated')
 *         if r.errcode & BCF_ERR_CHAR:             # <<<<<<<<<<<<<<
 *             msg.append('invalid character found')
 *         if r.errcode & BCF_ERR_CTG_INVALID:
 */
    __pyx_t_2 = ((__pyx_v_r->errcode & BCF_ERR_CHAR) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":3334
 *             msg.append('limits violated')
 *         if r.errcode & BCF_ERR_CHAR:
 *             msg.append('invalid character found')             # <<<<<<<<<<<<<<
 *         if r.errcode & BCF_ERR_CTG_INVALID:
 *             msg.append('invalid contig')
 */
      __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_msg, __pyx_kp_s_invalid_character_found); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 3334, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3333
 *         if r.errcode & BCF_ERR_LIMITS:
 *             msg.append('limits violated')
 *         if r.errcode & BCF_ERR_CHAR:             # <<<<<<<<<<<<<<
 *             msg.append('invalid character found')
 *         if r.errcode & BCF_ERR_CTG_INVALID:
 */
    }

    /* "pysam/libcbcf.pyx":3335
 *         if r.errcode & BCF_ERR_CHAR:
 *             msg.append('invalid character found')
 *         if r.errcode & BCF_ERR_CTG_INVALID:             # <<<<<<<<<<<<<<
 *             msg.append('invalid contig')
 *         if r.errcode & BCF_ERR_TAG_INVALID:
 */
    __pyx_t_2 = ((__pyx_v_r->errcode & BCF_ERR_CTG_INVALID) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":3336
 *             msg.append('invalid character found')
 *         if r.errcode & BCF_ERR_CTG_INVALID:
 *             msg.append('invalid contig')             # <<<<<<<<<<<<<<
 *         if r.errcode & BCF_ERR_TAG_INVALID:
 *             msg.append('invalid tag')
 */
      __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_msg, __pyx_kp_s_invalid_contig_2); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 3336, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3335
 *         if r.errcode & BCF_ERR_CHAR:
 *             msg.append('invalid character found')
 *         if r.errcode & BCF_ERR_CTG_INVALID:             # <<<<<<<<<<<<<<
 *             msg.append('invalid contig')
 *         if r.errcode & BCF_ERR_TAG_INVALID:
 */
    }

    /* "pysam/libcbcf.pyx":3337
 *         if r.errcode & BCF_ERR_CTG_INVALID:
 *             msg.append('invalid contig')
 *         if r.errcode & BCF_ERR_TAG_INVALID:             # <<<<<<<<<<<<<<
 *             msg.append('invalid tag')
 * 
 */
    __pyx_t_2 = ((__pyx_v_r->errcode & BCF_ERR_TAG_INVALID) != 0);
    if (__pyx_t_2) {

      /* "pysam/libcbcf.pyx":3338
 *             msg.append('invalid contig')
 *         if r.errcode & BCF_ERR_TAG_INVALID:
 *             msg.append('invalid tag')             # <<<<<<<<<<<<<<
 * 
 *         if msg:
 */
      __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_msg, __pyx_kp_s_invalid_tag); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 3338, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3337
 *         if r.errcode & BCF_ERR_CTG_INVALID:
 *             msg.append('invalid contig')
 *         if r.errcode & BCF_ERR_TAG_INVALID:             # <<<<<<<<<<<<<<
 *             msg.append('invalid tag')
 * 
 */
    }

    /* "pysam/libcbcf.pyx":3340
 *             msg.append('invalid tag')
 * 
 *         if msg:             # <<<<<<<<<<<<<<
 *             msg = ', '.join(msg)
 *             raise ValueError('Error(s) reading record: {}'.format(msg))
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_msg); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3340, __pyx_L1_error)
    if (unlikely(__pyx_t_2)) {

      /* "pysam/libcbcf.pyx":3341
 * 
 *         if msg:
 *             msg = ', '.join(msg)             # <<<<<<<<<<<<<<
 *             raise ValueError('Error(s) reading record: {}'.format(msg))
 * 
 */
      __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__175, __pyx_v_msg); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3341, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":3342
 *         if msg:
 *             msg = ', '.join(msg)
 *             raise ValueError('Error(s) reading record: {}'.format(msg))             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantRecord record = VariantRecord.__new__(VariantRecord)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Error_s_reading_record, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3342, __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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_msg); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3342, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_msg};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3342, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_msg};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3342, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3342, __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_INCREF(__pyx_v_msg);
          __Pyx_GIVEREF(__pyx_v_msg);
          PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_msg);
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3342, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3342, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 3342, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3340
 *             msg.append('invalid tag')
 * 
 *         if msg:             # <<<<<<<<<<<<<<
 *             msg = ', '.join(msg)
 *             raise ValueError('Error(s) reading record: {}'.format(msg))
 */
    }

    /* "pysam/libcbcf.pyx":3323
 *         raise ValueError('cannot create VariantRecord')
 * 
 *     if r.errcode:             # <<<<<<<<<<<<<<
 *         msg = []
 *         #if r.errcode & BCF_ERR_CTG_UNDEF:
 */
  }

  /* "pysam/libcbcf.pyx":3344
 *             raise ValueError('Error(s) reading record: {}'.format(msg))
 * 
 *     cdef VariantRecord record = VariantRecord.__new__(VariantRecord)             # <<<<<<<<<<<<<<
 *     record.header = header
 *     record.ptr = r
 */
  __pyx_t_5 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantRecord(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecord), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3344, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __pyx_v_record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pysam/libcbcf.pyx":3345
 * 
 *     cdef VariantRecord record = VariantRecord.__new__(VariantRecord)
 *     record.header = header             # <<<<<<<<<<<<<<
 *     record.ptr = r
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_header));
  __Pyx_GOTREF(__pyx_v_record->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_record->header));
  __pyx_v_record->header = __pyx_v_header;

  /* "pysam/libcbcf.pyx":3346
 *     cdef VariantRecord record = VariantRecord.__new__(VariantRecord)
 *     record.header = header
 *     record.ptr = r             # <<<<<<<<<<<<<<
 * 
 *     return record
 */
  __pyx_v_record->ptr = __pyx_v_r;

  /* "pysam/libcbcf.pyx":3348
 *     record.ptr = r
 * 
 *     return record             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_record));
  __pyx_r = __pyx_v_record;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3316
 * 
 * 
 * cdef VariantRecord makeVariantRecord(VariantHeader header, bcf1_t *r):             # <<<<<<<<<<<<<<
 *     if not header:
 *         raise ValueError('invalid VariantHeader')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantRecord", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF((PyObject *)__pyx_v_record);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3362
 *        from format name to values.
 *     """
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample___init__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 3362, 0, __PYX_ERR(0, 3362, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3363
 *     """
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__176, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 3363, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":3362
 *        from format name to values.
 *     """
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         raise TypeError('this class cannot be instantiated from Python')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3366
 * 
 *     @property
 *     def name(self):             # <<<<<<<<<<<<<<
 *         """sample name"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_4name_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_4name___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_4name___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int32_t __pyx_v_n;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  uint32_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3366, 0, __PYX_ERR(0, 3366, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3368
 *     def name(self):
 *         """sample name"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int32_t n = r.n_sample
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3369
 *         """sample name"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int32_t n = r.n_sample
 * 
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":3370
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int32_t n = r.n_sample             # <<<<<<<<<<<<<<
 * 
 *         if self.index < 0 or self.index >= n:
 */
  __pyx_t_3 = __pyx_v_r->n_sample;
  __pyx_v_n = __pyx_t_3;

  /* "pysam/libcbcf.pyx":3372
 *         cdef int32_t n = r.n_sample
 * 
 *         if self.index < 0 or self.index >= n:             # <<<<<<<<<<<<<<
 *             raise ValueError('invalid sample index')
 * 
 */
  __pyx_t_5 = ((__pyx_v_self->index < 0) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_self->index >= __pyx_v_n) != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_4)) {

    /* "pysam/libcbcf.pyx":3373
 * 
 *         if self.index < 0 or self.index >= n:
 *             raise ValueError('invalid sample index')             # <<<<<<<<<<<<<<
 * 
 *         return charptr_to_str(hdr.samples[self.index])
 */
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__177, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(0, 3373, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3372
 *         cdef int32_t n = r.n_sample
 * 
 *         if self.index < 0 or self.index >= n:             # <<<<<<<<<<<<<<
 *             raise ValueError('invalid sample index')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3375
 *             raise ValueError('invalid sample index')
 * 
 *         return charptr_to_str(hdr.samples[self.index])             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = __pyx_f_5pysam_9libcutils_charptr_to_str((__pyx_v_hdr->samples[__pyx_v_self->index]), NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3366
 * 
 *     @property
 *     def name(self):             # <<<<<<<<<<<<<<
 *         """sample name"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.name.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3378
 * 
 *     @property
 *     def allele_indices(self):             # <<<<<<<<<<<<<<
 *         """allele indices for called genotype, if present.  Otherwise None"""
 *         return bcf_format_get_allele_indices(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_14allele_indices___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_14allele_indices___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3378, 0, __PYX_ERR(0, 3378, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3380
 *     def allele_indices(self):
 *         """allele indices for called genotype, if present.  Otherwise None"""
 *         return bcf_format_get_allele_indices(self)             # <<<<<<<<<<<<<<
 * 
 *     @allele_indices.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf_bcf_format_get_allele_indices(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3378
 * 
 *     @property
 *     def allele_indices(self):             # <<<<<<<<<<<<<<
 *         """allele indices for called genotype, if present.  Otherwise None"""
 *         return bcf_format_get_allele_indices(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.allele_indices.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3383
 * 
 *     @allele_indices.setter
 *     def allele_indices(self, value):             # <<<<<<<<<<<<<<
 *         self['GT'] = value
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3383, 0, __PYX_ERR(0, 3383, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3384
 *     @allele_indices.setter
 *     def allele_indices(self, value):
 *         self['GT'] = value             # <<<<<<<<<<<<<<
 * 
 *     @allele_indices.deleter
 */
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_n_s_GT, __pyx_v_value) < 0)) __PYX_ERR(0, 3384, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":3383
 * 
 *     @allele_indices.setter
 *     def allele_indices(self, value):             # <<<<<<<<<<<<<<
 *         self['GT'] = value
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.allele_indices.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3387
 * 
 *     @allele_indices.deleter
 *     def allele_indices(self):             # <<<<<<<<<<<<<<
 *         self['GT'] = ()
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_4__del__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_4__del__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[0], 3387, 0, __PYX_ERR(0, 3387, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3388
 *     @allele_indices.deleter
 *     def allele_indices(self):
 *         self['GT'] = ()             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_n_s_GT, __pyx_empty_tuple) < 0)) __PYX_ERR(0, 3388, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":3387
 * 
 *     @allele_indices.deleter
 *     def allele_indices(self):             # <<<<<<<<<<<<<<
 *         self['GT'] = ()
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.allele_indices.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3391
 * 
 *     @property
 *     def alleles(self):             # <<<<<<<<<<<<<<
 *         """alleles for called genotype, if present.  Otherwise None"""
 *         return bcf_format_get_alleles(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_7alleles_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_7alleles_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_7alleles___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_7alleles___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3391, 0, __PYX_ERR(0, 3391, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3393
 *     def alleles(self):
 *         """alleles for called genotype, if present.  Otherwise None"""
 *         return bcf_format_get_alleles(self)             # <<<<<<<<<<<<<<
 * 
 *     @alleles.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf_bcf_format_get_alleles(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3391
 * 
 *     @property
 *     def alleles(self):             # <<<<<<<<<<<<<<
 *         """alleles for called genotype, if present.  Otherwise None"""
 *         return bcf_format_get_alleles(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.alleles.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3396
 * 
 *     @alleles.setter
 *     def alleles(self, value):             # <<<<<<<<<<<<<<
 *         self['GT'] = value
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_7alleles_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_7alleles_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_7alleles_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_7alleles_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3396, 0, __PYX_ERR(0, 3396, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3397
 *     @alleles.setter
 *     def alleles(self, value):
 *         self['GT'] = value             # <<<<<<<<<<<<<<
 * 
 *     @alleles.deleter
 */
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_n_s_GT, __pyx_v_value) < 0)) __PYX_ERR(0, 3397, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":3396
 * 
 *     @alleles.setter
 *     def alleles(self, value):             # <<<<<<<<<<<<<<
 *         self['GT'] = value
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.alleles.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3400
 * 
 *     @alleles.deleter
 *     def alleles(self):             # <<<<<<<<<<<<<<
 *         self['GT'] = ()
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_7alleles_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_7alleles_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_7alleles_4__del__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_7alleles_4__del__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[0], 3400, 0, __PYX_ERR(0, 3400, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3401
 *     @alleles.deleter
 *     def alleles(self):
 *         self['GT'] = ()             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_n_s_GT, __pyx_empty_tuple) < 0)) __PYX_ERR(0, 3401, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":3400
 * 
 *     @alleles.deleter
 *     def alleles(self):             # <<<<<<<<<<<<<<
 *         self['GT'] = ()
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.alleles.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3404
 * 
 *     @property
 *     def phased(self):             # <<<<<<<<<<<<<<
 *         """False if genotype is missing or any allele is unphased.  Otherwise True."""
 *         return bcf_sample_get_phased(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_6phased_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_6phased_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_6phased___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_6phased___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 3404, 0, __PYX_ERR(0, 3404, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3406
 *     def phased(self):
 *         """False if genotype is missing or any allele is unphased.  Otherwise True."""
 *         return bcf_sample_get_phased(self)             # <<<<<<<<<<<<<<
 * 
 *     @phased.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_5pysam_7libcbcf_bcf_sample_get_phased(__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3404
 * 
 *     @property
 *     def phased(self):             # <<<<<<<<<<<<<<
 *         """False if genotype is missing or any allele is unphased.  Otherwise True."""
 *         return bcf_sample_get_phased(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.phased.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3409
 * 
 *     @phased.setter
 *     def phased(self, value):             # <<<<<<<<<<<<<<
 *         bcf_sample_set_phased(self, value)
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_6phased_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_6phased_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_6phased_2__set__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_6phased_2__set__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 3409, 0, __PYX_ERR(0, 3409, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3410
 *     @phased.setter
 *     def phased(self, value):
 *         bcf_sample_set_phased(self, value)             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3410, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_5pysam_7libcbcf_bcf_sample_set_phased(__pyx_v_self, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":3409
 * 
 *     @phased.setter
 *     def phased(self, value):             # <<<<<<<<<<<<<<
 *         bcf_sample_set_phased(self, value)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.phased.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3412
 *         bcf_sample_set_phased(self, value)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_3__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_3__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_2__len__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_2__len__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  CYTHON_UNUSED bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int __pyx_v_i;
  int __pyx_v_n;
  Py_ssize_t __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  uint32_t __pyx_t_5;
  uint32_t __pyx_t_6;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__len__", 0);
  __Pyx_TraceCall("__len__", __pyx_f[0], 3412, 0, __PYX_ERR(0, 3412, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3413
 * 
 *     def __len__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int i, n = 0
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3414
 *     def __len__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int i, n = 0
 * 
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":3415
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int i, n = 0             # <<<<<<<<<<<<<<
 * 
 *         if bcf_unpack(r, BCF_UN_FMT) < 0:
 */
  __pyx_v_n = 0;

  /* "pysam/libcbcf.pyx":3417
 *         cdef int i, n = 0
 * 
 *         if bcf_unpack(r, BCF_UN_FMT) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_v_r, BCF_UN_FMT) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":3418
 * 
 *         if bcf_unpack(r, BCF_UN_FMT) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_fmt):
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__178, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3418, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 3418, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3417
 *         cdef int i, n = 0
 * 
 *         if bcf_unpack(r, BCF_UN_FMT) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3420
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         for i in range(r.n_fmt):             # <<<<<<<<<<<<<<
 *             if r.d.fmt[i].p:
 *                 n += 1
 */
  __pyx_t_5 = __pyx_v_r->n_fmt;
  __pyx_t_6 = __pyx_t_5;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "pysam/libcbcf.pyx":3421
 * 
 *         for i in range(r.n_fmt):
 *             if r.d.fmt[i].p:             # <<<<<<<<<<<<<<
 *                 n += 1
 *         return n
 */
    __pyx_t_3 = ((__pyx_v_r->d.fmt[__pyx_v_i]).p != 0);
    if (__pyx_t_3) {

      /* "pysam/libcbcf.pyx":3422
 *         for i in range(r.n_fmt):
 *             if r.d.fmt[i].p:
 *                 n += 1             # <<<<<<<<<<<<<<
 *         return n
 * 
 */
      __pyx_v_n = (__pyx_v_n + 1);

      /* "pysam/libcbcf.pyx":3421
 * 
 *         for i in range(r.n_fmt):
 *             if r.d.fmt[i].p:             # <<<<<<<<<<<<<<
 *                 n += 1
 *         return n
 */
    }
  }

  /* "pysam/libcbcf.pyx":3423
 *             if r.d.fmt[i].p:
 *                 n += 1
 *         return n             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
  __pyx_r = __pyx_v_n;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3412
 *         bcf_sample_set_phased(self, value)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3425
 *         return n
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_5__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_5__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_4__bool__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_4__bool__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  CYTHON_UNUSED bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  int __pyx_v_i;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  uint32_t __pyx_t_5;
  uint32_t __pyx_t_6;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__bool__", 0);
  __Pyx_TraceCall("__bool__", __pyx_f[0], 3425, 0, __PYX_ERR(0, 3425, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3426
 * 
 *     def __bool__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef int i
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3427
 *     def __bool__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef int i
 * 
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":3430
 *         cdef int i
 * 
 *         if bcf_unpack(r, BCF_UN_FMT) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  __pyx_t_3 = ((bcf_unpack(__pyx_v_r, BCF_UN_FMT) < 0) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":3431
 * 
 *         if bcf_unpack(r, BCF_UN_FMT) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_fmt):
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__179, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 3431, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3430
 *         cdef int i
 * 
 *         if bcf_unpack(r, BCF_UN_FMT) < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3433
 *             raise ValueError('Error unpacking VariantRecord')
 * 
 *         for i in range(r.n_fmt):             # <<<<<<<<<<<<<<
 *             if r.d.fmt[i].p:
 *                 return True
 */
  __pyx_t_5 = __pyx_v_r->n_fmt;
  __pyx_t_6 = __pyx_t_5;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "pysam/libcbcf.pyx":3434
 * 
 *         for i in range(r.n_fmt):
 *             if r.d.fmt[i].p:             # <<<<<<<<<<<<<<
 *                 return True
 *         return False
 */
    __pyx_t_3 = ((__pyx_v_r->d.fmt[__pyx_v_i]).p != 0);
    if (__pyx_t_3) {

      /* "pysam/libcbcf.pyx":3435
 *         for i in range(r.n_fmt):
 *             if r.d.fmt[i].p:
 *                 return True             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
      __pyx_r = 1;
      goto __pyx_L0;

      /* "pysam/libcbcf.pyx":3434
 * 
 *         for i in range(r.n_fmt):
 *             if r.d.fmt[i].p:             # <<<<<<<<<<<<<<
 *                 return True
 *         return False
 */
    }
  }

  /* "pysam/libcbcf.pyx":3436
 *             if r.d.fmt[i].p:
 *                 return True
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3425
 *         return n
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3438
 *         return False
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         return bcf_format_get_value(self, key)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_6__getitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_TraceCall("__getitem__", __pyx_f[0], 3438, 0, __PYX_ERR(0, 3438, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3439
 * 
 *     def __getitem__(self, key):
 *         return bcf_format_get_value(self, key)             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, key, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf_bcf_format_get_value(__pyx_v_self, __pyx_v_key); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3438
 *         return False
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         return bcf_format_get_value(self, key)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3441
 *         return bcf_format_get_value(self, key)
 * 
 *     def __setitem__(self, key, value):             # <<<<<<<<<<<<<<
 *         bcf_format_set_value(self, key, value)
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_8__setitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), ((PyObject *)__pyx_v_key), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_8__setitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setitem__", 0);
  __Pyx_TraceCall("__setitem__", __pyx_f[0], 3441, 0, __PYX_ERR(0, 3441, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3442
 * 
 *     def __setitem__(self, key, value):
 *         bcf_format_set_value(self, key, value)             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, key):
 */
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf_bcf_format_set_value(__pyx_v_self, __pyx_v_key, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":3441
 *         return bcf_format_get_value(self, key)
 * 
 *     def __setitem__(self, key, value):             # <<<<<<<<<<<<<<
 *         bcf_format_set_value(self, key, value)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3444
 *         bcf_format_set_value(self, key, value)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         bcf_format_del_value(self, key)
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_11__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_11__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_10__delitem__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_10__delitem__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__delitem__", 0);
  __Pyx_TraceCall("__delitem__", __pyx_f[0], 3444, 0, __PYX_ERR(0, 3444, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3445
 * 
 *     def __delitem__(self, key):
 *         bcf_format_del_value(self, key)             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf_bcf_format_del_value(__pyx_v_self, __pyx_v_key); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":3444
 *         bcf_format_set_value(self, key, value)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         bcf_format_del_value(self, key)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.__delitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3447
 *         bcf_format_del_value(self, key)
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         """Clear all format data (including genotype) for this sample"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_13clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_12clear[] = "VariantRecordSample.clear(self)\nClear all format data (including genotype) for this sample";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_13clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_12clear(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_12clear(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  bcf_fmt_t *__pyx_v_fmt;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  uint32_t __pyx_t_3;
  uint32_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("clear", 0);
  __Pyx_TraceCall("clear", __pyx_f[0], 3447, 0, __PYX_ERR(0, 3447, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3449
 *     def clear(self):
 *         """Clear all format data (including genotype) for this sample"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bcf_fmt_t *fmt
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3450
 *         """Clear all format data (including genotype) for this sample"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_fmt_t *fmt
 *         cdef int i
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":3454
 *         cdef int i
 * 
 *         for i in range(r.n_fmt):             # <<<<<<<<<<<<<<
 *             fmt = &r.d.fmt[i]
 *             if fmt.p:
 */
  __pyx_t_3 = __pyx_v_r->n_fmt;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "pysam/libcbcf.pyx":3455
 * 
 *         for i in range(r.n_fmt):
 *             fmt = &r.d.fmt[i]             # <<<<<<<<<<<<<<
 *             if fmt.p:
 *                 bcf_format_del_value(self, bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 */
    __pyx_v_fmt = (&(__pyx_v_r->d.fmt[__pyx_v_i]));

    /* "pysam/libcbcf.pyx":3456
 *         for i in range(r.n_fmt):
 *             fmt = &r.d.fmt[i]
 *             if fmt.p:             # <<<<<<<<<<<<<<
 *                 bcf_format_del_value(self, bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 */
    __pyx_t_6 = (__pyx_v_fmt->p != 0);
    if (__pyx_t_6) {

      /* "pysam/libcbcf.pyx":3457
 *             fmt = &r.d.fmt[i]
 *             if fmt.p:
 *                 bcf_format_del_value(self, bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
      __pyx_t_7 = __Pyx_PyBytes_FromString(bcf_hdr_int2id(__pyx_v_hdr, BCF_DT_ID, __pyx_v_fmt->id)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3457, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __pyx_f_5pysam_7libcbcf_bcf_format_del_value(__pyx_v_self, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3457, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "pysam/libcbcf.pyx":3456
 *         for i in range(r.n_fmt):
 *             fmt = &r.d.fmt[i]
 *             if fmt.p:             # <<<<<<<<<<<<<<
 *                 bcf_format_del_value(self, bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 */
    }
  }

  /* "pysam/libcbcf.pyx":3447
 *         bcf_format_del_value(self, key)
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         """Clear all format data (including genotype) for this sample"""
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.clear", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantRecordSample_16generator23(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":3459
 *                 bcf_format_del_value(self, bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_15__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_15__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_14__iter__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_14__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__ *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__ *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_33___iter__(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_33___iter__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 3459, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantRecordSample_16generator23, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_VariantRecordSample___iter, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 3459, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.__iter__", __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_5pysam_7libcbcf_19VariantRecordSample_16generator23(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__ *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  uint32_t __pyx_t_3;
  uint32_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 3459, 0, __PYX_ERR(0, 3459, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L7_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3459, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":3460
 * 
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bcf_fmt_t *fmt
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->record->header->ptr;
  __pyx_cur_scope->__pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3461
 *     def __iter__(self):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf_fmt_t *fmt
 *         cdef int i
 */
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self->record->ptr;
  __pyx_cur_scope->__pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":3465
 *         cdef int i
 * 
 *         for i in range(r.n_fmt):             # <<<<<<<<<<<<<<
 *             fmt = &r.d.fmt[i]
 *             if r.d.fmt[i].p:
 */
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_r->n_fmt;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_5;

    /* "pysam/libcbcf.pyx":3466
 * 
 *         for i in range(r.n_fmt):
 *             fmt = &r.d.fmt[i]             # <<<<<<<<<<<<<<
 *             if r.d.fmt[i].p:
 *                 yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 */
    __pyx_cur_scope->__pyx_v_fmt = (&(__pyx_cur_scope->__pyx_v_r->d.fmt[__pyx_cur_scope->__pyx_v_i]));

    /* "pysam/libcbcf.pyx":3467
 *         for i in range(r.n_fmt):
 *             fmt = &r.d.fmt[i]
 *             if r.d.fmt[i].p:             # <<<<<<<<<<<<<<
 *                 yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 */
    __pyx_t_6 = ((__pyx_cur_scope->__pyx_v_r->d.fmt[__pyx_cur_scope->__pyx_v_i]).p != 0);
    if (__pyx_t_6) {

      /* "pysam/libcbcf.pyx":3468
 *             fmt = &r.d.fmt[i]
 *             if r.d.fmt[i].p:
 *                 yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
      __pyx_t_7 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(bcf_hdr_int2id(__pyx_cur_scope->__pyx_v_hdr, BCF_DT_ID, __pyx_cur_scope->__pyx_v_fmt->id)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3468, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_r = __pyx_t_7;
      __pyx_t_7 = 0;
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_TraceReturn(__pyx_r, 0);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L7_resume_from_yield:;
      __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
      __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3468, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3467
 *         for i in range(r.n_fmt):
 *             fmt = &r.d.fmt[i]
 *             if r.d.fmt[i].p:             # <<<<<<<<<<<<<<
 *                 yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 */
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":3459
 *                 bcf_format_del_value(self, bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3470
 *                 yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_18get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_17get[] = "VariantRecordSample.get(self, key, default=None)\nD.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_18get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 3470, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3470, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_17get(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_17get(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("get", 0);
  __Pyx_TraceCall("get", __pyx_f[0], 3470, 0, __PYX_ERR(0, 3470, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3472
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":3473
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 *             return self[key]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return default
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3473, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "pysam/libcbcf.pyx":3472
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":3474
 *         try:
 *             return self[key]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 3474, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":3475
 *             return self[key]
 *         except KeyError:
 *             return default             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_default);
      __pyx_r = __pyx_v_default;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":3472
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":3470
 *                 yield bcf_str_cache_get_charptr(bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id))
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3477
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_20__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_20__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_19__contains__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_19__contains__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_key) {
  bcf_hdr_t *__pyx_v_hdr;
  bcf1_t *__pyx_v_r;
  PyObject *__pyx_v_bkey = 0;
  bcf_fmt_t *__pyx_v_fmt;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  bcf_hdr_t *__pyx_t_1;
  bcf1_t *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  char const *__pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__contains__", 0);
  __Pyx_TraceCall("__contains__", __pyx_f[0], 3477, 0, __PYX_ERR(0, 3477, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3478
 * 
 *     def __contains__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr             # <<<<<<<<<<<<<<
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_t_1 = __pyx_v_self->record->header->ptr;
  __pyx_v_hdr = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3479
 *     def __contains__(self, key):
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr             # <<<<<<<<<<<<<<
 *         cdef bytes bkey = force_bytes(key)
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 */
  __pyx_t_2 = __pyx_v_self->record->ptr;
  __pyx_v_r = __pyx_t_2;

  /* "pysam/libcbcf.pyx":3480
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bytes bkey = force_bytes(key)             # <<<<<<<<<<<<<<
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 *         return fmt != NULL and fmt.p != NULL
 */
  __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_key, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_bkey = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3481
 *         cdef bcf1_t *r = self.record.ptr
 *         cdef bytes bkey = force_bytes(key)
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)             # <<<<<<<<<<<<<<
 *         return fmt != NULL and fmt.p != NULL
 * 
 */
  if (unlikely(__pyx_v_bkey == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 3481, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_v_bkey); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 3481, __pyx_L1_error)
  __pyx_v_fmt = bcf_get_fmt(__pyx_v_hdr, __pyx_v_r, __pyx_t_4);

  /* "pysam/libcbcf.pyx":3482
 *         cdef bytes bkey = force_bytes(key)
 *         cdef bcf_fmt_t *fmt = bcf_get_fmt(hdr, r, bkey)
 *         return fmt != NULL and fmt.p != NULL             # <<<<<<<<<<<<<<
 * 
 *     def iterkeys(self):
 */
  __pyx_t_6 = (__pyx_v_fmt != NULL);
  if (__pyx_t_6) {
  } else {
    __pyx_t_5 = __pyx_t_6;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_6 = (__pyx_v_fmt->p != NULL);
  __pyx_t_5 = __pyx_t_6;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_5;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3477
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bkey);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3484
 *         return fmt != NULL and fmt.p != NULL
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_22iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_21iterkeys[] = "VariantRecordSample.iterkeys(self)\nD.iterkeys() -> an iterator over the keys of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_22iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iterkeys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_21iterkeys(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_21iterkeys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("iterkeys", 0);
  __Pyx_TraceCall("iterkeys", __pyx_f[0], 3484, 0, __PYX_ERR(0, 3484, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3486
 *     def iterkeys(self):
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)             # <<<<<<<<<<<<<<
 * 
 *     def itervalues(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3484
 *         return fmt != NULL and fmt.p != NULL
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.iterkeys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantRecordSample_25generator24(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":3488
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_24itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_23itervalues[] = "VariantRecordSample.itervalues(self)\nD.itervalues() -> an iterator over the values of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_24itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_23itervalues(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_23itervalues(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_34_itervalues(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_34_itervalues, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 3488, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantRecordSample_25generator24, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_itervalues, __pyx_n_s_VariantRecordSample_itervalues, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 3488, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.itervalues", __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_5pysam_7libcbcf_19VariantRecordSample_25generator24(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __Pyx_TraceCall("itervalues", __pyx_f[0], 3488, 0, __PYX_ERR(0, 3488, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3488, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":3490
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield self[key]
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3490, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3490, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 3490, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3490, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 3490, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3490, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3490, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":3491
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 *             yield self[key]             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3491, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3491, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3490
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield self[key]
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":3488
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("itervalues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_19VariantRecordSample_28generator25(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":3493
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_27iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_26iteritems[] = "VariantRecordSample.iteritems(self)\nD.iteritems() -> an iterator over the (key, value) items of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_27iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_26iteritems(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_26iteritems(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_35_iteritems(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_35_iteritems, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 3493, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_19VariantRecordSample_28generator25, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iteritems, __pyx_n_s_VariantRecordSample_iteritems, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 3493, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.iteritems", __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_5pysam_7libcbcf_19VariantRecordSample_28generator25(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __Pyx_TraceCall("iteritems", __pyx_f[0], 3493, 0, __PYX_ERR(0, 3493, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3493, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":3495
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield (key, self[key])
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3495, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3495, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 3495, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3495, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 3495, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3495, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3495, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":3496
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 *             yield (key, self[key])             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_cur_scope->__pyx_v_key);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3496, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3495
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield (key, self[key])
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":3493
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("iteritems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3498
 *             yield (key, self[key])
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_30keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_29keys[] = "VariantRecordSample.keys(self)\nD.keys() -> list of D's keys";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_30keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_29keys(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_29keys(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("keys", 0);
  __Pyx_TraceCall("keys", __pyx_f[0], 3498, 0, __PYX_ERR(0, 3498, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3500
 *     def keys(self):
 *         """D.keys() -> list of D's keys"""
 *         return list(self)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_List(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3498
 *             yield (key, self[key])
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3502
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_32items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_31items[] = "VariantRecordSample.items(self)\nD.items() -> list of D's (key, value) pairs, as 2-tuples";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_32items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("items (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_31items(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_31items(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("items", 0);
  __Pyx_TraceCall("items", __pyx_f[0], 3502, 0, __PYX_ERR(0, 3502, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3504
 *     def items(self):
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_iteritems); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3504, __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, 3504, __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, 3504, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3504, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3502
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.items", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3506
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_34values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_33values[] = "VariantRecordSample.values(self)\nD.values() -> list of D's values";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_34values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("values (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_33values(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_33values(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("values", 0);
  __Pyx_TraceCall("values", __pyx_f[0], 3506, 0, __PYX_ERR(0, 3506, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3508
 *     def values(self):
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())             # <<<<<<<<<<<<<<
 * 
 *     def update(self, items=None, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itervalues); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3508, __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, 3508, __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, 3508, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3506
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3510
 *         return list(self.itervalues())
 * 
 *     def update(self, items=None, **kwargs):             # <<<<<<<<<<<<<<
 *         """D.update([E, ]**F) -> None.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_36update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_35update[] = "VariantRecordSample.update(self, items=None, **kwargs)\nD.update([E, ]**F) -> None.\n\n        Update D from dict/iterable E and F.\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_36update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update (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_items,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "update") < 0)) __PYX_ERR(0, 3510, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("update", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3510, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_35update(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), __pyx_v_items, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_35update(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("update", 0);
  __Pyx_TraceCall("update", __pyx_f[0], 3510, 0, __PYX_ERR(0, 3510, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3515
 *         Update D from dict/iterable E and F.
 *         """
 *         for k, v in items.items():             # <<<<<<<<<<<<<<
 *             self[k] = v
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3515, __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, 3515, __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, 3515, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3515, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 3515, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3515, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 3515, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3515, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3515, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 3515, __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, 3515, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3515, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3515, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 3515, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 3515, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pysam/libcbcf.pyx":3516
 *         """
 *         for k, v in items.items():
 *             self[k] = v             # <<<<<<<<<<<<<<
 * 
 *         if kwargs:
 */
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_k, __pyx_v_v) < 0)) __PYX_ERR(0, 3516, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3515
 *         Update D from dict/iterable E and F.
 *         """
 *         for k, v in items.items():             # <<<<<<<<<<<<<<
 *             self[k] = v
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":3518
 *             self[k] = v
 * 
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             for k, v in kwargs.items():
 *                 self[k] = v
 */
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3518, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "pysam/libcbcf.pyx":3519
 * 
 *         if kwargs:
 *             for k, v in kwargs.items():             # <<<<<<<<<<<<<<
 *                 self[k] = v
 * 
 */
    __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3519, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3519, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 3519, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3519, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 3519, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3519, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 3519, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 3519, __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_3 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3519, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3519, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3519, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L10_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L10_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 3519, __pyx_L1_error)
        __pyx_t_8 = NULL;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L11_unpacking_done;
        __pyx_L10_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, 3519, __pyx_L1_error)
        __pyx_L11_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":3520
 *         if kwargs:
 *             for k, v in kwargs.items():
 *                 self[k] = v             # <<<<<<<<<<<<<<
 * 
 *     def pop(self, key, default=_nothing):
 */
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_k, __pyx_v_v) < 0)) __PYX_ERR(0, 3520, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3519
 * 
 *         if kwargs:
 *             for k, v in kwargs.items():             # <<<<<<<<<<<<<<
 *                 self[k] = v
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":3518
 *             self[k] = v
 * 
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             for k, v in kwargs.items():
 *                 self[k] = v
 */
  }

  /* "pysam/libcbcf.pyx":3510
 *         return list(self.itervalues())
 * 
 *     def update(self, items=None, **kwargs):             # <<<<<<<<<<<<<<
 *         """D.update([E, ]**F) -> None.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3522
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         try:
 *             value = self[key]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_38pop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_37pop[] = "VariantRecordSample.pop(self, key, default=_nothing)";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_38pop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pop (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k__180;
    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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "pop") < 0)) __PYX_ERR(0, 3522, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("pop", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3522, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_37pop(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_37pop(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("pop", 0);
  __Pyx_TraceCall("pop", __pyx_f[0], 3522, 0, __PYX_ERR(0, 3522, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3523
 * 
 *     def pop(self, key, default=_nothing):
 *         try:             # <<<<<<<<<<<<<<
 *             value = self[key]
 *             del self[key]
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":3524
 *     def pop(self, key, default=_nothing):
 *         try:
 *             value = self[key]             # <<<<<<<<<<<<<<
 *             del self[key]
 *             return value
 */
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3524, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_value = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "pysam/libcbcf.pyx":3525
 *         try:
 *             value = self[key]
 *             del self[key]             # <<<<<<<<<<<<<<
 *             return value
 *         except KeyError:
 */
      if (unlikely(PyObject_DelItem(((PyObject *)__pyx_v_self), __pyx_v_key) < 0)) __PYX_ERR(0, 3525, __pyx_L3_error)

      /* "pysam/libcbcf.pyx":3526
 *             value = self[key]
 *             del self[key]
 *             return value             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             if default is not _nothing:
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_value);
      __pyx_r = __pyx_v_value;
      goto __pyx_L7_try_return;

      /* "pysam/libcbcf.pyx":3523
 * 
 *     def pop(self, key, default=_nothing):
 *         try:             # <<<<<<<<<<<<<<
 *             value = self[key]
 *             del self[key]
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":3527
 *             del self[key]
 *             return value
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             if default is not _nothing:
 *                 return default
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 3527, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":3528
 *             return value
 *         except KeyError:
 *             if default is not _nothing:             # <<<<<<<<<<<<<<
 *                 return default
 *             raise
 */
      __pyx_t_8 = (__pyx_v_default != __pyx_v_5pysam_7libcbcf__nothing);
      __pyx_t_9 = (__pyx_t_8 != 0);
      if (__pyx_t_9) {

        /* "pysam/libcbcf.pyx":3529
 *         except KeyError:
 *             if default is not _nothing:
 *                 return default             # <<<<<<<<<<<<<<
 *             raise
 * 
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_v_default);
        __pyx_r = __pyx_v_default;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L6_except_return;

        /* "pysam/libcbcf.pyx":3528
 *             return value
 *         except KeyError:
 *             if default is not _nothing:             # <<<<<<<<<<<<<<
 *                 return default
 *             raise
 */
      }

      /* "pysam/libcbcf.pyx":3530
 *             if default is not _nothing:
 *                 return default
 *             raise             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(VariantRecordSample self not None, VariantRecordSample other not None, int op):
 */
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_6, __pyx_t_7);
      __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; 
      __PYX_ERR(0, 3530, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":3523
 * 
 *     def pop(self, key, default=_nothing):
 *         try:             # <<<<<<<<<<<<<<
 *             value = self[key]
 *             del self[key]
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":3522
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         try:
 *             value = self[key]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3532
 *             raise
 * 
 *     def __richcmp__(VariantRecordSample self not None, VariantRecordSample other not None, int op):             # <<<<<<<<<<<<<<
 *         if op != 2 and op != 3:
 *             return NotImplemented
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_40__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_40__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  if (unlikely(((PyObject *)__pyx_v_self) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "self"); __PYX_ERR(0, 3532, __pyx_L1_error)
  }
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5pysam_7libcbcf_VariantRecordSample, 0, "other", 0))) __PYX_ERR(0, 3532, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_39__richcmp__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), ((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_other), ((int)__pyx_v_op));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_39__richcmp__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_other, int __pyx_v_op) {
  int __pyx_v_cmp;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__richcmp__", 0);
  __Pyx_TraceCall("__richcmp__", __pyx_f[0], 3532, 0, __PYX_ERR(0, 3532, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3533
 * 
 *     def __richcmp__(VariantRecordSample self not None, VariantRecordSample other not None, int op):
 *         if op != 2 and op != 3:             # <<<<<<<<<<<<<<
 *             return NotImplemented
 * 
 */
  switch (__pyx_v_op) {
    case 2:
    case 3:
    __pyx_t_1 = 0;
    break;
    default:
    __pyx_t_1 = 1;
    break;
  }
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3534
 *     def __richcmp__(VariantRecordSample self not None, VariantRecordSample other not None, int op):
 *         if op != 2 and op != 3:
 *             return NotImplemented             # <<<<<<<<<<<<<<
 * 
 *         cdef bint cmp = dict(self) == dict(other)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":3533
 * 
 *     def __richcmp__(VariantRecordSample self not None, VariantRecordSample other not None, int op):
 *         if op != 2 and op != 3:             # <<<<<<<<<<<<<<
 *             return NotImplemented
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3536
 *             return NotImplemented
 * 
 *         cdef bint cmp = dict(self) == dict(other)             # <<<<<<<<<<<<<<
 * 
 *         if op == 3:
 */
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyDict_Type)), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyDict_Type)), ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3536, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3536, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_cmp = __pyx_t_1;

  /* "pysam/libcbcf.pyx":3538
 *         cdef bint cmp = dict(self) == dict(other)
 * 
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             cmp = not cmp
 * 
 */
  __pyx_t_1 = ((__pyx_v_op == 3) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3539
 * 
 *         if op == 3:
 *             cmp = not cmp             # <<<<<<<<<<<<<<
 * 
 *         return cmp
 */
    __pyx_v_cmp = (!(__pyx_v_cmp != 0));

    /* "pysam/libcbcf.pyx":3538
 *         cdef bint cmp = dict(self) == dict(other)
 * 
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             cmp = not cmp
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3541
 *             cmp = not cmp
 * 
 *         return cmp             # <<<<<<<<<<<<<<
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_cmp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3532
 *             raise
 * 
 *     def __richcmp__(VariantRecordSample self not None, VariantRecordSample other not None, int op):             # <<<<<<<<<<<<<<
 *         if op != 2 and op != 3:
 *             return NotImplemented
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":100
 * cdef class VariantRecordSample(object):
 *     cdef VariantRecord record
 *     cdef readonly int32_t index             # <<<<<<<<<<<<<<
 * 
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_5index_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_5index_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_5index___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_5index___get__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 100, 0, __PYX_ERR(1, 100, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_v_self->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.index.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.index, self.record)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_42__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_41__reduce_cython__[] = "VariantRecordSample.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_42__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_41__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_41__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.index, self.record)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_v_self->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->record));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->record));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self->record));
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.index, self.record)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":5
 *     state = (self.index, self.record)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.record is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.index, self.record)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.record is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_VariantRecordSample, (type(self), 0x5d6ff7b, None), state
 */
  /*else*/ {
    __pyx_t_4 = (((PyObject *)__pyx_v_self->record) != Py_None);
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.record is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantRecordSample, (type(self), 0x5d6ff7b, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":11
 *         use_setstate = self.record is not None
 *     if use_setstate:
 *         return __pyx_unpickle_VariantRecordSample, (type(self), 0x5d6ff7b, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_VariantRecordSample, (type(self), 0x5d6ff7b, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantRecordSamp_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_97976187);
    __Pyx_GIVEREF(__pyx_int_97976187);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_97976187);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.record is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VariantRecordSample, (type(self), 0x5d6ff7b, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_VariantRecordSample, (type(self), 0x5d6ff7b, None), state
 *     else:
 *         return __pyx_unpickle_VariantRecordSample, (type(self), 0x5d6ff7b, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantRecordSample__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_VariantRecordSamp_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_97976187);
    __Pyx_GIVEREF(__pyx_int_97976187);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_97976187);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.index, self.record)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantRecordSample, (type(self), 0x5d6ff7b, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantRecordSample__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_44__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_43__setstate_cython__[] = "VariantRecordSample.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_44__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_19VariantRecordSample_43__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_19VariantRecordSample_43__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 14, 0, __PYX_ERR(2, 14, __pyx_L1_error));

  /* "(tree fragment)":15
 *         return __pyx_unpickle_VariantRecordSample, (type(self), 0x5d6ff7b, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VariantRecordSample__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordSample__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_VariantRecordSample, (type(self), 0x5d6ff7b, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VariantRecordSample__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantRecordSample.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3547
 * 
 * 
 * cdef VariantRecordSample makeVariantRecordSample(VariantRecord record, int32_t sample_index):             # <<<<<<<<<<<<<<
 *     if not record or sample_index < 0:
 *         raise ValueError('cannot create VariantRecordSample')
 */

static struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_f_5pysam_7libcbcf_makeVariantRecordSample(struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record, int32_t __pyx_v_sample_index) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v_sample = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("makeVariantRecordSample", 0);
  __Pyx_TraceCall("makeVariantRecordSample", __pyx_f[0], 3547, 0, __PYX_ERR(0, 3547, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3548
 * 
 * cdef VariantRecordSample makeVariantRecordSample(VariantRecord record, int32_t sample_index):
 *     if not record or sample_index < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('cannot create VariantRecordSample')
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_record)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3548, __pyx_L1_error)
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = ((__pyx_v_sample_index < 0) != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3549
 * cdef VariantRecordSample makeVariantRecordSample(VariantRecord record, int32_t sample_index):
 *     if not record or sample_index < 0:
 *         raise ValueError('cannot create VariantRecordSample')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantRecordSample sample = VariantRecordSample.__new__(VariantRecordSample)
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__181, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 3549, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3548
 * 
 * cdef VariantRecordSample makeVariantRecordSample(VariantRecord record, int32_t sample_index):
 *     if not record or sample_index < 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('cannot create VariantRecordSample')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3551
 *         raise ValueError('cannot create VariantRecordSample')
 * 
 *     cdef VariantRecordSample sample = VariantRecordSample.__new__(VariantRecordSample)             # <<<<<<<<<<<<<<
 *     sample.record = record
 *     sample.index = sample_index
 */
  __pyx_t_4 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantRecordSample(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordSample), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3551, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_v_sample = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pysam/libcbcf.pyx":3552
 * 
 *     cdef VariantRecordSample sample = VariantRecordSample.__new__(VariantRecordSample)
 *     sample.record = record             # <<<<<<<<<<<<<<
 *     sample.index = sample_index
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_record));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_record));
  __Pyx_GOTREF(__pyx_v_sample->record);
  __Pyx_DECREF(((PyObject *)__pyx_v_sample->record));
  __pyx_v_sample->record = __pyx_v_record;

  /* "pysam/libcbcf.pyx":3553
 *     cdef VariantRecordSample sample = VariantRecordSample.__new__(VariantRecordSample)
 *     sample.record = record
 *     sample.index = sample_index             # <<<<<<<<<<<<<<
 * 
 *     return sample
 */
  __pyx_v_sample->index = __pyx_v_sample_index;

  /* "pysam/libcbcf.pyx":3555
 *     sample.index = sample_index
 * 
 *     return sample             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_sample));
  __pyx_r = __pyx_v_sample;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3547
 * 
 * 
 * cdef VariantRecordSample makeVariantRecordSample(VariantRecord record, int32_t sample_index):             # <<<<<<<<<<<<<<
 *     if not record or sample_index < 0:
 *         raise ValueError('cannot create VariantRecordSample')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.makeVariantRecordSample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_sample);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3565
 * 
 * cdef class BaseIndex(object):
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.refs = ()
 *         self.remap = {}
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_9BaseIndex_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_9BaseIndex_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_5pysam_7libcbcf_9BaseIndex___init__(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_9BaseIndex___init__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 3565, 0, __PYX_ERR(0, 3565, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3566
 * cdef class BaseIndex(object):
 *     def __init__(self):
 *         self.refs = ()             # <<<<<<<<<<<<<<
 *         self.remap = {}
 * 
 */
  __Pyx_INCREF(__pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_GOTREF(__pyx_v_self->refs);
  __Pyx_DECREF(__pyx_v_self->refs);
  __pyx_v_self->refs = __pyx_empty_tuple;

  /* "pysam/libcbcf.pyx":3567
 *     def __init__(self):
 *         self.refs = ()
 *         self.remap = {}             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_remap, __pyx_t_1) < 0) __PYX_ERR(0, 3567, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":3565
 * 
 * cdef class BaseIndex(object):
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.refs = ()
 *         self.remap = {}
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3569
 *         self.remap = {}
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self.refs)
 * 
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_9BaseIndex_3__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_5pysam_7libcbcf_9BaseIndex_3__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_2__len__(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_5pysam_7libcbcf_9BaseIndex_2__len__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  __Pyx_RefNannySetupContext("__len__", 0);
  __Pyx_TraceCall("__len__", __pyx_f[0], 3569, 0, __PYX_ERR(0, 3569, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3570
 * 
 *     def __len__(self):
 *         return len(self.refs)             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
  __pyx_t_1 = __pyx_v_self->refs;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 3570, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3570, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3569
 *         self.remap = {}
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self.refs)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3572
 *         return len(self.refs)
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         return len(self.refs) != 0
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_9BaseIndex_5__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_9BaseIndex_5__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_4__bool__(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_9BaseIndex_4__bool__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  __Pyx_RefNannySetupContext("__bool__", 0);
  __Pyx_TraceCall("__bool__", __pyx_f[0], 3572, 0, __PYX_ERR(0, 3572, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3573
 * 
 *     def __bool__(self):
 *         return len(self.refs) != 0             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key):
 */
  __pyx_t_1 = __pyx_v_self->refs;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 3573, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3573, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = (__pyx_t_2 != 0);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3572
 *         return len(self.refs)
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         return len(self.refs) != 0
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3575
 *         return len(self.refs) != 0
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         if isinstance(key, int):
 *             return self.refs[key]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_6__getitem__(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_6__getitem__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_TraceCall("__getitem__", __pyx_f[0], 3575, 0, __PYX_ERR(0, 3575, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3576
 * 
 *     def __getitem__(self, key):
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             return self.refs[key]
 *         else:
 */
  __pyx_t_1 = PyInt_Check(__pyx_v_key); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":3577
 *     def __getitem__(self, key):
 *         if isinstance(key, int):
 *             return self.refs[key]             # <<<<<<<<<<<<<<
 *         else:
 *             return self.refmap[key]
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_self->refs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 3577, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_self->refs, __pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3577, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":3576
 * 
 *     def __getitem__(self, key):
 *         if isinstance(key, int):             # <<<<<<<<<<<<<<
 *             return self.refs[key]
 *         else:
 */
  }

  /* "pysam/libcbcf.pyx":3579
 *             return self.refs[key]
 *         else:
 *             return self.refmap[key]             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_self->refmap == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 3579, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_self->refmap, __pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3579, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":3575
 *         return len(self.refs) != 0
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         if isinstance(key, int):
 *             return self.refs[key]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3581
 *             return self.refmap[key]
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return iter(self.refs)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_9__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_9__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_8__iter__(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_8__iter__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 3581, 0, __PYX_ERR(0, 3581, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3582
 * 
 *     def __iter__(self):
 *         return iter(self.refs)             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_self->refs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3582, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3581
 *             return self.refmap[key]
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return iter(self.refs)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3584
 *         return iter(self.refs)
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_11get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_9BaseIndex_10get[] = "BaseIndex.get(self, key, default=None)\nD.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.";
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_11get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 3584, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3584, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_10get(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_10get(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("get", 0);
  __Pyx_TraceCall("get", __pyx_f[0], 3584, 0, __PYX_ERR(0, 3584, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3586
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":3587
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 *             return self[key]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return default
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3587, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "pysam/libcbcf.pyx":3586
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":3588
 *         try:
 *             return self[key]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 3588, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":3589
 *             return self[key]
 *         except KeyError:
 *             return default             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_default);
      __pyx_r = __pyx_v_default;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":3586
 *     def get(self, key, default=None):
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":3584
 *         return iter(self.refs)
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
 *         try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3591
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         try:
 *             self[key]
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_9BaseIndex_13__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_9BaseIndex_13__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_12__contains__(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_5pysam_7libcbcf_9BaseIndex_12__contains__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("__contains__", 0);
  __Pyx_TraceCall("__contains__", __pyx_f[0], 3591, 0, __PYX_ERR(0, 3591, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3592
 * 
 *     def __contains__(self, key):
 *         try:             # <<<<<<<<<<<<<<
 *             self[key]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":3593
 *     def __contains__(self, key):
 *         try:
 *             self[key]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return False
 */
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3593, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pysam/libcbcf.pyx":3592
 * 
 *     def __contains__(self, key):
 *         try:             # <<<<<<<<<<<<<<
 *             self[key]
 *         except KeyError:
 */
    }

    /* "pysam/libcbcf.pyx":3597
 *             return False
 *         else:
 *             return True             # <<<<<<<<<<<<<<
 * 
 *     def iterkeys(self):
 */
    /*else:*/ {
      __pyx_r = 1;
      goto __pyx_L6_except_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":3594
 *         try:
 *             self[key]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return False
 *         else:
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 3594, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":3595
 *             self[key]
 *         except KeyError:
 *             return False             # <<<<<<<<<<<<<<
 *         else:
 *             return True
 */
      __pyx_r = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":3592
 * 
 *     def __contains__(self, key):
 *         try:             # <<<<<<<<<<<<<<
 *             self[key]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":3591
 *             return default
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         try:
 *             self[key]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3599
 *             return True
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_15iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_9BaseIndex_14iterkeys[] = "BaseIndex.iterkeys(self)\nD.iterkeys() -> an iterator over the keys of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_15iterkeys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iterkeys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_14iterkeys(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_14iterkeys(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("iterkeys", 0);
  __Pyx_TraceCall("iterkeys", __pyx_f[0], 3599, 0, __PYX_ERR(0, 3599, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3601
 *     def iterkeys(self):
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)             # <<<<<<<<<<<<<<
 * 
 *     def itervalues(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3599
 *             return True
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         """D.iterkeys() -> an iterator over the keys of D"""
 *         return iter(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.iterkeys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_9BaseIndex_18generator26(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":3603
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_17itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_9BaseIndex_16itervalues[] = "BaseIndex.itervalues(self)\nD.itervalues() -> an iterator over the values of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_17itervalues(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_16itervalues(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_16itervalues(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_36_itervalues(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_36_itervalues, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 3603, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_9BaseIndex_18generator26, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_itervalues, __pyx_n_s_BaseIndex_itervalues, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 3603, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.itervalues", __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_5pysam_7libcbcf_9BaseIndex_18generator26(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itervalues", 0);
  __Pyx_TraceCall("itervalues", __pyx_f[0], 3603, 0, __PYX_ERR(0, 3603, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3603, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":3605
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield self[key]
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3605, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3605, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 3605, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3605, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 3605, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3605, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3605, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":3606
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 *             yield self[key]             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3606, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3606, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3605
 *     def itervalues(self):
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield self[key]
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":3603
 *         return iter(self)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         """D.itervalues() -> an iterator over the values of D"""
 *         for key in self:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("itervalues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_5pysam_7libcbcf_9BaseIndex_21generator27(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pysam/libcbcf.pyx":3608
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_20iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_9BaseIndex_19iteritems[] = "BaseIndex.iteritems(self)\nD.iteritems() -> an iterator over the (key, value) items of D";
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_20iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_19iteritems(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_19iteritems(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __pyx_cur_scope = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems *)__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_37_iteritems(__pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_37_iteritems, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 3608, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pysam_7libcbcf_9BaseIndex_21generator27, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iteritems, __pyx_n_s_BaseIndex_iteritems, __pyx_n_s_pysam_libcbcf); if (unlikely(!gen)) __PYX_ERR(0, 3608, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.iteritems", __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_5pysam_7libcbcf_9BaseIndex_21generator27(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems *__pyx_cur_scope = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems", 0);
  __Pyx_TraceCall("iteritems", __pyx_f[0], 3608, 0, __PYX_ERR(0, 3608, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3608, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":3610
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield (key, self[key])
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3610, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3610, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 3610, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3610, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 3610, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3610, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3610, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":3611
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 *             yield (key, self[key])             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3611, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3611, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_cur_scope->__pyx_v_key);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3611, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3610
 *     def iteritems(self):
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:             # <<<<<<<<<<<<<<
 *             yield (key, self[key])
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysam/libcbcf.pyx":3608
 *             yield self[key]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         """D.iteritems() -> an iterator over the (key, value) items of D"""
 *         for key in self:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("iteritems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3613
 *             yield (key, self[key])
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_23keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_9BaseIndex_22keys[] = "BaseIndex.keys(self)\nD.keys() -> list of D's keys";
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_23keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_22keys(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_22keys(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("keys", 0);
  __Pyx_TraceCall("keys", __pyx_f[0], 3613, 0, __PYX_ERR(0, 3613, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3615
 *     def keys(self):
 *         """D.keys() -> list of D's keys"""
 *         return list(self)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_List(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3613
 *             yield (key, self[key])
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """D.keys() -> list of D's keys"""
 *         return list(self)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3617
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_25items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_9BaseIndex_24items[] = "BaseIndex.items(self)\nD.items() -> list of D's (key, value) pairs, as 2-tuples";
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_25items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("items (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_24items(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_24items(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("items", 0);
  __Pyx_TraceCall("items", __pyx_f[0], 3617, 0, __PYX_ERR(0, 3617, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3619
 *     def items(self):
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_iteritems); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3619, __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, 3619, __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, 3619, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3617
 *         return list(self)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
 *         return list(self.iteritems())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.items", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3621
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_27values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_9BaseIndex_26values[] = "BaseIndex.values(self)\nD.values() -> list of D's values";
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_27values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("values (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_26values(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_26values(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("values", 0);
  __Pyx_TraceCall("values", __pyx_f[0], 3621, 0, __PYX_ERR(0, 3621, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3623
 *     def values(self):
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())             # <<<<<<<<<<<<<<
 * 
 *     def update(self, items=None, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itervalues); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3623, __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, 3623, __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, 3623, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3621
 *         return list(self.iteritems())
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """D.values() -> list of D's values"""
 *         return list(self.itervalues())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3625
 *         return list(self.itervalues())
 * 
 *     def update(self, items=None, **kwargs):             # <<<<<<<<<<<<<<
 *         """D.update([E, ]**F) -> None.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_29update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_9BaseIndex_28update[] = "BaseIndex.update(self, items=None, **kwargs)\nD.update([E, ]**F) -> None.\n\n        Update D from dict/iterable E and F.\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_29update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update (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_items,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "update") < 0)) __PYX_ERR(0, 3625, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("update", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3625, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_28update(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self), __pyx_v_items, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_28update(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("update", 0);
  __Pyx_TraceCall("update", __pyx_f[0], 3625, 0, __PYX_ERR(0, 3625, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3630
 *         Update D from dict/iterable E and F.
 *         """
 *         for k, v in items.items():             # <<<<<<<<<<<<<<
 *             self[k] = v
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3630, __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, 3630, __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, 3630, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3630, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3630, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 3630, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3630, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 3630, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3630, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3630, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 3630, __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, 3630, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3630, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3630, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 3630, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 3630, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pysam/libcbcf.pyx":3631
 *         """
 *         for k, v in items.items():
 *             self[k] = v             # <<<<<<<<<<<<<<
 * 
 *         if kwargs:
 */
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_k, __pyx_v_v) < 0)) __PYX_ERR(0, 3631, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3630
 *         Update D from dict/iterable E and F.
 *         """
 *         for k, v in items.items():             # <<<<<<<<<<<<<<
 *             self[k] = v
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":3633
 *             self[k] = v
 * 
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             for k, v in kwargs.items():
 *                 self[k] = v
 */
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3633, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "pysam/libcbcf.pyx":3634
 * 
 *         if kwargs:
 *             for k, v in kwargs.items():             # <<<<<<<<<<<<<<
 *                 self[k] = v
 * 
 */
    __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3634, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 3634, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3634, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 3634, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3634, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 3634, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 3634, __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_3 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3634, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3634, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3634, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L10_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L10_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 3634, __pyx_L1_error)
        __pyx_t_8 = NULL;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L11_unpacking_done;
        __pyx_L10_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, 3634, __pyx_L1_error)
        __pyx_L11_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pysam/libcbcf.pyx":3635
 *         if kwargs:
 *             for k, v in kwargs.items():
 *                 self[k] = v             # <<<<<<<<<<<<<<
 * 
 *     def pop(self, key, default=_nothing):
 */
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_k, __pyx_v_v) < 0)) __PYX_ERR(0, 3635, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3634
 * 
 *         if kwargs:
 *             for k, v in kwargs.items():             # <<<<<<<<<<<<<<
 *                 self[k] = v
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":3633
 *             self[k] = v
 * 
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             for k, v in kwargs.items():
 *                 self[k] = v
 */
  }

  /* "pysam/libcbcf.pyx":3625
 *         return list(self.itervalues())
 * 
 *     def update(self, items=None, **kwargs):             # <<<<<<<<<<<<<<
 *         """D.update([E, ]**F) -> None.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3637
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         try:
 *             value = self[key]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_31pop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_9BaseIndex_30pop[] = "BaseIndex.pop(self, key, default=_nothing)";
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_31pop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pop (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k__182;
    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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "pop") < 0)) __PYX_ERR(0, 3637, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("pop", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3637, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_30pop(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_30pop(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("pop", 0);
  __Pyx_TraceCall("pop", __pyx_f[0], 3637, 0, __PYX_ERR(0, 3637, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3638
 * 
 *     def pop(self, key, default=_nothing):
 *         try:             # <<<<<<<<<<<<<<
 *             value = self[key]
 *             del self[key]
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":3639
 *     def pop(self, key, default=_nothing):
 *         try:
 *             value = self[key]             # <<<<<<<<<<<<<<
 *             del self[key]
 *             return value
 */
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3639, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_value = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "pysam/libcbcf.pyx":3640
 *         try:
 *             value = self[key]
 *             del self[key]             # <<<<<<<<<<<<<<
 *             return value
 *         except KeyError:
 */
      if (unlikely(PyObject_DelItem(((PyObject *)__pyx_v_self), __pyx_v_key) < 0)) __PYX_ERR(0, 3640, __pyx_L3_error)

      /* "pysam/libcbcf.pyx":3641
 *             value = self[key]
 *             del self[key]
 *             return value             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             if default is not _nothing:
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_value);
      __pyx_r = __pyx_v_value;
      goto __pyx_L7_try_return;

      /* "pysam/libcbcf.pyx":3638
 * 
 *     def pop(self, key, default=_nothing):
 *         try:             # <<<<<<<<<<<<<<
 *             value = self[key]
 *             del self[key]
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysam/libcbcf.pyx":3642
 *             del self[key]
 *             return value
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             if default is not _nothing:
 *                 return default
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 3642, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "pysam/libcbcf.pyx":3643
 *             return value
 *         except KeyError:
 *             if default is not _nothing:             # <<<<<<<<<<<<<<
 *                 return default
 *             raise
 */
      __pyx_t_8 = (__pyx_v_default != __pyx_v_5pysam_7libcbcf__nothing);
      __pyx_t_9 = (__pyx_t_8 != 0);
      if (__pyx_t_9) {

        /* "pysam/libcbcf.pyx":3644
 *         except KeyError:
 *             if default is not _nothing:
 *                 return default             # <<<<<<<<<<<<<<
 *             raise
 * 
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_v_default);
        __pyx_r = __pyx_v_default;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L6_except_return;

        /* "pysam/libcbcf.pyx":3643
 *             return value
 *         except KeyError:
 *             if default is not _nothing:             # <<<<<<<<<<<<<<
 *                 return default
 *             raise
 */
      }

      /* "pysam/libcbcf.pyx":3645
 *             if default is not _nothing:
 *                 return default
 *             raise             # <<<<<<<<<<<<<<
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 */
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_6, __pyx_t_7);
      __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; 
      __PYX_ERR(0, 3645, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pysam/libcbcf.pyx":3638
 * 
 *     def pop(self, key, default=_nothing):
 *         try:             # <<<<<<<<<<<<<<
 *             value = self[key]
 *             del self[key]
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "pysam/libcbcf.pyx":3637
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         try:
 *             value = self[key]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.refmap, self.refs)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_33__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_9BaseIndex_32__reduce_cython__[] = "BaseIndex.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_33__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_32__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_32__reduce_cython__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.refmap, self.refs)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->refmap);
  __Pyx_GIVEREF(__pyx_v_self->refmap);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->refmap);
  __Pyx_INCREF(__pyx_v_self->refs);
  __Pyx_GIVEREF(__pyx_v_self->refs);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->refs);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.refmap, self.refs)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":5
 *     state = (self.refmap, self.refs)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.refmap is not None or self.refs is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.refmap, self.refs)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.refmap is not None or self.refs is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_BaseIndex, (type(self), 0xd936de3, None), state
 */
  /*else*/ {
    __pyx_t_2 = (__pyx_v_self->refmap != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->refs != ((PyObject*)Py_None));
    __pyx_t_2 = (__pyx_t_5 != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.refmap is not None or self.refs is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_BaseIndex, (type(self), 0xd936de3, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":11
 *         use_setstate = self.refmap is not None or self.refs is not None
 *     if use_setstate:
 *         return __pyx_unpickle_BaseIndex, (type(self), 0xd936de3, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_BaseIndex, (type(self), 0xd936de3, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_BaseIndex); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_227765731);
    __Pyx_GIVEREF(__pyx_int_227765731);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_227765731);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.refmap is not None or self.refs is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_BaseIndex, (type(self), 0xd936de3, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_BaseIndex, (type(self), 0xd936de3, None), state
 *     else:
 *         return __pyx_unpickle_BaseIndex, (type(self), 0xd936de3, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_BaseIndex__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_BaseIndex); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_227765731);
    __Pyx_GIVEREF(__pyx_int_227765731);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_227765731);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.refmap, self.refs)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_BaseIndex, (type(self), 0xd936de3, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_BaseIndex__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_35__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_9BaseIndex_34__setstate_cython__[] = "BaseIndex.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_9BaseIndex_35__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_9BaseIndex_34__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_9BaseIndex_34__setstate_cython__(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 14, 0, __PYX_ERR(2, 14, __pyx_L1_error));

  /* "(tree fragment)":15
 *         return __pyx_unpickle_BaseIndex, (type(self), 0xd936de3, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_BaseIndex__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_BaseIndex__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_BaseIndex, (type(self), 0xd936de3, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_BaseIndex__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIndex.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3655
 * cdef class BCFIndex(object):
 *     """CSI index data structure for BCF files"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.refs = ()
 *         self.refmap = {}
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_8BCFIndex_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_8BCFIndex_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_5pysam_7libcbcf_8BCFIndex___init__(((struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_8BCFIndex___init__(struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_self) {
  int __pyx_v_n;
  char const **__pyx_v_refs;
  PyObject *__pyx_8genexpr6__pyx_v_i = NULL;
  PyObject *__pyx_8genexpr6__pyx_v_r = NULL;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  struct __pyx_opt_args_5pysam_7libcbcf_char_array_to_tuple __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 3655, 0, __PYX_ERR(0, 3655, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3656
 *     """CSI index data structure for BCF files"""
 *     def __init__(self):
 *         self.refs = ()             # <<<<<<<<<<<<<<
 *         self.refmap = {}
 * 
 */
  __Pyx_INCREF(__pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.refs);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.refs);
  __pyx_v_self->__pyx_base.refs = __pyx_empty_tuple;

  /* "pysam/libcbcf.pyx":3657
 *     def __init__(self):
 *         self.refs = ()
 *         self.refmap = {}             # <<<<<<<<<<<<<<
 * 
 *         if not self.ptr:
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3657, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.refmap);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.refmap);
  __pyx_v_self->__pyx_base.refmap = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":3659
 *         self.refmap = {}
 * 
 *         if not self.ptr:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid index object')
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_self->ptr != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3660
 * 
 *         if not self.ptr:
 *             raise ValueError('Invalid index object')             # <<<<<<<<<<<<<<
 * 
 *         cdef int n
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__183, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3660, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 3660, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3659
 *         self.refmap = {}
 * 
 *         if not self.ptr:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid index object')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3663
 * 
 *         cdef int n
 *         cdef const char **refs = bcf_index_seqnames(self.ptr, self.header.ptr, &n)             # <<<<<<<<<<<<<<
 * 
 *         self.refs = char_array_to_tuple(refs, n, free_after=1) if refs else ()
 */
  __pyx_v_refs = bcf_index_seqnames(__pyx_v_self->ptr, __pyx_v_self->header->ptr, (&__pyx_v_n));

  /* "pysam/libcbcf.pyx":3665
 *         cdef const char **refs = bcf_index_seqnames(self.ptr, self.header.ptr, &n)
 * 
 *         self.refs = char_array_to_tuple(refs, n, free_after=1) if refs else ()             # <<<<<<<<<<<<<<
 *         self.refmap = { r:i for i,r in enumerate(self.refs) }
 * 
 */
  if ((__pyx_v_refs != 0)) {
    __pyx_t_4.__pyx_n = 1;
    __pyx_t_4.free_after = 1;
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf_char_array_to_tuple(__pyx_v_refs, __pyx_v_n, &__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3665, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
  } else {
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_t_1 = __pyx_empty_tuple;
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.refs);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.refs);
  __pyx_v_self->__pyx_base.refs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":3666
 * 
 *         self.refs = char_array_to_tuple(refs, n, free_after=1) if refs else ()
 *         self.refmap = { r:i for i,r in enumerate(self.refs) }             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  { /* enter inner scope */
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3666, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_3 = __pyx_int_0;
    __pyx_t_5 = __pyx_v_self->__pyx_base.refs; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
    for (;;) {
      if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 3666, __pyx_L6_error)
      #else
      __pyx_t_7 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3666, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_XDECREF_SET(__pyx_8genexpr6__pyx_v_r, __pyx_t_7);
      __pyx_t_7 = 0;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_8genexpr6__pyx_v_i, __pyx_t_3);
      __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3666, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3);
      __pyx_t_3 = __pyx_t_7;
      __pyx_t_7 = 0;
      if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_8genexpr6__pyx_v_r, (PyObject*)__pyx_8genexpr6__pyx_v_i))) __PYX_ERR(0, 3666, __pyx_L6_error)
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_i); __pyx_8genexpr6__pyx_v_i = 0;
    __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_r); __pyx_8genexpr6__pyx_v_r = 0;
    goto __pyx_L9_exit_scope;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_i); __pyx_8genexpr6__pyx_v_i = 0;
    __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_r); __pyx_8genexpr6__pyx_v_r = 0;
    goto __pyx_L1_error;
    __pyx_L9_exit_scope:;
  } /* exit inner scope */
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.refmap);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.refmap);
  __pyx_v_self->__pyx_base.refmap = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":3655
 * cdef class BCFIndex(object):
 *     """CSI index data structure for BCF files"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.refs = ()
 *         self.refmap = {}
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.BCFIndex.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_i);
  __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_r);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3668
 *         self.refmap = { r:i for i,r in enumerate(self.refs) }
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.ptr:
 *             hts_idx_destroy(self.ptr)
 */

/* Python wrapper */
static void __pyx_pw_5pysam_7libcbcf_8BCFIndex_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5pysam_7libcbcf_8BCFIndex_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5pysam_7libcbcf_8BCFIndex_2__dealloc__(((struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)__pyx_v_self));

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

static void __pyx_pf_5pysam_7libcbcf_8BCFIndex_2__dealloc__(struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_self) {
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);
  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3668, 0, __PYX_ERR(0, 3668, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3669
 * 
 *     def __dealloc__(self):
 *         if self.ptr:             # <<<<<<<<<<<<<<
 *             hts_idx_destroy(self.ptr)
 *             self.ptr = NULL
 */
  __pyx_t_1 = (__pyx_v_self->ptr != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3670
 *     def __dealloc__(self):
 *         if self.ptr:
 *             hts_idx_destroy(self.ptr)             # <<<<<<<<<<<<<<
 *             self.ptr = NULL
 * 
 */
    hts_idx_destroy(__pyx_v_self->ptr);

    /* "pysam/libcbcf.pyx":3671
 *         if self.ptr:
 *             hts_idx_destroy(self.ptr)
 *             self.ptr = NULL             # <<<<<<<<<<<<<<
 * 
 *     def fetch(self, bcf, contig, start, stop, reopen):
 */
    __pyx_v_self->ptr = NULL;

    /* "pysam/libcbcf.pyx":3669
 * 
 *     def __dealloc__(self):
 *         if self.ptr:             # <<<<<<<<<<<<<<
 *             hts_idx_destroy(self.ptr)
 *             self.ptr = NULL
 */
  }

  /* "pysam/libcbcf.pyx":3668
 *         self.refmap = { r:i for i,r in enumerate(self.refs) }
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.ptr:
 *             hts_idx_destroy(self.ptr)
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pysam.libcbcf.BCFIndex.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
}

/* "pysam/libcbcf.pyx":3673
 *             self.ptr = NULL
 * 
 *     def fetch(self, bcf, contig, start, stop, reopen):             # <<<<<<<<<<<<<<
 *         return BCFIterator(bcf, contig, start, stop, reopen)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_8BCFIndex_5fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_8BCFIndex_4fetch[] = "BCFIndex.fetch(self, bcf, contig, start, stop, reopen)";
static PyObject *__pyx_pw_5pysam_7libcbcf_8BCFIndex_5fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bcf = 0;
  PyObject *__pyx_v_contig = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  PyObject *__pyx_v_reopen = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fetch (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bcf,&__pyx_n_s_contig,&__pyx_n_s_start,&__pyx_n_s_stop,&__pyx_n_s_reopen,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);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bcf)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_contig)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fetch", 1, 5, 5, 1); __PYX_ERR(0, 3673, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_start)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fetch", 1, 5, 5, 2); __PYX_ERR(0, 3673, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stop)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fetch", 1, 5, 5, 3); __PYX_ERR(0, 3673, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reopen)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fetch", 1, 5, 5, 4); __PYX_ERR(0, 3673, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fetch") < 0)) __PYX_ERR(0, 3673, __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_bcf = values[0];
    __pyx_v_contig = values[1];
    __pyx_v_start = values[2];
    __pyx_v_stop = values[3];
    __pyx_v_reopen = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fetch", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3673, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.BCFIndex.fetch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_8BCFIndex_4fetch(((struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)__pyx_v_self), __pyx_v_bcf, __pyx_v_contig, __pyx_v_start, __pyx_v_stop, __pyx_v_reopen);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_8BCFIndex_4fetch(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_self, PyObject *__pyx_v_bcf, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_reopen) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("fetch", 0);
  __Pyx_TraceCall("fetch", __pyx_f[0], 3673, 0, __PYX_ERR(0, 3673, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3674
 * 
 *     def fetch(self, bcf, contig, start, stop, reopen):
 *         return BCFIterator(bcf, contig, start, stop, reopen)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3674, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_bcf);
  __Pyx_GIVEREF(__pyx_v_bcf);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_bcf);
  __Pyx_INCREF(__pyx_v_contig);
  __Pyx_GIVEREF(__pyx_v_contig);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_contig);
  __Pyx_INCREF(__pyx_v_start);
  __Pyx_GIVEREF(__pyx_v_start);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_start);
  __Pyx_INCREF(__pyx_v_stop);
  __Pyx_GIVEREF(__pyx_v_stop);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_stop);
  __Pyx_INCREF(__pyx_v_reopen);
  __Pyx_GIVEREF(__pyx_v_reopen);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_v_reopen);
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5pysam_7libcbcf_BCFIterator), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3674, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3673
 *             self.ptr = NULL
 * 
 *     def fetch(self, bcf, contig, start, stop, reopen):             # <<<<<<<<<<<<<<
 *         return BCFIterator(bcf, contig, start, stop, reopen)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.BCFIndex.fetch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":109
 * 
 * cdef class BCFIndex(BaseIndex):
 *     cdef readonly VariantHeader header             # <<<<<<<<<<<<<<
 *     cdef hts_idx_t *ptr
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_8BCFIndex_6header_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_8BCFIndex_6header_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_8BCFIndex_6header___get__(((struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_8BCFIndex_6header___get__(struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 109, 0, __PYX_ERR(1, 109, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __pyx_r = ((PyObject *)__pyx_v_self->header);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.BCFIndex.header.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_8BCFIndex_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_8BCFIndex_6__reduce_cython__[] = "BCFIndex.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_8BCFIndex_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_8BCFIndex_6__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_8BCFIndex_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__184, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.BCFIndex.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_8BCFIndex_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_8BCFIndex_8__setstate_cython__[] = "BCFIndex.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_8BCFIndex_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_8BCFIndex_8__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_8BCFIndex_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 3, 0, __PYX_ERR(2, 3, __pyx_L1_error));

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__185, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.BCFIndex.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3677
 * 
 * 
 * cdef BCFIndex makeBCFIndex(VariantHeader header, hts_idx_t *idx):             # <<<<<<<<<<<<<<
 *     if not idx:
 *         return None
 */

static struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_f_5pysam_7libcbcf_makeBCFIndex(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header, hts_idx_t *__pyx_v_idx) {
  struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_index = 0;
  struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  __Pyx_RefNannySetupContext("makeBCFIndex", 0);
  __Pyx_TraceCall("makeBCFIndex", __pyx_f[0], 3677, 0, __PYX_ERR(0, 3677, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3678
 * 
 * cdef BCFIndex makeBCFIndex(VariantHeader header, hts_idx_t *idx):
 *     if not idx:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_idx != 0)) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3679
 * cdef BCFIndex makeBCFIndex(VariantHeader header, hts_idx_t *idx):
 *     if not idx:
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     if not header:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_r = ((struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)Py_None); __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":3678
 * 
 * cdef BCFIndex makeBCFIndex(VariantHeader header, hts_idx_t *idx):
 *     if not idx:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3681
 *         return None
 * 
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_header)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3681, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3682
 * 
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     cdef BCFIndex index = BCFIndex.__new__(BCFIndex)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__186, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3682, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3681
 *         return None
 * 
 *     if not header:             # <<<<<<<<<<<<<<
 *         raise ValueError('invalid VariantHeader')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3684
 *         raise ValueError('invalid VariantHeader')
 * 
 *     cdef BCFIndex index = BCFIndex.__new__(BCFIndex)             # <<<<<<<<<<<<<<
 *     index.header = header
 *     index.ptr = idx
 */
  __pyx_t_3 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_BCFIndex(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_BCFIndex), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3684, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_index = ((struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3685
 * 
 *     cdef BCFIndex index = BCFIndex.__new__(BCFIndex)
 *     index.header = header             # <<<<<<<<<<<<<<
 *     index.ptr = idx
 *     index.__init__()
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_header));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_header));
  __Pyx_GOTREF(__pyx_v_index->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_index->header));
  __pyx_v_index->header = __pyx_v_header;

  /* "pysam/libcbcf.pyx":3686
 *     cdef BCFIndex index = BCFIndex.__new__(BCFIndex)
 *     index.header = header
 *     index.ptr = idx             # <<<<<<<<<<<<<<
 *     index.__init__()
 * 
 */
  __pyx_v_index->ptr = __pyx_v_idx;

  /* "pysam/libcbcf.pyx":3687
 *     index.header = header
 *     index.ptr = idx
 *     index.__init__()             # <<<<<<<<<<<<<<
 * 
 *     return index
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_index), __pyx_n_s_init); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3687, __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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3687, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3687, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3689
 *     index.__init__()
 * 
 *     return index             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_index));
  __pyx_r = __pyx_v_index;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3677
 * 
 * 
 * cdef BCFIndex makeBCFIndex(VariantHeader header, hts_idx_t *idx):             # <<<<<<<<<<<<<<
 *     if not idx:
 *         return None
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.makeBCFIndex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_index);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3694
 * cdef class TabixIndex(BaseIndex):
 *     """Tabix index data structure for VCF files"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.refs = ()
 *         self.refmap = {}
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_10TabixIndex_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_10TabixIndex_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_5pysam_7libcbcf_10TabixIndex___init__(((struct __pyx_obj_5pysam_7libcbcf_TabixIndex *)__pyx_v_self));

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

static int __pyx_pf_5pysam_7libcbcf_10TabixIndex___init__(struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_v_self) {
  int __pyx_v_n;
  char const **__pyx_v_refs;
  PyObject *__pyx_8genexpr7__pyx_v_i = NULL;
  PyObject *__pyx_8genexpr7__pyx_v_r = NULL;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  struct __pyx_opt_args_5pysam_7libcbcf_char_array_to_tuple __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 3694, 0, __PYX_ERR(0, 3694, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3695
 *     """Tabix index data structure for VCF files"""
 *     def __init__(self):
 *         self.refs = ()             # <<<<<<<<<<<<<<
 *         self.refmap = {}
 * 
 */
  __Pyx_INCREF(__pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.refs);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.refs);
  __pyx_v_self->__pyx_base.refs = __pyx_empty_tuple;

  /* "pysam/libcbcf.pyx":3696
 *     def __init__(self):
 *         self.refs = ()
 *         self.refmap = {}             # <<<<<<<<<<<<<<
 * 
 *         if not self.ptr:
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3696, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.refmap);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.refmap);
  __pyx_v_self->__pyx_base.refmap = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":3698
 *         self.refmap = {}
 * 
 *         if not self.ptr:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid index object')
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_self->ptr != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3699
 * 
 *         if not self.ptr:
 *             raise ValueError('Invalid index object')             # <<<<<<<<<<<<<<
 * 
 *         cdef int n
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__187, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3699, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 3699, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3698
 *         self.refmap = {}
 * 
 *         if not self.ptr:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid index object')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3702
 * 
 *         cdef int n
 *         cdef const char **refs = tbx_seqnames(self.ptr, &n)             # <<<<<<<<<<<<<<
 * 
 *         self.refs = char_array_to_tuple(refs, n, free_after=1) if refs else ()
 */
  __pyx_v_refs = tbx_seqnames(__pyx_v_self->ptr, (&__pyx_v_n));

  /* "pysam/libcbcf.pyx":3704
 *         cdef const char **refs = tbx_seqnames(self.ptr, &n)
 * 
 *         self.refs = char_array_to_tuple(refs, n, free_after=1) if refs else ()             # <<<<<<<<<<<<<<
 *         self.refmap = { r:i for i,r in enumerate(self.refs) }
 * 
 */
  if ((__pyx_v_refs != 0)) {
    __pyx_t_4.__pyx_n = 1;
    __pyx_t_4.free_after = 1;
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf_char_array_to_tuple(__pyx_v_refs, __pyx_v_n, &__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3704, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
  } else {
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_t_1 = __pyx_empty_tuple;
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.refs);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.refs);
  __pyx_v_self->__pyx_base.refs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":3705
 * 
 *         self.refs = char_array_to_tuple(refs, n, free_after=1) if refs else ()
 *         self.refmap = { r:i for i,r in enumerate(self.refs) }             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  { /* enter inner scope */
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3705, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_3 = __pyx_int_0;
    __pyx_t_5 = __pyx_v_self->__pyx_base.refs; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
    for (;;) {
      if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 3705, __pyx_L6_error)
      #else
      __pyx_t_7 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3705, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_XDECREF_SET(__pyx_8genexpr7__pyx_v_r, __pyx_t_7);
      __pyx_t_7 = 0;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_8genexpr7__pyx_v_i, __pyx_t_3);
      __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3705, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3);
      __pyx_t_3 = __pyx_t_7;
      __pyx_t_7 = 0;
      if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_8genexpr7__pyx_v_r, (PyObject*)__pyx_8genexpr7__pyx_v_i))) __PYX_ERR(0, 3705, __pyx_L6_error)
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_i); __pyx_8genexpr7__pyx_v_i = 0;
    __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_r); __pyx_8genexpr7__pyx_v_r = 0;
    goto __pyx_L9_exit_scope;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_i); __pyx_8genexpr7__pyx_v_i = 0;
    __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_r); __pyx_8genexpr7__pyx_v_r = 0;
    goto __pyx_L1_error;
    __pyx_L9_exit_scope:;
  } /* exit inner scope */
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.refmap);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.refmap);
  __pyx_v_self->__pyx_base.refmap = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":3694
 * cdef class TabixIndex(BaseIndex):
 *     """Tabix index data structure for VCF files"""
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.refs = ()
 *         self.refmap = {}
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysam.libcbcf.TabixIndex.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_i);
  __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_r);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3707
 *         self.refmap = { r:i for i,r in enumerate(self.refs) }
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.ptr:
 *             tbx_destroy(self.ptr)
 */

/* Python wrapper */
static void __pyx_pw_5pysam_7libcbcf_10TabixIndex_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5pysam_7libcbcf_10TabixIndex_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5pysam_7libcbcf_10TabixIndex_2__dealloc__(((struct __pyx_obj_5pysam_7libcbcf_TabixIndex *)__pyx_v_self));

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

static void __pyx_pf_5pysam_7libcbcf_10TabixIndex_2__dealloc__(struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_v_self) {
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);
  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3707, 0, __PYX_ERR(0, 3707, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3708
 * 
 *     def __dealloc__(self):
 *         if self.ptr:             # <<<<<<<<<<<<<<
 *             tbx_destroy(self.ptr)
 *             self.ptr = NULL
 */
  __pyx_t_1 = (__pyx_v_self->ptr != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3709
 *     def __dealloc__(self):
 *         if self.ptr:
 *             tbx_destroy(self.ptr)             # <<<<<<<<<<<<<<
 *             self.ptr = NULL
 * 
 */
    tbx_destroy(__pyx_v_self->ptr);

    /* "pysam/libcbcf.pyx":3710
 *         if self.ptr:
 *             tbx_destroy(self.ptr)
 *             self.ptr = NULL             # <<<<<<<<<<<<<<
 * 
 *     def fetch(self, bcf, contig, start, stop, reopen):
 */
    __pyx_v_self->ptr = NULL;

    /* "pysam/libcbcf.pyx":3708
 * 
 *     def __dealloc__(self):
 *         if self.ptr:             # <<<<<<<<<<<<<<
 *             tbx_destroy(self.ptr)
 *             self.ptr = NULL
 */
  }

  /* "pysam/libcbcf.pyx":3707
 *         self.refmap = { r:i for i,r in enumerate(self.refs) }
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.ptr:
 *             tbx_destroy(self.ptr)
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pysam.libcbcf.TabixIndex.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
}

/* "pysam/libcbcf.pyx":3712
 *             self.ptr = NULL
 * 
 *     def fetch(self, bcf, contig, start, stop, reopen):             # <<<<<<<<<<<<<<
 *         return TabixIterator(bcf, contig, start, stop, reopen)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_10TabixIndex_5fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_10TabixIndex_4fetch[] = "TabixIndex.fetch(self, bcf, contig, start, stop, reopen)";
static PyObject *__pyx_pw_5pysam_7libcbcf_10TabixIndex_5fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bcf = 0;
  PyObject *__pyx_v_contig = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  PyObject *__pyx_v_reopen = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fetch (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bcf,&__pyx_n_s_contig,&__pyx_n_s_start,&__pyx_n_s_stop,&__pyx_n_s_reopen,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);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bcf)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_contig)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fetch", 1, 5, 5, 1); __PYX_ERR(0, 3712, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_start)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fetch", 1, 5, 5, 2); __PYX_ERR(0, 3712, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stop)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fetch", 1, 5, 5, 3); __PYX_ERR(0, 3712, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reopen)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fetch", 1, 5, 5, 4); __PYX_ERR(0, 3712, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fetch") < 0)) __PYX_ERR(0, 3712, __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_bcf = values[0];
    __pyx_v_contig = values[1];
    __pyx_v_start = values[2];
    __pyx_v_stop = values[3];
    __pyx_v_reopen = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fetch", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3712, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.TabixIndex.fetch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_10TabixIndex_4fetch(((struct __pyx_obj_5pysam_7libcbcf_TabixIndex *)__pyx_v_self), __pyx_v_bcf, __pyx_v_contig, __pyx_v_start, __pyx_v_stop, __pyx_v_reopen);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_10TabixIndex_4fetch(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_v_self, PyObject *__pyx_v_bcf, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_reopen) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("fetch", 0);
  __Pyx_TraceCall("fetch", __pyx_f[0], 3712, 0, __PYX_ERR(0, 3712, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3713
 * 
 *     def fetch(self, bcf, contig, start, stop, reopen):
 *         return TabixIterator(bcf, contig, start, stop, reopen)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_bcf);
  __Pyx_GIVEREF(__pyx_v_bcf);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_bcf);
  __Pyx_INCREF(__pyx_v_contig);
  __Pyx_GIVEREF(__pyx_v_contig);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_contig);
  __Pyx_INCREF(__pyx_v_start);
  __Pyx_GIVEREF(__pyx_v_start);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_start);
  __Pyx_INCREF(__pyx_v_stop);
  __Pyx_GIVEREF(__pyx_v_stop);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_stop);
  __Pyx_INCREF(__pyx_v_reopen);
  __Pyx_GIVEREF(__pyx_v_reopen);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_v_reopen);
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5pysam_7libcbcf_TabixIterator), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3712
 *             self.ptr = NULL
 * 
 *     def fetch(self, bcf, contig, start, stop, reopen):             # <<<<<<<<<<<<<<
 *         return TabixIterator(bcf, contig, start, stop, reopen)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.TabixIndex.fetch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_10TabixIndex_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_10TabixIndex_6__reduce_cython__[] = "TabixIndex.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_10TabixIndex_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_10TabixIndex_6__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_TabixIndex *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_10TabixIndex_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__188, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.TabixIndex.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_10TabixIndex_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_10TabixIndex_8__setstate_cython__[] = "TabixIndex.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_10TabixIndex_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_10TabixIndex_8__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_TabixIndex *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_10TabixIndex_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 3, 0, __PYX_ERR(2, 3, __pyx_L1_error));

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__189, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.TabixIndex.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3716
 * 
 * 
 * cdef TabixIndex makeTabixIndex(tbx_t *idx):             # <<<<<<<<<<<<<<
 *     if not idx:
 *         return None
 */

static struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_f_5pysam_7libcbcf_makeTabixIndex(tbx_t *__pyx_v_idx) {
  struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_v_index = 0;
  struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("makeTabixIndex", 0);
  __Pyx_TraceCall("makeTabixIndex", __pyx_f[0], 3716, 0, __PYX_ERR(0, 3716, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3717
 * 
 * cdef TabixIndex makeTabixIndex(tbx_t *idx):
 *     if not idx:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_idx != 0)) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3718
 * cdef TabixIndex makeTabixIndex(tbx_t *idx):
 *     if not idx:
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     cdef TabixIndex index = TabixIndex.__new__(TabixIndex)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_r = ((struct __pyx_obj_5pysam_7libcbcf_TabixIndex *)Py_None); __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":3717
 * 
 * cdef TabixIndex makeTabixIndex(tbx_t *idx):
 *     if not idx:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3720
 *         return None
 * 
 *     cdef TabixIndex index = TabixIndex.__new__(TabixIndex)             # <<<<<<<<<<<<<<
 *     index.ptr = idx
 *     index.__init__()
 */
  __pyx_t_2 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_TabixIndex(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_TabixIndex), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3720, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_v_index = ((struct __pyx_obj_5pysam_7libcbcf_TabixIndex *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":3721
 * 
 *     cdef TabixIndex index = TabixIndex.__new__(TabixIndex)
 *     index.ptr = idx             # <<<<<<<<<<<<<<
 *     index.__init__()
 * 
 */
  __pyx_v_index->ptr = __pyx_v_idx;

  /* "pysam/libcbcf.pyx":3722
 *     cdef TabixIndex index = TabixIndex.__new__(TabixIndex)
 *     index.ptr = idx
 *     index.__init__()             # <<<<<<<<<<<<<<
 * 
 *     return index
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_index), __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3722, __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, 3722, __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, 3722, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":3724
 *     index.__init__()
 * 
 *     return index             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_index));
  __pyx_r = __pyx_v_index;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3716
 * 
 * 
 * cdef TabixIndex makeTabixIndex(tbx_t *idx):             # <<<<<<<<<<<<<<
 *     if not idx:
 *         return None
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.makeTabixIndex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_index);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_12BaseIterator_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_12BaseIterator___reduce_cython__[] = "BaseIterator.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_12BaseIterator_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_12BaseIterator___reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_BaseIterator *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_12BaseIterator___reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BaseIterator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__190, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIterator.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_12BaseIterator_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_12BaseIterator_2__setstate_cython__[] = "BaseIterator.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_12BaseIterator_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_12BaseIterator_2__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_BaseIterator *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_12BaseIterator_2__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BaseIterator *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 3, 0, __PYX_ERR(2, 3, __pyx_L1_error));

  /* "(tree fragment)":4
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__191, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.BaseIterator.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3739
 * # Interal function to clean up after iteration stop or failure.
 * # This would be a nested function if it weren't a cdef function.
 * cdef void _stop_BCFIterator(BCFIterator self, bcf1_t *record):             # <<<<<<<<<<<<<<
 *     bcf_destroy1(record)
 * 
 */

static void __pyx_f_5pysam_7libcbcf__stop_BCFIterator(struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self, bcf1_t *__pyx_v_record) {
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_stop_BCFIterator", 0);
  __Pyx_TraceCall("_stop_BCFIterator", __pyx_f[0], 3739, 0, __PYX_ERR(0, 3739, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3740
 * # This would be a nested function if it weren't a cdef function.
 * cdef void _stop_BCFIterator(BCFIterator self, bcf1_t *record):
 *     bcf_destroy1(record)             # <<<<<<<<<<<<<<
 * 
 *     # destroy iter so future calls to __next__ raise StopIteration
 */
  bcf_destroy1(__pyx_v_record);

  /* "pysam/libcbcf.pyx":3743
 * 
 *     # destroy iter so future calls to __next__ raise StopIteration
 *     bcf_itr_destroy(self.iter)             # <<<<<<<<<<<<<<
 *     self.iter = NULL
 * 
 */
  bcf_itr_destroy(__pyx_v_self->__pyx_base.iter);

  /* "pysam/libcbcf.pyx":3744
 *     # destroy iter so future calls to __next__ raise StopIteration
 *     bcf_itr_destroy(self.iter)
 *     self.iter = NULL             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_self->__pyx_base.iter = NULL;

  /* "pysam/libcbcf.pyx":3739
 * # Interal function to clean up after iteration stop or failure.
 * # This would be a nested function if it weren't a cdef function.
 * cdef void _stop_BCFIterator(BCFIterator self, bcf1_t *record):             # <<<<<<<<<<<<<<
 *     bcf_destroy1(record)
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pysam.libcbcf._stop_BCFIterator", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
}

/* "pysam/libcbcf.pyx":3748
 * 
 * cdef class BCFIterator(BaseIterator):
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):             # <<<<<<<<<<<<<<
 *         if bcf is None:
 *             raise ValueError('bcf must not be None')
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_11BCFIterator_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_11BCFIterator_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_bcf = 0;
  PyObject *__pyx_v_contig = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  PyObject *__pyx_v_reopen = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bcf,&__pyx_n_s_contig,&__pyx_n_s_start,&__pyx_n_s_stop,&__pyx_n_s_reopen,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bcf)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_contig);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stop);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reopen);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 3748, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_bcf = ((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)values[0]);
    __pyx_v_contig = values[1];
    __pyx_v_start = values[2];
    __pyx_v_stop = values[3];
    __pyx_v_reopen = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3748, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.BCFIterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bcf), __pyx_ptype_5pysam_7libcbcf_VariantFile, 1, "bcf", 0))) __PYX_ERR(0, 3748, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11BCFIterator___init__(((struct __pyx_obj_5pysam_7libcbcf_BCFIterator *)__pyx_v_self), __pyx_v_bcf, __pyx_v_contig, __pyx_v_start, __pyx_v_stop, __pyx_v_reopen);

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

static int __pyx_pf_5pysam_7libcbcf_11BCFIterator___init__(struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_bcf, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_reopen) {
  struct __pyx_obj_5pysam_7libcbcf_BCFIndex *__pyx_v_index = 0;
  int __pyx_v_rid;
  int __pyx_v_cstart;
  int __pyx_v_cstop;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __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;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 3748, 0, __PYX_ERR(0, 3748, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3749
 * cdef class BCFIterator(BaseIterator):
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):
 *         if bcf is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('bcf must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_bcf) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3750
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):
 *         if bcf is None:
 *             raise ValueError('bcf must not be None')             # <<<<<<<<<<<<<<
 * 
 *         if contig is None:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__192, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3750, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3749
 * cdef class BCFIterator(BaseIterator):
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):
 *         if bcf is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('bcf must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3752
 *             raise ValueError('bcf must not be None')
 * 
 *         if contig is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('contig must be specified')
 * 
 */
  __pyx_t_2 = (__pyx_v_contig == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3753
 * 
 *         if contig is None:
 *             raise ValueError('contig must be specified')             # <<<<<<<<<<<<<<
 * 
 *         if not isinstance(bcf.index, BCFIndex):
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__193, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3753, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3753, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3752
 *             raise ValueError('bcf must not be None')
 * 
 *         if contig is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('contig must be specified')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3755
 *             raise ValueError('contig must be specified')
 * 
 *         if not isinstance(bcf.index, BCFIndex):             # <<<<<<<<<<<<<<
 *             raise ValueError('bcf index required')
 * 
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_bcf->index);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_t_3, __pyx_ptype_5pysam_7libcbcf_BCFIndex); 
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3756
 * 
 *         if not isinstance(bcf.index, BCFIndex):
 *             raise ValueError('bcf index required')             # <<<<<<<<<<<<<<
 * 
 *         cdef BCFIndex index = bcf.index
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__194, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3756, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3756, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3755
 *             raise ValueError('contig must be specified')
 * 
 *         if not isinstance(bcf.index, BCFIndex):             # <<<<<<<<<<<<<<
 *             raise ValueError('bcf index required')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3758
 *             raise ValueError('bcf index required')
 * 
 *         cdef BCFIndex index = bcf.index             # <<<<<<<<<<<<<<
 * 
 *         self.bcf = bcf
 */
  if (!(likely(((((PyObject *)__pyx_v_bcf->index)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_bcf->index), __pyx_ptype_5pysam_7libcbcf_BCFIndex))))) __PYX_ERR(0, 3758, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)__pyx_v_bcf->index);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_index = ((struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3760
 *         cdef BCFIndex index = bcf.index
 * 
 *         self.bcf = bcf             # <<<<<<<<<<<<<<
 *         self.index = index
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_bcf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_bcf));
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.bcf);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.bcf));
  __pyx_v_self->__pyx_base.bcf = __pyx_v_bcf;

  /* "pysam/libcbcf.pyx":3761
 * 
 *         self.bcf = bcf
 *         self.index = index             # <<<<<<<<<<<<<<
 * 
 *         cdef int rid, cstart, cstop
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_index));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_index));
  __Pyx_GOTREF(__pyx_v_self->index);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->index));
  __pyx_v_self->index = __pyx_v_index;

  /* "pysam/libcbcf.pyx":3765
 *         cdef int rid, cstart, cstop
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             rid = index.refmap[contig]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":3766
 * 
 *         try:
 *             rid = index.refmap[contig]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             # A query for a non-existant contig yields an empty iterator, does not raise an error
 */
      if (unlikely(__pyx_v_index->__pyx_base.refmap == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 3766, __pyx_L6_error)
      }
      __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_index->__pyx_base.refmap, __pyx_v_contig); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3766, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3766, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_rid = __pyx_t_7;

      /* "pysam/libcbcf.pyx":3765
 *         cdef int rid, cstart, cstop
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             rid = index.refmap[contig]
 *         except KeyError:
 */
    }
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L11_try_end;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":3767
 *         try:
 *             rid = index.refmap[contig]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             # A query for a non-existant contig yields an empty iterator, does not raise an error
 *             self.iter = NULL
 */
    __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("pysam.libcbcf.BCFIterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 3767, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_9);

      /* "pysam/libcbcf.pyx":3769
 *         except KeyError:
 *             # A query for a non-existant contig yields an empty iterator, does not raise an error
 *             self.iter = NULL             # <<<<<<<<<<<<<<
 *             return
 * 
 */
      __pyx_v_self->__pyx_base.iter = NULL;

      /* "pysam/libcbcf.pyx":3770
 *             # A query for a non-existant contig yields an empty iterator, does not raise an error
 *             self.iter = NULL
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if reopen:
 */
      __pyx_r = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L9_except_return;
    }
    goto __pyx_L8_except_error;
    __pyx_L8_except_error:;

    /* "pysam/libcbcf.pyx":3765
 *         cdef int rid, cstart, cstop
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             rid = index.refmap[contig]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L9_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L11_try_end:;
  }

  /* "pysam/libcbcf.pyx":3772
 *             return
 * 
 *         if reopen:             # <<<<<<<<<<<<<<
 *             self.bcf = self.bcf.copy()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_reopen); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3772, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":3773
 * 
 *         if reopen:
 *             self.bcf = self.bcf.copy()             # <<<<<<<<<<<<<<
 * 
 *         cstart = start if start is not None else 0
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.bcf), __pyx_n_s_copy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3773, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3773, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3773, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5pysam_7libcbcf_VariantFile))))) __PYX_ERR(0, 3773, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_9);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.bcf);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.bcf));
    __pyx_v_self->__pyx_base.bcf = ((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_t_9);
    __pyx_t_9 = 0;

    /* "pysam/libcbcf.pyx":3772
 *             return
 * 
 *         if reopen:             # <<<<<<<<<<<<<<
 *             self.bcf = self.bcf.copy()
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3775
 *             self.bcf = self.bcf.copy()
 * 
 *         cstart = start if start is not None else 0             # <<<<<<<<<<<<<<
 *         cstop  = stop  if stop  is not None else MAX_POS
 * 
 */
  __pyx_t_2 = (__pyx_v_start != Py_None);
  if ((__pyx_t_2 != 0)) {
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_start); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3775, __pyx_L1_error)
    __pyx_t_7 = __pyx_t_10;
  } else {
    __pyx_t_7 = 0;
  }
  __pyx_v_cstart = __pyx_t_7;

  /* "pysam/libcbcf.pyx":3776
 * 
 *         cstart = start if start is not None else 0
 *         cstop  = stop  if stop  is not None else MAX_POS             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_t_2 = (__pyx_v_stop != Py_None);
  if ((__pyx_t_2 != 0)) {
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_stop); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3776, __pyx_L1_error)
    __pyx_t_7 = __pyx_t_10;
  } else {
    __pyx_t_7 = __pyx_v_5pysam_7libcbcf_MAX_POS;
  }
  __pyx_v_cstop = __pyx_t_7;

  /* "pysam/libcbcf.pyx":3778
 *         cstop  = stop  if stop  is not None else MAX_POS
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self.iter = bcf_itr_queryi(index.ptr, rid, cstart, cstop)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "pysam/libcbcf.pyx":3779
 * 
 *         with nogil:
 *             self.iter = bcf_itr_queryi(index.ptr, rid, cstart, cstop)             # <<<<<<<<<<<<<<
 * 
 *         if not self.iter:
 */
        __pyx_v_self->__pyx_base.iter = bcf_itr_queryi(__pyx_v_index->ptr, __pyx_v_rid, __pyx_v_cstart, __pyx_v_cstop);
      }

      /* "pysam/libcbcf.pyx":3778
 *         cstop  = stop  if stop  is not None else MAX_POS
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self.iter = bcf_itr_queryi(index.ptr, rid, cstart, cstop)
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L17;
        }
        __pyx_L17:;
      }
  }

  /* "pysam/libcbcf.pyx":3781
 *             self.iter = bcf_itr_queryi(index.ptr, rid, cstart, cstop)
 * 
 *         if not self.iter:             # <<<<<<<<<<<<<<
 *             if errno:
 *                 raise IOError(errno, strerror(errno))
 */
  __pyx_t_2 = ((!(__pyx_v_self->__pyx_base.iter != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":3782
 * 
 *         if not self.iter:
 *             if errno:             # <<<<<<<<<<<<<<
 *                 raise IOError(errno, strerror(errno))
 *             else:
 */
    __pyx_t_2 = (errno != 0);
    if (unlikely(__pyx_t_2)) {

      /* "pysam/libcbcf.pyx":3783
 *         if not self.iter:
 *             if errno:
 *                 raise IOError(errno, strerror(errno))             # <<<<<<<<<<<<<<
 *             else:
 *                 raise IOError('unable to fetch {}:{}-{}'.format(contig, start+1, stop))
 */
      __pyx_t_9 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3783, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3783, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3783, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8);
      __pyx_t_9 = 0;
      __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3783, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(0, 3783, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3782
 * 
 *         if not self.iter:
 *             if errno:             # <<<<<<<<<<<<<<
 *                 raise IOError(errno, strerror(errno))
 *             else:
 */
    }

    /* "pysam/libcbcf.pyx":3785
 *                 raise IOError(errno, strerror(errno))
 *             else:
 *                 raise IOError('unable to fetch {}:{}-{}'.format(contig, start+1, stop))             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_unable_to_fetch, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3785, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyInt_AddObjC(__pyx_v_start, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3785, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_11);
          __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[4] = {__pyx_t_11, __pyx_v_contig, __pyx_t_9, __pyx_v_stop};
        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3785, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_v_contig, __pyx_t_9, __pyx_v_stop};
        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3785, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3785, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_11) {
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
        }
        __Pyx_INCREF(__pyx_v_contig);
        __Pyx_GIVEREF(__pyx_v_contig);
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_7, __pyx_v_contig);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_7, __pyx_t_9);
        __Pyx_INCREF(__pyx_v_stop);
        __Pyx_GIVEREF(__pyx_v_stop);
        PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_7, __pyx_v_stop);
        __pyx_t_9 = 0;
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3785, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IOError, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3785, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 3785, __pyx_L1_error)
    }

    /* "pysam/libcbcf.pyx":3781
 *             self.iter = bcf_itr_queryi(index.ptr, rid, cstart, cstop)
 * 
 *         if not self.iter:             # <<<<<<<<<<<<<<
 *             if errno:
 *                 raise IOError(errno, strerror(errno))
 */
  }

  /* "pysam/libcbcf.pyx":3748
 * 
 * cdef class BCFIterator(BaseIterator):
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):             # <<<<<<<<<<<<<<
 *         if bcf is None:
 *             raise ValueError('bcf must not be None')
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("pysam.libcbcf.BCFIterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_index);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3787
 *                 raise IOError('unable to fetch {}:{}-{}'.format(contig, start+1, stop))
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.iter:
 *             bcf_itr_destroy(self.iter)
 */

/* Python wrapper */
static void __pyx_pw_5pysam_7libcbcf_11BCFIterator_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5pysam_7libcbcf_11BCFIterator_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5pysam_7libcbcf_11BCFIterator_2__dealloc__(((struct __pyx_obj_5pysam_7libcbcf_BCFIterator *)__pyx_v_self));

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

static void __pyx_pf_5pysam_7libcbcf_11BCFIterator_2__dealloc__(struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self) {
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);
  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3787, 0, __PYX_ERR(0, 3787, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3788
 * 
 *     def __dealloc__(self):
 *         if self.iter:             # <<<<<<<<<<<<<<
 *             bcf_itr_destroy(self.iter)
 *             self.iter = NULL
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.iter != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3789
 *     def __dealloc__(self):
 *         if self.iter:
 *             bcf_itr_destroy(self.iter)             # <<<<<<<<<<<<<<
 *             self.iter = NULL
 * 
 */
    bcf_itr_destroy(__pyx_v_self->__pyx_base.iter);

    /* "pysam/libcbcf.pyx":3790
 *         if self.iter:
 *             bcf_itr_destroy(self.iter)
 *             self.iter = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
    __pyx_v_self->__pyx_base.iter = NULL;

    /* "pysam/libcbcf.pyx":3788
 * 
 *     def __dealloc__(self):
 *         if self.iter:             # <<<<<<<<<<<<<<
 *             bcf_itr_destroy(self.iter)
 *             self.iter = NULL
 */
  }

  /* "pysam/libcbcf.pyx":3787
 *                 raise IOError('unable to fetch {}:{}-{}'.format(contig, start+1, stop))
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.iter:
 *             bcf_itr_destroy(self.iter)
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pysam.libcbcf.BCFIterator.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
}

/* "pysam/libcbcf.pyx":3792
 *             self.iter = NULL
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11BCFIterator_5__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_11BCFIterator_5__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11BCFIterator_4__iter__(((struct __pyx_obj_5pysam_7libcbcf_BCFIterator *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11BCFIterator_4__iter__(struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 3792, 0, __PYX_ERR(0, 3792, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3793
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3792
 *             self.iter = NULL
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.BCFIterator.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3795
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if not self.iter:
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11BCFIterator_7__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_11BCFIterator_7__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11BCFIterator_6__next__(((struct __pyx_obj_5pysam_7libcbcf_BCFIterator *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11BCFIterator_6__next__(struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self) {
  bcf1_t *__pyx_v_record;
  int __pyx_v_ret;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__next__", 0);
  __Pyx_TraceCall("__next__", __pyx_f[0], 3795, 0, __PYX_ERR(0, 3795, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3796
 * 
 *     def __next__(self):
 *         if not self.iter:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_self->__pyx_base.iter != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3797
 *     def __next__(self):
 *         if not self.iter:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf1_t *record = bcf_init1()
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    __PYX_ERR(0, 3797, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3796
 * 
 *     def __next__(self):
 *         if not self.iter:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3799
 *             raise StopIteration
 * 
 *         cdef bcf1_t *record = bcf_init1()             # <<<<<<<<<<<<<<
 * 
 *         if not record:
 */
  __pyx_v_record = bcf_init1();

  /* "pysam/libcbcf.pyx":3801
 *         cdef bcf1_t *record = bcf_init1()
 * 
 *         if not record:             # <<<<<<<<<<<<<<
 *             raise MemoryError('unable to allocate BCF record')
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_record != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3802
 * 
 *         if not record:
 *             raise MemoryError('unable to allocate BCF record')             # <<<<<<<<<<<<<<
 * 
 *         record.pos = -1
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__195, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3802, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 3802, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3801
 *         cdef bcf1_t *record = bcf_init1()
 * 
 *         if not record:             # <<<<<<<<<<<<<<
 *             raise MemoryError('unable to allocate BCF record')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3804
 *             raise MemoryError('unable to allocate BCF record')
 * 
 *         record.pos = -1             # <<<<<<<<<<<<<<
 *         if self.bcf.drop_samples:
 *             record.max_unpack = BCF_UN_SHR
 */
  __pyx_v_record->pos = -1;

  /* "pysam/libcbcf.pyx":3805
 * 
 *         record.pos = -1
 *         if self.bcf.drop_samples:             # <<<<<<<<<<<<<<
 *             record.max_unpack = BCF_UN_SHR
 * 
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.bcf->drop_samples != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3806
 *         record.pos = -1
 *         if self.bcf.drop_samples:
 *             record.max_unpack = BCF_UN_SHR             # <<<<<<<<<<<<<<
 * 
 *         cdef int ret
 */
    __pyx_v_record->max_unpack = BCF_UN_SHR;

    /* "pysam/libcbcf.pyx":3805
 * 
 *         record.pos = -1
 *         if self.bcf.drop_samples:             # <<<<<<<<<<<<<<
 *             record.max_unpack = BCF_UN_SHR
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3810
 *         cdef int ret
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             ret = bcf_itr_next(self.bcf.htsfile, self.iter, record)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "pysam/libcbcf.pyx":3811
 * 
 *         with nogil:
 *             ret = bcf_itr_next(self.bcf.htsfile, self.iter, record)             # <<<<<<<<<<<<<<
 * 
 *         if ret < 0:
 */
        __pyx_v_ret = bcf_itr_next(__pyx_v_self->__pyx_base.bcf->__pyx_base.htsfile, __pyx_v_self->__pyx_base.iter, __pyx_v_record);
      }

      /* "pysam/libcbcf.pyx":3810
 *         cdef int ret
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             ret = bcf_itr_next(self.bcf.htsfile, self.iter, record)
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L8;
        }
        __pyx_L8:;
      }
  }

  /* "pysam/libcbcf.pyx":3813
 *             ret = bcf_itr_next(self.bcf.htsfile, self.iter, record)
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             _stop_BCFIterator(self, record)
 *             if ret == -1:
 */
  __pyx_t_1 = ((__pyx_v_ret < 0) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3814
 * 
 *         if ret < 0:
 *             _stop_BCFIterator(self, record)             # <<<<<<<<<<<<<<
 *             if ret == -1:
 *                 raise StopIteration
 */
    __pyx_f_5pysam_7libcbcf__stop_BCFIterator(__pyx_v_self, __pyx_v_record);

    /* "pysam/libcbcf.pyx":3815
 *         if ret < 0:
 *             _stop_BCFIterator(self, record)
 *             if ret == -1:             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *             elif ret == -2:
 */
    __pyx_t_1 = ((__pyx_v_ret == -1L) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":3816
 *             _stop_BCFIterator(self, record)
 *             if ret == -1:
 *                 raise StopIteration             # <<<<<<<<<<<<<<
 *             elif ret == -2:
 *                 raise IOError('truncated file')
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
      __PYX_ERR(0, 3816, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3815
 *         if ret < 0:
 *             _stop_BCFIterator(self, record)
 *             if ret == -1:             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *             elif ret == -2:
 */
    }

    /* "pysam/libcbcf.pyx":3817
 *             if ret == -1:
 *                 raise StopIteration
 *             elif ret == -2:             # <<<<<<<<<<<<<<
 *                 raise IOError('truncated file')
 *             elif errno:
 */
    __pyx_t_1 = ((__pyx_v_ret == -2L) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":3818
 *                 raise StopIteration
 *             elif ret == -2:
 *                 raise IOError('truncated file')             # <<<<<<<<<<<<<<
 *             elif errno:
 *                 raise IOError(errno, strerror(errno))
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_tuple__196, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3818, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(0, 3818, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3817
 *             if ret == -1:
 *                 raise StopIteration
 *             elif ret == -2:             # <<<<<<<<<<<<<<
 *                 raise IOError('truncated file')
 *             elif errno:
 */
    }

    /* "pysam/libcbcf.pyx":3819
 *             elif ret == -2:
 *                 raise IOError('truncated file')
 *             elif errno:             # <<<<<<<<<<<<<<
 *                 raise IOError(errno, strerror(errno))
 *             else:
 */
    __pyx_t_1 = (errno != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":3820
 *                 raise IOError('truncated file')
 *             elif errno:
 *                 raise IOError(errno, strerror(errno))             # <<<<<<<<<<<<<<
 *             else:
 *                 raise IOError('unable to fetch next record')
 */
      __pyx_t_2 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 3820, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3819
 *             elif ret == -2:
 *                 raise IOError('truncated file')
 *             elif errno:             # <<<<<<<<<<<<<<
 *                 raise IOError(errno, strerror(errno))
 *             else:
 */
    }

    /* "pysam/libcbcf.pyx":3822
 *                 raise IOError(errno, strerror(errno))
 *             else:
 *                 raise IOError('unable to fetch next record')             # <<<<<<<<<<<<<<
 * 
 *         ret = bcf_subset_format(self.bcf.header.ptr, record)
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_tuple__197, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3822, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 3822, __pyx_L1_error)
    }

    /* "pysam/libcbcf.pyx":3813
 *             ret = bcf_itr_next(self.bcf.htsfile, self.iter, record)
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             _stop_BCFIterator(self, record)
 *             if ret == -1:
 */
  }

  /* "pysam/libcbcf.pyx":3824
 *                 raise IOError('unable to fetch next record')
 * 
 *         ret = bcf_subset_format(self.bcf.header.ptr, record)             # <<<<<<<<<<<<<<
 * 
 *         if ret < 0:
 */
  __pyx_v_ret = bcf_subset_format(__pyx_v_self->__pyx_base.bcf->header->ptr, __pyx_v_record);

  /* "pysam/libcbcf.pyx":3826
 *         ret = bcf_subset_format(self.bcf.header.ptr, record)
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             _stop_BCFIterator(self, record)
 *             raise ValueError('error in bcf_subset_format')
 */
  __pyx_t_1 = ((__pyx_v_ret < 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3827
 * 
 *         if ret < 0:
 *             _stop_BCFIterator(self, record)             # <<<<<<<<<<<<<<
 *             raise ValueError('error in bcf_subset_format')
 * 
 */
    __pyx_f_5pysam_7libcbcf__stop_BCFIterator(__pyx_v_self, __pyx_v_record);

    /* "pysam/libcbcf.pyx":3828
 *         if ret < 0:
 *             _stop_BCFIterator(self, record)
 *             raise ValueError('error in bcf_subset_format')             # <<<<<<<<<<<<<<
 * 
 *         return makeVariantRecord(self.bcf.header, record)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__198, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3828, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3828, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3826
 *         ret = bcf_subset_format(self.bcf.header.ptr, record)
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             _stop_BCFIterator(self, record)
 *             raise ValueError('error in bcf_subset_format')
 */
  }

  /* "pysam/libcbcf.pyx":3830
 *             raise ValueError('error in bcf_subset_format')
 * 
 *         return makeVariantRecord(self.bcf.header, record)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = ((PyObject *)__pyx_v_self->__pyx_base.bcf->header);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantRecord(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_3), __pyx_v_record)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3830, __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;

  /* "pysam/libcbcf.pyx":3795
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if not self.iter:
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.BCFIterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11BCFIterator_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11BCFIterator_8__reduce_cython__[] = "BCFIterator.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_11BCFIterator_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11BCFIterator_8__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_BCFIterator *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11BCFIterator_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__199, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.BCFIterator.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11BCFIterator_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11BCFIterator_10__setstate_cython__[] = "BCFIterator.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_11BCFIterator_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11BCFIterator_10__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_BCFIterator *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11BCFIterator_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_BCFIterator *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 3, 0, __PYX_ERR(2, 3, __pyx_L1_error));

  /* "(tree fragment)":4
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__200, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.BCFIterator.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3834
 * 
 * cdef class TabixIterator(BaseIterator):
 *     def __cinit__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         self.line_buffer.l = 0
 *         self.line_buffer.m = 0
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13TabixIterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13TabixIterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13TabixIterator___cinit__(((struct __pyx_obj_5pysam_7libcbcf_TabixIterator *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_13TabixIterator___cinit__(struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);
  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3834, 0, __PYX_ERR(0, 3834, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3835
 * cdef class TabixIterator(BaseIterator):
 *     def __cinit__(self, *args, **kwargs):
 *         self.line_buffer.l = 0             # <<<<<<<<<<<<<<
 *         self.line_buffer.m = 0
 *         self.line_buffer.s = NULL
 */
  __pyx_v_self->line_buffer.l = 0;

  /* "pysam/libcbcf.pyx":3836
 *     def __cinit__(self, *args, **kwargs):
 *         self.line_buffer.l = 0
 *         self.line_buffer.m = 0             # <<<<<<<<<<<<<<
 *         self.line_buffer.s = NULL
 * 
 */
  __pyx_v_self->line_buffer.m = 0;

  /* "pysam/libcbcf.pyx":3837
 *         self.line_buffer.l = 0
 *         self.line_buffer.m = 0
 *         self.line_buffer.s = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):
 */
  __pyx_v_self->line_buffer.s = NULL;

  /* "pysam/libcbcf.pyx":3834
 * 
 * cdef class TabixIterator(BaseIterator):
 *     def __cinit__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         self.line_buffer.l = 0
 *         self.line_buffer.m = 0
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.TabixIterator.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3839
 *         self.line_buffer.s = NULL
 * 
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):             # <<<<<<<<<<<<<<
 *         if bcf is None:
 *             raise ValueError('bcf must not be None')
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_13TabixIterator_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_13TabixIterator_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_bcf = 0;
  PyObject *__pyx_v_contig = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  PyObject *__pyx_v_reopen = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bcf,&__pyx_n_s_contig,&__pyx_n_s_start,&__pyx_n_s_stop,&__pyx_n_s_reopen,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bcf)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_contig);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stop);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reopen);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 3839, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_bcf = ((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)values[0]);
    __pyx_v_contig = values[1];
    __pyx_v_start = values[2];
    __pyx_v_stop = values[3];
    __pyx_v_reopen = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3839, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.TabixIterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bcf), __pyx_ptype_5pysam_7libcbcf_VariantFile, 1, "bcf", 0))) __PYX_ERR(0, 3839, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13TabixIterator_2__init__(((struct __pyx_obj_5pysam_7libcbcf_TabixIterator *)__pyx_v_self), __pyx_v_bcf, __pyx_v_contig, __pyx_v_start, __pyx_v_stop, __pyx_v_reopen);

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

static int __pyx_pf_5pysam_7libcbcf_13TabixIterator_2__init__(struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_bcf, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_reopen) {
  struct __pyx_obj_5pysam_7libcbcf_TabixIndex *__pyx_v_index = 0;
  int __pyx_v_rid;
  CYTHON_UNUSED int __pyx_v_cstart;
  CYTHON_UNUSED int __pyx_v_cstop;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __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;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 3839, 0, __PYX_ERR(0, 3839, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3840
 * 
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):
 *         if bcf is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('bcf must not be None')
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_bcf) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":3841
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):
 *         if bcf is None:
 *             raise ValueError('bcf must not be None')             # <<<<<<<<<<<<<<
 * 
 *         if not isinstance(bcf.index, TabixIndex):
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__201, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3841, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3841, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3840
 * 
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):
 *         if bcf is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('bcf must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3843
 *             raise ValueError('bcf must not be None')
 * 
 *         if not isinstance(bcf.index, TabixIndex):             # <<<<<<<<<<<<<<
 *             raise ValueError('tabix index required')
 * 
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_bcf->index);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_t_3, __pyx_ptype_5pysam_7libcbcf_TabixIndex); 
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3844
 * 
 *         if not isinstance(bcf.index, TabixIndex):
 *             raise ValueError('tabix index required')             # <<<<<<<<<<<<<<
 * 
 *         cdef TabixIndex index = bcf.index
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__202, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3844, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3844, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3843
 *             raise ValueError('bcf must not be None')
 * 
 *         if not isinstance(bcf.index, TabixIndex):             # <<<<<<<<<<<<<<
 *             raise ValueError('tabix index required')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3846
 *             raise ValueError('tabix index required')
 * 
 *         cdef TabixIndex index = bcf.index             # <<<<<<<<<<<<<<
 * 
 *         self.bcf = bcf
 */
  if (!(likely(((((PyObject *)__pyx_v_bcf->index)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_bcf->index), __pyx_ptype_5pysam_7libcbcf_TabixIndex))))) __PYX_ERR(0, 3846, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)__pyx_v_bcf->index);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_index = ((struct __pyx_obj_5pysam_7libcbcf_TabixIndex *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysam/libcbcf.pyx":3848
 *         cdef TabixIndex index = bcf.index
 * 
 *         self.bcf = bcf             # <<<<<<<<<<<<<<
 *         self.index = index
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_bcf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_bcf));
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.bcf);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.bcf));
  __pyx_v_self->__pyx_base.bcf = __pyx_v_bcf;

  /* "pysam/libcbcf.pyx":3849
 * 
 *         self.bcf = bcf
 *         self.index = index             # <<<<<<<<<<<<<<
 * 
 *         cdef int rid, cstart, cstop
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_index));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_index));
  __Pyx_GOTREF(__pyx_v_self->index);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->index));
  __pyx_v_self->index = __pyx_v_index;

  /* "pysam/libcbcf.pyx":3853
 *         cdef int rid, cstart, cstop
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             rid = index.refmap[contig]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":3854
 * 
 *         try:
 *             rid = index.refmap[contig]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             # A query for a non-existant contig yields an empty iterator, does not raise an error
 */
      if (unlikely(__pyx_v_index->__pyx_base.refmap == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 3854, __pyx_L5_error)
      }
      __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_index->__pyx_base.refmap, __pyx_v_contig); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3854, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3854, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_rid = __pyx_t_7;

      /* "pysam/libcbcf.pyx":3853
 *         cdef int rid, cstart, cstop
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             rid = index.refmap[contig]
 *         except KeyError:
 */
    }
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L10_try_end;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pysam/libcbcf.pyx":3855
 *         try:
 *             rid = index.refmap[contig]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             # A query for a non-existant contig yields an empty iterator, does not raise an error
 *             self.iter = NULL
 */
    __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("pysam.libcbcf.TabixIterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 3855, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_9);

      /* "pysam/libcbcf.pyx":3857
 *         except KeyError:
 *             # A query for a non-existant contig yields an empty iterator, does not raise an error
 *             self.iter = NULL             # <<<<<<<<<<<<<<
 *             return
 * 
 */
      __pyx_v_self->__pyx_base.iter = NULL;

      /* "pysam/libcbcf.pyx":3858
 *             # A query for a non-existant contig yields an empty iterator, does not raise an error
 *             self.iter = NULL
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if reopen:
 */
      __pyx_r = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L8_except_return;
    }
    goto __pyx_L7_except_error;
    __pyx_L7_except_error:;

    /* "pysam/libcbcf.pyx":3853
 *         cdef int rid, cstart, cstop
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             rid = index.refmap[contig]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L8_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L10_try_end:;
  }

  /* "pysam/libcbcf.pyx":3860
 *             return
 * 
 *         if reopen:             # <<<<<<<<<<<<<<
 *             self.bcf = self.bcf.copy()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_reopen); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3860, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3861
 * 
 *         if reopen:
 *             self.bcf = self.bcf.copy()             # <<<<<<<<<<<<<<
 * 
 *         cstart = start if start is not None else 0
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.bcf), __pyx_n_s_copy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3861, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3861, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3861, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5pysam_7libcbcf_VariantFile))))) __PYX_ERR(0, 3861, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_9);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.bcf);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.bcf));
    __pyx_v_self->__pyx_base.bcf = ((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_t_9);
    __pyx_t_9 = 0;

    /* "pysam/libcbcf.pyx":3860
 *             return
 * 
 *         if reopen:             # <<<<<<<<<<<<<<
 *             self.bcf = self.bcf.copy()
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3863
 *             self.bcf = self.bcf.copy()
 * 
 *         cstart = start if start is not None else 0             # <<<<<<<<<<<<<<
 *         cstop  = stop  if stop  is not None else MAX_POS
 * 
 */
  __pyx_t_1 = (__pyx_v_start != Py_None);
  if ((__pyx_t_1 != 0)) {
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_start); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3863, __pyx_L1_error)
    __pyx_t_7 = __pyx_t_10;
  } else {
    __pyx_t_7 = 0;
  }
  __pyx_v_cstart = __pyx_t_7;

  /* "pysam/libcbcf.pyx":3864
 * 
 *         cstart = start if start is not None else 0
 *         cstop  = stop  if stop  is not None else MAX_POS             # <<<<<<<<<<<<<<
 * 
 *         self.iter = tbx_itr_queryi(index.ptr, rid, start, stop)
 */
  __pyx_t_1 = (__pyx_v_stop != Py_None);
  if ((__pyx_t_1 != 0)) {
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_stop); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3864, __pyx_L1_error)
    __pyx_t_7 = __pyx_t_10;
  } else {
    __pyx_t_7 = __pyx_v_5pysam_7libcbcf_MAX_POS;
  }
  __pyx_v_cstop = __pyx_t_7;

  /* "pysam/libcbcf.pyx":3866
 *         cstop  = stop  if stop  is not None else MAX_POS
 * 
 *         self.iter = tbx_itr_queryi(index.ptr, rid, start, stop)             # <<<<<<<<<<<<<<
 * 
 *         if not self.iter:
 */
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_start); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3866, __pyx_L1_error)
  __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_stop); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3866, __pyx_L1_error)
  __pyx_v_self->__pyx_base.iter = tbx_itr_queryi(__pyx_v_index->ptr, __pyx_v_rid, __pyx_t_7, __pyx_t_10);

  /* "pysam/libcbcf.pyx":3868
 *         self.iter = tbx_itr_queryi(index.ptr, rid, start, stop)
 * 
 *         if not self.iter:             # <<<<<<<<<<<<<<
 *             if errno:
 *                 raise IOError(errno, strerror(errno))
 */
  __pyx_t_1 = ((!(__pyx_v_self->__pyx_base.iter != 0)) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3869
 * 
 *         if not self.iter:
 *             if errno:             # <<<<<<<<<<<<<<
 *                 raise IOError(errno, strerror(errno))
 *             else:
 */
    __pyx_t_1 = (errno != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":3870
 *         if not self.iter:
 *             if errno:
 *                 raise IOError(errno, strerror(errno))             # <<<<<<<<<<<<<<
 *             else:
 *                 raise IOError('unable to fetch {}:{}-{}'.format(contig, start+1, stop))
 */
      __pyx_t_9 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3870, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3870, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3870, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8);
      __pyx_t_9 = 0;
      __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3870, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(0, 3870, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3869
 * 
 *         if not self.iter:
 *             if errno:             # <<<<<<<<<<<<<<
 *                 raise IOError(errno, strerror(errno))
 *             else:
 */
    }

    /* "pysam/libcbcf.pyx":3872
 *                 raise IOError(errno, strerror(errno))
 *             else:
 *                 raise IOError('unable to fetch {}:{}-{}'.format(contig, start+1, stop))             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_unable_to_fetch, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyInt_AddObjC(__pyx_v_start, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_v_contig, __pyx_t_9, __pyx_v_stop};
        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3872, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_v_contig, __pyx_t_9, __pyx_v_stop};
        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3872, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3872, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_11) {
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
        }
        __Pyx_INCREF(__pyx_v_contig);
        __Pyx_GIVEREF(__pyx_v_contig);
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_10, __pyx_v_contig);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_10, __pyx_t_9);
        __Pyx_INCREF(__pyx_v_stop);
        __Pyx_GIVEREF(__pyx_v_stop);
        PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_10, __pyx_v_stop);
        __pyx_t_9 = 0;
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3872, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IOError, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 3872, __pyx_L1_error)
    }

    /* "pysam/libcbcf.pyx":3868
 *         self.iter = tbx_itr_queryi(index.ptr, rid, start, stop)
 * 
 *         if not self.iter:             # <<<<<<<<<<<<<<
 *             if errno:
 *                 raise IOError(errno, strerror(errno))
 */
  }

  /* "pysam/libcbcf.pyx":3839
 *         self.line_buffer.s = NULL
 * 
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):             # <<<<<<<<<<<<<<
 *         if bcf is None:
 *             raise ValueError('bcf must not be None')
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("pysam.libcbcf.TabixIterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_index);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3874
 *                 raise IOError('unable to fetch {}:{}-{}'.format(contig, start+1, stop))
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.iter:
 *             tbx_itr_destroy(self.iter)
 */

/* Python wrapper */
static void __pyx_pw_5pysam_7libcbcf_13TabixIterator_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5pysam_7libcbcf_13TabixIterator_5__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5pysam_7libcbcf_13TabixIterator_4__dealloc__(((struct __pyx_obj_5pysam_7libcbcf_TabixIterator *)__pyx_v_self));

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

static void __pyx_pf_5pysam_7libcbcf_13TabixIterator_4__dealloc__(struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self) {
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);
  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3874, 0, __PYX_ERR(0, 3874, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3875
 * 
 *     def __dealloc__(self):
 *         if self.iter:             # <<<<<<<<<<<<<<
 *             tbx_itr_destroy(self.iter)
 *             self.iter = NULL
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.iter != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3876
 *     def __dealloc__(self):
 *         if self.iter:
 *             tbx_itr_destroy(self.iter)             # <<<<<<<<<<<<<<
 *             self.iter = NULL
 * 
 */
    tbx_itr_destroy(__pyx_v_self->__pyx_base.iter);

    /* "pysam/libcbcf.pyx":3877
 *         if self.iter:
 *             tbx_itr_destroy(self.iter)
 *             self.iter = NULL             # <<<<<<<<<<<<<<
 * 
 *         if self.line_buffer.m:
 */
    __pyx_v_self->__pyx_base.iter = NULL;

    /* "pysam/libcbcf.pyx":3875
 * 
 *     def __dealloc__(self):
 *         if self.iter:             # <<<<<<<<<<<<<<
 *             tbx_itr_destroy(self.iter)
 *             self.iter = NULL
 */
  }

  /* "pysam/libcbcf.pyx":3879
 *             self.iter = NULL
 * 
 *         if self.line_buffer.m:             # <<<<<<<<<<<<<<
 *             free(self.line_buffer.s)
 * 
 */
  __pyx_t_1 = (__pyx_v_self->line_buffer.m != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3880
 * 
 *         if self.line_buffer.m:
 *             free(self.line_buffer.s)             # <<<<<<<<<<<<<<
 * 
 *         self.line_buffer.l = 0
 */
    free(__pyx_v_self->line_buffer.s);

    /* "pysam/libcbcf.pyx":3879
 *             self.iter = NULL
 * 
 *         if self.line_buffer.m:             # <<<<<<<<<<<<<<
 *             free(self.line_buffer.s)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3882
 *             free(self.line_buffer.s)
 * 
 *         self.line_buffer.l = 0             # <<<<<<<<<<<<<<
 *         self.line_buffer.m = 0
 *         self.line_buffer.s = NULL
 */
  __pyx_v_self->line_buffer.l = 0;

  /* "pysam/libcbcf.pyx":3883
 * 
 *         self.line_buffer.l = 0
 *         self.line_buffer.m = 0             # <<<<<<<<<<<<<<
 *         self.line_buffer.s = NULL
 * 
 */
  __pyx_v_self->line_buffer.m = 0;

  /* "pysam/libcbcf.pyx":3884
 *         self.line_buffer.l = 0
 *         self.line_buffer.m = 0
 *         self.line_buffer.s = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_v_self->line_buffer.s = NULL;

  /* "pysam/libcbcf.pyx":3874
 *                 raise IOError('unable to fetch {}:{}-{}'.format(contig, start+1, stop))
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.iter:
 *             tbx_itr_destroy(self.iter)
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pysam.libcbcf.TabixIterator.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
}

/* "pysam/libcbcf.pyx":3886
 *         self.line_buffer.s = NULL
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13TabixIterator_7__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13TabixIterator_7__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13TabixIterator_6__iter__(((struct __pyx_obj_5pysam_7libcbcf_TabixIterator *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13TabixIterator_6__iter__(struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 3886, 0, __PYX_ERR(0, 3886, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3887
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":3886
 *         self.line_buffer.s = NULL
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.TabixIterator.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3889
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if not self.iter:
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13TabixIterator_9__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_13TabixIterator_9__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13TabixIterator_8__next__(((struct __pyx_obj_5pysam_7libcbcf_TabixIterator *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13TabixIterator_8__next__(struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self) {
  int __pyx_v_ret;
  bcf1_t *__pyx_v_record;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__next__", 0);
  __Pyx_TraceCall("__next__", __pyx_f[0], 3889, 0, __PYX_ERR(0, 3889, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3890
 * 
 *     def __next__(self):
 *         if not self.iter:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_self->__pyx_base.iter != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3891
 *     def __next__(self):
 *         if not self.iter:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 * 
 *         cdef int ret
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    __PYX_ERR(0, 3891, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3890
 * 
 *     def __next__(self):
 *         if not self.iter:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3895
 *         cdef int ret
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             ret = tbx_itr_next(self.bcf.htsfile, self.index.ptr, self.iter, &self.line_buffer)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "pysam/libcbcf.pyx":3896
 * 
 *         with nogil:
 *             ret = tbx_itr_next(self.bcf.htsfile, self.index.ptr, self.iter, &self.line_buffer)             # <<<<<<<<<<<<<<
 * 
 *         if ret < 0:
 */
        __pyx_v_ret = tbx_itr_next(__pyx_v_self->__pyx_base.bcf->__pyx_base.htsfile, __pyx_v_self->index->ptr, __pyx_v_self->__pyx_base.iter, (&__pyx_v_self->line_buffer));
      }

      /* "pysam/libcbcf.pyx":3895
 *         cdef int ret
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             ret = tbx_itr_next(self.bcf.htsfile, self.index.ptr, self.iter, &self.line_buffer)
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L6;
        }
        __pyx_L6:;
      }
  }

  /* "pysam/libcbcf.pyx":3898
 *             ret = tbx_itr_next(self.bcf.htsfile, self.index.ptr, self.iter, &self.line_buffer)
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             tbx_itr_destroy(self.iter)
 *             self.iter = NULL
 */
  __pyx_t_1 = ((__pyx_v_ret < 0) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3899
 * 
 *         if ret < 0:
 *             tbx_itr_destroy(self.iter)             # <<<<<<<<<<<<<<
 *             self.iter = NULL
 *             if ret == -1:
 */
    tbx_itr_destroy(__pyx_v_self->__pyx_base.iter);

    /* "pysam/libcbcf.pyx":3900
 *         if ret < 0:
 *             tbx_itr_destroy(self.iter)
 *             self.iter = NULL             # <<<<<<<<<<<<<<
 *             if ret == -1:
 *                 raise StopIteration
 */
    __pyx_v_self->__pyx_base.iter = NULL;

    /* "pysam/libcbcf.pyx":3901
 *             tbx_itr_destroy(self.iter)
 *             self.iter = NULL
 *             if ret == -1:             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *             elif ret == -2:
 */
    __pyx_t_1 = ((__pyx_v_ret == -1L) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":3902
 *             self.iter = NULL
 *             if ret == -1:
 *                 raise StopIteration             # <<<<<<<<<<<<<<
 *             elif ret == -2:
 *                 raise IOError('truncated file')
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
      __PYX_ERR(0, 3902, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3901
 *             tbx_itr_destroy(self.iter)
 *             self.iter = NULL
 *             if ret == -1:             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *             elif ret == -2:
 */
    }

    /* "pysam/libcbcf.pyx":3903
 *             if ret == -1:
 *                 raise StopIteration
 *             elif ret == -2:             # <<<<<<<<<<<<<<
 *                 raise IOError('truncated file')
 *             elif errno:
 */
    __pyx_t_1 = ((__pyx_v_ret == -2L) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":3904
 *                 raise StopIteration
 *             elif ret == -2:
 *                 raise IOError('truncated file')             # <<<<<<<<<<<<<<
 *             elif errno:
 *                 raise IOError(errno, strerror(errno))
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_tuple__203, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3904, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(0, 3904, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3903
 *             if ret == -1:
 *                 raise StopIteration
 *             elif ret == -2:             # <<<<<<<<<<<<<<
 *                 raise IOError('truncated file')
 *             elif errno:
 */
    }

    /* "pysam/libcbcf.pyx":3905
 *             elif ret == -2:
 *                 raise IOError('truncated file')
 *             elif errno:             # <<<<<<<<<<<<<<
 *                 raise IOError(errno, strerror(errno))
 *             else:
 */
    __pyx_t_1 = (errno != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":3906
 *                 raise IOError('truncated file')
 *             elif errno:
 *                 raise IOError(errno, strerror(errno))             # <<<<<<<<<<<<<<
 *             else:
 *                 raise IOError('unable to fetch next record')
 */
      __pyx_t_2 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3906, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3906, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3906, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3906, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 3906, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":3905
 *             elif ret == -2:
 *                 raise IOError('truncated file')
 *             elif errno:             # <<<<<<<<<<<<<<
 *                 raise IOError(errno, strerror(errno))
 *             else:
 */
    }

    /* "pysam/libcbcf.pyx":3908
 *                 raise IOError(errno, strerror(errno))
 *             else:
 *                 raise IOError('unable to fetch next record')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf1_t *record = bcf_init1()
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_tuple__204, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3908, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 3908, __pyx_L1_error)
    }

    /* "pysam/libcbcf.pyx":3898
 *             ret = tbx_itr_next(self.bcf.htsfile, self.index.ptr, self.iter, &self.line_buffer)
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             tbx_itr_destroy(self.iter)
 *             self.iter = NULL
 */
  }

  /* "pysam/libcbcf.pyx":3910
 *                 raise IOError('unable to fetch next record')
 * 
 *         cdef bcf1_t *record = bcf_init1()             # <<<<<<<<<<<<<<
 * 
 *         if not record:
 */
  __pyx_v_record = bcf_init1();

  /* "pysam/libcbcf.pyx":3912
 *         cdef bcf1_t *record = bcf_init1()
 * 
 *         if not record:             # <<<<<<<<<<<<<<
 *             raise MemoryError('unable to allocate BCF record')
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_record != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3913
 * 
 *         if not record:
 *             raise MemoryError('unable to allocate BCF record')             # <<<<<<<<<<<<<<
 * 
 *         record.pos = -1
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__205, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3913, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3913, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3912
 *         cdef bcf1_t *record = bcf_init1()
 * 
 *         if not record:             # <<<<<<<<<<<<<<
 *             raise MemoryError('unable to allocate BCF record')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3915
 *             raise MemoryError('unable to allocate BCF record')
 * 
 *         record.pos = -1             # <<<<<<<<<<<<<<
 *         if self.bcf.drop_samples:
 *             record.max_unpack = BCF_UN_SHR
 */
  __pyx_v_record->pos = -1;

  /* "pysam/libcbcf.pyx":3916
 * 
 *         record.pos = -1
 *         if self.bcf.drop_samples:             # <<<<<<<<<<<<<<
 *             record.max_unpack = BCF_UN_SHR
 * 
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.bcf->drop_samples != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":3917
 *         record.pos = -1
 *         if self.bcf.drop_samples:
 *             record.max_unpack = BCF_UN_SHR             # <<<<<<<<<<<<<<
 * 
 *         ret = vcf_parse1(&self.line_buffer, self.bcf.header.ptr, record)
 */
    __pyx_v_record->max_unpack = BCF_UN_SHR;

    /* "pysam/libcbcf.pyx":3916
 * 
 *         record.pos = -1
 *         if self.bcf.drop_samples:             # <<<<<<<<<<<<<<
 *             record.max_unpack = BCF_UN_SHR
 * 
 */
  }

  /* "pysam/libcbcf.pyx":3919
 *             record.max_unpack = BCF_UN_SHR
 * 
 *         ret = vcf_parse1(&self.line_buffer, self.bcf.header.ptr, record)             # <<<<<<<<<<<<<<
 * 
 *         # FIXME: stop iteration on parse failure?
 */
  __pyx_v_ret = vcf_parse1((&__pyx_v_self->line_buffer), __pyx_v_self->__pyx_base.bcf->header->ptr, __pyx_v_record);

  /* "pysam/libcbcf.pyx":3922
 * 
 *         # FIXME: stop iteration on parse failure?
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             bcf_destroy1(record)
 *             raise ValueError('error in vcf_parse')
 */
  __pyx_t_1 = ((__pyx_v_ret < 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":3923
 *         # FIXME: stop iteration on parse failure?
 *         if ret < 0:
 *             bcf_destroy1(record)             # <<<<<<<<<<<<<<
 *             raise ValueError('error in vcf_parse')
 * 
 */
    bcf_destroy1(__pyx_v_record);

    /* "pysam/libcbcf.pyx":3924
 *         if ret < 0:
 *             bcf_destroy1(record)
 *             raise ValueError('error in vcf_parse')             # <<<<<<<<<<<<<<
 * 
 *         return makeVariantRecord(self.bcf.header, record)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__206, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3924, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3924, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":3922
 * 
 *         # FIXME: stop iteration on parse failure?
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             bcf_destroy1(record)
 *             raise ValueError('error in vcf_parse')
 */
  }

  /* "pysam/libcbcf.pyx":3926
 *             raise ValueError('error in vcf_parse')
 * 
 *         return makeVariantRecord(self.bcf.header, record)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = ((PyObject *)__pyx_v_self->__pyx_base.bcf->header);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantRecord(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_3), __pyx_v_record)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3926, __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;

  /* "pysam/libcbcf.pyx":3889
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if not self.iter:
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.TabixIterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13TabixIterator_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13TabixIterator_10__reduce_cython__[] = "TabixIterator.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_13TabixIterator_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13TabixIterator_10__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_TabixIterator *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13TabixIterator_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__207, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.TabixIterator.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13TabixIterator_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_13TabixIterator_12__setstate_cython__[] = "TabixIterator.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_13TabixIterator_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_13TabixIterator_12__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_TabixIterator *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_13TabixIterator_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_TabixIterator *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 3, 0, __PYX_ERR(2, 3, __pyx_L1_error));

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__208, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.TabixIterator.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":3998
 * 
 *     """
 *     def __cinit__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         self.htsfile = NULL
 * 
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_11VariantFile_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_11VariantFile_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 1))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile___cinit__(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_11VariantFile___cinit__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);
  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3998, 0, __PYX_ERR(0, 3998, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":3999
 *     """
 *     def __cinit__(self, *args, **kwargs):
 *         self.htsfile = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, *args, **kwargs):
 */
  __pyx_v_self->__pyx_base.htsfile = NULL;

  /* "pysam/libcbcf.pyx":3998
 * 
 *     """
 *     def __cinit__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         self.htsfile = NULL
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4001
 *         self.htsfile = NULL
 * 
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         self.header         = None
 *         self.index          = None
 */

/* Python wrapper */
static int __pyx_pw_5pysam_7libcbcf_11VariantFile_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5pysam_7libcbcf_11VariantFile_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  if (unlikely(__pyx_kwds)) {
    __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return -1;
    __Pyx_GOTREF(__pyx_v_kwargs);
  } else {
    __pyx_v_kwargs = NULL;
  }
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_2__init__(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_5pysam_7libcbcf_11VariantFile_2__init__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 4001, 0, __PYX_ERR(0, 4001, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":4002
 * 
 *     def __init__(self, *args, **kwargs):
 *         self.header         = None             # <<<<<<<<<<<<<<
 *         self.index          = None
 *         self.filename       = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->header));
  __pyx_v_self->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None);

  /* "pysam/libcbcf.pyx":4003
 *     def __init__(self, *args, **kwargs):
 *         self.header         = None
 *         self.index          = None             # <<<<<<<<<<<<<<
 *         self.filename       = None
 *         self.mode           = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->index);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->index));
  __pyx_v_self->index = ((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)Py_None);

  /* "pysam/libcbcf.pyx":4004
 *         self.header         = None
 *         self.index          = None
 *         self.filename       = None             # <<<<<<<<<<<<<<
 *         self.mode           = None
 *         self.threads        = 1
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.filename);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.filename);
  __pyx_v_self->__pyx_base.filename = Py_None;

  /* "pysam/libcbcf.pyx":4005
 *         self.index          = None
 *         self.filename       = None
 *         self.mode           = None             # <<<<<<<<<<<<<<
 *         self.threads        = 1
 *         self.index_filename = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.mode);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.mode);
  __pyx_v_self->__pyx_base.mode = Py_None;

  /* "pysam/libcbcf.pyx":4006
 *         self.filename       = None
 *         self.mode           = None
 *         self.threads        = 1             # <<<<<<<<<<<<<<
 *         self.index_filename = None
 *         self.is_stream      = False
 */
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.threads);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.threads);
  __pyx_v_self->__pyx_base.threads = __pyx_int_1;

  /* "pysam/libcbcf.pyx":4007
 *         self.mode           = None
 *         self.threads        = 1
 *         self.index_filename = None             # <<<<<<<<<<<<<<
 *         self.is_stream      = False
 *         self.is_remote      = False
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.index_filename);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.index_filename);
  __pyx_v_self->__pyx_base.index_filename = Py_None;

  /* "pysam/libcbcf.pyx":4008
 *         self.threads        = 1
 *         self.index_filename = None
 *         self.is_stream      = False             # <<<<<<<<<<<<<<
 *         self.is_remote      = False
 *         self.is_reading     = False
 */
  __pyx_v_self->__pyx_base.is_stream = 0;

  /* "pysam/libcbcf.pyx":4009
 *         self.index_filename = None
 *         self.is_stream      = False
 *         self.is_remote      = False             # <<<<<<<<<<<<<<
 *         self.is_reading     = False
 *         self.drop_samples   = False
 */
  __pyx_v_self->__pyx_base.is_remote = 0;

  /* "pysam/libcbcf.pyx":4010
 *         self.is_stream      = False
 *         self.is_remote      = False
 *         self.is_reading     = False             # <<<<<<<<<<<<<<
 *         self.drop_samples   = False
 *         self.header_written = False
 */
  __pyx_v_self->is_reading = 0;

  /* "pysam/libcbcf.pyx":4011
 *         self.is_remote      = False
 *         self.is_reading     = False
 *         self.drop_samples   = False             # <<<<<<<<<<<<<<
 *         self.header_written = False
 *         self.start_offset   = -1
 */
  __pyx_v_self->drop_samples = 0;

  /* "pysam/libcbcf.pyx":4012
 *         self.is_reading     = False
 *         self.drop_samples   = False
 *         self.header_written = False             # <<<<<<<<<<<<<<
 *         self.start_offset   = -1
 * 
 */
  __pyx_v_self->header_written = 0;

  /* "pysam/libcbcf.pyx":4013
 *         self.drop_samples   = False
 *         self.header_written = False
 *         self.start_offset   = -1             # <<<<<<<<<<<<<<
 * 
 *         self.open(*args, **kwargs)
 */
  __pyx_v_self->__pyx_base.start_offset = -1L;

  /* "pysam/libcbcf.pyx":4015
 *         self.start_offset   = -1
 * 
 *         self.open(*args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":4001
 *         self.htsfile = NULL
 * 
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         self.header         = None
 *         self.index          = None
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4017
 *         self.open(*args, **kwargs)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if not self.htsfile or not self.header:
 *             return
 */

/* Python wrapper */
static void __pyx_pw_5pysam_7libcbcf_11VariantFile_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5pysam_7libcbcf_11VariantFile_5__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5pysam_7libcbcf_11VariantFile_4__dealloc__(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self));

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

static void __pyx_pf_5pysam_7libcbcf_11VariantFile_4__dealloc__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self) {
  int __pyx_v_ret;
  __Pyx_TraceDeclarations
  __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("__dealloc__", 0);
  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 4017, 0, __PYX_ERR(0, 4017, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":4018
 * 
 *     def __dealloc__(self):
 *         if not self.htsfile or not self.header:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_self->__pyx_base.htsfile != 0)) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->header)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 4018, __pyx_L1_error)
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":4019
 *     def __dealloc__(self):
 *         if not self.htsfile or not self.header:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # Write header if no records were written
 */
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":4018
 * 
 *     def __dealloc__(self):
 *         if not self.htsfile or not self.header:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4022
 * 
 *         # Write header if no records were written
 *         if self.htsfile.is_write and not self.header_written:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 */
  __pyx_t_3 = (__pyx_v_self->__pyx_base.htsfile->is_write != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_3 = ((!(__pyx_v_self->header_written != 0)) != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":4023
 *         # Write header if no records were written
 *         if self.htsfile.is_write and not self.header_written:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 * 
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        __Pyx_FastGIL_Remember();
        #endif
        /*try:*/ {

          /* "pysam/libcbcf.pyx":4024
 *         if self.htsfile.is_write and not self.header_written:
 *             with nogil:
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)             # <<<<<<<<<<<<<<
 * 
 *         cdef int ret = hts_close(self.htsfile)
 */
          (void)(bcf_hdr_write(__pyx_v_self->__pyx_base.htsfile, __pyx_v_self->header->ptr));
        }

        /* "pysam/libcbcf.pyx":4023
 *         # Write header if no records were written
 *         if self.htsfile.is_write and not self.header_written:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 * 
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L11;
          }
          __pyx_L11:;
        }
    }

    /* "pysam/libcbcf.pyx":4022
 * 
 *         # Write header if no records were written
 *         if self.htsfile.is_write and not self.header_written:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 */
  }

  /* "pysam/libcbcf.pyx":4026
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 * 
 *         cdef int ret = hts_close(self.htsfile)             # <<<<<<<<<<<<<<
 *         self.htsfile = NULL
 *         self.header = self.index = None
 */
  __pyx_v_ret = hts_close(__pyx_v_self->__pyx_base.htsfile);

  /* "pysam/libcbcf.pyx":4027
 * 
 *         cdef int ret = hts_close(self.htsfile)
 *         self.htsfile = NULL             # <<<<<<<<<<<<<<
 *         self.header = self.index = None
 * 
 */
  __pyx_v_self->__pyx_base.htsfile = NULL;

  /* "pysam/libcbcf.pyx":4028
 *         cdef int ret = hts_close(self.htsfile)
 *         self.htsfile = NULL
 *         self.header = self.index = None             # <<<<<<<<<<<<<<
 * 
 *         if ret < 0:
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->header));
  __pyx_v_self->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->index);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->index));
  __pyx_v_self->index = ((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)Py_None);

  /* "pysam/libcbcf.pyx":4030
 *         self.header = self.index = None
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             global errno
 *             if errno == EPIPE:
 */
  __pyx_t_1 = ((__pyx_v_ret < 0) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":4032
 *         if ret < 0:
 *             global errno
 *             if errno == EPIPE:             # <<<<<<<<<<<<<<
 *                 errno = 0
 *             else:
 */
    __pyx_t_1 = ((errno == EPIPE) != 0);
    if (likely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":4033
 *             global errno
 *             if errno == EPIPE:
 *                 errno = 0             # <<<<<<<<<<<<<<
 *             else:
 *                 raise IOError(errno, force_str(strerror(errno)))
 */
      errno = 0;

      /* "pysam/libcbcf.pyx":4032
 *         if ret < 0:
 *             global errno
 *             if errno == EPIPE:             # <<<<<<<<<<<<<<
 *                 errno = 0
 *             else:
 */
      goto __pyx_L13;
    }

    /* "pysam/libcbcf.pyx":4035
 *                 errno = 0
 *             else:
 *                 raise IOError(errno, force_str(strerror(errno)))             # <<<<<<<<<<<<<<
 * 
 *     def close(self):
 */
    /*else*/ {
      __pyx_t_4 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4035, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4035, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __pyx_f_5pysam_9libcutils_force_str(__pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4035, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4035, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
      __pyx_t_4 = 0;
      __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4035, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_ERR(0, 4035, __pyx_L1_error)
    }
    __pyx_L13:;

    /* "pysam/libcbcf.pyx":4030
 *         self.header = self.index = None
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             global errno
 *             if errno == EPIPE:
 */
  }

  /* "pysam/libcbcf.pyx":4017
 *         self.open(*args, **kwargs)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if not self.htsfile or not self.header:
 *             return
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("pysam.libcbcf.VariantFile.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
}

/* "pysam/libcbcf.pyx":4037
 *                 raise IOError(errno, force_str(strerror(errno)))
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         """closes the :class:`pysam.VariantFile`."""
 *         if not self.htsfile:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_7close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_6close[] = "VariantFile.close(self)\ncloses the :class:`pysam.VariantFile`.";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_7close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_6close(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_6close(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self) {
  int __pyx_v_ret;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  __Pyx_RefNannySetupContext("close", 0);
  __Pyx_TraceCall("close", __pyx_f[0], 4037, 0, __PYX_ERR(0, 4037, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":4039
 *     def close(self):
 *         """closes the :class:`pysam.VariantFile`."""
 *         if not self.htsfile:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_self->__pyx_base.htsfile != 0)) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":4040
 *         """closes the :class:`pysam.VariantFile`."""
 *         if not self.htsfile:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # Write header if no records were written
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":4039
 *     def close(self):
 *         """closes the :class:`pysam.VariantFile`."""
 *         if not self.htsfile:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4043
 * 
 *         # Write header if no records were written
 *         if self.htsfile.is_write and not self.header_written:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 */
  __pyx_t_2 = (__pyx_v_self->__pyx_base.htsfile->is_write != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_2 = ((!(__pyx_v_self->header_written != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":4044
 *         # Write header if no records were written
 *         if self.htsfile.is_write and not self.header_written:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 * 
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        __Pyx_FastGIL_Remember();
        #endif
        /*try:*/ {

          /* "pysam/libcbcf.pyx":4045
 *         if self.htsfile.is_write and not self.header_written:
 *             with nogil:
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)             # <<<<<<<<<<<<<<
 * 
 *         cdef int ret = hts_close(self.htsfile)
 */
          (void)(bcf_hdr_write(__pyx_v_self->__pyx_base.htsfile, __pyx_v_self->header->ptr));
        }

        /* "pysam/libcbcf.pyx":4044
 *         # Write header if no records were written
 *         if self.htsfile.is_write and not self.header_written:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 * 
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L9;
          }
          __pyx_L9:;
        }
    }

    /* "pysam/libcbcf.pyx":4043
 * 
 *         # Write header if no records were written
 *         if self.htsfile.is_write and not self.header_written:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 */
  }

  /* "pysam/libcbcf.pyx":4047
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 * 
 *         cdef int ret = hts_close(self.htsfile)             # <<<<<<<<<<<<<<
 *         self.htsfile = NULL
 *         self.header = self.index = None
 */
  __pyx_v_ret = hts_close(__pyx_v_self->__pyx_base.htsfile);

  /* "pysam/libcbcf.pyx":4048
 * 
 *         cdef int ret = hts_close(self.htsfile)
 *         self.htsfile = NULL             # <<<<<<<<<<<<<<
 *         self.header = self.index = None
 * 
 */
  __pyx_v_self->__pyx_base.htsfile = NULL;

  /* "pysam/libcbcf.pyx":4049
 *         cdef int ret = hts_close(self.htsfile)
 *         self.htsfile = NULL
 *         self.header = self.index = None             # <<<<<<<<<<<<<<
 * 
 *         if ret < 0:
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->header));
  __pyx_v_self->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->index);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->index));
  __pyx_v_self->index = ((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)Py_None);

  /* "pysam/libcbcf.pyx":4051
 *         self.header = self.index = None
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             global errno
 *             if errno == EPIPE:
 */
  __pyx_t_1 = ((__pyx_v_ret < 0) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":4053
 *         if ret < 0:
 *             global errno
 *             if errno == EPIPE:             # <<<<<<<<<<<<<<
 *                 errno = 0
 *             else:
 */
    __pyx_t_1 = ((errno == EPIPE) != 0);
    if (likely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":4054
 *             global errno
 *             if errno == EPIPE:
 *                 errno = 0             # <<<<<<<<<<<<<<
 *             else:
 *                 raise IOError(errno, force_str(strerror(errno)))
 */
      errno = 0;

      /* "pysam/libcbcf.pyx":4053
 *         if ret < 0:
 *             global errno
 *             if errno == EPIPE:             # <<<<<<<<<<<<<<
 *                 errno = 0
 *             else:
 */
      goto __pyx_L11;
    }

    /* "pysam/libcbcf.pyx":4056
 *                 errno = 0
 *             else:
 *                 raise IOError(errno, force_str(strerror(errno)))             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4056, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4056, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __pyx_f_5pysam_9libcutils_force_str(__pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4056, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4056, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
      __pyx_t_3 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4056, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 4056, __pyx_L1_error)
    }
    __pyx_L11:;

    /* "pysam/libcbcf.pyx":4051
 *         self.header = self.index = None
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             global errno
 *             if errno == EPIPE:
 */
  }

  /* "pysam/libcbcf.pyx":4037
 *                 raise IOError(errno, force_str(strerror(errno)))
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         """closes the :class:`pysam.VariantFile`."""
 *         if not self.htsfile:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4058
 *                 raise IOError(errno, force_str(strerror(errno)))
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_9__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_9__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_8__iter__(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_8__iter__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("__iter__", 0);
  __Pyx_TraceCall("__iter__", __pyx_f[0], 4058, 0, __PYX_ERR(0, 4058, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":4059
 * 
 *     def __iter__(self):
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError('I/O operation on closed file')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4059, __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, 4059, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4060
 *     def __iter__(self):
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         if self.htsfile.is_write:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__209, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4060, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4060, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4059
 * 
 *     def __iter__(self):
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError('I/O operation on closed file')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4062
 *             raise ValueError('I/O operation on closed file')
 * 
 *         if self.htsfile.is_write:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot iterate over Variantfile opened for writing')
 * 
 */
  __pyx_t_3 = (__pyx_v_self->__pyx_base.htsfile->is_write != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4063
 * 
 *         if self.htsfile.is_write:
 *             raise ValueError('cannot iterate over Variantfile opened for writing')             # <<<<<<<<<<<<<<
 * 
 *         self.is_reading = 1
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__210, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4063, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4063, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4062
 *             raise ValueError('I/O operation on closed file')
 * 
 *         if self.htsfile.is_write:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot iterate over Variantfile opened for writing')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4065
 *             raise ValueError('cannot iterate over Variantfile opened for writing')
 * 
 *         self.is_reading = 1             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  __pyx_v_self->is_reading = 1;

  /* "pysam/libcbcf.pyx":4066
 * 
 *         self.is_reading = 1
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":4058
 *                 raise IOError(errno, force_str(strerror(errno)))
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4068
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         cdef int ret
 *         cdef bcf1_t *record = bcf_init1()
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_11__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_11__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_10__next__(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_10__next__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self) {
  int __pyx_v_ret;
  bcf1_t *__pyx_v_record;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__next__", 0);
  __Pyx_TraceCall("__next__", __pyx_f[0], 4068, 0, __PYX_ERR(0, 4068, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":4070
 *     def __next__(self):
 *         cdef int ret
 *         cdef bcf1_t *record = bcf_init1()             # <<<<<<<<<<<<<<
 * 
 *         if not record:
 */
  __pyx_v_record = bcf_init1();

  /* "pysam/libcbcf.pyx":4072
 *         cdef bcf1_t *record = bcf_init1()
 * 
 *         if not record:             # <<<<<<<<<<<<<<
 *             raise MemoryError('unable to allocate BCF record')
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_record != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":4073
 * 
 *         if not record:
 *             raise MemoryError('unable to allocate BCF record')             # <<<<<<<<<<<<<<
 * 
 *         record.pos = -1
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__211, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4073, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 4073, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4072
 *         cdef bcf1_t *record = bcf_init1()
 * 
 *         if not record:             # <<<<<<<<<<<<<<
 *             raise MemoryError('unable to allocate BCF record')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4075
 *             raise MemoryError('unable to allocate BCF record')
 * 
 *         record.pos = -1             # <<<<<<<<<<<<<<
 *         if self.drop_samples:
 *             record.max_unpack = BCF_UN_SHR
 */
  __pyx_v_record->pos = -1;

  /* "pysam/libcbcf.pyx":4076
 * 
 *         record.pos = -1
 *         if self.drop_samples:             # <<<<<<<<<<<<<<
 *             record.max_unpack = BCF_UN_SHR
 * 
 */
  __pyx_t_1 = (__pyx_v_self->drop_samples != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":4077
 *         record.pos = -1
 *         if self.drop_samples:
 *             record.max_unpack = BCF_UN_SHR             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
    __pyx_v_record->max_unpack = BCF_UN_SHR;

    /* "pysam/libcbcf.pyx":4076
 * 
 *         record.pos = -1
 *         if self.drop_samples:             # <<<<<<<<<<<<<<
 *             record.max_unpack = BCF_UN_SHR
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4079
 *             record.max_unpack = BCF_UN_SHR
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             ret = bcf_read1(self.htsfile, self.header.ptr, record)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "pysam/libcbcf.pyx":4080
 * 
 *         with nogil:
 *             ret = bcf_read1(self.htsfile, self.header.ptr, record)             # <<<<<<<<<<<<<<
 * 
 *         if ret < 0:
 */
        __pyx_v_ret = bcf_read1(__pyx_v_self->__pyx_base.htsfile, __pyx_v_self->header->ptr, __pyx_v_record);
      }

      /* "pysam/libcbcf.pyx":4079
 *             record.max_unpack = BCF_UN_SHR
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             ret = bcf_read1(self.htsfile, self.header.ptr, record)
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L7;
        }
        __pyx_L7:;
      }
  }

  /* "pysam/libcbcf.pyx":4082
 *             ret = bcf_read1(self.htsfile, self.header.ptr, record)
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             bcf_destroy1(record)
 *             if ret == -1:
 */
  __pyx_t_1 = ((__pyx_v_ret < 0) != 0);
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":4083
 * 
 *         if ret < 0:
 *             bcf_destroy1(record)             # <<<<<<<<<<<<<<
 *             if ret == -1:
 *                 raise StopIteration
 */
    bcf_destroy1(__pyx_v_record);

    /* "pysam/libcbcf.pyx":4084
 *         if ret < 0:
 *             bcf_destroy1(record)
 *             if ret == -1:             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *             elif ret == -2:
 */
    __pyx_t_1 = ((__pyx_v_ret == -1L) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":4085
 *             bcf_destroy1(record)
 *             if ret == -1:
 *                 raise StopIteration             # <<<<<<<<<<<<<<
 *             elif ret == -2:
 *                 raise IOError('truncated file')
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
      __PYX_ERR(0, 4085, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":4084
 *         if ret < 0:
 *             bcf_destroy1(record)
 *             if ret == -1:             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *             elif ret == -2:
 */
    }

    /* "pysam/libcbcf.pyx":4086
 *             if ret == -1:
 *                 raise StopIteration
 *             elif ret == -2:             # <<<<<<<<<<<<<<
 *                 raise IOError('truncated file')
 *             elif errno:
 */
    __pyx_t_1 = ((__pyx_v_ret == -2L) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":4087
 *                 raise StopIteration
 *             elif ret == -2:
 *                 raise IOError('truncated file')             # <<<<<<<<<<<<<<
 *             elif errno:
 *                 raise IOError(errno, strerror(errno))
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_tuple__212, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4087, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(0, 4087, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":4086
 *             if ret == -1:
 *                 raise StopIteration
 *             elif ret == -2:             # <<<<<<<<<<<<<<
 *                 raise IOError('truncated file')
 *             elif errno:
 */
    }

    /* "pysam/libcbcf.pyx":4088
 *             elif ret == -2:
 *                 raise IOError('truncated file')
 *             elif errno:             # <<<<<<<<<<<<<<
 *                 raise IOError(errno, strerror(errno))
 *             else:
 */
    __pyx_t_1 = (errno != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":4089
 *                 raise IOError('truncated file')
 *             elif errno:
 *                 raise IOError(errno, strerror(errno))             # <<<<<<<<<<<<<<
 *             else:
 *                 raise IOError('unable to fetch next record')
 */
      __pyx_t_2 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4089, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4089, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4089, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4089, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 4089, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":4088
 *             elif ret == -2:
 *                 raise IOError('truncated file')
 *             elif errno:             # <<<<<<<<<<<<<<
 *                 raise IOError(errno, strerror(errno))
 *             else:
 */
    }

    /* "pysam/libcbcf.pyx":4091
 *                 raise IOError(errno, strerror(errno))
 *             else:
 *                 raise IOError('unable to fetch next record')             # <<<<<<<<<<<<<<
 * 
 *         return makeVariantRecord(self.header, record)
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_tuple__213, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4091, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 4091, __pyx_L1_error)
    }

    /* "pysam/libcbcf.pyx":4082
 *             ret = bcf_read1(self.htsfile, self.header.ptr, record)
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             bcf_destroy1(record)
 *             if ret == -1:
 */
  }

  /* "pysam/libcbcf.pyx":4093
 *                 raise IOError('unable to fetch next record')
 * 
 *         return makeVariantRecord(self.header, record)             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = ((PyObject *)__pyx_v_self->header);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantRecord(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_3), __pyx_v_record)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4093, __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;

  /* "pysam/libcbcf.pyx":4068
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         cdef int ret
 *         cdef bcf1_t *record = bcf_init1()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4095
 *         return makeVariantRecord(self.header, record)
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         if not self.is_open:
 *             raise ValueError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_13copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_12copy[] = "VariantFile.copy(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_13copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_12copy(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_12copy(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self) {
  struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_vars = 0;
  bcf_hdr_t *__pyx_v_hdr;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  htsFile *__pyx_t_4;
  int64_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("copy", 0);
  __Pyx_TraceCall("copy", __pyx_f[0], 4095, 0, __PYX_ERR(0, 4095, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":4096
 * 
 *     def copy(self):
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4096, __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, 4096, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4097
 *     def copy(self):
 *         if not self.is_open:
 *             raise ValueError             # <<<<<<<<<<<<<<
 * 
 *         cdef VariantFile vars = VariantFile.__new__(VariantFile)
 */
    __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0);
    __PYX_ERR(0, 4097, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4096
 * 
 *     def copy(self):
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4099
 *             raise ValueError
 * 
 *         cdef VariantFile vars = VariantFile.__new__(VariantFile)             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_5pysam_7libcbcf_VariantFile(((PyTypeObject *)__pyx_ptype_5pysam_7libcbcf_VariantFile), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4099, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_vars = ((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":4103
 * 
 *         # FIXME: re-open using fd or else header and index could be invalid
 *         vars.htsfile = self._open_htsfile()             # <<<<<<<<<<<<<<
 * 
 *         if not vars.htsfile:
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_5pysam_7libcbcf_VariantFile *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._open_htsfile(((struct __pyx_obj_5pysam_10libchtslib_HTSFile *)__pyx_v_self)); if (unlikely(__pyx_t_4 == ((htsFile *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 4103, __pyx_L1_error)
  __pyx_v_vars->__pyx_base.htsfile = __pyx_t_4;

  /* "pysam/libcbcf.pyx":4105
 *         vars.htsfile = self._open_htsfile()
 * 
 *         if not vars.htsfile:             # <<<<<<<<<<<<<<
 *             raise ValueError('Cannot re-open htsfile')
 * 
 */
  __pyx_t_3 = ((!(__pyx_v_vars->__pyx_base.htsfile != 0)) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4106
 * 
 *         if not vars.htsfile:
 *             raise ValueError('Cannot re-open htsfile')             # <<<<<<<<<<<<<<
 * 
 *         # minimize overhead by re-using header and index.  This approach is
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__214, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4106, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4105
 *         vars.htsfile = self._open_htsfile()
 * 
 *         if not vars.htsfile:             # <<<<<<<<<<<<<<
 *             raise ValueError('Cannot re-open htsfile')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4110
 *         # minimize overhead by re-using header and index.  This approach is
 *         # currently risky, but see above for how this can be mitigated.
 *         vars.header         = self.header             # <<<<<<<<<<<<<<
 *         vars.index          = self.index
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->header);
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_vars->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_vars->header));
  __pyx_v_vars->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":4111
 *         # currently risky, but see above for how this can be mitigated.
 *         vars.header         = self.header
 *         vars.index          = self.index             # <<<<<<<<<<<<<<
 * 
 *         vars.filename       = self.filename
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->index);
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_vars->index);
  __Pyx_DECREF(((PyObject *)__pyx_v_vars->index));
  __pyx_v_vars->index = ((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":4113
 *         vars.index          = self.index
 * 
 *         vars.filename       = self.filename             # <<<<<<<<<<<<<<
 *         vars.mode           = self.mode
 *         vars.threads        = self.threads
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.filename;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_vars->__pyx_base.filename);
  __Pyx_DECREF(__pyx_v_vars->__pyx_base.filename);
  __pyx_v_vars->__pyx_base.filename = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":4114
 * 
 *         vars.filename       = self.filename
 *         vars.mode           = self.mode             # <<<<<<<<<<<<<<
 *         vars.threads        = self.threads
 *         vars.index_filename = self.index_filename
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.mode;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_vars->__pyx_base.mode);
  __Pyx_DECREF(__pyx_v_vars->__pyx_base.mode);
  __pyx_v_vars->__pyx_base.mode = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":4115
 *         vars.filename       = self.filename
 *         vars.mode           = self.mode
 *         vars.threads        = self.threads             # <<<<<<<<<<<<<<
 *         vars.index_filename = self.index_filename
 *         vars.drop_samples   = self.drop_samples
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.threads;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_vars->__pyx_base.threads);
  __Pyx_DECREF(__pyx_v_vars->__pyx_base.threads);
  __pyx_v_vars->__pyx_base.threads = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":4116
 *         vars.mode           = self.mode
 *         vars.threads        = self.threads
 *         vars.index_filename = self.index_filename             # <<<<<<<<<<<<<<
 *         vars.drop_samples   = self.drop_samples
 *         vars.is_stream      = self.is_stream
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.index_filename;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_vars->__pyx_base.index_filename);
  __Pyx_DECREF(__pyx_v_vars->__pyx_base.index_filename);
  __pyx_v_vars->__pyx_base.index_filename = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":4117
 *         vars.threads        = self.threads
 *         vars.index_filename = self.index_filename
 *         vars.drop_samples   = self.drop_samples             # <<<<<<<<<<<<<<
 *         vars.is_stream      = self.is_stream
 *         vars.is_remote      = self.is_remote
 */
  __pyx_t_3 = __pyx_v_self->drop_samples;
  __pyx_v_vars->drop_samples = __pyx_t_3;

  /* "pysam/libcbcf.pyx":4118
 *         vars.index_filename = self.index_filename
 *         vars.drop_samples   = self.drop_samples
 *         vars.is_stream      = self.is_stream             # <<<<<<<<<<<<<<
 *         vars.is_remote      = self.is_remote
 *         vars.is_reading     = self.is_reading
 */
  __pyx_t_3 = __pyx_v_self->__pyx_base.is_stream;
  __pyx_v_vars->__pyx_base.is_stream = __pyx_t_3;

  /* "pysam/libcbcf.pyx":4119
 *         vars.drop_samples   = self.drop_samples
 *         vars.is_stream      = self.is_stream
 *         vars.is_remote      = self.is_remote             # <<<<<<<<<<<<<<
 *         vars.is_reading     = self.is_reading
 *         vars.start_offset   = self.start_offset
 */
  __pyx_t_3 = __pyx_v_self->__pyx_base.is_remote;
  __pyx_v_vars->__pyx_base.is_remote = __pyx_t_3;

  /* "pysam/libcbcf.pyx":4120
 *         vars.is_stream      = self.is_stream
 *         vars.is_remote      = self.is_remote
 *         vars.is_reading     = self.is_reading             # <<<<<<<<<<<<<<
 *         vars.start_offset   = self.start_offset
 *         vars.header_written = self.header_written
 */
  __pyx_t_3 = __pyx_v_self->is_reading;
  __pyx_v_vars->is_reading = __pyx_t_3;

  /* "pysam/libcbcf.pyx":4121
 *         vars.is_remote      = self.is_remote
 *         vars.is_reading     = self.is_reading
 *         vars.start_offset   = self.start_offset             # <<<<<<<<<<<<<<
 *         vars.header_written = self.header_written
 * 
 */
  __pyx_t_5 = __pyx_v_self->__pyx_base.start_offset;
  __pyx_v_vars->__pyx_base.start_offset = __pyx_t_5;

  /* "pysam/libcbcf.pyx":4122
 *         vars.is_reading     = self.is_reading
 *         vars.start_offset   = self.start_offset
 *         vars.header_written = self.header_written             # <<<<<<<<<<<<<<
 * 
 *         if self.htsfile.is_bin:
 */
  __pyx_t_3 = __pyx_v_self->header_written;
  __pyx_v_vars->header_written = __pyx_t_3;

  /* "pysam/libcbcf.pyx":4124
 *         vars.header_written = self.header_written
 * 
 *         if self.htsfile.is_bin:             # <<<<<<<<<<<<<<
 *             vars.seek(self.tell())
 *         else:
 */
  __pyx_t_3 = (__pyx_v_self->__pyx_base.htsfile->is_bin != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":4125
 * 
 *         if self.htsfile.is_bin:
 *             vars.seek(self.tell())             # <<<<<<<<<<<<<<
 *         else:
 *             with nogil:
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_vars), __pyx_n_s_seek); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tell); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (__pyx_t_9) {
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4125, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4125, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4125, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_7};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4125, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_7};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4125, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4125, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4125, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":4124
 *         vars.header_written = self.header_written
 * 
 *         if self.htsfile.is_bin:             # <<<<<<<<<<<<<<
 *             vars.seek(self.tell())
 *         else:
 */
    goto __pyx_L5;
  }

  /* "pysam/libcbcf.pyx":4127
 *             vars.seek(self.tell())
 *         else:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 hdr = bcf_hdr_read(vars.htsfile)
 *             makeVariantHeader(hdr)
 */
  /*else*/ {
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        __Pyx_FastGIL_Remember();
        #endif
        /*try:*/ {

          /* "pysam/libcbcf.pyx":4128
 *         else:
 *             with nogil:
 *                 hdr = bcf_hdr_read(vars.htsfile)             # <<<<<<<<<<<<<<
 *             makeVariantHeader(hdr)
 * 
 */
          __pyx_v_hdr = bcf_hdr_read(__pyx_v_vars->__pyx_base.htsfile);
        }

        /* "pysam/libcbcf.pyx":4127
 *             vars.seek(self.tell())
 *         else:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 hdr = bcf_hdr_read(vars.htsfile)
 *             makeVariantHeader(hdr)
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L8;
          }
          __pyx_L8:;
        }
    }

    /* "pysam/libcbcf.pyx":4129
 *             with nogil:
 *                 hdr = bcf_hdr_read(vars.htsfile)
 *             makeVariantHeader(hdr)             # <<<<<<<<<<<<<<
 * 
 *         return vars
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeader(__pyx_v_hdr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L5:;

  /* "pysam/libcbcf.pyx":4131
 *             makeVariantHeader(hdr)
 * 
 *         return vars             # <<<<<<<<<<<<<<
 * 
 *     def open(self, filename, mode='r',
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_vars));
  __pyx_r = ((PyObject *)__pyx_v_vars);
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":4095
 *         return makeVariantRecord(self.header, record)
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         if not self.is_open:
 *             raise ValueError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_vars);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4133
 *         return vars
 * 
 *     def open(self, filename, mode='r',             # <<<<<<<<<<<<<<
 *              index_filename=None,
 *              VariantHeader header=None,
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_15open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_14open[] = "VariantFile.open(self, filename, mode='r', index_filename=None, VariantHeader header=None, drop_samples=False, duplicate_filehandle=True, ignore_truncation=False, threads=1)\nopen a vcf/bcf file.\n\n        If open is called on an existing VariantFile, the current file will be\n        closed and a new file will be opened.\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_15open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  PyObject *__pyx_v_mode = 0;
  PyObject *__pyx_v_index_filename = 0;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header = 0;
  PyObject *__pyx_v_drop_samples = 0;
  PyObject *__pyx_v_duplicate_filehandle = 0;
  PyObject *__pyx_v_ignore_truncation = 0;
  PyObject *__pyx_v_threads = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("open (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_filename,&__pyx_n_s_mode,&__pyx_n_s_index_filename,&__pyx_n_s_header,&__pyx_n_s_drop_samples,&__pyx_n_s_duplicate_filehandle,&__pyx_n_s_ignore_truncation,&__pyx_n_s_threads,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    values[1] = ((PyObject *)__pyx_n_s_r);

    /* "pysam/libcbcf.pyx":4134
 * 
 *     def open(self, filename, mode='r',
 *              index_filename=None,             # <<<<<<<<<<<<<<
 *              VariantHeader header=None,
 *              drop_samples=False,
 */
    values[2] = ((PyObject *)Py_None);

    /* "pysam/libcbcf.pyx":4135
 *     def open(self, filename, mode='r',
 *              index_filename=None,
 *              VariantHeader header=None,             # <<<<<<<<<<<<<<
 *              drop_samples=False,
 *              duplicate_filehandle=True,
 */
    values[3] = (PyObject *)((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None);

    /* "pysam/libcbcf.pyx":4136
 *              index_filename=None,
 *              VariantHeader header=None,
 *              drop_samples=False,             # <<<<<<<<<<<<<<
 *              duplicate_filehandle=True,
 *              ignore_truncation=False,
 */
    values[4] = ((PyObject *)Py_False);

    /* "pysam/libcbcf.pyx":4137
 *              VariantHeader header=None,
 *              drop_samples=False,
 *              duplicate_filehandle=True,             # <<<<<<<<<<<<<<
 *              ignore_truncation=False,
 *              threads=1):
 */
    values[5] = ((PyObject *)Py_True);

    /* "pysam/libcbcf.pyx":4138
 *              drop_samples=False,
 *              duplicate_filehandle=True,
 *              ignore_truncation=False,             # <<<<<<<<<<<<<<
 *              threads=1):
 *         """open a vcf/bcf file.
 */
    values[6] = ((PyObject *)Py_False);
    values[7] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_filename)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_index_filename);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_header);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_drop_samples);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_duplicate_filehandle);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ignore_truncation);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_threads);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "open") < 0)) __PYX_ERR(0, 4133, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_filename = values[0];
    __pyx_v_mode = values[1];
    __pyx_v_index_filename = values[2];
    __pyx_v_header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)values[3]);
    __pyx_v_drop_samples = values[4];
    __pyx_v_duplicate_filehandle = values[5];
    __pyx_v_ignore_truncation = values[6];
    __pyx_v_threads = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("open", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4133, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.open", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_header), __pyx_ptype_5pysam_7libcbcf_VariantHeader, 1, "header", 0))) __PYX_ERR(0, 4135, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_14open(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self), __pyx_v_filename, __pyx_v_mode, __pyx_v_index_filename, __pyx_v_header, __pyx_v_drop_samples, __pyx_v_duplicate_filehandle, __pyx_v_ignore_truncation, __pyx_v_threads);

  /* "pysam/libcbcf.pyx":4133
 *         return vars
 * 
 *     def open(self, filename, mode='r',             # <<<<<<<<<<<<<<
 *              index_filename=None,
 *              VariantHeader header=None,
 */

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_14open(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_filename, PyObject *__pyx_v_mode, PyObject *__pyx_v_index_filename, struct __pyx_obj_5pysam_7libcbcf_VariantHeader *__pyx_v_header, PyObject *__pyx_v_drop_samples, PyObject *__pyx_v_duplicate_filehandle, PyObject *__pyx_v_ignore_truncation, PyObject *__pyx_v_threads) {
  bcf_hdr_t *__pyx_v_hdr;
  hts_idx_t *__pyx_v_idx;
  tbx_t *__pyx_v_tidx;
  char *__pyx_v_cfilename;
  char *__pyx_v_cindex_filename;
  PyObject *__pyx_v_format_modes = NULL;
  PyObject *__pyx_v_invalid_modes = NULL;
  PyObject *__pyx_v_m = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  char const *__pyx_t_14;
  int __pyx_t_15;
  htsFile *__pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  char *__pyx_t_19;
  int64_t __pyx_t_20;
  __Pyx_RefNannySetupContext("open", 0);
  __Pyx_TraceCall("open", __pyx_f[0], 4133, 0, __PYX_ERR(0, 4133, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_filename);
  __Pyx_INCREF(__pyx_v_mode);
  __Pyx_INCREF(__pyx_v_index_filename);

  /* "pysam/libcbcf.pyx":4150
 *         cdef tbx_t *tidx
 *         cdef char *cfilename
 *         cdef char *cindex_filename = NULL             # <<<<<<<<<<<<<<
 *         cdef char *cmode
 * 
 */
  __pyx_v_cindex_filename = NULL;

  /* "pysam/libcbcf.pyx":4153
 *         cdef char *cmode
 * 
 *         if threads > 1 and ignore_truncation:             # <<<<<<<<<<<<<<
 *             # This won't raise errors if reaching a truncated alignment,
 *             # because bgzf_mt_reader in htslib does not deal with
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_threads, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4153, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 4153, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_ignore_truncation); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 4153, __pyx_L1_error)
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":4159
 *             # to bgzf_read (https://github.com/samtools/htslib/blob/1.7/bgzf.c#L888)
 *             # Better to avoid this (for now) than to produce seemingly correct results.
 *             raise ValueError('Cannot add extra threads when "ignore_truncation" is True')             # <<<<<<<<<<<<<<
 *         self.threads = threads
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__215, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 4159, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4153
 *         cdef char *cmode
 * 
 *         if threads > 1 and ignore_truncation:             # <<<<<<<<<<<<<<
 *             # This won't raise errors if reaching a truncated alignment,
 *             # because bgzf_mt_reader in htslib does not deal with
 */
  }

  /* "pysam/libcbcf.pyx":4160
 *             # Better to avoid this (for now) than to produce seemingly correct results.
 *             raise ValueError('Cannot add extra threads when "ignore_truncation" is True')
 *         self.threads = threads             # <<<<<<<<<<<<<<
 * 
 *         # close a previously opened file
 */
  __Pyx_INCREF(__pyx_v_threads);
  __Pyx_GIVEREF(__pyx_v_threads);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.threads);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.threads);
  __pyx_v_self->__pyx_base.threads = __pyx_v_threads;

  /* "pysam/libcbcf.pyx":4163
 * 
 *         # close a previously opened file
 *         if self.is_open:             # <<<<<<<<<<<<<<
 *             self.close()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 4163, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":4164
 *         # close a previously opened file
 *         if self.is_open:
 *             self.close()             # <<<<<<<<<<<<<<
 * 
 *         if not mode or mode[0] not in 'rwa':
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4164, __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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4164, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4164, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pysam/libcbcf.pyx":4163
 * 
 *         # close a previously opened file
 *         if self.is_open:             # <<<<<<<<<<<<<<
 *             self.close()
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4166
 *             self.close()
 * 
 *         if not mode or mode[0] not in 'rwa':             # <<<<<<<<<<<<<<
 *             raise ValueError('mode must begin with r, w or a')
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_mode); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 4166, __pyx_L1_error)
  __pyx_t_6 = ((!__pyx_t_3) != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_1 = __pyx_t_6;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_t_2, __pyx_n_s_rwa, Py_NE)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 4166, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = (__pyx_t_6 != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L8_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":4167
 * 
 *         if not mode or mode[0] not in 'rwa':
 *             raise ValueError('mode must begin with r, w or a')             # <<<<<<<<<<<<<<
 * 
 *         self.duplicate_filehandle = duplicate_filehandle
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__216, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 4167, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4166
 *             self.close()
 * 
 *         if not mode or mode[0] not in 'rwa':             # <<<<<<<<<<<<<<
 *             raise ValueError('mode must begin with r, w or a')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4169
 *             raise ValueError('mode must begin with r, w or a')
 * 
 *         self.duplicate_filehandle = duplicate_filehandle             # <<<<<<<<<<<<<<
 * 
 *         format_modes = [m for m in mode[1:] if m in 'bcguz']
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_duplicate_filehandle); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 4169, __pyx_L1_error)
  __pyx_v_self->__pyx_base.duplicate_filehandle = __pyx_t_1;

  /* "pysam/libcbcf.pyx":4171
 *         self.duplicate_filehandle = duplicate_filehandle
 * 
 *         format_modes = [m for m in mode[1:] if m in 'bcguz']             # <<<<<<<<<<<<<<
 *         if len(format_modes) > 1:
 *             raise ValueError('mode contains conflicting format specifiers: {}'.format(''.join(format_modes)))
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_mode, 1, 0, NULL, NULL, &__pyx_slice__217, 1, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_5 = __pyx_t_4; __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_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4171, __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, 4171, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 4171, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4171, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 4171, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4171, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_8(__pyx_t_5);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 4171, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_m, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_m, __pyx_n_s_bcguz, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 4171, __pyx_L1_error)
    __pyx_t_3 = (__pyx_t_1 != 0);
    if (__pyx_t_3) {
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_v_m))) __PYX_ERR(0, 4171, __pyx_L1_error)
    }
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_format_modes = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":4172
 * 
 *         format_modes = [m for m in mode[1:] if m in 'bcguz']
 *         if len(format_modes) > 1:             # <<<<<<<<<<<<<<
 *             raise ValueError('mode contains conflicting format specifiers: {}'.format(''.join(format_modes)))
 * 
 */
  __pyx_t_7 = PyList_GET_SIZE(__pyx_v_format_modes); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4172, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_7 > 1) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4173
 *         format_modes = [m for m in mode[1:] if m in 'bcguz']
 *         if len(format_modes) > 1:
 *             raise ValueError('mode contains conflicting format specifiers: {}'.format(''.join(format_modes)))             # <<<<<<<<<<<<<<
 * 
 *         invalid_modes = [m for m in mode[1:] if m not in 'bcguz0123456789ex']
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_mode_contains_conflicting_format, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyString_Join(__pyx_kp_s__15, __pyx_v_format_modes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4173, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_4};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4173, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_4};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4173, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4173, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4173, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 4173, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4172
 * 
 *         format_modes = [m for m in mode[1:] if m in 'bcguz']
 *         if len(format_modes) > 1:             # <<<<<<<<<<<<<<
 *             raise ValueError('mode contains conflicting format specifiers: {}'.format(''.join(format_modes)))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4175
 *             raise ValueError('mode contains conflicting format specifiers: {}'.format(''.join(format_modes)))
 * 
 *         invalid_modes = [m for m in mode[1:] if m not in 'bcguz0123456789ex']             # <<<<<<<<<<<<<<
 *         if invalid_modes:
 *             raise ValueError('invalid mode options: {}'.format(''.join(invalid_modes)))
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_mode, 1, 0, NULL, NULL, &__pyx_slice__218, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_10 = __pyx_t_2; __Pyx_INCREF(__pyx_t_10); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_8 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4175, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_10))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_10)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 4175, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_10, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4175, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 4175, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_10, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4175, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_8(__pyx_t_10);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 4175, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_m, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_v_m, __pyx_n_s_bcguz0123456789ex, Py_NE)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 4175, __pyx_L1_error)
    __pyx_t_1 = (__pyx_t_3 != 0);
    if (__pyx_t_1) {
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_v_m))) __PYX_ERR(0, 4175, __pyx_L1_error)
    }
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_v_invalid_modes = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pysam/libcbcf.pyx":4176
 * 
 *         invalid_modes = [m for m in mode[1:] if m not in 'bcguz0123456789ex']
 *         if invalid_modes:             # <<<<<<<<<<<<<<
 *             raise ValueError('invalid mode options: {}'.format(''.join(invalid_modes)))
 * 
 */
  __pyx_t_1 = (PyList_GET_SIZE(__pyx_v_invalid_modes) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":4177
 *         invalid_modes = [m for m in mode[1:] if m not in 'bcguz0123456789ex']
 *         if invalid_modes:
 *             raise ValueError('invalid mode options: {}'.format(''.join(invalid_modes)))             # <<<<<<<<<<<<<<
 * 
 *         # Autodetect mode from filename
 */
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_invalid_mode_options, __pyx_n_s_format); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4177, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__15, __pyx_v_invalid_modes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4177, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4177, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4177, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4177, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4177, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4177, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4177, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_10, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __PYX_ERR(0, 4177, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4176
 * 
 *         invalid_modes = [m for m in mode[1:] if m not in 'bcguz0123456789ex']
 *         if invalid_modes:             # <<<<<<<<<<<<<<
 *             raise ValueError('invalid mode options: {}'.format(''.join(invalid_modes)))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4180
 * 
 *         # Autodetect mode from filename
 *         if mode == 'w' and isinstance(filename, str):             # <<<<<<<<<<<<<<
 *             if filename.endswith('.gz'):
 *                 mode = 'wz'
 */
  __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_w, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 4180, __pyx_L1_error)
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L19_bool_binop_done;
  }
  __pyx_t_3 = PyString_Check(__pyx_v_filename); 
  __pyx_t_6 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_6;
  __pyx_L19_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":4181
 *         # Autodetect mode from filename
 *         if mode == 'w' and isinstance(filename, str):
 *             if filename.endswith('.gz'):             # <<<<<<<<<<<<<<
 *                 mode = 'wz'
 *             elif filename.endswith('.bcf'):
 */
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_filename, __pyx_n_s_endswith); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__219, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 4181, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":4182
 *         if mode == 'w' and isinstance(filename, str):
 *             if filename.endswith('.gz'):
 *                 mode = 'wz'             # <<<<<<<<<<<<<<
 *             elif filename.endswith('.bcf'):
 *                 mode = 'wb'
 */
      __Pyx_INCREF(__pyx_n_s_wz);
      __Pyx_DECREF_SET(__pyx_v_mode, __pyx_n_s_wz);

      /* "pysam/libcbcf.pyx":4181
 *         # Autodetect mode from filename
 *         if mode == 'w' and isinstance(filename, str):
 *             if filename.endswith('.gz'):             # <<<<<<<<<<<<<<
 *                 mode = 'wz'
 *             elif filename.endswith('.bcf'):
 */
      goto __pyx_L21;
    }

    /* "pysam/libcbcf.pyx":4183
 *             if filename.endswith('.gz'):
 *                 mode = 'wz'
 *             elif filename.endswith('.bcf'):             # <<<<<<<<<<<<<<
 *                 mode = 'wb'
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_filename, __pyx_n_s_endswith); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4183, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__220, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4183, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 4183, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":4184
 *                 mode = 'wz'
 *             elif filename.endswith('.bcf'):
 *                 mode = 'wb'             # <<<<<<<<<<<<<<
 * 
 *         # for htslib, wbu seems to not work
 */
      __Pyx_INCREF(__pyx_n_s_wb);
      __Pyx_DECREF_SET(__pyx_v_mode, __pyx_n_s_wb);

      /* "pysam/libcbcf.pyx":4183
 *             if filename.endswith('.gz'):
 *                 mode = 'wz'
 *             elif filename.endswith('.bcf'):             # <<<<<<<<<<<<<<
 *                 mode = 'wb'
 * 
 */
    }
    __pyx_L21:;

    /* "pysam/libcbcf.pyx":4180
 * 
 *         # Autodetect mode from filename
 *         if mode == 'w' and isinstance(filename, str):             # <<<<<<<<<<<<<<
 *             if filename.endswith('.gz'):
 *                 mode = 'wz'
 */
  }

  /* "pysam/libcbcf.pyx":4187
 * 
 *         # for htslib, wbu seems to not work
 *         if mode == 'wbu':             # <<<<<<<<<<<<<<
 *             mode = 'wb0'
 * 
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_wbu, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 4187, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "pysam/libcbcf.pyx":4188
 *         # for htslib, wbu seems to not work
 *         if mode == 'wbu':
 *             mode = 'wb0'             # <<<<<<<<<<<<<<
 * 
 *         self.mode = mode = force_bytes(mode)
 */
    __Pyx_INCREF(__pyx_n_s_wb0);
    __Pyx_DECREF_SET(__pyx_v_mode, __pyx_n_s_wb0);

    /* "pysam/libcbcf.pyx":4187
 * 
 *         # for htslib, wbu seems to not work
 *         if mode == 'wbu':             # <<<<<<<<<<<<<<
 *             mode = 'wb0'
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4190
 *             mode = 'wb0'
 * 
 *         self.mode = mode = force_bytes(mode)             # <<<<<<<<<<<<<<
 *         try:
 *             filename = encode_filename(filename)
 */
  __pyx_t_10 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_mode, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_INCREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_10);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.mode);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.mode);
  __pyx_v_self->__pyx_base.mode = __pyx_t_10;
  __Pyx_INCREF(__pyx_t_10);
  __Pyx_DECREF_SET(__pyx_v_mode, __pyx_t_10);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "pysam/libcbcf.pyx":4191
 * 
 *         self.mode = mode = force_bytes(mode)
 *         try:             # <<<<<<<<<<<<<<
 *             filename = encode_filename(filename)
 *             self.is_remote = hisremote(filename)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
    __Pyx_XGOTREF(__pyx_t_11);
    __Pyx_XGOTREF(__pyx_t_12);
    __Pyx_XGOTREF(__pyx_t_13);
    /*try:*/ {

      /* "pysam/libcbcf.pyx":4192
 *         self.mode = mode = force_bytes(mode)
 *         try:
 *             filename = encode_filename(filename)             # <<<<<<<<<<<<<<
 *             self.is_remote = hisremote(filename)
 *             self.is_stream = filename == b'-'
 */
      __pyx_t_10 = __pyx_f_5pysam_9libcutils_encode_filename(__pyx_v_filename); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4192, __pyx_L23_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF_SET(__pyx_v_filename, __pyx_t_10);
      __pyx_t_10 = 0;

      /* "pysam/libcbcf.pyx":4193
 *         try:
 *             filename = encode_filename(filename)
 *             self.is_remote = hisremote(filename)             # <<<<<<<<<<<<<<
 *             self.is_stream = filename == b'-'
 *         except TypeError:
 */
      __pyx_t_14 = __Pyx_PyObject_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) __PYX_ERR(0, 4193, __pyx_L23_error)
      __pyx_v_self->__pyx_base.is_remote = hisremote(__pyx_t_14);

      /* "pysam/libcbcf.pyx":4194
 *             filename = encode_filename(filename)
 *             self.is_remote = hisremote(filename)
 *             self.is_stream = filename == b'-'             # <<<<<<<<<<<<<<
 *         except TypeError:
 *             filename = filename
 */
      __pyx_t_10 = PyObject_RichCompare(__pyx_v_filename, __pyx_kp_b__221, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4194, __pyx_L23_error)
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 4194, __pyx_L23_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_v_self->__pyx_base.is_stream = __pyx_t_1;

      /* "pysam/libcbcf.pyx":4191
 * 
 *         self.mode = mode = force_bytes(mode)
 *         try:             # <<<<<<<<<<<<<<
 *             filename = encode_filename(filename)
 *             self.is_remote = hisremote(filename)
 */
    }
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    goto __pyx_L28_try_end;
    __pyx_L23_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "pysam/libcbcf.pyx":4195
 *             self.is_remote = hisremote(filename)
 *             self.is_stream = filename == b'-'
 *         except TypeError:             # <<<<<<<<<<<<<<
 *             filename = filename
 *             self.is_remote = False
 */
    __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
    if (__pyx_t_15) {
      __Pyx_AddTraceback("pysam.libcbcf.VariantFile.open", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_5, &__pyx_t_9) < 0) __PYX_ERR(0, 4195, __pyx_L25_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_9);

      /* "pysam/libcbcf.pyx":4196
 *             self.is_stream = filename == b'-'
 *         except TypeError:
 *             filename = filename             # <<<<<<<<<<<<<<
 *             self.is_remote = False
 *             self.is_stream = True
 */
      __Pyx_INCREF(__pyx_v_filename);
      __Pyx_DECREF_SET(__pyx_v_filename, __pyx_v_filename);

      /* "pysam/libcbcf.pyx":4197
 *         except TypeError:
 *             filename = filename
 *             self.is_remote = False             # <<<<<<<<<<<<<<
 *             self.is_stream = True
 * 
 */
      __pyx_v_self->__pyx_base.is_remote = 0;

      /* "pysam/libcbcf.pyx":4198
 *             filename = filename
 *             self.is_remote = False
 *             self.is_stream = True             # <<<<<<<<<<<<<<
 * 
 *         self.filename = filename
 */
      __pyx_v_self->__pyx_base.is_stream = 1;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L24_exception_handled;
    }
    goto __pyx_L25_except_error;
    __pyx_L25_except_error:;

    /* "pysam/libcbcf.pyx":4191
 * 
 *         self.mode = mode = force_bytes(mode)
 *         try:             # <<<<<<<<<<<<<<
 *             filename = encode_filename(filename)
 *             self.is_remote = hisremote(filename)
 */
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
    goto __pyx_L1_error;
    __pyx_L24_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
    __pyx_L28_try_end:;
  }

  /* "pysam/libcbcf.pyx":4200
 *             self.is_stream = True
 * 
 *         self.filename = filename             # <<<<<<<<<<<<<<
 * 
 *         if index_filename is not None:
 */
  __Pyx_INCREF(__pyx_v_filename);
  __Pyx_GIVEREF(__pyx_v_filename);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.filename);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.filename);
  __pyx_v_self->__pyx_base.filename = __pyx_v_filename;

  /* "pysam/libcbcf.pyx":4202
 *         self.filename = filename
 * 
 *         if index_filename is not None:             # <<<<<<<<<<<<<<
 *             self.index_filename = index_filename = encode_filename(index_filename)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_index_filename != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "pysam/libcbcf.pyx":4203
 * 
 *         if index_filename is not None:
 *             self.index_filename = index_filename = encode_filename(index_filename)             # <<<<<<<<<<<<<<
 *         else:
 *             self.index_filename = None
 */
    __pyx_t_9 = __pyx_f_5pysam_9libcutils_encode_filename(__pyx_v_index_filename); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4203, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.index_filename);
    __Pyx_DECREF(__pyx_v_self->__pyx_base.index_filename);
    __pyx_v_self->__pyx_base.index_filename = __pyx_t_9;
    __Pyx_INCREF(__pyx_t_9);
    __Pyx_DECREF_SET(__pyx_v_index_filename, __pyx_t_9);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pysam/libcbcf.pyx":4202
 *         self.filename = filename
 * 
 *         if index_filename is not None:             # <<<<<<<<<<<<<<
 *             self.index_filename = index_filename = encode_filename(index_filename)
 *         else:
 */
    goto __pyx_L31;
  }

  /* "pysam/libcbcf.pyx":4205
 *             self.index_filename = index_filename = encode_filename(index_filename)
 *         else:
 *             self.index_filename = None             # <<<<<<<<<<<<<<
 * 
 *         self.drop_samples = bool(drop_samples)
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.index_filename);
    __Pyx_DECREF(__pyx_v_self->__pyx_base.index_filename);
    __pyx_v_self->__pyx_base.index_filename = Py_None;
  }
  __pyx_L31:;

  /* "pysam/libcbcf.pyx":4207
 *             self.index_filename = None
 * 
 *         self.drop_samples = bool(drop_samples)             # <<<<<<<<<<<<<<
 *         self.header = None
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_drop_samples); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 4207, __pyx_L1_error)
  __pyx_v_self->drop_samples = (!(!__pyx_t_6));

  /* "pysam/libcbcf.pyx":4208
 * 
 *         self.drop_samples = bool(drop_samples)
 *         self.header = None             # <<<<<<<<<<<<<<
 * 
 *         self.header_written = False
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->header);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->header));
  __pyx_v_self->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None);

  /* "pysam/libcbcf.pyx":4210
 *         self.header = None
 * 
 *         self.header_written = False             # <<<<<<<<<<<<<<
 * 
 *         if mode.startswith(b'w'):
 */
  __pyx_v_self->header_written = 0;

  /* "pysam/libcbcf.pyx":4212
 *         self.header_written = False
 * 
 *         if mode.startswith(b'w'):             # <<<<<<<<<<<<<<
 *             # open file for writing
 *             if index_filename is not None:
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_mode, __pyx_n_s_startswith); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__222, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 4212, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_6) {

    /* "pysam/libcbcf.pyx":4214
 *         if mode.startswith(b'w'):
 *             # open file for writing
 *             if index_filename is not None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Cannot specify an index filename when writing a VCF/BCF file')
 * 
 */
    __pyx_t_6 = (__pyx_v_index_filename != Py_None);
    __pyx_t_1 = (__pyx_t_6 != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":4215
 *             # open file for writing
 *             if index_filename is not None:
 *                 raise ValueError('Cannot specify an index filename when writing a VCF/BCF file')             # <<<<<<<<<<<<<<
 * 
 *             # header structure (used for writing)
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__223, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4215, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 4215, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":4214
 *         if mode.startswith(b'w'):
 *             # open file for writing
 *             if index_filename is not None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Cannot specify an index filename when writing a VCF/BCF file')
 * 
 */
    }

    /* "pysam/libcbcf.pyx":4218
 * 
 *             # header structure (used for writing)
 *             if header:             # <<<<<<<<<<<<<<
 *                 self.header = header.copy()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_header)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 4218, __pyx_L1_error)
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":4219
 *             # header structure (used for writing)
 *             if header:
 *                 self.header = header.copy()             # <<<<<<<<<<<<<<
 *             else:
 *                 self.header = VariantHeader()
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_header), __pyx_n_s_copy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4219, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_10) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4219, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else {
        __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4219, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5pysam_7libcbcf_VariantHeader))))) __PYX_ERR(0, 4219, __pyx_L1_error)
      __Pyx_GIVEREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_v_self->header);
      __Pyx_DECREF(((PyObject *)__pyx_v_self->header));
      __pyx_v_self->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_5);
      __pyx_t_5 = 0;

      /* "pysam/libcbcf.pyx":4218
 * 
 *             # header structure (used for writing)
 *             if header:             # <<<<<<<<<<<<<<
 *                 self.header = header.copy()
 *             else:
 */
      goto __pyx_L34;
    }

    /* "pysam/libcbcf.pyx":4221
 *                 self.header = header.copy()
 *             else:
 *                 self.header = VariantHeader()             # <<<<<<<<<<<<<<
 *                 #raise ValueError('a VariantHeader must be specified')
 * 
 */
    /*else*/ {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeader)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4221, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_v_self->header);
      __Pyx_DECREF(((PyObject *)__pyx_v_self->header));
      __pyx_v_self->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_5);
      __pyx_t_5 = 0;
    }
    __pyx_L34:;

    /* "pysam/libcbcf.pyx":4225
 * 
 *             # Header is not written until the first write or on close
 *             self.htsfile = self._open_htsfile()             # <<<<<<<<<<<<<<
 * 
 *             if not self.htsfile:
 */
    __pyx_t_16 = ((struct __pyx_vtabstruct_5pysam_7libcbcf_VariantFile *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._open_htsfile(((struct __pyx_obj_5pysam_10libchtslib_HTSFile *)__pyx_v_self)); if (unlikely(__pyx_t_16 == ((htsFile *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 4225, __pyx_L1_error)
    __pyx_v_self->__pyx_base.htsfile = __pyx_t_16;

    /* "pysam/libcbcf.pyx":4227
 *             self.htsfile = self._open_htsfile()
 * 
 *             if not self.htsfile:             # <<<<<<<<<<<<<<
 *                 raise ValueError("could not open file `{}` (mode='{}')".format(filename, mode))
 * 
 */
    __pyx_t_1 = ((!(__pyx_v_self->__pyx_base.htsfile != 0)) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "pysam/libcbcf.pyx":4228
 * 
 *             if not self.htsfile:
 *                 raise ValueError("could not open file `{}` (mode='{}')".format(filename, mode))             # <<<<<<<<<<<<<<
 * 
 *         elif mode.startswith(b'r'):
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_could_not_open_file_mode, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4228, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      __pyx_t_15 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_15 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_filename, __pyx_v_mode};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4228, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_filename, __pyx_v_mode};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4228, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else
      #endif
      {
        __pyx_t_2 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4228, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_INCREF(__pyx_v_filename);
        __Pyx_GIVEREF(__pyx_v_filename);
        PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_15, __pyx_v_filename);
        __Pyx_INCREF(__pyx_v_mode);
        __Pyx_GIVEREF(__pyx_v_mode);
        PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_15, __pyx_v_mode);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4228, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4228, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 4228, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":4227
 *             self.htsfile = self._open_htsfile()
 * 
 *             if not self.htsfile:             # <<<<<<<<<<<<<<
 *                 raise ValueError("could not open file `{}` (mode='{}')".format(filename, mode))
 * 
 */
    }

    /* "pysam/libcbcf.pyx":4212
 *         self.header_written = False
 * 
 *         if mode.startswith(b'w'):             # <<<<<<<<<<<<<<
 *             # open file for writing
 *             if index_filename is not None:
 */
    goto __pyx_L32;
  }

  /* "pysam/libcbcf.pyx":4230
 *                 raise ValueError("could not open file `{}` (mode='{}')".format(filename, mode))
 * 
 *         elif mode.startswith(b'r'):             # <<<<<<<<<<<<<<
 *             # open file for reading
 *             self.htsfile = self._open_htsfile()
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_mode, __pyx_n_s_startswith); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__224, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 4230, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(__pyx_t_1)) {

    /* "pysam/libcbcf.pyx":4232
 *         elif mode.startswith(b'r'):
 *             # open file for reading
 *             self.htsfile = self._open_htsfile()             # <<<<<<<<<<<<<<
 * 
 *             if not self.htsfile:
 */
    __pyx_t_16 = ((struct __pyx_vtabstruct_5pysam_7libcbcf_VariantFile *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._open_htsfile(((struct __pyx_obj_5pysam_10libchtslib_HTSFile *)__pyx_v_self)); if (unlikely(__pyx_t_16 == ((htsFile *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 4232, __pyx_L1_error)
    __pyx_v_self->__pyx_base.htsfile = __pyx_t_16;

    /* "pysam/libcbcf.pyx":4234
 *             self.htsfile = self._open_htsfile()
 * 
 *             if not self.htsfile:             # <<<<<<<<<<<<<<
 *                 if errno:
 *                     raise IOError(errno, 'could not open variant file `{}`: {}'.format(filename, force_str(strerror(errno))))
 */
    __pyx_t_1 = ((!(__pyx_v_self->__pyx_base.htsfile != 0)) != 0);
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":4235
 * 
 *             if not self.htsfile:
 *                 if errno:             # <<<<<<<<<<<<<<
 *                     raise IOError(errno, 'could not open variant file `{}`: {}'.format(filename, force_str(strerror(errno))))
 *                 else:
 */
      __pyx_t_1 = (errno != 0);
      if (unlikely(__pyx_t_1)) {

        /* "pysam/libcbcf.pyx":4236
 *             if not self.htsfile:
 *                 if errno:
 *                     raise IOError(errno, 'could not open variant file `{}`: {}'.format(filename, force_str(strerror(errno))))             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError('could not open variant file `{}`'.format(filename))
 */
        __pyx_t_5 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4236, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_could_not_open_variant_file, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4236, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_10 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4236, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_4 = __pyx_f_5pysam_9libcutils_force_str(__pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4236, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = NULL;
        __pyx_t_15 = 0;
        if (CYTHON_UNPACK_METHODS && likely(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_15 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_filename, __pyx_t_4};
          __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4236, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __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_10, __pyx_v_filename, __pyx_t_4};
          __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4236, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        {
          __pyx_t_17 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4236, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (__pyx_t_10) {
            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_10); __pyx_t_10 = NULL;
          }
          __Pyx_INCREF(__pyx_v_filename);
          __Pyx_GIVEREF(__pyx_v_filename);
          PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_15, __pyx_v_filename);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_15, __pyx_t_4);
          __pyx_t_4 = 0;
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_17, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4236, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4236, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_9);
        __pyx_t_5 = 0;
        __pyx_t_9 = 0;
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4236, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_9, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __PYX_ERR(0, 4236, __pyx_L1_error)

        /* "pysam/libcbcf.pyx":4235
 * 
 *             if not self.htsfile:
 *                 if errno:             # <<<<<<<<<<<<<<
 *                     raise IOError(errno, 'could not open variant file `{}`: {}'.format(filename, force_str(strerror(errno))))
 *                 else:
 */
      }

      /* "pysam/libcbcf.pyx":4238
 *                     raise IOError(errno, 'could not open variant file `{}`: {}'.format(filename, force_str(strerror(errno))))
 *                 else:
 *                     raise ValueError('could not open variant file `{}`'.format(filename))             # <<<<<<<<<<<<<<
 * 
 *             if self.htsfile.format.format not in (bcf, vcf):
 */
      /*else*/ {
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_could_not_open_variant_file_2, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4238, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(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);
          }
        }
        if (!__pyx_t_5) {
          __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_filename); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4238, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_2)) {
            PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_filename};
            __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4238, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_9);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
            PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_filename};
            __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4238, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_9);
          } else
          #endif
          {
            __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4238, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_5); __pyx_t_5 = NULL;
            __Pyx_INCREF(__pyx_v_filename);
            __Pyx_GIVEREF(__pyx_v_filename);
            PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_v_filename);
            __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_17, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4238, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4238, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(0, 4238, __pyx_L1_error)
      }

      /* "pysam/libcbcf.pyx":4234
 *             self.htsfile = self._open_htsfile()
 * 
 *             if not self.htsfile:             # <<<<<<<<<<<<<<
 *                 if errno:
 *                     raise IOError(errno, 'could not open variant file `{}`: {}'.format(filename, force_str(strerror(errno))))
 */
    }

    /* "pysam/libcbcf.pyx":4240
 *                     raise ValueError('could not open variant file `{}`'.format(filename))
 * 
 *             if self.htsfile.format.format not in (bcf, vcf):             # <<<<<<<<<<<<<<
 *                 raise ValueError('invalid file `{}` (mode=`{}`) - is it VCF/BCF format?'.format(filename, mode))
 * 
 */
    switch (__pyx_v_self->__pyx_base.htsfile->format.format) {
      case bcf:
      case vcf:
      __pyx_t_1 = 0;
      break;
      default:
      __pyx_t_1 = 1;
      break;
    }
    __pyx_t_6 = (__pyx_t_1 != 0);
    if (unlikely(__pyx_t_6)) {

      /* "pysam/libcbcf.pyx":4241
 * 
 *             if self.htsfile.format.format not in (bcf, vcf):
 *                 raise ValueError('invalid file `{}` (mode=`{}`) - is it VCF/BCF format?'.format(filename, mode))             # <<<<<<<<<<<<<<
 * 
 *             self.check_truncation(ignore_truncation)
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_invalid_file_mode_is_it_VCF_BCF, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4241, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_17 = NULL;
      __pyx_t_15 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_17)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_17);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_15 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_17, __pyx_v_filename, __pyx_v_mode};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4241, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_17, __pyx_v_filename, __pyx_v_mode};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4241, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4241, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (__pyx_t_17) {
          __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_17); __pyx_t_17 = NULL;
        }
        __Pyx_INCREF(__pyx_v_filename);
        __Pyx_GIVEREF(__pyx_v_filename);
        PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_15, __pyx_v_filename);
        __Pyx_INCREF(__pyx_v_mode);
        __Pyx_GIVEREF(__pyx_v_mode);
        PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_15, __pyx_v_mode);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4241, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4241, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 4241, __pyx_L1_error)

      /* "pysam/libcbcf.pyx":4240
 *                     raise ValueError('could not open variant file `{}`'.format(filename))
 * 
 *             if self.htsfile.format.format not in (bcf, vcf):             # <<<<<<<<<<<<<<
 *                 raise ValueError('invalid file `{}` (mode=`{}`) - is it VCF/BCF format?'.format(filename, mode))
 * 
 */
    }

    /* "pysam/libcbcf.pyx":4243
 *                 raise ValueError('invalid file `{}` (mode=`{}`) - is it VCF/BCF format?'.format(filename, mode))
 * 
 *             self.check_truncation(ignore_truncation)             # <<<<<<<<<<<<<<
 * 
 *             with nogil:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_check_truncation); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4243, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_ignore_truncation); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4243, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_ignore_truncation};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4243, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_ignore_truncation};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4243, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      {
        __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4243, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_INCREF(__pyx_v_ignore_truncation);
        __Pyx_GIVEREF(__pyx_v_ignore_truncation);
        PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_v_ignore_truncation);
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_17, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4243, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pysam/libcbcf.pyx":4245
 *             self.check_truncation(ignore_truncation)
 * 
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 hdr = bcf_hdr_read(self.htsfile)
 * 
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        __Pyx_FastGIL_Remember();
        #endif
        /*try:*/ {

          /* "pysam/libcbcf.pyx":4246
 * 
 *             with nogil:
 *                 hdr = bcf_hdr_read(self.htsfile)             # <<<<<<<<<<<<<<
 * 
 *             try:
 */
          __pyx_v_hdr = bcf_hdr_read(__pyx_v_self->__pyx_base.htsfile);
        }

        /* "pysam/libcbcf.pyx":4245
 *             self.check_truncation(ignore_truncation)
 * 
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 hdr = bcf_hdr_read(self.htsfile)
 * 
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L41;
          }
          __pyx_L41:;
        }
    }

    /* "pysam/libcbcf.pyx":4248
 *                 hdr = bcf_hdr_read(self.htsfile)
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 self.header = makeVariantHeader(hdr)
 *             except ValueError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_11);
      /*try:*/ {

        /* "pysam/libcbcf.pyx":4249
 * 
 *             try:
 *                 self.header = makeVariantHeader(hdr)             # <<<<<<<<<<<<<<
 *             except ValueError:
 *                 raise ValueError('file `{}` does not have valid header (mode=`{}`) - is it VCF/BCF format?'.format(filename, mode))
 */
        __pyx_t_9 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeVariantHeader(__pyx_v_hdr)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4249, __pyx_L42_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_v_self->header);
        __Pyx_DECREF(((PyObject *)__pyx_v_self->header));
        __pyx_v_self->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_9);
        __pyx_t_9 = 0;

        /* "pysam/libcbcf.pyx":4248
 *                 hdr = bcf_hdr_read(self.htsfile)
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 self.header = makeVariantHeader(hdr)
 *             except ValueError:
 */
      }
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L47_try_end;
      __pyx_L42_error:;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "pysam/libcbcf.pyx":4250
 *             try:
 *                 self.header = makeVariantHeader(hdr)
 *             except ValueError:             # <<<<<<<<<<<<<<
 *                 raise ValueError('file `{}` does not have valid header (mode=`{}`) - is it VCF/BCF format?'.format(filename, mode))
 * 
 */
      __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
      if (__pyx_t_15) {
        __Pyx_AddTraceback("pysam.libcbcf.VariantFile.open", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_2, &__pyx_t_17) < 0) __PYX_ERR(0, 4250, __pyx_L44_except_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_17);

        /* "pysam/libcbcf.pyx":4251
 *                 self.header = makeVariantHeader(hdr)
 *             except ValueError:
 *                 raise ValueError('file `{}` does not have valid header (mode=`{}`) - is it VCF/BCF format?'.format(filename, mode))             # <<<<<<<<<<<<<<
 * 
 *             if isinstance(self.filename, bytes):
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_file_does_not_have_valid_header, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4251, __pyx_L44_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = NULL;
        __pyx_t_15 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
            __pyx_t_15 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_filename, __pyx_v_mode};
          __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4251, __pyx_L44_except_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_5);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_filename, __pyx_v_mode};
          __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4251, __pyx_L44_except_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_5);
        } else
        #endif
        {
          __pyx_t_18 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4251, __pyx_L44_except_error)
          __Pyx_GOTREF(__pyx_t_18);
          if (__pyx_t_10) {
            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_10); __pyx_t_10 = NULL;
          }
          __Pyx_INCREF(__pyx_v_filename);
          __Pyx_GIVEREF(__pyx_v_filename);
          PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_15, __pyx_v_filename);
          __Pyx_INCREF(__pyx_v_mode);
          __Pyx_GIVEREF(__pyx_v_mode);
          PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_15, __pyx_v_mode);
          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_18, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4251, __pyx_L44_except_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4251, __pyx_L44_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 4251, __pyx_L44_except_error)
      }
      goto __pyx_L44_except_error;
      __pyx_L44_except_error:;

      /* "pysam/libcbcf.pyx":4248
 *                 hdr = bcf_hdr_read(self.htsfile)
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 self.header = makeVariantHeader(hdr)
 *             except ValueError:
 */
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
      goto __pyx_L1_error;
      __pyx_L47_try_end:;
    }

    /* "pysam/libcbcf.pyx":4253
 *                 raise ValueError('file `{}` does not have valid header (mode=`{}`) - is it VCF/BCF format?'.format(filename, mode))
 * 
 *             if isinstance(self.filename, bytes):             # <<<<<<<<<<<<<<
 *                 cfilename = self.filename
 *             else:
 */
    __pyx_t_17 = __pyx_v_self->__pyx_base.filename;
    __Pyx_INCREF(__pyx_t_17);
    __pyx_t_6 = PyBytes_Check(__pyx_t_17); 
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __pyx_t_1 = (__pyx_t_6 != 0);
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":4254
 * 
 *             if isinstance(self.filename, bytes):
 *                 cfilename = self.filename             # <<<<<<<<<<<<<<
 *             else:
 *                 cfilename = NULL
 */
      __pyx_t_19 = __Pyx_PyObject_AsWritableString(__pyx_v_self->__pyx_base.filename); if (unlikely((!__pyx_t_19) && PyErr_Occurred())) __PYX_ERR(0, 4254, __pyx_L1_error)
      __pyx_v_cfilename = __pyx_t_19;

      /* "pysam/libcbcf.pyx":4253
 *                 raise ValueError('file `{}` does not have valid header (mode=`{}`) - is it VCF/BCF format?'.format(filename, mode))
 * 
 *             if isinstance(self.filename, bytes):             # <<<<<<<<<<<<<<
 *                 cfilename = self.filename
 *             else:
 */
      goto __pyx_L50;
    }

    /* "pysam/libcbcf.pyx":4256
 *                 cfilename = self.filename
 *             else:
 *                 cfilename = NULL             # <<<<<<<<<<<<<<
 * 
 *             # check for index and open if present
 */
    /*else*/ {
      __pyx_v_cfilename = NULL;
    }
    __pyx_L50:;

    /* "pysam/libcbcf.pyx":4259
 * 
 *             # check for index and open if present
 *             if self.htsfile.format.format == bcf and cfilename:             # <<<<<<<<<<<<<<
 *                 if index_filename is not None:
 *                     cindex_filename = index_filename
 */
    __pyx_t_6 = ((__pyx_v_self->__pyx_base.htsfile->format.format == bcf) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_1 = __pyx_t_6;
      goto __pyx_L52_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_cfilename != 0);
    __pyx_t_1 = __pyx_t_6;
    __pyx_L52_bool_binop_done:;
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":4260
 *             # check for index and open if present
 *             if self.htsfile.format.format == bcf and cfilename:
 *                 if index_filename is not None:             # <<<<<<<<<<<<<<
 *                     cindex_filename = index_filename
 *                 with nogil:
 */
      __pyx_t_1 = (__pyx_v_index_filename != Py_None);
      __pyx_t_6 = (__pyx_t_1 != 0);
      if (__pyx_t_6) {

        /* "pysam/libcbcf.pyx":4261
 *             if self.htsfile.format.format == bcf and cfilename:
 *                 if index_filename is not None:
 *                     cindex_filename = index_filename             # <<<<<<<<<<<<<<
 *                 with nogil:
 *                     idx = bcf_index_load2(cfilename, cindex_filename)
 */
        __pyx_t_19 = __Pyx_PyObject_AsWritableString(__pyx_v_index_filename); if (unlikely((!__pyx_t_19) && PyErr_Occurred())) __PYX_ERR(0, 4261, __pyx_L1_error)
        __pyx_v_cindex_filename = __pyx_t_19;

        /* "pysam/libcbcf.pyx":4260
 *             # check for index and open if present
 *             if self.htsfile.format.format == bcf and cfilename:
 *                 if index_filename is not None:             # <<<<<<<<<<<<<<
 *                     cindex_filename = index_filename
 *                 with nogil:
 */
      }

      /* "pysam/libcbcf.pyx":4262
 *                 if index_filename is not None:
 *                     cindex_filename = index_filename
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     idx = bcf_index_load2(cfilename, cindex_filename)
 *                 self.index = makeBCFIndex(self.header, idx)
 */
      {
          #ifdef WITH_THREAD
          PyThreadState *_save;
          Py_UNBLOCK_THREADS
          __Pyx_FastGIL_Remember();
          #endif
          /*try:*/ {

            /* "pysam/libcbcf.pyx":4263
 *                     cindex_filename = index_filename
 *                 with nogil:
 *                     idx = bcf_index_load2(cfilename, cindex_filename)             # <<<<<<<<<<<<<<
 *                 self.index = makeBCFIndex(self.header, idx)
 * 
 */
            __pyx_v_idx = bcf_index_load2(__pyx_v_cfilename, __pyx_v_cindex_filename);
          }

          /* "pysam/libcbcf.pyx":4262
 *                 if index_filename is not None:
 *                     cindex_filename = index_filename
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     idx = bcf_index_load2(cfilename, cindex_filename)
 *                 self.index = makeBCFIndex(self.header, idx)
 */
          /*finally:*/ {
            /*normal exit:*/{
              #ifdef WITH_THREAD
              __Pyx_FastGIL_Forget();
              Py_BLOCK_THREADS
              #endif
              goto __pyx_L57;
            }
            __pyx_L57:;
          }
      }

      /* "pysam/libcbcf.pyx":4264
 *                 with nogil:
 *                     idx = bcf_index_load2(cfilename, cindex_filename)
 *                 self.index = makeBCFIndex(self.header, idx)             # <<<<<<<<<<<<<<
 * 
 *             elif self.htsfile.format.compression == bgzf and cfilename:
 */
      __pyx_t_17 = ((PyObject *)__pyx_v_self->header);
      __Pyx_INCREF(__pyx_t_17);
      __pyx_t_2 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeBCFIndex(((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_17), __pyx_v_idx)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4264, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GIVEREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_v_self->index);
      __Pyx_DECREF(((PyObject *)__pyx_v_self->index));
      __pyx_v_self->index = ((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "pysam/libcbcf.pyx":4259
 * 
 *             # check for index and open if present
 *             if self.htsfile.format.format == bcf and cfilename:             # <<<<<<<<<<<<<<
 *                 if index_filename is not None:
 *                     cindex_filename = index_filename
 */
      goto __pyx_L51;
    }

    /* "pysam/libcbcf.pyx":4266
 *                 self.index = makeBCFIndex(self.header, idx)
 * 
 *             elif self.htsfile.format.compression == bgzf and cfilename:             # <<<<<<<<<<<<<<
 *                 if index_filename is not None:
 *                     cindex_filename = index_filename
 */
    __pyx_t_1 = ((__pyx_v_self->__pyx_base.htsfile->format.compression == bgzf) != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_6 = __pyx_t_1;
      goto __pyx_L58_bool_binop_done;
    }
    __pyx_t_1 = (__pyx_v_cfilename != 0);
    __pyx_t_6 = __pyx_t_1;
    __pyx_L58_bool_binop_done:;
    if (__pyx_t_6) {

      /* "pysam/libcbcf.pyx":4267
 * 
 *             elif self.htsfile.format.compression == bgzf and cfilename:
 *                 if index_filename is not None:             # <<<<<<<<<<<<<<
 *                     cindex_filename = index_filename
 *                 with nogil:
 */
      __pyx_t_6 = (__pyx_v_index_filename != Py_None);
      __pyx_t_1 = (__pyx_t_6 != 0);
      if (__pyx_t_1) {

        /* "pysam/libcbcf.pyx":4268
 *             elif self.htsfile.format.compression == bgzf and cfilename:
 *                 if index_filename is not None:
 *                     cindex_filename = index_filename             # <<<<<<<<<<<<<<
 *                 with nogil:
 *                     tidx = tbx_index_load2(cfilename, cindex_filename)
 */
        __pyx_t_19 = __Pyx_PyObject_AsWritableString(__pyx_v_index_filename); if (unlikely((!__pyx_t_19) && PyErr_Occurred())) __PYX_ERR(0, 4268, __pyx_L1_error)
        __pyx_v_cindex_filename = __pyx_t_19;

        /* "pysam/libcbcf.pyx":4267
 * 
 *             elif self.htsfile.format.compression == bgzf and cfilename:
 *                 if index_filename is not None:             # <<<<<<<<<<<<<<
 *                     cindex_filename = index_filename
 *                 with nogil:
 */
      }

      /* "pysam/libcbcf.pyx":4269
 *                 if index_filename is not None:
 *                     cindex_filename = index_filename
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     tidx = tbx_index_load2(cfilename, cindex_filename)
 *                 self.index = makeTabixIndex(tidx)
 */
      {
          #ifdef WITH_THREAD
          PyThreadState *_save;
          Py_UNBLOCK_THREADS
          __Pyx_FastGIL_Remember();
          #endif
          /*try:*/ {

            /* "pysam/libcbcf.pyx":4270
 *                     cindex_filename = index_filename
 *                 with nogil:
 *                     tidx = tbx_index_load2(cfilename, cindex_filename)             # <<<<<<<<<<<<<<
 *                 self.index = makeTabixIndex(tidx)
 * 
 */
            __pyx_v_tidx = tbx_index_load2(__pyx_v_cfilename, __pyx_v_cindex_filename);
          }

          /* "pysam/libcbcf.pyx":4269
 *                 if index_filename is not None:
 *                     cindex_filename = index_filename
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     tidx = tbx_index_load2(cfilename, cindex_filename)
 *                 self.index = makeTabixIndex(tidx)
 */
          /*finally:*/ {
            /*normal exit:*/{
              #ifdef WITH_THREAD
              __Pyx_FastGIL_Forget();
              Py_BLOCK_THREADS
              #endif
              goto __pyx_L63;
            }
            __pyx_L63:;
          }
      }

      /* "pysam/libcbcf.pyx":4271
 *                 with nogil:
 *                     tidx = tbx_index_load2(cfilename, cindex_filename)
 *                 self.index = makeTabixIndex(tidx)             # <<<<<<<<<<<<<<
 * 
 *             if not self.is_stream:
 */
      __pyx_t_2 = ((PyObject *)__pyx_f_5pysam_7libcbcf_makeTabixIndex(__pyx_v_tidx)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4271, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_v_self->index);
      __Pyx_DECREF(((PyObject *)__pyx_v_self->index));
      __pyx_v_self->index = ((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "pysam/libcbcf.pyx":4266
 *                 self.index = makeBCFIndex(self.header, idx)
 * 
 *             elif self.htsfile.format.compression == bgzf and cfilename:             # <<<<<<<<<<<<<<
 *                 if index_filename is not None:
 *                     cindex_filename = index_filename
 */
    }
    __pyx_L51:;

    /* "pysam/libcbcf.pyx":4273
 *                 self.index = makeTabixIndex(tidx)
 * 
 *             if not self.is_stream:             # <<<<<<<<<<<<<<
 *                 self.start_offset = self.tell()
 *         else:
 */
    __pyx_t_1 = ((!(__pyx_v_self->__pyx_base.is_stream != 0)) != 0);
    if (__pyx_t_1) {

      /* "pysam/libcbcf.pyx":4274
 * 
 *             if not self.is_stream:
 *                 self.start_offset = self.tell()             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError('unknown mode {}'.format(mode))
 */
      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tell); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4274, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_17))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_17);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_17, function);
        }
      }
      if (__pyx_t_9) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4274, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4274, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_20 = __Pyx_PyInt_As_int64_t(__pyx_t_2); if (unlikely((__pyx_t_20 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 4274, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_self->__pyx_base.start_offset = __pyx_t_20;

      /* "pysam/libcbcf.pyx":4273
 *                 self.index = makeTabixIndex(tidx)
 * 
 *             if not self.is_stream:             # <<<<<<<<<<<<<<
 *                 self.start_offset = self.tell()
 *         else:
 */
    }

    /* "pysam/libcbcf.pyx":4230
 *                 raise ValueError("could not open file `{}` (mode='{}')".format(filename, mode))
 * 
 *         elif mode.startswith(b'r'):             # <<<<<<<<<<<<<<
 *             # open file for reading
 *             self.htsfile = self._open_htsfile()
 */
    goto __pyx_L32;
  }

  /* "pysam/libcbcf.pyx":4276
 *                 self.start_offset = self.tell()
 *         else:
 *             raise ValueError('unknown mode {}'.format(mode))             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  /*else*/ {
    __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_unknown_mode, __pyx_n_s_format); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_17))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_17);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_17, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_v_mode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4276, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_17)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_mode};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_17, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4276, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_17)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_mode};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_17, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4276, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4276, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_INCREF(__pyx_v_mode);
        __Pyx_GIVEREF(__pyx_v_mode);
        PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_mode);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4276, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_17, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __PYX_ERR(0, 4276, __pyx_L1_error)
  }
  __pyx_L32:;

  /* "pysam/libcbcf.pyx":4133
 *         return vars
 * 
 *     def open(self, filename, mode='r',             # <<<<<<<<<<<<<<
 *              index_filename=None,
 *              VariantHeader header=None,
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.open", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_format_modes);
  __Pyx_XDECREF(__pyx_v_invalid_modes);
  __Pyx_XDECREF(__pyx_v_m);
  __Pyx_XDECREF(__pyx_v_filename);
  __Pyx_XDECREF(__pyx_v_mode);
  __Pyx_XDECREF(__pyx_v_index_filename);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4278
 *             raise ValueError('unknown mode {}'.format(mode))
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         """reset file position to beginning of file just after the header."""
 *         return self.seek(self.start_offset)
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_17reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_16reset[] = "VariantFile.reset(self)\nreset file position to beginning of file just after the header.";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_17reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_16reset(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_16reset(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);
  __Pyx_TraceCall("reset", __pyx_f[0], 4278, 0, __PYX_ERR(0, 4278, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":4280
 *     def reset(self):
 *         """reset file position to beginning of file just after the header."""
 *         return self.seek(self.start_offset)             # <<<<<<<<<<<<<<
 * 
 *     def is_valid_tid(self, tid):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_seek); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int64_t(__pyx_v_self->__pyx_base.start_offset); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4280, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4280, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4280, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4280, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4280, __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;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":4278
 *             raise ValueError('unknown mode {}'.format(mode))
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         """reset file position to beginning of file just after the header."""
 *         return self.seek(self.start_offset)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4282
 *         return self.seek(self.start_offset)
 * 
 *     def is_valid_tid(self, tid):             # <<<<<<<<<<<<<<
 *         """
 *         return True if the numerical :term:`tid` is valid; False otherwise.
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_19is_valid_tid(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_18is_valid_tid[] = "VariantFile.is_valid_tid(self, tid)\n\n        return True if the numerical :term:`tid` is valid; False otherwise.\n\n        returns -1 if reference is not known.\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_19is_valid_tid(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_valid_tid (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_18is_valid_tid(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self), ((PyObject *)__pyx_v_tid));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_18is_valid_tid(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_tid) {
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_rid;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  bcf_hdr_t *__pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("is_valid_tid", 0);
  __Pyx_TraceCall("is_valid_tid", __pyx_f[0], 4282, 0, __PYX_ERR(0, 4282, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":4288
 *         returns -1 if reference is not known.
 *         """
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError('I/O operation on closed file')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4288, __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, 4288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4289
 *         """
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__225, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4289, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4289, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4288
 *         returns -1 if reference is not known.
 *         """
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError('I/O operation on closed file')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4291
 *             raise ValueError('I/O operation on closed file')
 * 
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef int rid = tid
 *         return 0 <= rid < hdr.n[BCF_DT_CTG]
 */
  __pyx_t_4 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":4292
 * 
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int rid = tid             # <<<<<<<<<<<<<<
 *         return 0 <= rid < hdr.n[BCF_DT_CTG]
 * 
 */
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_tid); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 4292, __pyx_L1_error)
  __pyx_v_rid = __pyx_t_5;

  /* "pysam/libcbcf.pyx":4293
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int rid = tid
 *         return 0 <= rid < hdr.n[BCF_DT_CTG]             # <<<<<<<<<<<<<<
 * 
 *     def get_tid(self, reference):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = (0 <= __pyx_v_rid);
  if (__pyx_t_3) {
    __pyx_t_3 = (__pyx_v_rid < (__pyx_v_hdr->n[BCF_DT_CTG]));
  }
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":4282
 *         return self.seek(self.start_offset)
 * 
 *     def is_valid_tid(self, tid):             # <<<<<<<<<<<<<<
 *         """
 *         return True if the numerical :term:`tid` is valid; False otherwise.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.is_valid_tid", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4295
 *         return 0 <= rid < hdr.n[BCF_DT_CTG]
 * 
 *     def get_tid(self, reference):             # <<<<<<<<<<<<<<
 *         """
 *         return the numerical :term:`tid` corresponding to
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_21get_tid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_20get_tid[] = "VariantFile.get_tid(self, reference)\n\n        return the numerical :term:`tid` corresponding to\n        :term:`reference`\n\n        returns -1 if reference is not known.\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_21get_tid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_tid (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_20get_tid(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self), ((PyObject *)__pyx_v_reference));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_20get_tid(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_reference) {
  vdict_t *__pyx_v_d;
  khint_t __pyx_v_k;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  char const *__pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("get_tid", 0);
  __Pyx_TraceCall("get_tid", __pyx_f[0], 4295, 0, __PYX_ERR(0, 4295, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_reference);

  /* "pysam/libcbcf.pyx":4302
 *         returns -1 if reference is not known.
 *         """
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError('I/O operation on closed file')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4302, __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, 4302, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4303
 *         """
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__226, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4303, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4303, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4302
 *         returns -1 if reference is not known.
 *         """
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError('I/O operation on closed file')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4305
 *             raise ValueError('I/O operation on closed file')
 * 
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]             # <<<<<<<<<<<<<<
 *         reference = force_bytes(reference)
 *         cdef khint_t k = kh_get_vdict(d, reference)
 */
  __pyx_v_d = ((vdict_t *)(__pyx_v_self->header->ptr->dict[BCF_DT_CTG]));

  /* "pysam/libcbcf.pyx":4306
 * 
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]
 *         reference = force_bytes(reference)             # <<<<<<<<<<<<<<
 *         cdef khint_t k = kh_get_vdict(d, reference)
 *         return kh_val_vdict(d, k).id if k != kh_end(d) else -1
 */
  __pyx_t_1 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_reference, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_reference, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":4307
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]
 *         reference = force_bytes(reference)
 *         cdef khint_t k = kh_get_vdict(d, reference)             # <<<<<<<<<<<<<<
 *         return kh_val_vdict(d, k).id if k != kh_end(d) else -1
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_AsString(__pyx_v_reference); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 4307, __pyx_L1_error)
  __pyx_v_k = kh_get_vdict(__pyx_v_d, __pyx_t_4);

  /* "pysam/libcbcf.pyx":4308
 *         reference = force_bytes(reference)
 *         cdef khint_t k = kh_get_vdict(d, reference)
 *         return kh_val_vdict(d, k).id if k != kh_end(d) else -1             # <<<<<<<<<<<<<<
 * 
 *     def get_reference_name(self, tid):
 */
  __Pyx_XDECREF(__pyx_r);
  if (((__pyx_v_k != kh_end(__pyx_v_d)) != 0)) {
    __pyx_t_5 = __Pyx_PyInt_From_int(kh_val(__pyx_v_d, __pyx_v_k).id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __pyx_t_5;
    __pyx_t_5 = 0;
  } else {
    __Pyx_INCREF(__pyx_int_neg_1);
    __pyx_t_1 = __pyx_int_neg_1;
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":4295
 *         return 0 <= rid < hdr.n[BCF_DT_CTG]
 * 
 *     def get_tid(self, reference):             # <<<<<<<<<<<<<<
 *         """
 *         return the numerical :term:`tid` corresponding to
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.get_tid", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_reference);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4310
 *         return kh_val_vdict(d, k).id if k != kh_end(d) else -1
 * 
 *     def get_reference_name(self, tid):             # <<<<<<<<<<<<<<
 *         """
 *         return :term:`reference` name corresponding to numerical :term:`tid`
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_23get_reference_name(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_22get_reference_name[] = "VariantFile.get_reference_name(self, tid)\n\n        return :term:`reference` name corresponding to numerical :term:`tid`\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_23get_reference_name(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_reference_name (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_22get_reference_name(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self), ((PyObject *)__pyx_v_tid));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_22get_reference_name(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_tid) {
  bcf_hdr_t *__pyx_v_hdr;
  int __pyx_v_rid;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  bcf_hdr_t *__pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("get_reference_name", 0);
  __Pyx_TraceCall("get_reference_name", __pyx_f[0], 4310, 0, __PYX_ERR(0, 4310, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":4314
 *         return :term:`reference` name corresponding to numerical :term:`tid`
 *         """
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError('I/O operation on closed file')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4314, __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, 4314, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4315
 *         """
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__227, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4315, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4315, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4314
 *         return :term:`reference` name corresponding to numerical :term:`tid`
 *         """
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError('I/O operation on closed file')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4317
 *             raise ValueError('I/O operation on closed file')
 * 
 *         cdef bcf_hdr_t *hdr = self.header.ptr             # <<<<<<<<<<<<<<
 *         cdef int rid = tid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 */
  __pyx_t_4 = __pyx_v_self->header->ptr;
  __pyx_v_hdr = __pyx_t_4;

  /* "pysam/libcbcf.pyx":4318
 * 
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int rid = tid             # <<<<<<<<<<<<<<
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 *             raise ValueError('Invalid tid')
 */
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_tid); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 4318, __pyx_L1_error)
  __pyx_v_rid = __pyx_t_5;

  /* "pysam/libcbcf.pyx":4319
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int rid = tid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid tid')
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 */
  __pyx_t_2 = ((__pyx_v_rid < 0) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_3 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_rid >= (__pyx_v_hdr->n[BCF_DT_CTG])) != 0);
  __pyx_t_3 = __pyx_t_2;
  __pyx_L5_bool_binop_done:;
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4320
 *         cdef int rid = tid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 *             raise ValueError('Invalid tid')             # <<<<<<<<<<<<<<
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__228, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4320, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4320, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4319
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         cdef int rid = tid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid tid')
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 */
  }

  /* "pysam/libcbcf.pyx":4321
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 *             raise ValueError('Invalid tid')
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))             # <<<<<<<<<<<<<<
 * 
 *     def fetch(self, contig=None, start=None, stop=None, region=None, reopen=False, end=None, reference=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf_bcf_str_cache_get_charptr(bcf_hdr_id2name(__pyx_v_hdr, __pyx_v_rid)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":4310
 *         return kh_val_vdict(d, k).id if k != kh_end(d) else -1
 * 
 *     def get_reference_name(self, tid):             # <<<<<<<<<<<<<<
 *         """
 *         return :term:`reference` name corresponding to numerical :term:`tid`
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.get_reference_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4323
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 * 
 *     def fetch(self, contig=None, start=None, stop=None, region=None, reopen=False, end=None, reference=None):             # <<<<<<<<<<<<<<
 *         """fetch records in a :term:`region` using 0-based indexing. The
 *         region is specified by :term:`contig`, *start* and *end*.
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_25fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_24fetch[] = "VariantFile.fetch(self, contig=None, start=None, stop=None, region=None, reopen=False, end=None, reference=None)\nfetch records in a :term:`region` using 0-based indexing. The\n        region is specified by :term:`contig`, *start* and *end*.\n        Alternatively, a samtools :term:`region` string can be supplied.\n\n        Without *contig* or *region* all mapped records will be fetched.  The\n        records will be returned ordered by contig, which will not necessarily\n        be the order within the file.\n\n        Set *reopen* to true if you will be using multiple iterators on the\n        same file at the same time.  The iterator returned will receive its\n        own copy of a filehandle to the file effectively re-opening the\n        file.  Re-opening a file incurrs some overhead, so use with care.\n\n        If only *contig* is set, all records on *contig* will be fetched.\n        If both *region* and *contig* are given, an exception is raised.\n\n        Note that a bgzipped :term:`VCF`.gz file without a tabix/CSI index\n        (.tbi/.csi) or a :term:`BCF` file without a CSI index can only be\n        read sequentially.\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_25fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_contig = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  PyObject *__pyx_v_region = 0;
  PyObject *__pyx_v_reopen = 0;
  PyObject *__pyx_v_end = 0;
  PyObject *__pyx_v_reference = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fetch (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_contig,&__pyx_n_s_start,&__pyx_n_s_stop,&__pyx_n_s_region,&__pyx_n_s_reopen,&__pyx_n_s_end,&__pyx_n_s_reference,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)Py_False);
    values[5] = ((PyObject *)Py_None);
    values[6] = ((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  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_contig);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stop);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_region);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reopen);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_end);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reference);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fetch") < 0)) __PYX_ERR(0, 4323, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_contig = values[0];
    __pyx_v_start = values[1];
    __pyx_v_stop = values[2];
    __pyx_v_region = values[3];
    __pyx_v_reopen = values[4];
    __pyx_v_end = values[5];
    __pyx_v_reference = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fetch", 0, 0, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4323, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.fetch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_24fetch(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self), __pyx_v_contig, __pyx_v_start, __pyx_v_stop, __pyx_v_region, __pyx_v_reopen, __pyx_v_end, __pyx_v_reference);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_24fetch(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_region, PyObject *__pyx_v_reopen, PyObject *__pyx_v_end, PyObject *__pyx_v_reference) {
  PyObject *__pyx_v_bcf = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_tid = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  int __pyx_t_11;
  __Pyx_RefNannySetupContext("fetch", 0);
  __Pyx_TraceCall("fetch", __pyx_f[0], 4323, 0, __PYX_ERR(0, 4323, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_contig);
  __Pyx_INCREF(__pyx_v_start);
  __Pyx_INCREF(__pyx_v_stop);

  /* "pysam/libcbcf.pyx":4344
 *         read sequentially.
 *         """
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError('I/O operation on closed file')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4344, __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, 4344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4345
 *         """
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         if self.htsfile.is_write:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__229, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4345, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4345, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4344
 *         read sequentially.
 *         """
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError('I/O operation on closed file')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4347
 *             raise ValueError('I/O operation on closed file')
 * 
 *         if self.htsfile.is_write:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot fetch from Variantfile opened for writing')
 * 
 */
  __pyx_t_3 = (__pyx_v_self->__pyx_base.htsfile->is_write != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4348
 * 
 *         if self.htsfile.is_write:
 *             raise ValueError('cannot fetch from Variantfile opened for writing')             # <<<<<<<<<<<<<<
 * 
 *         if contig is None and region is None:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__230, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4348, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4348, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4347
 *             raise ValueError('I/O operation on closed file')
 * 
 *         if self.htsfile.is_write:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot fetch from Variantfile opened for writing')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4350
 *             raise ValueError('cannot fetch from Variantfile opened for writing')
 * 
 *         if contig is None and region is None:             # <<<<<<<<<<<<<<
 *             self.is_reading = 1
 *             bcf = self.copy() if reopen else self
 */
  __pyx_t_2 = (__pyx_v_contig == Py_None);
  __pyx_t_4 = (__pyx_t_2 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_region == Py_None);
  __pyx_t_2 = (__pyx_t_4 != 0);
  __pyx_t_3 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":4351
 * 
 *         if contig is None and region is None:
 *             self.is_reading = 1             # <<<<<<<<<<<<<<
 *             bcf = self.copy() if reopen else self
 *             bcf.seek(self.start_offset)
 */
    __pyx_v_self->is_reading = 1;

    /* "pysam/libcbcf.pyx":4352
 *         if contig is None and region is None:
 *             self.is_reading = 1
 *             bcf = self.copy() if reopen else self             # <<<<<<<<<<<<<<
 *             bcf.seek(self.start_offset)
 *             return iter(bcf)
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_reopen); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 4352, __pyx_L1_error)
    if (__pyx_t_3) {
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_copy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4352, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (__pyx_t_7) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4352, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4352, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_1 = __pyx_t_5;
      __pyx_t_5 = 0;
    } else {
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __pyx_t_1 = ((PyObject *)__pyx_v_self);
    }
    __pyx_v_bcf = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":4353
 *             self.is_reading = 1
 *             bcf = self.copy() if reopen else self
 *             bcf.seek(self.start_offset)             # <<<<<<<<<<<<<<
 *             return iter(bcf)
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_bcf, __pyx_n_s_seek); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4353, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyInt_From_int64_t(__pyx_v_self->__pyx_base.start_offset); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4353, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4353, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4353, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4353, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4353, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4353, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pysam/libcbcf.pyx":4354
 *             bcf = self.copy() if reopen else self
 *             bcf.seek(self.start_offset)
 *             return iter(bcf)             # <<<<<<<<<<<<<<
 * 
 *         if not self.index:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyObject_GetIter(__pyx_v_bcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4354, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":4350
 *             raise ValueError('cannot fetch from Variantfile opened for writing')
 * 
 *         if contig is None and region is None:             # <<<<<<<<<<<<<<
 *             self.is_reading = 1
 *             bcf = self.copy() if reopen else self
 */
  }

  /* "pysam/libcbcf.pyx":4356
 *             return iter(bcf)
 * 
 *         if not self.index:             # <<<<<<<<<<<<<<
 *             raise ValueError('fetch requires an index')
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->index)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 4356, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_3) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "pysam/libcbcf.pyx":4357
 * 
 *         if not self.index:
 *             raise ValueError('fetch requires an index')             # <<<<<<<<<<<<<<
 * 
 *         _, tid, start, stop = self.parse_region(contig, start, stop, region,
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__231, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4357, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4356
 *             return iter(bcf)
 * 
 *         if not self.index:             # <<<<<<<<<<<<<<
 *             raise ValueError('fetch requires an index')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4359
 *             raise ValueError('fetch requires an index')
 * 
 *         _, tid, start, stop = self.parse_region(contig, start, stop, region,             # <<<<<<<<<<<<<<
 *                                                 None, end=end, reference=reference)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parse_region); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "pysam/libcbcf.pyx":4360
 * 
 *         _, tid, start, stop = self.parse_region(contig, start, stop, region,
 *                                                 None, end=end, reference=reference)             # <<<<<<<<<<<<<<
 * 
 *         if contig is None:
 */
  __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_contig);
  __Pyx_GIVEREF(__pyx_v_contig);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_contig);
  __Pyx_INCREF(__pyx_v_start);
  __Pyx_GIVEREF(__pyx_v_start);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_start);
  __Pyx_INCREF(__pyx_v_stop);
  __Pyx_GIVEREF(__pyx_v_stop);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_stop);
  __Pyx_INCREF(__pyx_v_region);
  __Pyx_GIVEREF(__pyx_v_region);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_region);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_5, 4, Py_None);
  __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_end, __pyx_v_end) < 0) __PYX_ERR(0, 4360, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_reference, __pyx_v_reference) < 0) __PYX_ERR(0, 4360, __pyx_L1_error)

  /* "pysam/libcbcf.pyx":4359
 *             raise ValueError('fetch requires an index')
 * 
 *         _, tid, start, stop = self.parse_region(contig, start, stop, region,             # <<<<<<<<<<<<<<
 *                                                 None, end=end, reference=reference)
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
    PyObject* sequence = __pyx_t_6;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 4359, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_7 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_7);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_5,&__pyx_t_1,&__pyx_t_7};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 4359, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_5,&__pyx_t_1,&__pyx_t_7};
    __pyx_t_9 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4359, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_10(__pyx_t_9); if (unlikely(!item)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 4) < 0) __PYX_ERR(0, 4359, __pyx_L1_error)
    __pyx_t_10 = NULL;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L10_unpacking_done;
    __pyx_L9_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_10 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 4359, __pyx_L1_error)
    __pyx_L10_unpacking_done:;
  }
  __pyx_v__ = __pyx_t_8;
  __pyx_t_8 = 0;
  __pyx_v_tid = __pyx_t_5;
  __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_start, __pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_stop, __pyx_t_7);
  __pyx_t_7 = 0;

  /* "pysam/libcbcf.pyx":4362
 *                                                 None, end=end, reference=reference)
 * 
 *         if contig is None:             # <<<<<<<<<<<<<<
 *             contig = self.get_reference_name(tid)
 * 
 */
  __pyx_t_2 = (__pyx_v_contig == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pysam/libcbcf.pyx":4363
 * 
 *         if contig is None:
 *             contig = self.get_reference_name(tid)             # <<<<<<<<<<<<<<
 * 
 *         self.is_reading = 1
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_reference_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_1) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_tid); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4363, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_tid};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4363, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_tid};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4363, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4363, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
        __Pyx_INCREF(__pyx_v_tid);
        __Pyx_GIVEREF(__pyx_v_tid);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_tid);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4363, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF_SET(__pyx_v_contig, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pysam/libcbcf.pyx":4362
 *                                                 None, end=end, reference=reference)
 * 
 *         if contig is None:             # <<<<<<<<<<<<<<
 *             contig = self.get_reference_name(tid)
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4365
 *             contig = self.get_reference_name(tid)
 * 
 *         self.is_reading = 1             # <<<<<<<<<<<<<<
 *         return self.index.fetch(self, contig, start, stop, reopen)
 * 
 */
  __pyx_v_self->is_reading = 1;

  /* "pysam/libcbcf.pyx":4366
 * 
 *         self.is_reading = 1
 *         return self.index.fetch(self, contig, start, stop, reopen)             # <<<<<<<<<<<<<<
 * 
 *     def new_record(self, *args, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->index), __pyx_n_s_fetch); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4366, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_5 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[6] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_contig, __pyx_v_start, __pyx_v_stop, __pyx_v_reopen};
    __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4366, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[6] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_contig, __pyx_v_start, __pyx_v_stop, __pyx_v_reopen};
    __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4366, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else
  #endif
  {
    __pyx_t_1 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_11, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_contig);
    __Pyx_GIVEREF(__pyx_v_contig);
    PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_11, __pyx_v_contig);
    __Pyx_INCREF(__pyx_v_start);
    __Pyx_GIVEREF(__pyx_v_start);
    PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_11, __pyx_v_start);
    __Pyx_INCREF(__pyx_v_stop);
    __Pyx_GIVEREF(__pyx_v_stop);
    PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_11, __pyx_v_stop);
    __Pyx_INCREF(__pyx_v_reopen);
    __Pyx_GIVEREF(__pyx_v_reopen);
    PyTuple_SET_ITEM(__pyx_t_1, 4+__pyx_t_11, __pyx_v_reopen);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":4323
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 * 
 *     def fetch(self, contig=None, start=None, stop=None, region=None, reopen=False, end=None, reference=None):             # <<<<<<<<<<<<<<
 *         """fetch records in a :term:`region` using 0-based indexing. The
 *         region is specified by :term:`contig`, *start* and *end*.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.fetch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bcf);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_tid);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_start);
  __Pyx_XDECREF(__pyx_v_stop);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4368
 *         return self.index.fetch(self, contig, start, stop, reopen)
 * 
 *     def new_record(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Create a new empty :class:`VariantRecord`.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_27new_record(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_26new_record[] = "VariantFile.new_record(self, *args, **kwargs)\nCreate a new empty :class:`VariantRecord`.\n\n        See :meth:`VariantHeader.new_record`\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_27new_record(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("new_record (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "new_record", 1))) return NULL;
  if (unlikely(__pyx_kwds)) {
    __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return NULL;
    __Pyx_GOTREF(__pyx_v_kwargs);
  } else {
    __pyx_v_kwargs = NULL;
  }
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_26new_record(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_26new_record(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("new_record", 0);
  __Pyx_TraceCall("new_record", __pyx_f[0], 4368, 0, __PYX_ERR(0, 4368, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":4373
 *         See :meth:`VariantHeader.new_record`
 *         """
 *         return self.header.new_record(*args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     cpdef int write(self, VariantRecord record) except -1:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->header), __pyx_n_s_new_record); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":4368
 *         return self.index.fetch(self, contig, start, stop, reopen)
 * 
 *     def new_record(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Create a new empty :class:`VariantRecord`.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.new_record", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4375
 *         return self.header.new_record(*args, **kwargs)
 * 
 *     cpdef int write(self, VariantRecord record) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         write a single :class:`pysam.VariantRecord` to disk.
 */

static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_29write(PyObject *__pyx_v_self, PyObject *__pyx_v_record); /*proto*/
static int __pyx_f_5pysam_7libcbcf_11VariantFile_write(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_msg = NULL;
  int __pyx_v_ret;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("write", 0);
  __Pyx_TraceCall("write", __pyx_f[0], 4375, 0, __PYX_ERR(0, 4375, __pyx_L1_error));
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4375, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_29write)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      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);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_record)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4375, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_record)};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4375, __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[2] = {__pyx_t_4, ((PyObject *)__pyx_v_record)};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4375, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4375, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
          __Pyx_INCREF(((PyObject *)__pyx_v_record));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_record));
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_record));
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4375, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 4375, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "pysam/libcbcf.pyx":4381
 *         returns the number of bytes written.
 *         """
 *         if record is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('record must not be None')
 * 
 */
  __pyx_t_7 = (((PyObject *)__pyx_v_record) == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (unlikely(__pyx_t_8)) {

    /* "pysam/libcbcf.pyx":4382
 *         """
 *         if record is None:
 *             raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *         if not self.is_open:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__232, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4382, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4382, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4381
 *         returns the number of bytes written.
 *         """
 *         if record is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('record must not be None')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4384
 *             raise ValueError('record must not be None')
 * 
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             return ValueError('I/O operation on closed file')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 4384, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = ((!__pyx_t_8) != 0);
  if (__pyx_t_7) {

    /* "pysam/libcbcf.pyx":4385
 * 
 *         if not self.is_open:
 *             return ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         if not self.htsfile.is_write:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__233, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4385, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 4385, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    goto __pyx_L0;

    /* "pysam/libcbcf.pyx":4384
 *             raise ValueError('record must not be None')
 * 
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             return ValueError('I/O operation on closed file')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4387
 *             return ValueError('I/O operation on closed file')
 * 
 *         if not self.htsfile.is_write:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot write to a Variantfile opened for reading')
 * 
 */
  __pyx_t_7 = ((!(__pyx_v_self->__pyx_base.htsfile->is_write != 0)) != 0);
  if (unlikely(__pyx_t_7)) {

    /* "pysam/libcbcf.pyx":4388
 * 
 *         if not self.htsfile.is_write:
 *             raise ValueError('cannot write to a Variantfile opened for reading')             # <<<<<<<<<<<<<<
 * 
 *         if not self.header_written:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__234, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4388, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4387
 *             return ValueError('I/O operation on closed file')
 * 
 *         if not self.htsfile.is_write:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot write to a Variantfile opened for reading')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4390
 *             raise ValueError('cannot write to a Variantfile opened for reading')
 * 
 *         if not self.header_written:             # <<<<<<<<<<<<<<
 *             self.header_written = True
 *             with nogil:
 */
  __pyx_t_7 = ((!(__pyx_v_self->header_written != 0)) != 0);
  if (__pyx_t_7) {

    /* "pysam/libcbcf.pyx":4391
 * 
 *         if not self.header_written:
 *             self.header_written = True             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 */
    __pyx_v_self->header_written = 1;

    /* "pysam/libcbcf.pyx":4392
 *         if not self.header_written:
 *             self.header_written = True
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 * 
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        __Pyx_FastGIL_Remember();
        #endif
        /*try:*/ {

          /* "pysam/libcbcf.pyx":4393
 *             self.header_written = True
 *             with nogil:
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)             # <<<<<<<<<<<<<<
 * 
 *         #if record.header is not self.header:
 */
          (void)(bcf_hdr_write(__pyx_v_self->__pyx_base.htsfile, __pyx_v_self->header->ptr));
        }

        /* "pysam/libcbcf.pyx":4392
 *         if not self.header_written:
 *             self.header_written = True
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 bcf_hdr_write(self.htsfile, self.header.ptr)
 * 
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L9;
          }
          __pyx_L9:;
        }
    }

    /* "pysam/libcbcf.pyx":4390
 *             raise ValueError('cannot write to a Variantfile opened for reading')
 * 
 *         if not self.header_written:             # <<<<<<<<<<<<<<
 *             self.header_written = True
 *             with nogil:
 */
  }

  /* "pysam/libcbcf.pyx":4399
 *         #    raise ValueError('Writing records from a different VariantFile is not yet supported')
 * 
 *         if record.ptr.n_sample != bcf_hdr_nsamples(self.header.ptr):             # <<<<<<<<<<<<<<
 *             msg = 'Invalid VariantRecord.  Number of samples does not match header ({} vs {})'
 *             raise ValueError(msg.format(record.ptr.n_sample, bcf_hdr_nsamples(self.header.ptr)))
 */
  __pyx_t_7 = ((__pyx_v_record->ptr->n_sample != bcf_hdr_nsamples(__pyx_v_self->header->ptr)) != 0);
  if (unlikely(__pyx_t_7)) {

    /* "pysam/libcbcf.pyx":4400
 * 
 *         if record.ptr.n_sample != bcf_hdr_nsamples(self.header.ptr):
 *             msg = 'Invalid VariantRecord.  Number of samples does not match header ({} vs {})'             # <<<<<<<<<<<<<<
 *             raise ValueError(msg.format(record.ptr.n_sample, bcf_hdr_nsamples(self.header.ptr)))
 * 
 */
    __Pyx_INCREF(__pyx_kp_s_Invalid_VariantRecord_Number_of);
    __pyx_v_msg = __pyx_kp_s_Invalid_VariantRecord_Number_of;

    /* "pysam/libcbcf.pyx":4401
 *         if record.ptr.n_sample != bcf_hdr_nsamples(self.header.ptr):
 *             msg = 'Invalid VariantRecord.  Number of samples does not match header ({} vs {})'
 *             raise ValueError(msg.format(record.ptr.n_sample, bcf_hdr_nsamples(self.header.ptr)))             # <<<<<<<<<<<<<<
 * 
 *         # Sync END annotation before writing
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4401, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_From_uint32_t(__pyx_v_record->ptr->n_sample); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4401, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyInt_From_int32_t(bcf_hdr_nsamples(__pyx_v_self->header->ptr)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4401, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_3, __pyx_t_5};
      __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, 4401, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_3, __pyx_t_5};
      __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, 4401, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_6, __pyx_t_5);
      __pyx_t_3 = 0;
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4401, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 4401, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4399
 *         #    raise ValueError('Writing records from a different VariantFile is not yet supported')
 * 
 *         if record.ptr.n_sample != bcf_hdr_nsamples(self.header.ptr):             # <<<<<<<<<<<<<<
 *             msg = 'Invalid VariantRecord.  Number of samples does not match header ({} vs {})'
 *             raise ValueError(msg.format(record.ptr.n_sample, bcf_hdr_nsamples(self.header.ptr)))
 */
  }

  /* "pysam/libcbcf.pyx":4404
 * 
 *         # Sync END annotation before writing
 *         bcf_sync_end(record)             # <<<<<<<<<<<<<<
 * 
 *         cdef int ret
 */
  __pyx_t_2 = __pyx_f_5pysam_7libcbcf_bcf_sync_end(__pyx_v_record); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysam/libcbcf.pyx":4408
 *         cdef int ret
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             ret = bcf_write1(self.htsfile, self.header.ptr, record.ptr)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "pysam/libcbcf.pyx":4409
 * 
 *         with nogil:
 *             ret = bcf_write1(self.htsfile, self.header.ptr, record.ptr)             # <<<<<<<<<<<<<<
 * 
 *         if ret < 0:
 */
        __pyx_v_ret = bcf_write1(__pyx_v_self->__pyx_base.htsfile, __pyx_v_self->header->ptr, __pyx_v_record->ptr);
      }

      /* "pysam/libcbcf.pyx":4408
 *         cdef int ret
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             ret = bcf_write1(self.htsfile, self.header.ptr, record.ptr)
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L13;
        }
        __pyx_L13:;
      }
  }

  /* "pysam/libcbcf.pyx":4411
 *             ret = bcf_write1(self.htsfile, self.header.ptr, record.ptr)
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             raise IOError(errno, strerror(errno))
 * 
 */
  __pyx_t_7 = ((__pyx_v_ret < 0) != 0);
  if (unlikely(__pyx_t_7)) {

    /* "pysam/libcbcf.pyx":4412
 * 
 *         if ret < 0:
 *             raise IOError(errno, strerror(errno))             # <<<<<<<<<<<<<<
 * 
 *         return ret
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4412, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4411
 *             ret = bcf_write1(self.htsfile, self.header.ptr, record.ptr)
 * 
 *         if ret < 0:             # <<<<<<<<<<<<<<
 *             raise IOError(errno, strerror(errno))
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4414
 *             raise IOError(errno, strerror(errno))
 * 
 *         return ret             # <<<<<<<<<<<<<<
 * 
 *     def subset_samples(self, include_samples):
 */
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "pysam/libcbcf.pyx":4375
 *         return self.header.new_record(*args, **kwargs)
 * 
 *     cpdef int write(self, VariantRecord record) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         write a single :class:`pysam.VariantRecord` to disk.
 */

  /* 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_9);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_29write(PyObject *__pyx_v_self, PyObject *__pyx_v_record); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_28write[] = "VariantFile.write(self, VariantRecord record) -> int\n\n        write a single :class:`pysam.VariantRecord` to disk.\n\n        returns the number of bytes written.\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_29write(PyObject *__pyx_v_self, PyObject *__pyx_v_record) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_record), __pyx_ptype_5pysam_7libcbcf_VariantRecord, 1, "record", 0))) __PYX_ERR(0, 4375, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_28write(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self), ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_v_record));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_28write(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, struct __pyx_obj_5pysam_7libcbcf_VariantRecord *__pyx_v_record) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("write", 0);
  __Pyx_TraceCall("write (wrapper)", __pyx_f[0], 4375, 0, __PYX_ERR(0, 4375, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_5pysam_7libcbcf_11VariantFile_write(__pyx_v_self, __pyx_v_record, 1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 4375, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pyx":4416
 *         return ret
 * 
 *     def subset_samples(self, include_samples):             # <<<<<<<<<<<<<<
 *         """
 *         Read only a subset of samples to reduce processing time and memory.
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_31subset_samples(PyObject *__pyx_v_self, PyObject *__pyx_v_include_samples); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_30subset_samples[] = "VariantFile.subset_samples(self, include_samples)\n\n        Read only a subset of samples to reduce processing time and memory.\n        Must be called prior to retrieving records.\n        ";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_31subset_samples(PyObject *__pyx_v_self, PyObject *__pyx_v_include_samples) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("subset_samples (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_30subset_samples(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self), ((PyObject *)__pyx_v_include_samples));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_30subset_samples(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, PyObject *__pyx_v_include_samples) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("subset_samples", 0);
  __Pyx_TraceCall("subset_samples", __pyx_f[0], 4416, 0, __PYX_ERR(0, 4416, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":4421
 *         Must be called prior to retrieving records.
 *         """
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError('I/O operation on closed file')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4421, __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, 4421, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4422
 *         """
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         if self.htsfile.is_write:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__235, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4422, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4422, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4421
 *         Must be called prior to retrieving records.
 *         """
 *         if not self.is_open:             # <<<<<<<<<<<<<<
 *             raise ValueError('I/O operation on closed file')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4424
 *             raise ValueError('I/O operation on closed file')
 * 
 *         if self.htsfile.is_write:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot subset samples from Variantfile opened for writing')
 * 
 */
  __pyx_t_3 = (__pyx_v_self->__pyx_base.htsfile->is_write != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4425
 * 
 *         if self.htsfile.is_write:
 *             raise ValueError('cannot subset samples from Variantfile opened for writing')             # <<<<<<<<<<<<<<
 * 
 *         if self.is_reading:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__236, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4425, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4425, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4424
 *             raise ValueError('I/O operation on closed file')
 * 
 *         if self.htsfile.is_write:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot subset samples from Variantfile opened for writing')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4427
 *             raise ValueError('cannot subset samples from Variantfile opened for writing')
 * 
 *         if self.is_reading:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot subset samples after fetching records')
 * 
 */
  __pyx_t_3 = (__pyx_v_self->is_reading != 0);
  if (unlikely(__pyx_t_3)) {

    /* "pysam/libcbcf.pyx":4428
 * 
 *         if self.is_reading:
 *             raise ValueError('cannot subset samples after fetching records')             # <<<<<<<<<<<<<<
 * 
 *         self.header._subset_samples(include_samples)
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__237, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4428, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 4428, __pyx_L1_error)

    /* "pysam/libcbcf.pyx":4427
 *             raise ValueError('cannot subset samples from Variantfile opened for writing')
 * 
 *         if self.is_reading:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot subset samples after fetching records')
 * 
 */
  }

  /* "pysam/libcbcf.pyx":4430
 *             raise ValueError('cannot subset samples after fetching records')
 * 
 *         self.header._subset_samples(include_samples)             # <<<<<<<<<<<<<<
 * 
 *         # potentially unnecessary optimization that also sets max_unpack
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_5pysam_7libcbcf_VariantHeader *)__pyx_v_self->header->__pyx_vtab)->_subset_samples(__pyx_v_self->header, __pyx_v_include_samples); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":4433
 * 
 *         # potentially unnecessary optimization that also sets max_unpack
 *         if not include_samples:             # <<<<<<<<<<<<<<
 *             self.drop_samples = True
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_include_samples); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 4433, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_3) != 0);
  if (__pyx_t_2) {

    /* "pysam/libcbcf.pyx":4434
 *         # potentially unnecessary optimization that also sets max_unpack
 *         if not include_samples:
 *             self.drop_samples = True             # <<<<<<<<<<<<<<
 */
    __pyx_v_self->drop_samples = 1;

    /* "pysam/libcbcf.pyx":4433
 * 
 *         # potentially unnecessary optimization that also sets max_unpack
 *         if not include_samples:             # <<<<<<<<<<<<<<
 *             self.drop_samples = True
 */
  }

  /* "pysam/libcbcf.pyx":4416
 *         return ret
 * 
 *     def subset_samples(self, include_samples):             # <<<<<<<<<<<<<<
 *         """
 *         Read only a subset of samples to reduce processing time and memory.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.subset_samples", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":132
 * 
 * cdef class VariantFile(HTSFile):
 *     cdef readonly VariantHeader  header             # <<<<<<<<<<<<<<
 *     cdef readonly BaseIndex      index
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_6header_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_6header_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_6header___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_6header___get__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 132, 0, __PYX_ERR(1, 132, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->header));
  __pyx_r = ((PyObject *)__pyx_v_self->header);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.header.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":133
 * cdef class VariantFile(HTSFile):
 *     cdef readonly VariantHeader  header
 *     cdef readonly BaseIndex      index             # <<<<<<<<<<<<<<
 * 
 *     cdef readonly bint           drop_samples  # true if sample information is to be ignored
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_5index_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_5index_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_5index___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_5index___get__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 133, 0, __PYX_ERR(1, 133, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->index));
  __pyx_r = ((PyObject *)__pyx_v_self->index);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.index.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":135
 *     cdef readonly BaseIndex      index
 * 
 *     cdef readonly bint           drop_samples  # true if sample information is to be ignored             # <<<<<<<<<<<<<<
 * 
 *     # FIXME: Temporary, use htsFormat when it is available
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_12drop_samples_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_12drop_samples_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_12drop_samples___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_12drop_samples___get__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 135, 0, __PYX_ERR(1, 135, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->drop_samples); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 135, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.drop_samples.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":138
 * 
 *     # FIXME: Temporary, use htsFormat when it is available
 *     cdef readonly bint       is_reading     # true if file has begun reading records             # <<<<<<<<<<<<<<
 *     cdef readonly bint       header_written # true if header has already been written
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_10is_reading_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_10is_reading_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_10is_reading___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_10is_reading___get__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 138, 0, __PYX_ERR(1, 138, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->is_reading); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.is_reading.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysam/libcbcf.pxd":139
 *     # FIXME: Temporary, use htsFormat when it is available
 *     cdef readonly bint       is_reading     # true if file has begun reading records
 *     cdef readonly bint       header_written # true if header has already been written             # <<<<<<<<<<<<<<
 * 
 *     cpdef int write(self, VariantRecord record) except -1
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_14header_written_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_14header_written_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_14header_written___get__(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_14header_written___get__(struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 139, 0, __PYX_ERR(1, 139, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->header_written); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.header_written.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_33__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_32__reduce_cython__[] = "VariantFile.__reduce_cython__(self)";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_33__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_32__reduce_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_32__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__238, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_35__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_11VariantFile_34__setstate_cython__[] = "VariantFile.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5pysam_7libcbcf_11VariantFile_35__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5pysam_7libcbcf_11VariantFile_34__setstate_cython__(((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_5pysam_7libcbcf_11VariantFile_34__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5pysam_7libcbcf_VariantFile *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 3, 0, __PYX_ERR(2, 3, __pyx_L1_error));

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__239, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysam.libcbcf.VariantFile.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_VariantHeaderRecords(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_1__pyx_unpickle_VariantHeaderRecords(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf___pyx_unpickle_VariantHeaderRecords[] = "__pyx_unpickle_VariantHeaderRecords(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_5pysam_7libcbcf_1__pyx_unpickle_VariantHeaderRecords = {"__pyx_unpickle_VariantHeaderRecords", (PyCFunction)__pyx_pw_5pysam_7libcbcf_1__pyx_unpickle_VariantHeaderRecords, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf___pyx_unpickle_VariantHeaderRecords};
static PyObject *__pyx_pw_5pysam_7libcbcf_1__pyx_unpickle_VariantHeaderRecords(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantHeaderRecords (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantHeaderRecords", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantHeaderRecords", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_VariantHeaderRecords") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantHeaderRecords", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantHeaderRecords", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf___pyx_unpickle_VariantHeaderRecords(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_5pysam_7libcbcf___pyx_unpickle_VariantHeaderRecords(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_TraceFrameInit(__pyx_codeobj__240)
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantHeaderRecords", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantHeaderRecords", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __pyx_unpickle_VariantHeaderRecords(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x099fb99:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x099fb99) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_VariantHeaderRecords(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderRecords.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = VariantHeaderRecords.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x09, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_VariantHeaderRecords(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x099fb99:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderRecords.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantHeaderRecords__set_state(<VariantHeaderRecords> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderRecords), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderRecords.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantHeaderRecords__set_state(<VariantHeaderRecords> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = VariantHeaderRecords.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantHeaderRecords__set_state(<VariantHeaderRecords> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderRecords__set_state(VariantHeaderRecords __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderRecords__set_state(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderRecords.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantHeaderRecords__set_state(<VariantHeaderRecords> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantHeaderRecords__set_state(<VariantHeaderRecords> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_VariantHeaderRecords__set_state(VariantHeaderRecords __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantHeaderRecords(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantHeaderRecords", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_VariantHeaderRecords__set_state(<VariantHeaderRecords> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderRecords__set_state(VariantHeaderRecords __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderRecords__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantHeaderRecords__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantHeaderRecords__set_state", __pyx_f[2], 9, 0, __PYX_ERR(2, 9, __pyx_L1_error));

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderRecords__set_state(VariantHeaderRecords __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5pysam_7libcbcf_VariantHeader))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->header);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->header));
  __pyx_v___pyx_result->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantHeaderRecords__set_state(VariantHeaderRecords __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantHeaderRecords__set_state(VariantHeaderRecords __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantHeaderRecords__set_state(<VariantHeaderRecords> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderRecords__set_state(VariantHeaderRecords __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantHeaderRecords__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_VariantMetadata(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x9d0a56c:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_3__pyx_unpickle_VariantMetadata(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_2__pyx_unpickle_VariantMetadata[] = "__pyx_unpickle_VariantMetadata(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_5pysam_7libcbcf_3__pyx_unpickle_VariantMetadata = {"__pyx_unpickle_VariantMetadata", (PyCFunction)__pyx_pw_5pysam_7libcbcf_3__pyx_unpickle_VariantMetadata, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_2__pyx_unpickle_VariantMetadata};
static PyObject *__pyx_pw_5pysam_7libcbcf_3__pyx_unpickle_VariantMetadata(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantMetadata (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantMetadata", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantMetadata", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_VariantMetadata") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantMetadata", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantMetadata", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_2__pyx_unpickle_VariantMetadata(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_2__pyx_unpickle_VariantMetadata(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_TraceFrameInit(__pyx_codeobj__241)
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantMetadata", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantMetadata", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __pyx_unpickle_VariantMetadata(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x9d0a56c:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9d0a56c = (header, id, type))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x9d0a56c) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_VariantMetadata(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x9d0a56c:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9d0a56c = (header, id, type))" % __pyx_checksum)
 *     __pyx_result = VariantMetadata.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x9d0a56c:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9d0a56c = (header, id, type))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = VariantMetadata.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x9d, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_VariantMetadata(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x9d0a56c:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9d0a56c = (header, id, type))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9d0a56c = (header, id, type))" % __pyx_checksum)
 *     __pyx_result = VariantMetadata.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantMetadata__set_state(<VariantMetadata> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantMetadata), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9d0a56c = (header, id, type))" % __pyx_checksum)
 *     __pyx_result = VariantMetadata.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantMetadata__set_state(<VariantMetadata> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = VariantMetadata.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantMetadata__set_state(<VariantMetadata> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantMetadata__set_state(VariantMetadata __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantMetadata__set_state(((struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9d0a56c = (header, id, type))" % __pyx_checksum)
 *     __pyx_result = VariantMetadata.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantMetadata__set_state(<VariantMetadata> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantMetadata__set_state(<VariantMetadata> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_VariantMetadata__set_state(VariantMetadata __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.type = __pyx_state[2]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantMetadata(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x9d0a56c:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantMetadata", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_VariantMetadata__set_state(<VariantMetadata> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantMetadata__set_state(VariantMetadata __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.type = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantMetadata__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantMetadata__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantMetadata__set_state", __pyx_f[2], 9, 0, __PYX_ERR(2, 9, __pyx_L1_error));

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantMetadata__set_state(VariantMetadata __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.type = __pyx_state[2]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5pysam_7libcbcf_VariantHeader))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->header);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->header));
  __pyx_v___pyx_result->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->id = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->type = __pyx_t_2;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantMetadata__set_state(VariantMetadata __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.type = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 3) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":12
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.type = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 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_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantMetadata__set_state(VariantMetadata __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.type = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantMetadata__set_state(<VariantMetadata> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantMetadata__set_state(VariantMetadata __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.type = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantMetadata__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_VariantHeaderMetadata(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xed5e66b:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_5__pyx_unpickle_VariantHeaderMetadata(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_4__pyx_unpickle_VariantHeaderMetadata[] = "__pyx_unpickle_VariantHeaderMetadata(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_5pysam_7libcbcf_5__pyx_unpickle_VariantHeaderMetadata = {"__pyx_unpickle_VariantHeaderMetadata", (PyCFunction)__pyx_pw_5pysam_7libcbcf_5__pyx_unpickle_VariantHeaderMetadata, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_4__pyx_unpickle_VariantHeaderMetadata};
static PyObject *__pyx_pw_5pysam_7libcbcf_5__pyx_unpickle_VariantHeaderMetadata(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantHeaderMetadata (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantHeaderMetadata", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantHeaderMetadata", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_VariantHeaderMetadata") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantHeaderMetadata", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantHeaderMetadata", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_4__pyx_unpickle_VariantHeaderMetadata(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_4__pyx_unpickle_VariantHeaderMetadata(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_TraceFrameInit(__pyx_codeobj__242)
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantHeaderMetadata", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantHeaderMetadata", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __pyx_unpickle_VariantHeaderMetadata(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xed5e66b:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xed5e66b = (header, type))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xed5e66b) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_VariantHeaderMetadata(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xed5e66b:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xed5e66b = (header, type))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderMetadata.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0xed5e66b:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xed5e66b = (header, type))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = VariantHeaderMetadata.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xed, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_VariantHeaderMetadata(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xed5e66b:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xed5e66b = (header, type))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xed5e66b = (header, type))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderMetadata.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantHeaderMetadata__set_state(<VariantHeaderMetadata> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderMetadata), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xed5e66b = (header, type))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderMetadata.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantHeaderMetadata__set_state(<VariantHeaderMetadata> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = VariantHeaderMetadata.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantHeaderMetadata__set_state(<VariantHeaderMetadata> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderMetadata__set_state(VariantHeaderMetadata __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderMetadata__set_state(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xed5e66b = (header, type))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderMetadata.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantHeaderMetadata__set_state(<VariantHeaderMetadata> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantHeaderMetadata__set_state(<VariantHeaderMetadata> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_VariantHeaderMetadata__set_state(VariantHeaderMetadata __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.type = __pyx_state[1]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantHeaderMetadata(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xed5e66b:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantHeaderMetadata", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_VariantHeaderMetadata__set_state(<VariantHeaderMetadata> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderMetadata__set_state(VariantHeaderMetadata __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.type = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderMetadata__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantHeaderMetadata__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantHeaderMetadata__set_state", __pyx_f[2], 9, 0, __PYX_ERR(2, 9, __pyx_L1_error));

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderMetadata__set_state(VariantHeaderMetadata __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.type = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5pysam_7libcbcf_VariantHeader))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->header);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->header));
  __pyx_v___pyx_result->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_2 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->type = __pyx_t_2;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantHeaderMetadata__set_state(VariantHeaderMetadata __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.type = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 2) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":12
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.type = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 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_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantHeaderMetadata__set_state(VariantHeaderMetadata __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.type = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantHeaderMetadata__set_state(<VariantHeaderMetadata> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderMetadata__set_state(VariantHeaderMetadata __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.type = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantHeaderMetadata__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_VariantContig(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xbe66ecb:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_7__pyx_unpickle_VariantContig(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_6__pyx_unpickle_VariantContig[] = "__pyx_unpickle_VariantContig(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_5pysam_7libcbcf_7__pyx_unpickle_VariantContig = {"__pyx_unpickle_VariantContig", (PyCFunction)__pyx_pw_5pysam_7libcbcf_7__pyx_unpickle_VariantContig, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_6__pyx_unpickle_VariantContig};
static PyObject *__pyx_pw_5pysam_7libcbcf_7__pyx_unpickle_VariantContig(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantContig (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantContig", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantContig", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_VariantContig") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantContig", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantContig", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_6__pyx_unpickle_VariantContig(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_6__pyx_unpickle_VariantContig(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_TraceFrameInit(__pyx_codeobj__243)
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantContig", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantContig", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __pyx_unpickle_VariantContig(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xbe66ecb:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xbe66ecb = (header, id))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xbe66ecb) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_VariantContig(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xbe66ecb:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xbe66ecb = (header, id))" % __pyx_checksum)
 *     __pyx_result = VariantContig.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0xbe66ecb:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xbe66ecb = (header, id))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = VariantContig.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xbe, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_VariantContig(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xbe66ecb:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xbe66ecb = (header, id))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xbe66ecb = (header, id))" % __pyx_checksum)
 *     __pyx_result = VariantContig.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantContig__set_state(<VariantContig> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantContig), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xbe66ecb = (header, id))" % __pyx_checksum)
 *     __pyx_result = VariantContig.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantContig__set_state(<VariantContig> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = VariantContig.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantContig__set_state(<VariantContig> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantContig__set_state(VariantContig __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantContig__set_state(((struct __pyx_obj_5pysam_7libcbcf_VariantContig *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xbe66ecb = (header, id))" % __pyx_checksum)
 *     __pyx_result = VariantContig.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantContig__set_state(<VariantContig> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantContig__set_state(<VariantContig> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_VariantContig__set_state(VariantContig __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantContig(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xbe66ecb:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantContig", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_VariantContig__set_state(<VariantContig> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantContig__set_state(VariantContig __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantContig__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantContig *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantContig__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantContig__set_state", __pyx_f[2], 9, 0, __PYX_ERR(2, 9, __pyx_L1_error));

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantContig__set_state(VariantContig __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5pysam_7libcbcf_VariantHeader))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->header);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->header));
  __pyx_v___pyx_result->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __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(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->id = __pyx_t_2;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantContig__set_state(VariantContig __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 2) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":12
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 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_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantContig__set_state(VariantContig __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantContig__set_state(<VariantContig> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantContig__set_state(VariantContig __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.id = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantContig__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_VariantHeaderContigs(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_9__pyx_unpickle_VariantHeaderContigs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_8__pyx_unpickle_VariantHeaderContigs[] = "__pyx_unpickle_VariantHeaderContigs(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_5pysam_7libcbcf_9__pyx_unpickle_VariantHeaderContigs = {"__pyx_unpickle_VariantHeaderContigs", (PyCFunction)__pyx_pw_5pysam_7libcbcf_9__pyx_unpickle_VariantHeaderContigs, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_8__pyx_unpickle_VariantHeaderContigs};
static PyObject *__pyx_pw_5pysam_7libcbcf_9__pyx_unpickle_VariantHeaderContigs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantHeaderContigs (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantHeaderContigs", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantHeaderContigs", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_VariantHeaderContigs") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantHeaderContigs", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantHeaderContigs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_8__pyx_unpickle_VariantHeaderContigs(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_8__pyx_unpickle_VariantHeaderContigs(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_TraceFrameInit(__pyx_codeobj__244)
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantHeaderContigs", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantHeaderContigs", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __pyx_unpickle_VariantHeaderContigs(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x099fb99:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x099fb99) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_VariantHeaderContigs(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderContigs.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = VariantHeaderContigs.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x09, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_VariantHeaderContigs(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x099fb99:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderContigs.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantHeaderContigs__set_state(<VariantHeaderContigs> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderContigs), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderContigs.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantHeaderContigs__set_state(<VariantHeaderContigs> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = VariantHeaderContigs.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantHeaderContigs__set_state(<VariantHeaderContigs> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderContigs__set_state(VariantHeaderContigs __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderContigs__set_state(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderContigs.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantHeaderContigs__set_state(<VariantHeaderContigs> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantHeaderContigs__set_state(<VariantHeaderContigs> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_VariantHeaderContigs__set_state(VariantHeaderContigs __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantHeaderContigs(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantHeaderContigs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_VariantHeaderContigs__set_state(<VariantHeaderContigs> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderContigs__set_state(VariantHeaderContigs __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderContigs__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantHeaderContigs__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantHeaderContigs__set_state", __pyx_f[2], 9, 0, __PYX_ERR(2, 9, __pyx_L1_error));

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderContigs__set_state(VariantHeaderContigs __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5pysam_7libcbcf_VariantHeader))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->header);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->header));
  __pyx_v___pyx_result->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantHeaderContigs__set_state(VariantHeaderContigs __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantHeaderContigs__set_state(VariantHeaderContigs __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantHeaderContigs__set_state(<VariantHeaderContigs> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderContigs__set_state(VariantHeaderContigs __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantHeaderContigs__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_VariantHeaderSamples(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_11__pyx_unpickle_VariantHeaderSamples(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_10__pyx_unpickle_VariantHeaderSamples[] = "__pyx_unpickle_VariantHeaderSamples(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_5pysam_7libcbcf_11__pyx_unpickle_VariantHeaderSamples = {"__pyx_unpickle_VariantHeaderSamples", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11__pyx_unpickle_VariantHeaderSamples, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_10__pyx_unpickle_VariantHeaderSamples};
static PyObject *__pyx_pw_5pysam_7libcbcf_11__pyx_unpickle_VariantHeaderSamples(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantHeaderSamples (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantHeaderSamples", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantHeaderSamples", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_VariantHeaderSamples") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantHeaderSamples", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantHeaderSamples", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_10__pyx_unpickle_VariantHeaderSamples(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_10__pyx_unpickle_VariantHeaderSamples(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_TraceFrameInit(__pyx_codeobj__245)
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantHeaderSamples", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantHeaderSamples", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __pyx_unpickle_VariantHeaderSamples(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x099fb99:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x099fb99) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_VariantHeaderSamples(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderSamples.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = VariantHeaderSamples.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x09, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_VariantHeaderSamples(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x099fb99:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderSamples.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantHeaderSamples__set_state(<VariantHeaderSamples> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderSamples), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderSamples.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantHeaderSamples__set_state(<VariantHeaderSamples> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = VariantHeaderSamples.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantHeaderSamples__set_state(<VariantHeaderSamples> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderSamples__set_state(VariantHeaderSamples __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderSamples__set_state(((struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x099fb99 = (header))" % __pyx_checksum)
 *     __pyx_result = VariantHeaderSamples.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantHeaderSamples__set_state(<VariantHeaderSamples> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantHeaderSamples__set_state(<VariantHeaderSamples> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_VariantHeaderSamples__set_state(VariantHeaderSamples __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantHeaderSamples(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantHeaderSamples", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_VariantHeaderSamples__set_state(<VariantHeaderSamples> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderSamples__set_state(VariantHeaderSamples __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantHeaderSamples__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantHeaderSamples__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantHeaderSamples__set_state", __pyx_f[2], 9, 0, __PYX_ERR(2, 9, __pyx_L1_error));

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderSamples__set_state(VariantHeaderSamples __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5pysam_7libcbcf_VariantHeader))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->header);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->header));
  __pyx_v___pyx_result->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantHeaderSamples__set_state(VariantHeaderSamples __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantHeaderSamples__set_state(VariantHeaderSamples __pyx_result, tuple __pyx_state):
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantHeaderSamples__set_state(<VariantHeaderSamples> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderSamples__set_state(VariantHeaderSamples __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantHeaderSamples__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordFilter(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_13__pyx_unpickle_VariantRecordFilter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_12__pyx_unpickle_VariantRecordFilter[] = "__pyx_unpickle_VariantRecordFilter(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_5pysam_7libcbcf_13__pyx_unpickle_VariantRecordFilter = {"__pyx_unpickle_VariantRecordFilter", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13__pyx_unpickle_VariantRecordFilter, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_12__pyx_unpickle_VariantRecordFilter};
static PyObject *__pyx_pw_5pysam_7libcbcf_13__pyx_unpickle_VariantRecordFilter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordFilter (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordFilter", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordFilter", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_VariantRecordFilter") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordFilter", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordFilter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_12__pyx_unpickle_VariantRecordFilter(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_12__pyx_unpickle_VariantRecordFilter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_TraceFrameInit(__pyx_codeobj__246)
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordFilter", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantRecordFilter", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __pyx_unpickle_VariantRecordFilter(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xde17f0f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xde17f0f) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_VariantRecordFilter(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordFilter.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = VariantRecordFilter.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xde, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_VariantRecordFilter(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xde17f0f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordFilter.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordFilter__set_state(<VariantRecordFilter> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordFilter), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordFilter.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantRecordFilter__set_state(<VariantRecordFilter> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = VariantRecordFilter.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordFilter__set_state(<VariantRecordFilter> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordFilter__set_state(VariantRecordFilter __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordFilter__set_state(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordFilter.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantRecordFilter__set_state(<VariantRecordFilter> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordFilter__set_state(<VariantRecordFilter> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_VariantRecordFilter__set_state(VariantRecordFilter __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordFilter(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordFilter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordFilter__set_state(<VariantRecordFilter> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordFilter__set_state(VariantRecordFilter __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordFilter__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordFilter__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantRecordFilter__set_state", __pyx_f[2], 9, 0, __PYX_ERR(2, 9, __pyx_L1_error));

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordFilter__set_state(VariantRecordFilter __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5pysam_7libcbcf_VariantRecord))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->record);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->record));
  __pyx_v___pyx_result->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantRecordFilter__set_state(VariantRecordFilter __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantRecordFilter__set_state(VariantRecordFilter __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordFilter__set_state(<VariantRecordFilter> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordFilter__set_state(VariantRecordFilter __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordFilter__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordFormat(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_15__pyx_unpickle_VariantRecordFormat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_14__pyx_unpickle_VariantRecordFormat[] = "__pyx_unpickle_VariantRecordFormat(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_5pysam_7libcbcf_15__pyx_unpickle_VariantRecordFormat = {"__pyx_unpickle_VariantRecordFormat", (PyCFunction)__pyx_pw_5pysam_7libcbcf_15__pyx_unpickle_VariantRecordFormat, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_14__pyx_unpickle_VariantRecordFormat};
static PyObject *__pyx_pw_5pysam_7libcbcf_15__pyx_unpickle_VariantRecordFormat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordFormat (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordFormat", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordFormat", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_VariantRecordFormat") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordFormat", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordFormat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_14__pyx_unpickle_VariantRecordFormat(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_14__pyx_unpickle_VariantRecordFormat(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_TraceFrameInit(__pyx_codeobj__247)
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordFormat", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantRecordFormat", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __pyx_unpickle_VariantRecordFormat(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xde17f0f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xde17f0f) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_VariantRecordFormat(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordFormat.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = VariantRecordFormat.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xde, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_VariantRecordFormat(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xde17f0f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordFormat.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordFormat__set_state(<VariantRecordFormat> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordFormat), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordFormat.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantRecordFormat__set_state(<VariantRecordFormat> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = VariantRecordFormat.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordFormat__set_state(<VariantRecordFormat> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordFormat__set_state(VariantRecordFormat __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordFormat__set_state(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordFormat.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantRecordFormat__set_state(<VariantRecordFormat> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordFormat__set_state(<VariantRecordFormat> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_VariantRecordFormat__set_state(VariantRecordFormat __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordFormat(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordFormat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordFormat__set_state(<VariantRecordFormat> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordFormat__set_state(VariantRecordFormat __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordFormat__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordFormat__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantRecordFormat__set_state", __pyx_f[2], 9, 0, __PYX_ERR(2, 9, __pyx_L1_error));

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordFormat__set_state(VariantRecordFormat __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5pysam_7libcbcf_VariantRecord))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->record);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->record));
  __pyx_v___pyx_result->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantRecordFormat__set_state(VariantRecordFormat __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantRecordFormat__set_state(VariantRecordFormat __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordFormat__set_state(<VariantRecordFormat> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordFormat__set_state(VariantRecordFormat __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordFormat__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordInfo(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_17__pyx_unpickle_VariantRecordInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_16__pyx_unpickle_VariantRecordInfo[] = "__pyx_unpickle_VariantRecordInfo(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_5pysam_7libcbcf_17__pyx_unpickle_VariantRecordInfo = {"__pyx_unpickle_VariantRecordInfo", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17__pyx_unpickle_VariantRecordInfo, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_16__pyx_unpickle_VariantRecordInfo};
static PyObject *__pyx_pw_5pysam_7libcbcf_17__pyx_unpickle_VariantRecordInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordInfo (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordInfo", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordInfo", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_VariantRecordInfo") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordInfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordInfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_16__pyx_unpickle_VariantRecordInfo(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_16__pyx_unpickle_VariantRecordInfo(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_TraceFrameInit(__pyx_codeobj__248)
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordInfo", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantRecordInfo", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __pyx_unpickle_VariantRecordInfo(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xde17f0f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xde17f0f) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_VariantRecordInfo(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordInfo.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = VariantRecordInfo.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xde, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_VariantRecordInfo(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xde17f0f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordInfo.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordInfo__set_state(<VariantRecordInfo> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordInfo), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordInfo.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantRecordInfo__set_state(<VariantRecordInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = VariantRecordInfo.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordInfo__set_state(<VariantRecordInfo> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordInfo__set_state(VariantRecordInfo __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordInfo__set_state(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordInfo.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantRecordInfo__set_state(<VariantRecordInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordInfo__set_state(<VariantRecordInfo> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_VariantRecordInfo__set_state(VariantRecordInfo __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordInfo(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordInfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordInfo__set_state(<VariantRecordInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordInfo__set_state(VariantRecordInfo __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordInfo__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordInfo__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantRecordInfo__set_state", __pyx_f[2], 9, 0, __PYX_ERR(2, 9, __pyx_L1_error));

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordInfo__set_state(VariantRecordInfo __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5pysam_7libcbcf_VariantRecord))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->record);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->record));
  __pyx_v___pyx_result->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantRecordInfo__set_state(VariantRecordInfo __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantRecordInfo__set_state(VariantRecordInfo __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordInfo__set_state(<VariantRecordInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordInfo__set_state(VariantRecordInfo __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordInfo__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordSamples(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_19__pyx_unpickle_VariantRecordSamples(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_18__pyx_unpickle_VariantRecordSamples[] = "__pyx_unpickle_VariantRecordSamples(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_5pysam_7libcbcf_19__pyx_unpickle_VariantRecordSamples = {"__pyx_unpickle_VariantRecordSamples", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19__pyx_unpickle_VariantRecordSamples, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_18__pyx_unpickle_VariantRecordSamples};
static PyObject *__pyx_pw_5pysam_7libcbcf_19__pyx_unpickle_VariantRecordSamples(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordSamples (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordSamples", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordSamples", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_VariantRecordSamples") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordSamples", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordSamples", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_18__pyx_unpickle_VariantRecordSamples(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_18__pyx_unpickle_VariantRecordSamples(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_TraceFrameInit(__pyx_codeobj__249)
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordSamples", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantRecordSamples", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __pyx_unpickle_VariantRecordSamples(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xde17f0f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xde17f0f) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_VariantRecordSamples(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordSamples.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = VariantRecordSamples.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xde, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_VariantRecordSamples(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xde17f0f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordSamples.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordSamples__set_state(<VariantRecordSamples> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordSamples), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordSamples.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantRecordSamples__set_state(<VariantRecordSamples> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = VariantRecordSamples.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordSamples__set_state(<VariantRecordSamples> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordSamples__set_state(VariantRecordSamples __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordSamples__set_state(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xde17f0f = (record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordSamples.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantRecordSamples__set_state(<VariantRecordSamples> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordSamples__set_state(<VariantRecordSamples> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_VariantRecordSamples__set_state(VariantRecordSamples __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordSamples(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordSamples", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordSamples__set_state(<VariantRecordSamples> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordSamples__set_state(VariantRecordSamples __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordSamples__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordSamples__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantRecordSamples__set_state", __pyx_f[2], 9, 0, __PYX_ERR(2, 9, __pyx_L1_error));

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordSamples__set_state(VariantRecordSamples __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5pysam_7libcbcf_VariantRecord))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->record);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->record));
  __pyx_v___pyx_result->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantRecordSamples__set_state(VariantRecordSamples __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantRecordSamples__set_state(VariantRecordSamples __pyx_result, tuple __pyx_state):
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordSamples__set_state(<VariantRecordSamples> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordSamples__set_state(VariantRecordSamples __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordSamples__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordSample(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x5d6ff7b:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_21__pyx_unpickle_VariantRecordSample(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_20__pyx_unpickle_VariantRecordSample[] = "__pyx_unpickle_VariantRecordSample(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_5pysam_7libcbcf_21__pyx_unpickle_VariantRecordSample = {"__pyx_unpickle_VariantRecordSample", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21__pyx_unpickle_VariantRecordSample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_20__pyx_unpickle_VariantRecordSample};
static PyObject *__pyx_pw_5pysam_7libcbcf_21__pyx_unpickle_VariantRecordSample(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordSample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordSample", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordSample", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_VariantRecordSample") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VariantRecordSample", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordSample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_20__pyx_unpickle_VariantRecordSample(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_20__pyx_unpickle_VariantRecordSample(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_TraceFrameInit(__pyx_codeobj__250)
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordSample", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantRecordSample", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __pyx_unpickle_VariantRecordSample(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x5d6ff7b:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5d6ff7b = (index, record))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x5d6ff7b) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_VariantRecordSample(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x5d6ff7b:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5d6ff7b = (index, record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordSample.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x5d6ff7b:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5d6ff7b = (index, record))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = VariantRecordSample.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x5d, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_VariantRecordSample(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x5d6ff7b:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5d6ff7b = (index, record))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5d6ff7b = (index, record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordSample.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordSample__set_state(<VariantRecordSample> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordSample), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5d6ff7b = (index, record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordSample.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantRecordSample__set_state(<VariantRecordSample> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = VariantRecordSample.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordSample__set_state(<VariantRecordSample> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordSample__set_state(VariantRecordSample __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordSample__set_state(((struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5d6ff7b = (index, record))" % __pyx_checksum)
 *     __pyx_result = VariantRecordSample.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VariantRecordSample__set_state(<VariantRecordSample> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VariantRecordSample__set_state(<VariantRecordSample> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_VariantRecordSample__set_state(VariantRecordSample __pyx_result, tuple __pyx_state):
 *     __pyx_result.index = __pyx_state[0]; __pyx_result.record = __pyx_state[1]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordSample(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x5d6ff7b:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordSample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordSample__set_state(<VariantRecordSample> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordSample__set_state(VariantRecordSample __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.index = __pyx_state[0]; __pyx_result.record = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_VariantRecordSample__set_state(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VariantRecordSample__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_VariantRecordSample__set_state", __pyx_f[2], 9, 0, __PYX_ERR(2, 9, __pyx_L1_error));

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordSample__set_state(VariantRecordSample __pyx_result, tuple __pyx_state):
 *     __pyx_result.index = __pyx_state[0]; __pyx_result.record = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_2 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->index = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5pysam_7libcbcf_VariantRecord))))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->record);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->record));
  __pyx_v___pyx_result->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantRecordSample__set_state(VariantRecordSample __pyx_result, tuple __pyx_state):
 *     __pyx_result.index = __pyx_state[0]; __pyx_result.record = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 2) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":12
 *     __pyx_result.index = __pyx_state[0]; __pyx_result.record = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 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_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_VariantRecordSample__set_state(VariantRecordSample __pyx_result, tuple __pyx_state):
 *     __pyx_result.index = __pyx_state[0]; __pyx_result.record = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordSample__set_state(<VariantRecordSample> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordSample__set_state(VariantRecordSample __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.index = __pyx_state[0]; __pyx_result.record = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_VariantRecordSample__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_BaseIndex(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xd936de3:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_5pysam_7libcbcf_23__pyx_unpickle_BaseIndex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5pysam_7libcbcf_22__pyx_unpickle_BaseIndex[] = "__pyx_unpickle_BaseIndex(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_5pysam_7libcbcf_23__pyx_unpickle_BaseIndex = {"__pyx_unpickle_BaseIndex", (PyCFunction)__pyx_pw_5pysam_7libcbcf_23__pyx_unpickle_BaseIndex, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_22__pyx_unpickle_BaseIndex};
static PyObject *__pyx_pw_5pysam_7libcbcf_23__pyx_unpickle_BaseIndex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_BaseIndex (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BaseIndex", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BaseIndex", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_BaseIndex") < 0)) __PYX_ERR(2, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BaseIndex", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_BaseIndex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pysam_7libcbcf_22__pyx_unpickle_BaseIndex(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_5pysam_7libcbcf_22__pyx_unpickle_BaseIndex(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_TraceFrameInit(__pyx_codeobj__251)
  __Pyx_RefNannySetupContext("__pyx_unpickle_BaseIndex", 0);
  __Pyx_TraceCall("__pyx_unpickle_BaseIndex", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":2
 * def __pyx_unpickle_BaseIndex(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xd936de3:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd936de3 = (refmap, refs))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xd936de3) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_BaseIndex(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xd936de3:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd936de3 = (refmap, refs))" % __pyx_checksum)
 *     __pyx_result = BaseIndex.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0xd936de3:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd936de3 = (refmap, refs))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = BaseIndex.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xd9, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_BaseIndex(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xd936de3:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd936de3 = (refmap, refs))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd936de3 = (refmap, refs))" % __pyx_checksum)
 *     __pyx_result = BaseIndex.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_BaseIndex__set_state(<BaseIndex> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5pysam_7libcbcf_BaseIndex), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd936de3 = (refmap, refs))" % __pyx_checksum)
 *     __pyx_result = BaseIndex.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_BaseIndex__set_state(<BaseIndex> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = BaseIndex.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_BaseIndex__set_state(<BaseIndex> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_BaseIndex__set_state(BaseIndex __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_5pysam_7libcbcf___pyx_unpickle_BaseIndex__set_state(((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd936de3 = (refmap, refs))" % __pyx_checksum)
 *     __pyx_result = BaseIndex.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_BaseIndex__set_state(<BaseIndex> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_BaseIndex__set_state(<BaseIndex> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_BaseIndex__set_state(BaseIndex __pyx_result, tuple __pyx_state):
 *     __pyx_result.refmap = __pyx_state[0]; __pyx_result.refs = __pyx_state[1]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_BaseIndex(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xd936de3:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_BaseIndex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_BaseIndex__set_state(<BaseIndex> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_BaseIndex__set_state(BaseIndex __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.refmap = __pyx_state[0]; __pyx_result.refs = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_5pysam_7libcbcf___pyx_unpickle_BaseIndex__set_state(struct __pyx_obj_5pysam_7libcbcf_BaseIndex *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_BaseIndex__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_BaseIndex__set_state", __pyx_f[2], 9, 0, __PYX_ERR(2, 9, __pyx_L1_error));

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_BaseIndex__set_state(BaseIndex __pyx_result, tuple __pyx_state):
 *     __pyx_result.refmap = __pyx_state[0]; __pyx_result.refs = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->refmap);
  __Pyx_DECREF(__pyx_v___pyx_result->refmap);
  __pyx_v___pyx_result->refmap = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->refs);
  __Pyx_DECREF(__pyx_v___pyx_result->refs);
  __pyx_v___pyx_result->refs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_BaseIndex__set_state(BaseIndex __pyx_result, tuple __pyx_state):
 *     __pyx_result.refmap = __pyx_state[0]; __pyx_result.refs = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 2) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result.refmap = __pyx_state[0]; __pyx_result.refs = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_BaseIndex__set_state(BaseIndex __pyx_result, tuple __pyx_state):
 *     __pyx_result.refmap = __pyx_state[0]; __pyx_result.refs = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_BaseIndex__set_state(<BaseIndex> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_BaseIndex__set_state(BaseIndex __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.refmap = __pyx_state[0]; __pyx_result.refs = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysam.libcbcf.__pyx_unpickle_BaseIndex__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":93
 *             __data_union data
 * 
 *         def __getbuffer__(self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fulfill 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_TraceDeclarations
  __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;
  if (__pyx_v_info == NULL) {
    PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
    return -1;
  }
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(__pyx_v_info->obj);
  __Pyx_TraceCall("__getbuffer__", __pyx_f[3], 93, 0, __PYX_ERR(3, 93, __pyx_L1_error));

  /* "array.pxd":98
 *             # 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(3, 98, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_item_count = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "array.pxd":100
 *             item_count = Py_SIZE(self)
 * 
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *             info.buf = self.data.as_chars
 *             info.readonly = 0
 */
  __pyx_v_info->suboffsets = NULL;

  /* "array.pxd":101
 * 
 *             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":102
 *             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":103
 *             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":104
 *             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":105
 *             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(3, 105, __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(3, 105, __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(3, 105, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_info->len = __pyx_t_5;

  /* "array.pxd":107
 *             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":108
 * 
 *             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 (unlikely(__pyx_t_6)) {

    /* "array.pxd":109
 *             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(3, 109, __pyx_L1_error)

    /* "array.pxd":108
 * 
 *             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":110
 *             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(3, 110, __pyx_L1_error)
  (__pyx_v_info->shape[0]) = __pyx_t_5;

  /* "array.pxd":111
 *                 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":113
 *             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":114
 * 
 *             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":115
 *             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":116
 *             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":93
 *             __data_union data
 * 
 *         def __getbuffer__(self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fulfill 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->obj != NULL) {
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
  }
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
  }
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_item_count);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":118
 *             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_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__", 0);
  __Pyx_TraceCall("__releasebuffer__", __pyx_f[3], 118, 0, __PYX_ERR(3, 118, __pyx_L1_error));

  /* "array.pxd":119
 * 
 *         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":118
 *             info.obj = self
 * 
 *         def __releasebuffer__(self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             PyObject_Free(info.shape)
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("cpython.array.array.__releasebuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
}

/* "array.pxd":130
 * 
 * 
 * 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_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("clone", 0);
  __Pyx_TraceCall("clone", __pyx_f[3], 130, 0, __PYX_ERR(3, 130, __pyx_L1_error));

  /* "array.pxd":134
 *     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(3, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((arrayobject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "array.pxd":135
 *     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":136
 *     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
 * 
 */
    (void)(memset(__pyx_v_op->data.as_chars, 0, (__pyx_v_length * __pyx_v_op->ob_descr->itemsize)));

    /* "array.pxd":135
 *     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":137
 *     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":130
 * 
 * 
 * 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_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":139
 *     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_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("copy", 0);
  __Pyx_TraceCall("copy", __pyx_f[3], 139, 0, __PYX_ERR(3, 139, __pyx_L1_error));

  /* "array.pxd":141
 * 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(3, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((arrayobject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "array.pxd":142
 *     """ 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
 * 
 */
  (void)(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":143
 *     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":139
 *     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_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":145
 *     return op
 * 
 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1:             # <<<<<<<<<<<<<<
 *     """ efficient 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_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("extend_buffer", 0);
  __Pyx_TraceCall("extend_buffer", __pyx_f[3], 145, 0, __PYX_ERR(3, 145, __pyx_L1_error));

  /* "array.pxd":149
 *     (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":150
 *     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":151
 *     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 == ((int)-1))) __PYX_ERR(3, 151, __pyx_L1_error)

  /* "array.pxd":152
 *     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
 * 
 */
  (void)(memcpy((__pyx_v_self->data.as_chars + (__pyx_v_origsize * __pyx_v_itemsize)), __pyx_v_stuff, (__pyx_v_n * __pyx_v_itemsize)));

  /* "array.pxd":153
 *     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":145
 *     return op
 * 
 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1:             # <<<<<<<<<<<<<<
 *     """ efficient 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_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":155
 *     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_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("extend", 0);
  __Pyx_TraceCall("extend", __pyx_f[3], 155, 0, __PYX_ERR(3, 155, __pyx_L1_error));

  /* "array.pxd":157
 * 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":158
 *     """ 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 == ((int)0))) __PYX_ERR(3, 158, __pyx_L1_error)

    /* "array.pxd":157
 * 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":159
 *     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 == ((int)-1))) __PYX_ERR(3, 159, __pyx_L1_error)
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "array.pxd":155
 *     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_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":161
 *     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_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("zero", 0);
  __Pyx_TraceCall("zero", __pyx_f[3], 161, 0, __PYX_ERR(3, 161, __pyx_L1_error));

  /* "array.pxd":163
 * 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)             # <<<<<<<<<<<<<<
 */
  (void)(memset(__pyx_v_self->data.as_chars, 0, (Py_SIZE(((PyObject *)__pyx_v_self)) * __pyx_v_self->ob_descr->itemsize)));

  /* "array.pxd":161
 *     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 */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("cpython.array.zero", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
}
static struct __pyx_vtabstruct_5pysam_7libcbcf_VariantHeader __pyx_vtable_5pysam_7libcbcf_VariantHeader;

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantHeader(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeader *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_5pysam_7libcbcf_VariantHeader *)o);
  p->__pyx_vtab = __pyx_vtabptr_5pysam_7libcbcf_VariantHeader;
  if (unlikely(__pyx_pw_5pysam_7libcbcf_13VariantHeader_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantHeader(PyObject *o) {
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5pysam_7libcbcf_13VariantHeader_5__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantHeader_version(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantHeader_7version_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantHeader_samples(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantHeader_7samples_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantHeader_records(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantHeader_7records_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantHeader_contigs(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantHeader_7contigs_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantHeader_filters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantHeader_7filters_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantHeader_info(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantHeader_4info_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantHeader_formats(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantHeader_7formats_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantHeader_alts(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantHeader_4alts_1__get__(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantHeader[] = {
  {"copy", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantHeader_9copy, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_13VariantHeader_8copy},
  {"merge", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantHeader_11merge, METH_O, __pyx_doc_5pysam_7libcbcf_13VariantHeader_10merge},
  {"new_record", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantHeader_15new_record, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_13VariantHeader_14new_record},
  {"add_record", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantHeader_17add_record, METH_O, __pyx_doc_5pysam_7libcbcf_13VariantHeader_16add_record},
  {"add_line", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantHeader_19add_line, METH_O, __pyx_doc_5pysam_7libcbcf_13VariantHeader_18add_line},
  {"add_meta", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantHeader_21add_meta, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_13VariantHeader_20add_meta},
  {"add_sample", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantHeader_23add_sample, METH_O, __pyx_doc_5pysam_7libcbcf_13VariantHeader_22add_sample},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantHeader_25__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_13VariantHeader_24__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantHeader_27__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_13VariantHeader_26__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5pysam_7libcbcf_VariantHeader[] = {
  {(char *)"version", __pyx_getprop_5pysam_7libcbcf_13VariantHeader_version, 0, (char *)"VCF version", 0},
  {(char *)"samples", __pyx_getprop_5pysam_7libcbcf_13VariantHeader_samples, 0, (char *)"samples (:class:`VariantHeaderSamples`)", 0},
  {(char *)"records", __pyx_getprop_5pysam_7libcbcf_13VariantHeader_records, 0, (char *)"header records (:class:`VariantHeaderRecords`)", 0},
  {(char *)"contigs", __pyx_getprop_5pysam_7libcbcf_13VariantHeader_contigs, 0, (char *)"contig information (:class:`VariantHeaderContigs`)", 0},
  {(char *)"filters", __pyx_getprop_5pysam_7libcbcf_13VariantHeader_filters, 0, (char *)"filter metadata (:class:`VariantHeaderMetadata`)", 0},
  {(char *)"info", __pyx_getprop_5pysam_7libcbcf_13VariantHeader_info, 0, (char *)"info metadata (:class:`VariantHeaderMetadata`)", 0},
  {(char *)"formats", __pyx_getprop_5pysam_7libcbcf_13VariantHeader_formats, 0, (char *)"format metadata (:class:`VariantHeaderMetadata`)", 0},
  {(char *)"alts", __pyx_getprop_5pysam_7libcbcf_13VariantHeader_alts, 0, (char *)"alt metadata (:class:`dict` ID->record).\n\n        The data returned just a snapshot of alt records, is created\n        every time the property is requested, and modifications will\n        not be reflected in the header metadata and vice versa.\n\n        i.e. it is just a dict that reflects the state of alt records\n        at the time it is created.\n        ", 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VariantHeader = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_5pysam_7libcbcf_13VariantHeader_7__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantHeader = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantHeader", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantHeader), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantHeader, /*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*/
  &__pyx_tp_as_number_VariantHeader, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_5pysam_7libcbcf_13VariantHeader_13__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "VariantHeader()\nheader information for a :class:`VariantFile` object", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantHeader, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5pysam_7libcbcf_VariantHeader, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5pysam_7libcbcf_13VariantHeader_3__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantHeader, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantHeaderRecord(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *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_5pysam_7libcbcf_VariantHeaderRecord *)o);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantHeaderRecord(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->header);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantHeaderRecord(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)o;
  if (p->header) {
    e = (*v)(((PyObject *)p->header), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantHeaderRecord(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord *)o;
  tmp = ((PyObject*)p->header);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5pysam_7libcbcf_VariantHeaderRecord(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_19VariantHeaderRecord_type(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_4type_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_19VariantHeaderRecord_key(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_3key_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_19VariantHeaderRecord_value(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_5value_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_19VariantHeaderRecord_attrs(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_5attrs_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_19VariantHeaderRecord_header(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_6header_1__get__(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantHeaderRecord[] = {
  {"get", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_12get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_11get},
  {"iterkeys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_16iterkeys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_15iterkeys},
  {"itervalues", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_18itervalues, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_17itervalues},
  {"iteritems", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_21iteritems, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_20iteritems},
  {"keys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_24keys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_23keys},
  {"items", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_26items, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_25items},
  {"values", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_28values, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_27values},
  {"update", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_30update, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_29update},
  {"pop", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_32pop, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_31pop},
  {"remove", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_36remove, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_35remove},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_38__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_37__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_40__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_39__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5pysam_7libcbcf_VariantHeaderRecord[] = {
  {(char *)"type", __pyx_getprop_5pysam_7libcbcf_19VariantHeaderRecord_type, 0, (char *)"header type: FILTER, INFO, FORMAT, CONTIG, STRUCTURED, or GENERIC", 0},
  {(char *)"key", __pyx_getprop_5pysam_7libcbcf_19VariantHeaderRecord_key, 0, (char *)"header key (the part before '=', in FILTER/INFO/FORMAT/contig/fileformat etc.)", 0},
  {(char *)"value", __pyx_getprop_5pysam_7libcbcf_19VariantHeaderRecord_value, 0, (char *)"header value.  Set only for generic lines, None for FILTER/INFO, etc.", 0},
  {(char *)"attrs", __pyx_getprop_5pysam_7libcbcf_19VariantHeaderRecord_attrs, 0, (char *)"sequence of additional header attributes", 0},
  {(char *)"header", __pyx_getprop_5pysam_7libcbcf_19VariantHeaderRecord_header, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VariantHeaderRecord = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_5__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VariantHeaderRecord = {
  __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_3__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5pysam_7libcbcf_VariantHeaderRecord, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_14__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VariantHeaderRecord = {
  __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_3__len__, /*mp_length*/
  __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_7__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantHeaderRecord = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantHeaderRecord", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecord), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantHeaderRecord, /*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*/
  &__pyx_tp_as_number_VariantHeaderRecord, /*tp_as_number*/
  &__pyx_tp_as_sequence_VariantHeaderRecord, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VariantHeaderRecord, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_34__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "VariantHeaderRecord(*args, **kwargs)\nheader record from a :class:`VariantHeader` object", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantHeaderRecord, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantHeaderRecord, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_9__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantHeaderRecord, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5pysam_7libcbcf_VariantHeaderRecord, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5pysam_7libcbcf_19VariantHeaderRecord_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantHeaderRecord, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantHeaderRecords(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *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_5pysam_7libcbcf_VariantHeaderRecords *)o);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantHeaderRecords(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->header);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantHeaderRecords(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)o;
  if (p->header) {
    e = (*v)(((PyObject *)p->header), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantHeaderRecords(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords *)o;
  tmp = ((PyObject*)p->header);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5pysam_7libcbcf_VariantHeaderRecords(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_20VariantHeaderRecords_header(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_6header_1__get__(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantHeaderRecords[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_12__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantHeaderRecords_11__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_14__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_20VariantHeaderRecords_13__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5pysam_7libcbcf_VariantHeaderRecords[] = {
  {(char *)"header", __pyx_getprop_5pysam_7libcbcf_20VariantHeaderRecords_header, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VariantHeaderRecords = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_5__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VariantHeaderRecords = {
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_3__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5pysam_7libcbcf_VariantHeaderRecords, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VariantHeaderRecords = {
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_3__len__, /*mp_length*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_7__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantHeaderRecords = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantHeaderRecords", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderRecords), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantHeaderRecords, /*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*/
  &__pyx_tp_as_number_VariantHeaderRecords, /*tp_as_number*/
  &__pyx_tp_as_sequence_VariantHeaderRecords, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VariantHeaderRecords, /*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*/
  "VariantHeaderRecords(*args, **kwargs)\nsequence of :class:`VariantHeaderRecord` object from a :class:`VariantHeader` object", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantHeaderRecords, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantHeaderRecords, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_9__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantHeaderRecords, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5pysam_7libcbcf_VariantHeaderRecords, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderRecords_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantHeaderRecords, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantHeaderContigs(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *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_5pysam_7libcbcf_VariantHeaderContigs *)o);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantHeaderContigs(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->header);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantHeaderContigs(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)o;
  if (p->header) {
    e = (*v)(((PyObject *)p->header), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantHeaderContigs(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs *)o;
  tmp = ((PyObject*)p->header);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5pysam_7libcbcf_VariantHeaderContigs(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_20VariantHeaderContigs_header(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_6header_1__get__(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantHeaderContigs[] = {
  {"remove_header", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_9remove_header, METH_O, __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_8remove_header},
  {"clear_header", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_11clear_header, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_10clear_header},
  {"get", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_16get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_15get},
  {"iterkeys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_20iterkeys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_19iterkeys},
  {"itervalues", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_22itervalues, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_21itervalues},
  {"iteritems", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_25iteritems, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_24iteritems},
  {"keys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_28keys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_27keys},
  {"items", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_30items, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_29items},
  {"values", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_32values, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_31values},
  {"add", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_34add, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_33add},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_36__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_35__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_38__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_20VariantHeaderContigs_37__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5pysam_7libcbcf_VariantHeaderContigs[] = {
  {(char *)"header", __pyx_getprop_5pysam_7libcbcf_20VariantHeaderContigs_header, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VariantHeaderContigs = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_5__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VariantHeaderContigs = {
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_3__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5pysam_7libcbcf_VariantHeaderContigs, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_18__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VariantHeaderContigs = {
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_3__len__, /*mp_length*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_7__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantHeaderContigs = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantHeaderContigs", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderContigs), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantHeaderContigs, /*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*/
  &__pyx_tp_as_number_VariantHeaderContigs, /*tp_as_number*/
  &__pyx_tp_as_sequence_VariantHeaderContigs, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VariantHeaderContigs, /*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*/
  "VariantHeaderContigs(*args, **kwargs)\nmapping from contig name or index to :class:`VariantContig` object.", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantHeaderContigs, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantHeaderContigs, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_13__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantHeaderContigs, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5pysam_7libcbcf_VariantHeaderContigs, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderContigs_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantHeaderContigs, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantHeaderSamples(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *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_5pysam_7libcbcf_VariantHeaderSamples *)o);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantHeaderSamples(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->header);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantHeaderSamples(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)o;
  if (p->header) {
    e = (*v)(((PyObject *)p->header), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantHeaderSamples(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples *)o;
  tmp = ((PyObject*)p->header);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5pysam_7libcbcf_VariantHeaderSamples(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_20VariantHeaderSamples_header(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_6header_1__get__(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantHeaderSamples[] = {
  {"add", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_14add, METH_O, __pyx_doc_5pysam_7libcbcf_20VariantHeaderSamples_13add},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_16__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantHeaderSamples_15__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_18__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_20VariantHeaderSamples_17__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5pysam_7libcbcf_VariantHeaderSamples[] = {
  {(char *)"header", __pyx_getprop_5pysam_7libcbcf_20VariantHeaderSamples_header, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VariantHeaderSamples = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_5__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VariantHeaderSamples = {
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_3__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5pysam_7libcbcf_VariantHeaderSamples, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_12__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VariantHeaderSamples = {
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_3__len__, /*mp_length*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_7__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantHeaderSamples = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantHeaderSamples", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderSamples), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantHeaderSamples, /*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*/
  &__pyx_tp_as_number_VariantHeaderSamples, /*tp_as_number*/
  &__pyx_tp_as_sequence_VariantHeaderSamples, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VariantHeaderSamples, /*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*/
  "VariantHeaderSamples(*args, **kwargs)\nsequence of sample names from a :class:`VariantHeader` object", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantHeaderSamples, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantHeaderSamples, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_9__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantHeaderSamples, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5pysam_7libcbcf_VariantHeaderSamples, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5pysam_7libcbcf_20VariantHeaderSamples_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantHeaderSamples, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantContig(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantContig *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_5pysam_7libcbcf_VariantContig *)o);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantContig(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantContig *p = (struct __pyx_obj_5pysam_7libcbcf_VariantContig *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->header);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantContig(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantContig *p = (struct __pyx_obj_5pysam_7libcbcf_VariantContig *)o;
  if (p->header) {
    e = (*v)(((PyObject *)p->header), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantContig(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantContig *p = (struct __pyx_obj_5pysam_7libcbcf_VariantContig *)o;
  tmp = ((PyObject*)p->header);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantContig_name(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantContig_4name_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantContig_id(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantContig_2id_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantContig_length(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantContig_6length_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantContig_header_record(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantContig_13header_record_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantContig_header(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantContig_6header_1__get__(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantContig[] = {
  {"remove_header", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantContig_3remove_header, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_13VariantContig_2remove_header},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantContig_5__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_13VariantContig_4__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantContig_7__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_13VariantContig_6__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5pysam_7libcbcf_VariantContig[] = {
  {(char *)"name", __pyx_getprop_5pysam_7libcbcf_13VariantContig_name, 0, (char *)"contig name", 0},
  {(char *)"id", __pyx_getprop_5pysam_7libcbcf_13VariantContig_id, 0, (char *)"contig internal id number", 0},
  {(char *)"length", __pyx_getprop_5pysam_7libcbcf_13VariantContig_length, 0, (char *)"contig length or None if not available", 0},
  {(char *)"header_record", __pyx_getprop_5pysam_7libcbcf_13VariantContig_header_record, 0, (char *)":class:`VariantHeaderRecord` associated with this :class:`VariantContig` object", 0},
  {(char *)"header", __pyx_getprop_5pysam_7libcbcf_13VariantContig_header, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantContig = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantContig", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantContig), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantContig, /*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*/
  "VariantContig(*args, **kwargs)\ncontig metadata from a :class:`VariantHeader`", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantContig, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantContig, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantContig, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5pysam_7libcbcf_VariantContig, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5pysam_7libcbcf_13VariantContig_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantContig, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantMetadata(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *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_5pysam_7libcbcf_VariantMetadata *)o);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantMetadata(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *p = (struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->header);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantMetadata(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *p = (struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)o;
  if (p->header) {
    e = (*v)(((PyObject *)p->header), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantMetadata(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *p = (struct __pyx_obj_5pysam_7libcbcf_VariantMetadata *)o;
  tmp = ((PyObject*)p->header);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_15VariantMetadata_name(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_15VariantMetadata_4name_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_15VariantMetadata_id(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_15VariantMetadata_2id_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_15VariantMetadata_number(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_15VariantMetadata_6number_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_15VariantMetadata_type(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_15VariantMetadata_4type_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_15VariantMetadata_description(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_15VariantMetadata_11description_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_15VariantMetadata_record(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_15VariantMetadata_6record_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_15VariantMetadata_header(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_15VariantMetadata_6header_1__get__(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantMetadata[] = {
  {"remove_header", (PyCFunction)__pyx_pw_5pysam_7libcbcf_15VariantMetadata_3remove_header, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_15VariantMetadata_2remove_header},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_15VariantMetadata_5__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_15VariantMetadata_4__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_15VariantMetadata_7__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_15VariantMetadata_6__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5pysam_7libcbcf_VariantMetadata[] = {
  {(char *)"name", __pyx_getprop_5pysam_7libcbcf_15VariantMetadata_name, 0, (char *)"metadata name", 0},
  {(char *)"id", __pyx_getprop_5pysam_7libcbcf_15VariantMetadata_id, 0, (char *)"metadata internal header id number", 0},
  {(char *)"number", __pyx_getprop_5pysam_7libcbcf_15VariantMetadata_number, 0, (char *)"metadata number (i.e. cardinality)", 0},
  {(char *)"type", __pyx_getprop_5pysam_7libcbcf_15VariantMetadata_type, 0, (char *)"metadata value type", 0},
  {(char *)"description", __pyx_getprop_5pysam_7libcbcf_15VariantMetadata_description, 0, (char *)"metadata description (or None if not set)", 0},
  {(char *)"record", __pyx_getprop_5pysam_7libcbcf_15VariantMetadata_record, 0, (char *)":class:`VariantHeaderRecord` associated with this :class:`VariantMetadata` object", 0},
  {(char *)"header", __pyx_getprop_5pysam_7libcbcf_15VariantMetadata_header, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantMetadata = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantMetadata", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantMetadata), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantMetadata, /*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*/
  "VariantMetadata(*args, **kwargs)\nfilter, info or format metadata record from a :class:`VariantHeader` object", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantMetadata, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantMetadata, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantMetadata, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5pysam_7libcbcf_VariantMetadata, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5pysam_7libcbcf_15VariantMetadata_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantMetadata, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantHeaderMetadata(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *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_5pysam_7libcbcf_VariantHeaderMetadata *)o);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantHeaderMetadata(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->header);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantHeaderMetadata(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)o;
  if (p->header) {
    e = (*v)(((PyObject *)p->header), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantHeaderMetadata(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *p = (struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata *)o;
  tmp = ((PyObject*)p->header);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5pysam_7libcbcf_VariantHeaderMetadata(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_21VariantHeaderMetadata_header(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_6header_1__get__(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantHeaderMetadata[] = {
  {"add", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_3add, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_2add},
  {"remove_header", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_11remove_header, METH_O, __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_10remove_header},
  {"clear_header", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_13clear_header, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_12clear_header},
  {"get", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_18get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_17get},
  {"iterkeys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_22iterkeys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_21iterkeys},
  {"itervalues", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_24itervalues, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_23itervalues},
  {"iteritems", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_27iteritems, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_26iteritems},
  {"keys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_30keys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_29keys},
  {"items", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_32items, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_31items},
  {"values", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_34values, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_33values},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_36__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_35__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_38__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_21VariantHeaderMetadata_37__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5pysam_7libcbcf_VariantHeaderMetadata[] = {
  {(char *)"header", __pyx_getprop_5pysam_7libcbcf_21VariantHeaderMetadata_header, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VariantHeaderMetadata = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_7__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VariantHeaderMetadata = {
  __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_5__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5pysam_7libcbcf_VariantHeaderMetadata, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_20__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VariantHeaderMetadata = {
  __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_5__len__, /*mp_length*/
  __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_9__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantHeaderMetadata = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantHeaderMetadata", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantHeaderMetadata), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantHeaderMetadata, /*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*/
  &__pyx_tp_as_number_VariantHeaderMetadata, /*tp_as_number*/
  &__pyx_tp_as_sequence_VariantHeaderMetadata, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VariantHeaderMetadata, /*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*/
  "VariantHeaderMetadata(*args, **kwargs)\nmapping from filter, info or format name to :class:`VariantMetadata` object", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantHeaderMetadata, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantHeaderMetadata, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_15__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantHeaderMetadata, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5pysam_7libcbcf_VariantHeaderMetadata, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5pysam_7libcbcf_21VariantHeaderMetadata_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantHeaderMetadata, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantRecord(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecord *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_5pysam_7libcbcf_VariantRecord *)o);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantRecord(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecord *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5pysam_7libcbcf_13VariantRecord_3__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->header);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantRecord(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecord *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)o;
  if (p->header) {
    e = (*v)(((PyObject *)p->header), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantRecord(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecord *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)o;
  tmp = ((PyObject*)p->header);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_rid(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_3rid_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_13VariantRecord_rid(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_13VariantRecord_3rid_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_chrom(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_5chrom_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_13VariantRecord_chrom(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_13VariantRecord_5chrom_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_contig(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_6contig_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_13VariantRecord_contig(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_13VariantRecord_6contig_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_pos(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_3pos_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_13VariantRecord_pos(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_13VariantRecord_3pos_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_start(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_5start_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_13VariantRecord_start(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_13VariantRecord_5start_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_stop(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_4stop_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_13VariantRecord_stop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_13VariantRecord_4stop_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_rlen(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_4rlen_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_13VariantRecord_rlen(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_13VariantRecord_4rlen_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_qual(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_4qual_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_13VariantRecord_qual(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_13VariantRecord_4qual_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_id(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_2id_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_13VariantRecord_id(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_13VariantRecord_2id_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_ref(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_3ref_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_13VariantRecord_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_13VariantRecord_3ref_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_alleles(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_7alleles_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_13VariantRecord_alleles(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_13VariantRecord_7alleles_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_alts(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_4alts_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_13VariantRecord_alts(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_13VariantRecord_4alts_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_filter(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_6filter_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_info(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_4info_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_format(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_6format_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_samples(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_7samples_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_13VariantRecord_header(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_13VariantRecord_6header_1__get__(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantRecord[] = {
  {"copy", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantRecord_5copy, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_13VariantRecord_4copy},
  {"translate", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantRecord_7translate, METH_O, __pyx_doc_5pysam_7libcbcf_13VariantRecord_6translate},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantRecord_13__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_13VariantRecord_12__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13VariantRecord_15__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_13VariantRecord_14__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5pysam_7libcbcf_VariantRecord[] = {
  {(char *)"rid", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_rid, __pyx_setprop_5pysam_7libcbcf_13VariantRecord_rid, (char *)"internal reference id number", 0},
  {(char *)"chrom", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_chrom, __pyx_setprop_5pysam_7libcbcf_13VariantRecord_chrom, (char *)"chromosome/contig name", 0},
  {(char *)"contig", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_contig, __pyx_setprop_5pysam_7libcbcf_13VariantRecord_contig, (char *)"chromosome/contig name", 0},
  {(char *)"pos", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_pos, __pyx_setprop_5pysam_7libcbcf_13VariantRecord_pos, (char *)"record start position on chrom/contig (1-based inclusive)", 0},
  {(char *)"start", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_start, __pyx_setprop_5pysam_7libcbcf_13VariantRecord_start, (char *)"record start position on chrom/contig (0-based inclusive)", 0},
  {(char *)"stop", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_stop, __pyx_setprop_5pysam_7libcbcf_13VariantRecord_stop, (char *)"record stop position on chrom/contig (0-based exclusive)", 0},
  {(char *)"rlen", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_rlen, __pyx_setprop_5pysam_7libcbcf_13VariantRecord_rlen, (char *)"record length on chrom/contig (aka rec.stop - rec.start)", 0},
  {(char *)"qual", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_qual, __pyx_setprop_5pysam_7libcbcf_13VariantRecord_qual, (char *)"phred scaled quality score or None if not available", 0},
  {(char *)"id", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_id, __pyx_setprop_5pysam_7libcbcf_13VariantRecord_id, (char *)"record identifier or None if not available", 0},
  {(char *)"ref", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_ref, __pyx_setprop_5pysam_7libcbcf_13VariantRecord_ref, (char *)"reference allele", 0},
  {(char *)"alleles", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_alleles, __pyx_setprop_5pysam_7libcbcf_13VariantRecord_alleles, (char *)"tuple of reference allele followed by alt alleles", 0},
  {(char *)"alts", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_alts, __pyx_setprop_5pysam_7libcbcf_13VariantRecord_alts, (char *)"tuple of alt alleles", 0},
  {(char *)"filter", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_filter, 0, (char *)"filter information (see :class:`VariantRecordFilter`)", 0},
  {(char *)"info", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_info, 0, (char *)"info data (see :class:`VariantRecordInfo`)", 0},
  {(char *)"format", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_format, 0, (char *)"sample format metadata (see :class:`VariantRecordFormat`)", 0},
  {(char *)"samples", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_samples, 0, (char *)"sample data (see :class:`VariantRecordSamples`)", 0},
  {(char *)"header", __pyx_getprop_5pysam_7libcbcf_13VariantRecord_header, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantRecord = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantRecord", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantRecord), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantRecord, /*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*/
  __pyx_pw_5pysam_7libcbcf_13VariantRecord_11__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "VariantRecord(*args, **kwargs)\nVariant record", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantRecord, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantRecord, /*tp_clear*/
  __pyx_pw_5pysam_7libcbcf_13VariantRecord_9__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantRecord, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5pysam_7libcbcf_VariantRecord, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5pysam_7libcbcf_13VariantRecord_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantRecord, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantRecordFilter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *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_5pysam_7libcbcf_VariantRecordFilter *)o);
  p->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantRecordFilter(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->record);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantRecordFilter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)o;
  if (p->record) {
    e = (*v)(((PyObject *)p->record), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantRecordFilter(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter *)o;
  tmp = ((PyObject*)p->record);
  p->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5pysam_7libcbcf_VariantRecordFilter(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_5pysam_7libcbcf_VariantRecordFilter(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript assignment not supported by %.200s", Py_TYPE(o)->tp_name);
    return -1;
  }
  else {
    return __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_11__delitem__(o, i);
  }
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantRecordFilter[] = {
  {"add", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_9add, METH_O, __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_8add},
  {"clear", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_13clear, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_12clear},
  {"get", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_18get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_17get},
  {"iterkeys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_22iterkeys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_21iterkeys},
  {"itervalues", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_24itervalues, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_23itervalues},
  {"iteritems", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_27iteritems, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_26iteritems},
  {"keys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_30keys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_29keys},
  {"items", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_32items, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_31items},
  {"values", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_34values, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_33values},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_38__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_37__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_40__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_19VariantRecordFilter_39__setstate_cython__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VariantRecordFilter = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_5__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VariantRecordFilter = {
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_3__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5pysam_7libcbcf_VariantRecordFilter, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_20__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VariantRecordFilter = {
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_3__len__, /*mp_length*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_7__getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_5pysam_7libcbcf_VariantRecordFilter, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantRecordFilter = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantRecordFilter", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFilter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantRecordFilter, /*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*/
  &__pyx_tp_as_number_VariantRecordFilter, /*tp_as_number*/
  &__pyx_tp_as_sequence_VariantRecordFilter, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VariantRecordFilter, /*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*/
  "VariantRecordFilter(*args, **kwargs)\nFilters set on a :class:`VariantRecord` object, presented as a mapping from\n       filter index or name to :class:`VariantMetadata` object", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantRecordFilter, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantRecordFilter, /*tp_clear*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_36__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFilter_15__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantRecordFilter, /*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_5pysam_7libcbcf_19VariantRecordFilter_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantRecordFilter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantRecordFormat(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *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_5pysam_7libcbcf_VariantRecordFormat *)o);
  p->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantRecordFormat(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->record);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantRecordFormat(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)o;
  if (p->record) {
    e = (*v)(((PyObject *)p->record), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantRecordFormat(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat *)o;
  tmp = ((PyObject*)p->record);
  p->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5pysam_7libcbcf_VariantRecordFormat(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_5pysam_7libcbcf_VariantRecordFormat(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript assignment not supported by %.200s", Py_TYPE(o)->tp_name);
    return -1;
  }
  else {
    return __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_9__delitem__(o, i);
  }
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantRecordFormat[] = {
  {"clear", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_11clear, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_10clear},
  {"get", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_16get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_15get},
  {"iterkeys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_20iterkeys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_19iterkeys},
  {"itervalues", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_22itervalues, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_21itervalues},
  {"iteritems", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_25iteritems, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_24iteritems},
  {"keys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_28keys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_27keys},
  {"items", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_30items, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_29items},
  {"values", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_32values, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_31values},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_34__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_33__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_36__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_19VariantRecordFormat_35__setstate_cython__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VariantRecordFormat = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_5__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VariantRecordFormat = {
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_3__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5pysam_7libcbcf_VariantRecordFormat, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_18__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VariantRecordFormat = {
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_3__len__, /*mp_length*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_7__getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_5pysam_7libcbcf_VariantRecordFormat, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantRecordFormat = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantRecordFormat", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantRecordFormat), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantRecordFormat, /*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*/
  &__pyx_tp_as_number_VariantRecordFormat, /*tp_as_number*/
  &__pyx_tp_as_sequence_VariantRecordFormat, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VariantRecordFormat, /*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*/
  "VariantRecordFormat(*args, **kwargs)\nFormat data present for each sample in a :class:`VariantRecord` object,\n       presented as mapping from format name to :class:`VariantMetadata` object.", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantRecordFormat, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantRecordFormat, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordFormat_13__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantRecordFormat, /*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_5pysam_7libcbcf_19VariantRecordFormat_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantRecordFormat, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantRecordInfo(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *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_5pysam_7libcbcf_VariantRecordInfo *)o);
  p->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantRecordInfo(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->record);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantRecordInfo(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)o;
  if (p->record) {
    e = (*v)(((PyObject *)p->record), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantRecordInfo(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo *)o;
  tmp = ((PyObject*)p->record);
  p->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5pysam_7libcbcf_VariantRecordInfo(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_5pysam_7libcbcf_VariantRecordInfo(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_9__setitem__(o, i, v);
  }
  else {
    return __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_11__delitem__(o, i);
  }
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantRecordInfo[] = {
  {"clear", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_13clear, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_12clear},
  {"get", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_18get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_17get},
  {"iterkeys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_22iterkeys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_21iterkeys},
  {"itervalues", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_24itervalues, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_23itervalues},
  {"iteritems", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_27iteritems, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_26iteritems},
  {"keys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_30keys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_29keys},
  {"items", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_32items, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_31items},
  {"values", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_34values, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_33values},
  {"update", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_36update, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_35update},
  {"pop", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_38pop, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_37pop},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_42__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_41__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_44__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_17VariantRecordInfo_43__setstate_cython__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VariantRecordInfo = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_5__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VariantRecordInfo = {
  __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_3__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5pysam_7libcbcf_VariantRecordInfo, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_20__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VariantRecordInfo = {
  __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_3__len__, /*mp_length*/
  __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_7__getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_5pysam_7libcbcf_VariantRecordInfo, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantRecordInfo = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantRecordInfo", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantRecordInfo), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantRecordInfo, /*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*/
  &__pyx_tp_as_number_VariantRecordInfo, /*tp_as_number*/
  &__pyx_tp_as_sequence_VariantRecordInfo, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VariantRecordInfo, /*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*/
  "VariantRecordInfo(*args, **kwargs)\nInfo data stored in a :class:`VariantRecord` object, presented as a\n       mapping from info metadata name to value.", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantRecordInfo, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantRecordInfo, /*tp_clear*/
  __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_40__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_17VariantRecordInfo_15__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantRecordInfo, /*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_5pysam_7libcbcf_17VariantRecordInfo_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantRecordInfo, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantRecordSamples(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *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_5pysam_7libcbcf_VariantRecordSamples *)o);
  p->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantRecordSamples(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->record);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantRecordSamples(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)o;
  if (p->record) {
    e = (*v)(((PyObject *)p->record), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantRecordSamples(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples *)o;
  tmp = ((PyObject*)p->record);
  p->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5pysam_7libcbcf_VariantRecordSamples(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantRecordSamples[] = {
  {"get", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_12get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_11get},
  {"iterkeys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_16iterkeys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_15iterkeys},
  {"itervalues", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_18itervalues, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_17itervalues},
  {"iteritems", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_21iteritems, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_20iteritems},
  {"keys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_24keys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_23keys},
  {"items", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_26items, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_25items},
  {"values", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_28values, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_27values},
  {"update", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_30update, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_29update},
  {"pop", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_32pop, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_31pop},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_36__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_35__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_38__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_20VariantRecordSamples_37__setstate_cython__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VariantRecordSamples = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_5__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VariantRecordSamples = {
  __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_3__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5pysam_7libcbcf_VariantRecordSamples, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_14__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VariantRecordSamples = {
  __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_3__len__, /*mp_length*/
  __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_7__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantRecordSamples = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantRecordSamples", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSamples), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantRecordSamples, /*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*/
  &__pyx_tp_as_number_VariantRecordSamples, /*tp_as_number*/
  &__pyx_tp_as_sequence_VariantRecordSamples, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VariantRecordSamples, /*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*/
  "VariantRecordSamples(*args, **kwargs)\nmapping from sample index or name to :class:`VariantRecordSample` object.", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantRecordSamples, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantRecordSamples, /*tp_clear*/
  __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_34__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_20VariantRecordSamples_9__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantRecordSamples, /*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_5pysam_7libcbcf_20VariantRecordSamples_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantRecordSamples, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantRecordSample(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *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_5pysam_7libcbcf_VariantRecordSample *)o);
  p->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantRecordSample(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->record);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantRecordSample(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)o;
  if (p->record) {
    e = (*v)(((PyObject *)p->record), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantRecordSample(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *p = (struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample *)o;
  tmp = ((PyObject*)p->record);
  p->record = ((struct __pyx_obj_5pysam_7libcbcf_VariantRecord *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5pysam_7libcbcf_VariantRecordSample(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_5pysam_7libcbcf_VariantRecordSample(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_9__setitem__(o, i, v);
  }
  else {
    return __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_11__delitem__(o, i);
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_19VariantRecordSample_name(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_4name_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_19VariantRecordSample_allele_indices(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_19VariantRecordSample_allele_indices(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_3__set__(o, v);
  }
  else {
    return __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_14allele_indices_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_19VariantRecordSample_alleles(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_7alleles_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_19VariantRecordSample_alleles(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_7alleles_3__set__(o, v);
  }
  else {
    return __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_7alleles_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_19VariantRecordSample_phased(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_6phased_1__get__(o);
}

static int __pyx_setprop_5pysam_7libcbcf_19VariantRecordSample_phased(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_6phased_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_19VariantRecordSample_index(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_5index_1__get__(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantRecordSample[] = {
  {"clear", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_13clear, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_12clear},
  {"get", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_18get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_17get},
  {"iterkeys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_22iterkeys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_21iterkeys},
  {"itervalues", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_24itervalues, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_23itervalues},
  {"iteritems", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_27iteritems, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_26iteritems},
  {"keys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_30keys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_29keys},
  {"items", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_32items, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_31items},
  {"values", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_34values, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_33values},
  {"update", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_36update, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_35update},
  {"pop", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_38pop, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_37pop},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_42__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_41__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_19VariantRecordSample_44__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_19VariantRecordSample_43__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5pysam_7libcbcf_VariantRecordSample[] = {
  {(char *)"name", __pyx_getprop_5pysam_7libcbcf_19VariantRecordSample_name, 0, (char *)"sample name", 0},
  {(char *)"allele_indices", __pyx_getprop_5pysam_7libcbcf_19VariantRecordSample_allele_indices, __pyx_setprop_5pysam_7libcbcf_19VariantRecordSample_allele_indices, (char *)"allele indices for called genotype, if present.  Otherwise None", 0},
  {(char *)"alleles", __pyx_getprop_5pysam_7libcbcf_19VariantRecordSample_alleles, __pyx_setprop_5pysam_7libcbcf_19VariantRecordSample_alleles, (char *)"alleles for called genotype, if present.  Otherwise None", 0},
  {(char *)"phased", __pyx_getprop_5pysam_7libcbcf_19VariantRecordSample_phased, __pyx_setprop_5pysam_7libcbcf_19VariantRecordSample_phased, (char *)"False if genotype is missing or any allele is unphased.  Otherwise True.", 0},
  {(char *)"index", __pyx_getprop_5pysam_7libcbcf_19VariantRecordSample_index, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VariantRecordSample = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_5__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VariantRecordSample = {
  __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_3__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5pysam_7libcbcf_VariantRecordSample, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_20__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VariantRecordSample = {
  __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_3__len__, /*mp_length*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_7__getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_5pysam_7libcbcf_VariantRecordSample, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantRecordSample = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantRecordSample", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantRecordSample), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantRecordSample, /*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*/
  &__pyx_tp_as_number_VariantRecordSample, /*tp_as_number*/
  &__pyx_tp_as_sequence_VariantRecordSample, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VariantRecordSample, /*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*/
  "VariantRecordSample(*args, **kwargs)\nData for a single sample from a :class:`VariantRecord` object.\n       Provides data accessors for genotypes and a mapping interface\n       from format name to values.\n    ", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantRecordSample, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantRecordSample, /*tp_clear*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_40__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_15__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantRecordSample, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5pysam_7libcbcf_VariantRecordSample, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5pysam_7libcbcf_19VariantRecordSample_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantRecordSample, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_BaseIndex(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_BaseIndex *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_5pysam_7libcbcf_BaseIndex *)o);
  p->refs = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->refmap = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_BaseIndex(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_BaseIndex *p = (struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->refs);
  Py_CLEAR(p->refmap);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_BaseIndex(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_BaseIndex *p = (struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)o;
  if (p->refs) {
    e = (*v)(p->refs, a); if (e) return e;
  }
  if (p->refmap) {
    e = (*v)(p->refmap, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_BaseIndex(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_BaseIndex *p = (struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)o;
  tmp = ((PyObject*)p->refs);
  p->refs = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->refmap);
  p->refmap = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_5pysam_7libcbcf_BaseIndex(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_BaseIndex[] = {
  {"get", (PyCFunction)__pyx_pw_5pysam_7libcbcf_9BaseIndex_11get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_9BaseIndex_10get},
  {"iterkeys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_9BaseIndex_15iterkeys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_9BaseIndex_14iterkeys},
  {"itervalues", (PyCFunction)__pyx_pw_5pysam_7libcbcf_9BaseIndex_17itervalues, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_9BaseIndex_16itervalues},
  {"iteritems", (PyCFunction)__pyx_pw_5pysam_7libcbcf_9BaseIndex_20iteritems, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_9BaseIndex_19iteritems},
  {"keys", (PyCFunction)__pyx_pw_5pysam_7libcbcf_9BaseIndex_23keys, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_9BaseIndex_22keys},
  {"items", (PyCFunction)__pyx_pw_5pysam_7libcbcf_9BaseIndex_25items, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_9BaseIndex_24items},
  {"values", (PyCFunction)__pyx_pw_5pysam_7libcbcf_9BaseIndex_27values, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_9BaseIndex_26values},
  {"update", (PyCFunction)__pyx_pw_5pysam_7libcbcf_9BaseIndex_29update, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_9BaseIndex_28update},
  {"pop", (PyCFunction)__pyx_pw_5pysam_7libcbcf_9BaseIndex_31pop, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_9BaseIndex_30pop},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_9BaseIndex_33__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_9BaseIndex_32__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_9BaseIndex_35__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_9BaseIndex_34__setstate_cython__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_BaseIndex = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_5pysam_7libcbcf_9BaseIndex_5__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_BaseIndex = {
  __pyx_pw_5pysam_7libcbcf_9BaseIndex_3__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5pysam_7libcbcf_BaseIndex, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_5pysam_7libcbcf_9BaseIndex_13__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_BaseIndex = {
  __pyx_pw_5pysam_7libcbcf_9BaseIndex_3__len__, /*mp_length*/
  __pyx_pw_5pysam_7libcbcf_9BaseIndex_7__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_BaseIndex = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.BaseIndex", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_BaseIndex), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_BaseIndex, /*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*/
  &__pyx_tp_as_number_BaseIndex, /*tp_as_number*/
  &__pyx_tp_as_sequence_BaseIndex, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_BaseIndex, /*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*/
  "BaseIndex()", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_BaseIndex, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_BaseIndex, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_9BaseIndex_9__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_BaseIndex, /*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_5pysam_7libcbcf_9BaseIndex_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_BaseIndex, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_BCFIndex(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_BCFIndex *p;
  PyObject *o = __pyx_tp_new_5pysam_7libcbcf_BaseIndex(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)o);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_BCFIndex(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_BCFIndex *p = (struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5pysam_7libcbcf_8BCFIndex_3__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->header);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_5pysam_7libcbcf_BaseIndex(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_BCFIndex(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_BCFIndex *p = (struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)o;
  e = __pyx_tp_traverse_5pysam_7libcbcf_BaseIndex(o, v, a); if (e) return e;
  if (p->header) {
    e = (*v)(((PyObject *)p->header), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_BCFIndex(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_BCFIndex *p = (struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)o;
  __pyx_tp_clear_5pysam_7libcbcf_BaseIndex(o);
  tmp = ((PyObject*)p->header);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_8BCFIndex_header(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_8BCFIndex_6header_1__get__(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_BCFIndex[] = {
  {"fetch", (PyCFunction)__pyx_pw_5pysam_7libcbcf_8BCFIndex_5fetch, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_8BCFIndex_4fetch},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_8BCFIndex_7__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_8BCFIndex_6__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_8BCFIndex_9__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_8BCFIndex_8__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5pysam_7libcbcf_BCFIndex[] = {
  {(char *)"header", __pyx_getprop_5pysam_7libcbcf_8BCFIndex_header, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_BCFIndex = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.BCFIndex", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_BCFIndex), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_BCFIndex, /*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*/
  "BCFIndex()\nCSI index data structure for BCF files", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_BCFIndex, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_BCFIndex, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_5pysam_7libcbcf_9BaseIndex_9__iter__, /*tp_iter*/
  #else
  0, /*tp_iter*/
  #endif
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_BCFIndex, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5pysam_7libcbcf_BCFIndex, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5pysam_7libcbcf_8BCFIndex_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_BCFIndex, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_TabixIndex(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_5pysam_7libcbcf_BaseIndex(t, a, k);
  if (unlikely(!o)) return 0;
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_TabixIndex(PyObject *o) {
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5pysam_7libcbcf_10TabixIndex_3__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_5pysam_7libcbcf_BaseIndex(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_TabixIndex[] = {
  {"fetch", (PyCFunction)__pyx_pw_5pysam_7libcbcf_10TabixIndex_5fetch, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_10TabixIndex_4fetch},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_10TabixIndex_7__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_10TabixIndex_6__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_10TabixIndex_9__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_10TabixIndex_8__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_TabixIndex = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.TabixIndex", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_TabixIndex), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_TabixIndex, /*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*/
  "TabixIndex()\nTabix index data structure for VCF files", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_BaseIndex, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_BaseIndex, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_5pysam_7libcbcf_9BaseIndex_9__iter__, /*tp_iter*/
  #else
  0, /*tp_iter*/
  #endif
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_TabixIndex, /*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_5pysam_7libcbcf_10TabixIndex_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_TabixIndex, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_BaseIterator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_BaseIterator *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_5pysam_7libcbcf_BaseIterator *)o);
  p->bcf = ((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_BaseIterator(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_BaseIterator *p = (struct __pyx_obj_5pysam_7libcbcf_BaseIterator *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->bcf);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_BaseIterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_BaseIterator *p = (struct __pyx_obj_5pysam_7libcbcf_BaseIterator *)o;
  if (p->bcf) {
    e = (*v)(((PyObject *)p->bcf), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_BaseIterator(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_BaseIterator *p = (struct __pyx_obj_5pysam_7libcbcf_BaseIterator *)o;
  tmp = ((PyObject*)p->bcf);
  p->bcf = ((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_BaseIterator[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_12BaseIterator_1__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_12BaseIterator___reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_12BaseIterator_3__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_12BaseIterator_2__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_BaseIterator = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.BaseIterator", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_BaseIterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_BaseIterator, /*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*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_BaseIterator, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_BaseIterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_BaseIterator, /*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_5pysam_7libcbcf_BaseIterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_BCFIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_BCFIterator *p;
  PyObject *o = __pyx_tp_new_5pysam_7libcbcf_BaseIterator(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5pysam_7libcbcf_BCFIterator *)o);
  p->index = ((struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_BCFIterator(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_BCFIterator *p = (struct __pyx_obj_5pysam_7libcbcf_BCFIterator *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5pysam_7libcbcf_11BCFIterator_3__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->index);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_5pysam_7libcbcf_BaseIterator(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_BCFIterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_BCFIterator *p = (struct __pyx_obj_5pysam_7libcbcf_BCFIterator *)o;
  e = __pyx_tp_traverse_5pysam_7libcbcf_BaseIterator(o, v, a); if (e) return e;
  if (p->index) {
    e = (*v)(((PyObject *)p->index), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_BCFIterator(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_BCFIterator *p = (struct __pyx_obj_5pysam_7libcbcf_BCFIterator *)o;
  __pyx_tp_clear_5pysam_7libcbcf_BaseIterator(o);
  tmp = ((PyObject*)p->index);
  p->index = ((struct __pyx_obj_5pysam_7libcbcf_BCFIndex *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_BCFIterator[] = {
  {"__next__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11BCFIterator_7__next__, METH_NOARGS|METH_COEXIST, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11BCFIterator_9__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_11BCFIterator_8__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11BCFIterator_11__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_11BCFIterator_10__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_BCFIterator = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.BCFIterator", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_BCFIterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_BCFIterator, /*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*/
  "BCFIterator(VariantFile bcf, contig=None, start=None, stop=None, reopen=True)", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_BCFIterator, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_BCFIterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_11BCFIterator_5__iter__, /*tp_iter*/
  __pyx_pw_5pysam_7libcbcf_11BCFIterator_7__next__, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_BCFIterator, /*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_5pysam_7libcbcf_11BCFIterator_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_BCFIterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_5pysam_7libcbcf_TabixIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_TabixIterator *p;
  PyObject *o = __pyx_tp_new_5pysam_7libcbcf_BaseIterator(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5pysam_7libcbcf_TabixIterator *)o);
  p->index = ((struct __pyx_obj_5pysam_7libcbcf_TabixIndex *)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_5pysam_7libcbcf_13TabixIterator_1__cinit__(o, a, k) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_TabixIterator(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_TabixIterator *p = (struct __pyx_obj_5pysam_7libcbcf_TabixIterator *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5pysam_7libcbcf_13TabixIterator_5__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->index);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_5pysam_7libcbcf_BaseIterator(o);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_TabixIterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_TabixIterator *p = (struct __pyx_obj_5pysam_7libcbcf_TabixIterator *)o;
  e = __pyx_tp_traverse_5pysam_7libcbcf_BaseIterator(o, v, a); if (e) return e;
  if (p->index) {
    e = (*v)(((PyObject *)p->index), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_TabixIterator(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_TabixIterator *p = (struct __pyx_obj_5pysam_7libcbcf_TabixIterator *)o;
  __pyx_tp_clear_5pysam_7libcbcf_BaseIterator(o);
  tmp = ((PyObject*)p->index);
  p->index = ((struct __pyx_obj_5pysam_7libcbcf_TabixIndex *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_TabixIterator[] = {
  {"__next__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13TabixIterator_9__next__, METH_NOARGS|METH_COEXIST, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13TabixIterator_11__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_13TabixIterator_10__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_13TabixIterator_13__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_13TabixIterator_12__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_TabixIterator = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.TabixIterator", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_TabixIterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_TabixIterator, /*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*/
  "TabixIterator(VariantFile bcf, contig=None, start=None, stop=None, reopen=True)", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_TabixIterator, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_TabixIterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_13TabixIterator_7__iter__, /*tp_iter*/
  __pyx_pw_5pysam_7libcbcf_13TabixIterator_9__next__, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_TabixIterator, /*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_5pysam_7libcbcf_13TabixIterator_3__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_TabixIterator, /*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_5pysam_7libcbcf_VariantFile __pyx_vtable_5pysam_7libcbcf_VariantFile;

static PyObject *__pyx_tp_new_5pysam_7libcbcf_VariantFile(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5pysam_7libcbcf_VariantFile *p;
  PyObject *o = __pyx_ptype_5pysam_10libchtslib_HTSFile->tp_new(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5pysam_7libcbcf_VariantFile *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5pysam_10libchtslib_HTSFile*)__pyx_vtabptr_5pysam_7libcbcf_VariantFile;
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  p->index = ((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_5pysam_7libcbcf_11VariantFile_1__cinit__(o, a, k) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf_VariantFile(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf_VariantFile *p = (struct __pyx_obj_5pysam_7libcbcf_VariantFile *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_5pysam_7libcbcf_11VariantFile_5__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->header);
  Py_CLEAR(p->index);
  PyObject_GC_Track(o);
  if (likely(__pyx_ptype_5pysam_10libchtslib_HTSFile)) __pyx_ptype_5pysam_10libchtslib_HTSFile->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_5pysam_7libcbcf_VariantFile);
}

static int __pyx_tp_traverse_5pysam_7libcbcf_VariantFile(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf_VariantFile *p = (struct __pyx_obj_5pysam_7libcbcf_VariantFile *)o;
  e = ((likely(__pyx_ptype_5pysam_10libchtslib_HTSFile)) ? ((__pyx_ptype_5pysam_10libchtslib_HTSFile->tp_traverse) ? __pyx_ptype_5pysam_10libchtslib_HTSFile->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_5pysam_7libcbcf_VariantFile)); if (e) return e;
  if (p->header) {
    e = (*v)(((PyObject *)p->header), a); if (e) return e;
  }
  if (p->index) {
    e = (*v)(((PyObject *)p->index), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf_VariantFile(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf_VariantFile *p = (struct __pyx_obj_5pysam_7libcbcf_VariantFile *)o;
  if (likely(__pyx_ptype_5pysam_10libchtslib_HTSFile)) { if (__pyx_ptype_5pysam_10libchtslib_HTSFile->tp_clear) __pyx_ptype_5pysam_10libchtslib_HTSFile->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_5pysam_7libcbcf_VariantFile);
  tmp = ((PyObject*)p->header);
  p->header = ((struct __pyx_obj_5pysam_7libcbcf_VariantHeader *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->index);
  p->index = ((struct __pyx_obj_5pysam_7libcbcf_BaseIndex *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_11VariantFile_header(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_11VariantFile_6header_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_11VariantFile_index(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_11VariantFile_5index_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_11VariantFile_drop_samples(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_11VariantFile_12drop_samples_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_11VariantFile_is_reading(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_11VariantFile_10is_reading_1__get__(o);
}

static PyObject *__pyx_getprop_5pysam_7libcbcf_11VariantFile_header_written(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5pysam_7libcbcf_11VariantFile_14header_written_1__get__(o);
}

static PyMethodDef __pyx_methods_5pysam_7libcbcf_VariantFile[] = {
  {"close", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_7close, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_11VariantFile_6close},
  {"__next__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_11__next__, METH_NOARGS|METH_COEXIST, 0},
  {"copy", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_13copy, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_11VariantFile_12copy},
  {"open", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_15open, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_11VariantFile_14open},
  {"reset", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_17reset, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_11VariantFile_16reset},
  {"is_valid_tid", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_19is_valid_tid, METH_O, __pyx_doc_5pysam_7libcbcf_11VariantFile_18is_valid_tid},
  {"get_tid", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_21get_tid, METH_O, __pyx_doc_5pysam_7libcbcf_11VariantFile_20get_tid},
  {"get_reference_name", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_23get_reference_name, METH_O, __pyx_doc_5pysam_7libcbcf_11VariantFile_22get_reference_name},
  {"fetch", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_25fetch, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_11VariantFile_24fetch},
  {"new_record", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_27new_record, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5pysam_7libcbcf_11VariantFile_26new_record},
  {"write", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_29write, METH_O, __pyx_doc_5pysam_7libcbcf_11VariantFile_28write},
  {"subset_samples", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_31subset_samples, METH_O, __pyx_doc_5pysam_7libcbcf_11VariantFile_30subset_samples},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_33__reduce_cython__, METH_NOARGS, __pyx_doc_5pysam_7libcbcf_11VariantFile_32__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5pysam_7libcbcf_11VariantFile_35__setstate_cython__, METH_O, __pyx_doc_5pysam_7libcbcf_11VariantFile_34__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5pysam_7libcbcf_VariantFile[] = {
  {(char *)"header", __pyx_getprop_5pysam_7libcbcf_11VariantFile_header, 0, (char *)0, 0},
  {(char *)"index", __pyx_getprop_5pysam_7libcbcf_11VariantFile_index, 0, (char *)0, 0},
  {(char *)"drop_samples", __pyx_getprop_5pysam_7libcbcf_11VariantFile_drop_samples, 0, (char *)0, 0},
  {(char *)"is_reading", __pyx_getprop_5pysam_7libcbcf_11VariantFile_is_reading, 0, (char *)0, 0},
  {(char *)"header_written", __pyx_getprop_5pysam_7libcbcf_11VariantFile_header_written, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5pysam_7libcbcf_VariantFile = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.VariantFile", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf_VariantFile), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf_VariantFile, /*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*/
  "VariantFile(*args, **kwargs)\n*(filename, mode=None, index_filename=None, header=None, drop_samples=False,\n    duplicate_filehandle=True, ignore_truncation=False, threads=1)*\n\n    A :term:`VCF`/:term:`BCF` formatted file. The file is automatically\n    opened.\n\n    If an index for a variant file exists (.csi or .tbi), it will be\n    opened automatically.  Without an index random access to records\n    via :meth:`fetch` is disabled.\n\n    For writing, a :class:`VariantHeader` object must be provided,\n    typically obtained from another :term:`VCF` file/:term:`BCF`\n    file.\n\n    Parameters\n    ----------\n    mode : string\n        *mode* should be ``r`` for reading or ``w`` for writing. The default is\n        text mode (:term:`VCF`).  For binary (:term:`BCF`) I/O you should append\n        ``b`` for compressed or ``u`` for uncompressed :term:`BCF` output.\n\n        If ``b`` is present, it must immediately follow ``r`` or ``w``.  Valid\n        modes are ``r``, ``w``, ``wh``, ``rb``, ``wb``, ``wbu`` and ``wb0``.\n        For instance, to open a :term:`BCF` formatted file for reading, type::\n\n            f = pysam.VariantFile('ex1.bcf','r')\n\n        If mode is not specified, we will try to auto-detect the file type.  All\n        of the following should work::\n\n            f1 = pysam.VariantFile('ex1.bcf')\n            f2 = pysam.VariantFile('ex1.vcf')\n            f3 = pysam.VariantFile('ex1.vcf.gz')\n\n    index_filename : string\n        Explicit path to an index file.\n\n    header : VariantHeader\n        :class:`VariantHeader` object required for writing.\n\n    drop_samples: bool\n        Ignore sample information when reading.\n\n    duplicate_filehandle: bool\n        By default, file handles passed either directly or through\n        File-like objects will be duplicated before passing them to\n        htslib. The duplication prevents issues where the same stream\n        will be closed by htslib and through destruction of the\n        hig""h-level python object. Set to False to turn off\n        duplication.\n\n    ignore_truncation: bool\n        Issue a warning, instead of raising an error if the current file\n        appears to be truncated due to a missing EOF marker.  Only applies\n        to bgzipped formats. (Default=False)\n\n    threads: integer\n        Number of threads to use for compressing/decompressing VCF/BCF files.\n        Setting threads to > 1 cannot be combined with `ignore_truncation`.\n        (Default=1)\n\n    ", /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf_VariantFile, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf_VariantFile, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_5pysam_7libcbcf_11VariantFile_9__iter__, /*tp_iter*/
  __pyx_pw_5pysam_7libcbcf_11VariantFile_11__next__, /*tp_iternext*/
  __pyx_methods_5pysam_7libcbcf_VariantFile, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5pysam_7libcbcf_VariantFile, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5pysam_7libcbcf_11VariantFile_3__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5pysam_7libcbcf_VariantFile, /*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_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple));
    (void) PyObject_INIT(o, t);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple(PyObject *o) {
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple, /*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, /*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_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple, /*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_5pysam_7libcbcf___pyx_scope_struct_1_genexpr *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_1_genexpr[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_1_genexpr = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_1_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_1_genexpr[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_1_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_1_genexpr(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_1_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_1_genexpr[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_1_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_1_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_1_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_1_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_1_genexpr, /*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_5pysam_7libcbcf___pyx_scope_struct_1_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object));
    (void) PyObject_INIT(o, t);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object *)o;
  Py_CLEAR(p->__pyx_v_b);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object, /*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, /*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_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object, /*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_5pysam_7libcbcf___pyx_scope_struct_3_genexpr *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_3_genexpr[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_3_genexpr = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_3_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_3_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_3_genexpr[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_3_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_3_genexpr(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_3_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_3_genexpr[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_3_genexpr++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_3_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_3_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_3_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_3_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_3_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_3_genexpr, /*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_5pysam_7libcbcf___pyx_scope_struct_3_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array));
    (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_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_values);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *)o;
  if (p->__pyx_v_values) {
    e = (*v)(p->__pyx_v_values, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array *)o;
  tmp = ((PyObject*)p->__pyx_v_values);
  p->__pyx_v_values = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  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_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array, /*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_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_5_genexpr[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_5_genexpr = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_5_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_5_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_5_genexpr[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_5_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_5_genexpr(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_5_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_5_genexpr[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_5_genexpr++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_5_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_5_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_5_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_5_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_5_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_5_genexpr, /*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_5pysam_7libcbcf___pyx_scope_struct_5_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values));
    (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_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_values);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *)o;
  if (p->__pyx_v_values) {
    e = (*v)(p->__pyx_v_values, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values *)o;
  tmp = ((PyObject*)p->__pyx_v_values);
  p->__pyx_v_values = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values, /*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_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values, /*tp_traverse*/
  __pyx_tp_clear_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values, /*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_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values, /*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_5pysam_7libcbcf___pyx_scope_struct_7_genexpr *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_7_genexpr[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_7_genexpr = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_7_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_7_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_7_genexpr[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_7_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_7_genexpr(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_7_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_7_genexpr[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_7_genexpr++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_7_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_7_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_7_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_7_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_7_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_7_genexpr, /*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_5pysam_7libcbcf___pyx_scope_struct_7_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__ *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_8___get__[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_8___get__ = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_8___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_8___get__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_8___get__[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_8___get__];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__));
    (void) PyObject_INIT(o, t);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_8___get__(PyObject *o) {
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_8___get__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_8___get__[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_8___get__++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_8___get__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_8___get__", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_8___get__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_8___get__, /*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, /*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_5pysam_7libcbcf___pyx_scope_struct_8___get__, /*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_5pysam_7libcbcf___pyx_scope_struct_9_genexpr *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_9_genexpr[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_9_genexpr = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_9_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_9_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_9_genexpr[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_9_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_9_genexpr(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_9_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_9_genexpr[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_9_genexpr++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_9_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_9_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_9_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_9_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_9_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_9_genexpr, /*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_5pysam_7libcbcf___pyx_scope_struct_9_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__ *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_10___iter__[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_10___iter__ = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_10___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_10___iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_10___iter__[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_10___iter__];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__));
    (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_5pysam_7libcbcf___pyx_scope_struct_10___iter__(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_10___iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_10___iter__[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_10___iter__++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_10___iter__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_10___iter__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_10___iter__", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_10___iter__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_10___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_10___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_10___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_11_itervalues *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_11_itervalues[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_11_itervalues = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_11_itervalues(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_11_itervalues > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_11_itervalues[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_11_itervalues];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues));
    (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_5pysam_7libcbcf___pyx_scope_struct_11_itervalues(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_11_itervalues < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_11_itervalues[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_11_itervalues++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_11_itervalues(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_11_itervalues = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_11_itervalues", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_11_itervalues), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_11_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_11_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_11_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_12_iteritems *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_12_iteritems[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_12_iteritems = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_12_iteritems(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_12_iteritems > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_12_iteritems[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_12_iteritems];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems));
    (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_5pysam_7libcbcf___pyx_scope_struct_12_iteritems(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_12_iteritems < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_12_iteritems[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_12_iteritems++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_12_iteritems(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_12_iteritems = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_12_iteritems", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_12_iteritems), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_12_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_12_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_12_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_13___iter__ *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_13___iter__[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_13___iter__ = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_13___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_13___iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_13___iter__[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_13___iter__];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__));
    (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_5pysam_7libcbcf___pyx_scope_struct_13___iter__(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_13___iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_13___iter__[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_13___iter__++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_13___iter__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_13___iter__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_13___iter__", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_13___iter__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_13___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_13___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_13___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_14___iter__ *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_14___iter__[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_14___iter__ = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_14___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_14___iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_14___iter__[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_14___iter__];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__));
    (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_5pysam_7libcbcf___pyx_scope_struct_14___iter__(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_14___iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_14___iter__[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_14___iter__++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_14___iter__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_14___iter__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_14___iter__", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_14___iter__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_14___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_14___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_14___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_15_itervalues *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_15_itervalues[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_15_itervalues = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_15_itervalues(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_15_itervalues > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_15_itervalues[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_15_itervalues];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues));
    (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_5pysam_7libcbcf___pyx_scope_struct_15_itervalues(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_15_itervalues < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_15_itervalues[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_15_itervalues++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_15_itervalues(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_15_itervalues = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_15_itervalues", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_15_itervalues), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_15_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_15_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_15_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_16_iteritems *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_16_iteritems[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_16_iteritems = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_16_iteritems(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_16_iteritems > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_16_iteritems[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_16_iteritems];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems));
    (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_5pysam_7libcbcf___pyx_scope_struct_16_iteritems(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_16_iteritems < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_16_iteritems[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_16_iteritems++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_16_iteritems(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_16_iteritems = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_16_iteritems", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_16_iteritems), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_16_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_16_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_16_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_17___iter__ *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_17___iter__[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_17___iter__ = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_17___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_17___iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_17___iter__[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_17___iter__];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__));
    (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_5pysam_7libcbcf___pyx_scope_struct_17___iter__(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_17___iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_17___iter__[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_17___iter__++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_17___iter__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_17___iter__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_17___iter__", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_17___iter__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_17___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_17___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_17___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_18_itervalues *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_18_itervalues[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_18_itervalues = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_18_itervalues(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_18_itervalues > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_18_itervalues[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_18_itervalues];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues));
    (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_5pysam_7libcbcf___pyx_scope_struct_18_itervalues(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_18_itervalues < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_18_itervalues[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_18_itervalues++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_18_itervalues(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_18_itervalues = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_18_itervalues", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_18_itervalues), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_18_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_18_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_18_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_19_iteritems *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_19_iteritems[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_19_iteritems = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_19_iteritems(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_19_iteritems > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_19_iteritems[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_19_iteritems];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems));
    (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_5pysam_7libcbcf___pyx_scope_struct_19_iteritems(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_19_iteritems < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_19_iteritems[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_19_iteritems++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_19_iteritems(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_19_iteritems = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_19_iteritems", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_19_iteritems), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_19_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_19_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_19_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_20___iter__ *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_20___iter__[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_20___iter__ = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_20___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_20___iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_20___iter__[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_20___iter__];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__));
    (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_5pysam_7libcbcf___pyx_scope_struct_20___iter__(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_20___iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_20___iter__[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_20___iter__++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_20___iter__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_20___iter__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_20___iter__", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_20___iter__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_20___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_20___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_20___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_21___iter__ *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_21___iter__[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_21___iter__ = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_21___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_21___iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_21___iter__[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_21___iter__];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__));
    (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_5pysam_7libcbcf___pyx_scope_struct_21___iter__(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_21___iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_21___iter__[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_21___iter__++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_21___iter__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_21___iter__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_21___iter__", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_21___iter__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_21___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_21___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_21___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_22_itervalues *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_22_itervalues[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_22_itervalues = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_22_itervalues(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_22_itervalues > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_22_itervalues[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_22_itervalues];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues));
    (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_5pysam_7libcbcf___pyx_scope_struct_22_itervalues(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_22_itervalues < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_22_itervalues[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_22_itervalues++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_22_itervalues(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_22_itervalues = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_22_itervalues", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_22_itervalues), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_22_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_22_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_22_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_23_iteritems *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_23_iteritems[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_23_iteritems = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_23_iteritems(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_23_iteritems > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_23_iteritems[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_23_iteritems];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems));
    (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_5pysam_7libcbcf___pyx_scope_struct_23_iteritems(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_23_iteritems < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_23_iteritems[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_23_iteritems++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_23_iteritems(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_23_iteritems = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_23_iteritems", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_23_iteritems), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_23_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_23_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_23_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_24___iter__ *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_24___iter__[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_24___iter__ = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_24___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_24___iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_24___iter__[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_24___iter__];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__));
    (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_5pysam_7libcbcf___pyx_scope_struct_24___iter__(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_24___iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_24___iter__[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_24___iter__++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_24___iter__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_24___iter__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_24___iter__", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_24___iter__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_24___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_24___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_24___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_25_itervalues *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_25_itervalues[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_25_itervalues = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_25_itervalues(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_25_itervalues > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_25_itervalues[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_25_itervalues];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues));
    (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_5pysam_7libcbcf___pyx_scope_struct_25_itervalues(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_25_itervalues < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_25_itervalues[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_25_itervalues++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_25_itervalues(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_25_itervalues = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_25_itervalues", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_25_itervalues), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_25_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_25_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_25_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_26_iteritems *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_26_iteritems[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_26_iteritems = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_26_iteritems(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_26_iteritems > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_26_iteritems[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_26_iteritems];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems));
    (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_5pysam_7libcbcf___pyx_scope_struct_26_iteritems(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_26_iteritems < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_26_iteritems[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_26_iteritems++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_26_iteritems(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_26_iteritems = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_26_iteritems", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_26_iteritems), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_26_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_26_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_26_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_27___iter__ *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_27___iter__[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_27___iter__ = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_27___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_27___iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_27___iter__[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_27___iter__];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__));
    (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_5pysam_7libcbcf___pyx_scope_struct_27___iter__(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_27___iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_27___iter__[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_27___iter__++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_27___iter__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_27___iter__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_27___iter__", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_27___iter__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_27___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_27___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_27___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_28_itervalues *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_28_itervalues[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_28_itervalues = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_28_itervalues(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_28_itervalues > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_28_itervalues[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_28_itervalues];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues));
    (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_5pysam_7libcbcf___pyx_scope_struct_28_itervalues(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_28_itervalues < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_28_itervalues[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_28_itervalues++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_28_itervalues(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_28_itervalues = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_28_itervalues", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_28_itervalues), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_28_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_28_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_28_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_29_iteritems *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_29_iteritems[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_29_iteritems = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_29_iteritems(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_29_iteritems > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_29_iteritems[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_29_iteritems];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems));
    (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_5pysam_7libcbcf___pyx_scope_struct_29_iteritems(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_value);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_29_iteritems < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_29_iteritems[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_29_iteritems++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_29_iteritems(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_v_value) {
    e = (*v)(p->__pyx_v_value, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_29_iteritems = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_29_iteritems", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_29_iteritems), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_29_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_29_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_29_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_30___iter__ *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_30___iter__[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_30___iter__ = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_30___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_30___iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_30___iter__[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_30___iter__];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__));
    (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_5pysam_7libcbcf___pyx_scope_struct_30___iter__(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_30___iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_30___iter__[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_30___iter__++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_30___iter__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_30___iter__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_30___iter__", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_30___iter__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_30___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_30___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_30___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_31_itervalues *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_31_itervalues[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_31_itervalues = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_31_itervalues(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_31_itervalues > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_31_itervalues[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_31_itervalues];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues));
    (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_5pysam_7libcbcf___pyx_scope_struct_31_itervalues(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_31_itervalues < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_31_itervalues[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_31_itervalues++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_31_itervalues(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_31_itervalues = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_31_itervalues", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_31_itervalues), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_31_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_31_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_31_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_32_iteritems *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_32_iteritems[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_32_iteritems = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_32_iteritems(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_32_iteritems > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_32_iteritems[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_32_iteritems];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems));
    (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_5pysam_7libcbcf___pyx_scope_struct_32_iteritems(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_32_iteritems < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_32_iteritems[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_32_iteritems++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_32_iteritems(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_32_iteritems = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_32_iteritems", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_32_iteritems), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_32_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_32_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_32_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_33___iter__ *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_33___iter__[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_33___iter__ = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_33___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_33___iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_33___iter__[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_33___iter__];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__));
    (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_5pysam_7libcbcf___pyx_scope_struct_33___iter__(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_33___iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_33___iter__[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_33___iter__++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_33___iter__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__ *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_33___iter__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_33___iter__", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_33___iter__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_33___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_33___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_33___iter__, /*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_5pysam_7libcbcf___pyx_scope_struct_34_itervalues *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_34_itervalues[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_34_itervalues = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_34_itervalues(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_34_itervalues > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_34_itervalues[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_34_itervalues];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues));
    (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_5pysam_7libcbcf___pyx_scope_struct_34_itervalues(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_34_itervalues < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_34_itervalues[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_34_itervalues++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_34_itervalues(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_34_itervalues = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_34_itervalues", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_34_itervalues), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_34_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_34_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_34_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_35_iteritems *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_35_iteritems[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_35_iteritems = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_35_iteritems(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_35_iteritems > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_35_iteritems[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_35_iteritems];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems));
    (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_5pysam_7libcbcf___pyx_scope_struct_35_iteritems(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_35_iteritems < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_35_iteritems[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_35_iteritems++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_35_iteritems(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_35_iteritems = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_35_iteritems", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_35_iteritems), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_35_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_35_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_35_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_36_itervalues *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_36_itervalues[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_36_itervalues = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_36_itervalues(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_36_itervalues > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_36_itervalues[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_36_itervalues];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues));
    (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_5pysam_7libcbcf___pyx_scope_struct_36_itervalues(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_36_itervalues < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_36_itervalues[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_36_itervalues++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_36_itervalues(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_36_itervalues = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_36_itervalues", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_36_itervalues), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_36_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_36_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_36_itervalues, /*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_5pysam_7libcbcf___pyx_scope_struct_37_iteritems *__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_37_iteritems[8];
static int __pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_37_iteritems = 0;

static PyObject *__pyx_tp_new_5pysam_7libcbcf___pyx_scope_struct_37_iteritems(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_37_iteritems > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems)))) {
    o = (PyObject*)__pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_37_iteritems[--__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_37_iteritems];
    memset(o, 0, sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems));
    (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_5pysam_7libcbcf___pyx_scope_struct_37_iteritems(PyObject *o) {
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_37_iteritems < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems)))) {
    __pyx_freelist_5pysam_7libcbcf___pyx_scope_struct_37_iteritems[__pyx_freecount_5pysam_7libcbcf___pyx_scope_struct_37_iteritems++] = ((struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_5pysam_7libcbcf___pyx_scope_struct_37_iteritems(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems *p = (struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems *)o;
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_5pysam_7libcbcf___pyx_scope_struct_37_iteritems = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysam.libcbcf.__pyx_scope_struct_37_iteritems", /*tp_name*/
  sizeof(struct __pyx_obj_5pysam_7libcbcf___pyx_scope_struct_37_iteritems), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5pysam_7libcbcf___pyx_scope_struct_37_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_37_iteritems, /*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_5pysam_7libcbcf___pyx_scope_struct_37_iteritems, /*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
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_libcbcf(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_libcbcf},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "libcbcf",
    0, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1},
  {&__pyx_n_s_ALT, __pyx_k_ALT, sizeof(__pyx_k_ALT), 0, 0, 1, 1},
  {&__pyx_n_s_BaseIndex_iteritems, __pyx_k_BaseIndex_iteritems, sizeof(__pyx_k_BaseIndex_iteritems), 0, 0, 1, 1},
  {&__pyx_n_s_BaseIndex_itervalues, __pyx_k_BaseIndex_itervalues, sizeof(__pyx_k_BaseIndex_itervalues), 0, 0, 1, 1},
  {&__pyx_n_s_CONTIG, __pyx_k_CONTIG, sizeof(__pyx_k_CONTIG), 0, 0, 1, 1},
  {&__pyx_kp_s_Cannot_add_extra_threads_when_ig, __pyx_k_Cannot_add_extra_threads_when_ig, sizeof(__pyx_k_Cannot_add_extra_threads_when_ig), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_copy_arrays_with_src_valu, __pyx_k_Cannot_copy_arrays_with_src_valu, sizeof(__pyx_k_Cannot_copy_arrays_with_src_valu), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_create_empty_array, __pyx_k_Cannot_create_empty_array, sizeof(__pyx_k_Cannot_create_empty_array), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_re_open_htsfile, __pyx_k_Cannot_re_open_htsfile, sizeof(__pyx_k_Cannot_re_open_htsfile), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_set_phased_before_genotyp, __pyx_k_Cannot_set_phased_before_genotyp, sizeof(__pyx_k_Cannot_set_phased_before_genotyp), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_specify_an_index_filename, __pyx_k_Cannot_specify_an_index_filename, sizeof(__pyx_k_Cannot_specify_an_index_filename), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_translate_record_Number_o, __pyx_k_Cannot_translate_record_Number_o, sizeof(__pyx_k_Cannot_translate_record_Number_o), 0, 0, 1, 0},
  {&__pyx_n_s_Description, __pyx_k_Description, sizeof(__pyx_k_Description), 0, 0, 1, 1},
  {&__pyx_kp_s_Duplicated_sample_name, __pyx_k_Duplicated_sample_name, sizeof(__pyx_k_Duplicated_sample_name), 0, 0, 1, 0},
  {&__pyx_n_b_END, __pyx_k_END, sizeof(__pyx_k_END), 0, 0, 0, 1},
  {&__pyx_n_s_END, __pyx_k_END, sizeof(__pyx_k_END), 0, 0, 1, 1},
  {&__pyx_kp_s_END_is_a_reserved_attribute_acce, __pyx_k_END_is_a_reserved_attribute_acce, sizeof(__pyx_k_END_is_a_reserved_attribute_acce), 0, 0, 1, 0},
  {&__pyx_kp_s_Error_s_reading_record, __pyx_k_Error_s_reading_record, sizeof(__pyx_k_Error_s_reading_record), 0, 0, 1, 0},
  {&__pyx_kp_s_Error_unpacking_VariantRecord, __pyx_k_Error_unpacking_VariantRecord, sizeof(__pyx_k_Error_unpacking_VariantRecord), 0, 0, 1, 0},
  {&__pyx_kp_s_Error_updating_alleles, __pyx_k_Error_updating_alleles, sizeof(__pyx_k_Error_updating_alleles), 0, 0, 1, 0},
  {&__pyx_kp_s_Error_updating_id, __pyx_k_Error_updating_id, sizeof(__pyx_k_Error_updating_id), 0, 0, 1, 0},
  {&__pyx_n_s_FILTER, __pyx_k_FILTER, sizeof(__pyx_k_FILTER), 0, 0, 1, 1},
  {&__pyx_n_s_FIXED, __pyx_k_FIXED, sizeof(__pyx_k_FIXED), 0, 0, 1, 1},
  {&__pyx_n_s_FORMAT, __pyx_k_FORMAT, sizeof(__pyx_k_FORMAT), 0, 0, 1, 1},
  {&__pyx_n_s_Flag, __pyx_k_Flag, sizeof(__pyx_k_Flag), 0, 0, 1, 1},
  {&__pyx_kp_s_Flag_types_are_not_allowed_on_FO, __pyx_k_Flag_types_are_not_allowed_on_FO, sizeof(__pyx_k_Flag_types_are_not_allowed_on_FO), 0, 0, 1, 0},
  {&__pyx_kp_s_Flag_values_must_be_True_False_N, __pyx_k_Flag_values_must_be_True_False_N, sizeof(__pyx_k_Flag_values_must_be_True_False_N), 0, 0, 1, 0},
  {&__pyx_n_s_Float, __pyx_k_Float, sizeof(__pyx_k_Float), 0, 0, 1, 1},
  {&__pyx_n_s_G, __pyx_k_G, sizeof(__pyx_k_G), 0, 0, 1, 1},
  {&__pyx_n_s_GENERIC, __pyx_k_GENERIC, sizeof(__pyx_k_GENERIC), 0, 0, 1, 1},
  {&__pyx_n_s_GT, __pyx_k_GT, sizeof(__pyx_k_GT), 0, 0, 1, 1},
  {&__pyx_kp_s_Header_already_exists_for_contig, __pyx_k_Header_already_exists_for_contig, sizeof(__pyx_k_Header_already_exists_for_contig), 0, 0, 1, 0},
  {&__pyx_kp_s_Header_already_exists_for_id, __pyx_k_Header_already_exists_for_id, sizeof(__pyx_k_Header_already_exists_for_id), 0, 0, 1, 0},
  {&__pyx_n_s_ID, __pyx_k_ID, sizeof(__pyx_k_ID), 0, 0, 1, 1},
  {&__pyx_n_s_INFO, __pyx_k_INFO, sizeof(__pyx_k_INFO), 0, 0, 1, 1},
  {&__pyx_n_s_IOError, __pyx_k_IOError, sizeof(__pyx_k_IOError), 0, 0, 1, 1},
  {&__pyx_kp_s_I_O_operation_on_closed_file, __pyx_k_I_O_operation_on_closed_file, sizeof(__pyx_k_I_O_operation_on_closed_file), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x09, __pyx_k_Incompatible_checksums_s_vs_0x09, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x09), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x5d, __pyx_k_Incompatible_checksums_s_vs_0x5d, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x5d), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x9d, __pyx_k_Incompatible_checksums_s_vs_0x9d, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x9d), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xbe, __pyx_k_Incompatible_checksums_s_vs_0xbe, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xbe), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xd9, __pyx_k_Incompatible_checksums_s_vs_0xd9, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xd9), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xde, __pyx_k_Incompatible_checksums_s_vs_0xde, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xde), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xed, __pyx_k_Incompatible_checksums_s_vs_0xed, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xed), 0, 0, 1, 0},
  {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
  {&__pyx_n_s_Integer, __pyx_k_Integer, sizeof(__pyx_k_Integer), 0, 0, 1, 1},
  {&__pyx_kp_s_Integer_value_too_small_large_to, __pyx_k_Integer_value_too_small_large_to, sizeof(__pyx_k_Integer_value_too_small_large_to), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_INFO_field, __pyx_k_Invalid_INFO_field, sizeof(__pyx_k_Invalid_INFO_field), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_VariantRecord_Number_of, __pyx_k_Invalid_VariantRecord_Number_of, sizeof(__pyx_k_Invalid_VariantRecord_Number_of), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_allele_index, __pyx_k_Invalid_allele_index, sizeof(__pyx_k_Invalid_allele_index), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_chromosome_contig, __pyx_k_Invalid_chromosome_contig, sizeof(__pyx_k_Invalid_chromosome_contig), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_filter, __pyx_k_Invalid_filter, sizeof(__pyx_k_Invalid_filter), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_header, __pyx_k_Invalid_header, sizeof(__pyx_k_Invalid_header), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_header_id, __pyx_k_Invalid_header_id, sizeof(__pyx_k_Invalid_header_id), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_header_record_index, __pyx_k_Invalid_header_record_index, sizeof(__pyx_k_Invalid_header_record_index), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_index_object, __pyx_k_Invalid_index_object, sizeof(__pyx_k_Invalid_index_object), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_tid, __pyx_k_Invalid_tid, sizeof(__pyx_k_Invalid_tid), 0, 0, 1, 0},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
  {&__pyx_kp_s_NON_REF, __pyx_k_NON_REF, sizeof(__pyx_k_NON_REF), 0, 0, 1, 0},
  {&__pyx_n_s_NotImplemented, __pyx_k_NotImplemented, sizeof(__pyx_k_NotImplemented), 0, 0, 1, 1},
  {&__pyx_n_s_Number, __pyx_k_Number, sizeof(__pyx_k_Number), 0, 0, 1, 1},
  {&__pyx_kp_s_Number_must_be_None_when_adding, __pyx_k_Number_must_be_None_when_adding, sizeof(__pyx_k_Number_must_be_None_when_adding), 0, 0, 1, 0},
  {&__pyx_n_s_PASS, __pyx_k_PASS, sizeof(__pyx_k_PASS), 0, 0, 1, 1},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  {&__pyx_kp_s_Position_must_be_positive, __pyx_k_Position_must_be_positive, sizeof(__pyx_k_Position_must_be_positive), 0, 0, 1, 0},
  {&__pyx_n_s_R, __pyx_k_R, sizeof(__pyx_k_R), 0, 0, 1, 1},
  {&__pyx_n_s_STRUCTURED, __pyx_k_STRUCTURED, sizeof(__pyx_k_STRUCTURED), 0, 0, 1, 1},
  {&__pyx_kp_s_Start_coordinate_must_be_non_neg, __pyx_k_Start_coordinate_must_be_non_neg, sizeof(__pyx_k_Start_coordinate_must_be_non_neg), 0, 0, 1, 0},
  {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1},
  {&__pyx_kp_s_Stop_coordinate_must_be_non_nega, __pyx_k_Stop_coordinate_must_be_non_nega, sizeof(__pyx_k_Stop_coordinate_must_be_non_nega), 0, 0, 1, 0},
  {&__pyx_kp_s_Stop_position_of_the_interval, __pyx_k_Stop_position_of_the_interval, sizeof(__pyx_k_Stop_position_of_the_interval), 0, 0, 1, 0},
  {&__pyx_n_s_String, __pyx_k_String, sizeof(__pyx_k_String), 0, 0, 1, 1},
  {&__pyx_n_s_Type, __pyx_k_Type, sizeof(__pyx_k_Type), 0, 0, 1, 1},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Type_must_be_None_when_adding_a, __pyx_k_Type_must_be_None_when_adding_a, sizeof(__pyx_k_Type_must_be_None_when_adding_a), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_delete_END, __pyx_k_Unable_to_delete_END, sizeof(__pyx_k_Unable_to_delete_END), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_delete_FORMAT, __pyx_k_Unable_to_delete_FORMAT, sizeof(__pyx_k_Unable_to_delete_FORMAT), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_delete_INFO, __pyx_k_Unable_to_delete_INFO, sizeof(__pyx_k_Unable_to_delete_INFO), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_update_INFO_values, __pyx_k_Unable_to_update_INFO_values, sizeof(__pyx_k_Unable_to_update_INFO_values), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_update_format_values, __pyx_k_Unable_to_update_format_values, sizeof(__pyx_k_Unable_to_update_format_values), 0, 0, 1, 0},
  {&__pyx_kp_s_Unknown_INFO_field, __pyx_k_Unknown_INFO_field, sizeof(__pyx_k_Unknown_INFO_field), 0, 0, 1, 0},
  {&__pyx_kp_s_Unknown_allele, __pyx_k_Unknown_allele, sizeof(__pyx_k_Unknown_allele), 0, 0, 1, 0},
  {&__pyx_kp_s_Unknown_format_length, __pyx_k_Unknown_format_length, sizeof(__pyx_k_Unknown_format_length), 0, 0, 1, 0},
  {&__pyx_kp_s_Unsupported_FORMAT_type, __pyx_k_Unsupported_FORMAT_type, sizeof(__pyx_k_Unsupported_FORMAT_type), 0, 0, 1, 0},
  {&__pyx_kp_s_Unsupported_INFO_type, __pyx_k_Unsupported_INFO_type, sizeof(__pyx_k_Unsupported_INFO_type), 0, 0, 1, 0},
  {&__pyx_n_s_VARIABLE, __pyx_k_VARIABLE, sizeof(__pyx_k_VARIABLE), 0, 0, 1, 1},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_n_s_VariantFile, __pyx_k_VariantFile, sizeof(__pyx_k_VariantFile), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeader, __pyx_k_VariantHeader, sizeof(__pyx_k_VariantHeader), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderContigs___iter, __pyx_k_VariantHeaderContigs___iter, sizeof(__pyx_k_VariantHeaderContigs___iter), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderContigs_iteritems, __pyx_k_VariantHeaderContigs_iteritems, sizeof(__pyx_k_VariantHeaderContigs_iteritems), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderContigs_itervalues, __pyx_k_VariantHeaderContigs_itervalues, sizeof(__pyx_k_VariantHeaderContigs_itervalues), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderMetadata___iter, __pyx_k_VariantHeaderMetadata___iter, sizeof(__pyx_k_VariantHeaderMetadata___iter), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderMetadata_iteritems, __pyx_k_VariantHeaderMetadata_iteritems, sizeof(__pyx_k_VariantHeaderMetadata_iteritems), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderMetadata_itervalues, __pyx_k_VariantHeaderMetadata_itervalues, sizeof(__pyx_k_VariantHeaderMetadata_itervalues), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderRecord, __pyx_k_VariantHeaderRecord, sizeof(__pyx_k_VariantHeaderRecord), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderRecord___get___loca, __pyx_k_VariantHeaderRecord___get___loca, sizeof(__pyx_k_VariantHeaderRecord___get___loca), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderRecord___iter, __pyx_k_VariantHeaderRecord___iter, sizeof(__pyx_k_VariantHeaderRecord___iter), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderRecord_iteritems, __pyx_k_VariantHeaderRecord_iteritems, sizeof(__pyx_k_VariantHeaderRecord_iteritems), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderRecord_itervalues, __pyx_k_VariantHeaderRecord_itervalues, sizeof(__pyx_k_VariantHeaderRecord_itervalues), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderRecords___iter, __pyx_k_VariantHeaderRecords___iter, sizeof(__pyx_k_VariantHeaderRecords___iter), 0, 0, 1, 1},
  {&__pyx_n_s_VariantHeaderSamples___iter, __pyx_k_VariantHeaderSamples___iter, sizeof(__pyx_k_VariantHeaderSamples___iter), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecord, __pyx_k_VariantRecord, sizeof(__pyx_k_VariantRecord), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordFilter___iter, __pyx_k_VariantRecordFilter___iter, sizeof(__pyx_k_VariantRecordFilter___iter), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordFilter_iteritems, __pyx_k_VariantRecordFilter_iteritems, sizeof(__pyx_k_VariantRecordFilter_iteritems), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordFilter_itervalues, __pyx_k_VariantRecordFilter_itervalues, sizeof(__pyx_k_VariantRecordFilter_itervalues), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordFormat___iter, __pyx_k_VariantRecordFormat___iter, sizeof(__pyx_k_VariantRecordFormat___iter), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordFormat_iteritems, __pyx_k_VariantRecordFormat_iteritems, sizeof(__pyx_k_VariantRecordFormat_iteritems), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordFormat_itervalues, __pyx_k_VariantRecordFormat_itervalues, sizeof(__pyx_k_VariantRecordFormat_itervalues), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordInfo___iter, __pyx_k_VariantRecordInfo___iter, sizeof(__pyx_k_VariantRecordInfo___iter), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordInfo_iteritems, __pyx_k_VariantRecordInfo_iteritems, sizeof(__pyx_k_VariantRecordInfo_iteritems), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordInfo_itervalues, __pyx_k_VariantRecordInfo_itervalues, sizeof(__pyx_k_VariantRecordInfo_itervalues), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordSample___iter, __pyx_k_VariantRecordSample___iter, sizeof(__pyx_k_VariantRecordSample___iter), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordSample_iteritems, __pyx_k_VariantRecordSample_iteritems, sizeof(__pyx_k_VariantRecordSample_iteritems), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordSample_itervalues, __pyx_k_VariantRecordSample_itervalues, sizeof(__pyx_k_VariantRecordSample_itervalues), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordSamples___iter, __pyx_k_VariantRecordSamples___iter, sizeof(__pyx_k_VariantRecordSamples___iter), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordSamples_iteritems, __pyx_k_VariantRecordSamples_iteritems, sizeof(__pyx_k_VariantRecordSamples_iteritems), 0, 0, 1, 1},
  {&__pyx_n_s_VariantRecordSamples_itervalues, __pyx_k_VariantRecordSamples_itervalues, sizeof(__pyx_k_VariantRecordSamples_itervalues), 0, 0, 1, 1},
  {&__pyx_kp_b__15, __pyx_k__15, sizeof(__pyx_k__15), 0, 0, 0, 0},
  {&__pyx_kp_s__15, __pyx_k__15, sizeof(__pyx_k__15), 0, 0, 1, 0},
  {&__pyx_kp_s__175, __pyx_k__175, sizeof(__pyx_k__175), 0, 0, 1, 0},
  {&__pyx_kp_b__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 0, 0},
  {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
  {&__pyx_kp_b__221, __pyx_k__221, sizeof(__pyx_k__221), 0, 0, 0, 0},
  {&__pyx_kp_b__71, __pyx_k__71, sizeof(__pyx_k__71), 0, 0, 0, 0},
  {&__pyx_kp_s__71, __pyx_k__71, sizeof(__pyx_k__71), 0, 0, 1, 0},
  {&__pyx_kp_s__74, __pyx_k__74, sizeof(__pyx_k__74), 0, 0, 1, 0},
  {&__pyx_n_s_add, __pyx_k_add, sizeof(__pyx_k_add), 0, 0, 1, 1},
  {&__pyx_n_s_add_meta, __pyx_k_add_meta, sizeof(__pyx_k_add_meta), 0, 0, 1, 1},
  {&__pyx_n_s_add_sample, __pyx_k_add_sample, sizeof(__pyx_k_add_sample), 0, 0, 1, 1},
  {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  {&__pyx_n_s_alleles, __pyx_k_alleles, sizeof(__pyx_k_alleles), 0, 0, 1, 1},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 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_bcf, __pyx_k_bcf, sizeof(__pyx_k_bcf), 0, 0, 1, 1},
  {&__pyx_kp_s_bcf_2, __pyx_k_bcf_2, sizeof(__pyx_k_bcf_2), 0, 0, 1, 0},
  {&__pyx_n_s_bcf_array_to_object_locals_genex, __pyx_k_bcf_array_to_object_locals_genex, sizeof(__pyx_k_bcf_array_to_object_locals_genex), 0, 0, 1, 1},
  {&__pyx_n_s_bcf_check_values_locals_genexpr, __pyx_k_bcf_check_values_locals_genexpr, sizeof(__pyx_k_bcf_check_values_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_kp_s_bcf_hdr_set_samples_failed_ret, __pyx_k_bcf_hdr_set_samples_failed_ret, sizeof(__pyx_k_bcf_hdr_set_samples_failed_ret), 0, 0, 1, 0},
  {&__pyx_kp_s_bcf_index_required, __pyx_k_bcf_index_required, sizeof(__pyx_k_bcf_index_required), 0, 0, 1, 0},
  {&__pyx_kp_s_bcf_must_not_be_None, __pyx_k_bcf_must_not_be_None, sizeof(__pyx_k_bcf_must_not_be_None), 0, 0, 1, 0},
  {&__pyx_n_s_bcf_object_to_array_locals_genex, __pyx_k_bcf_object_to_array_locals_genex, sizeof(__pyx_k_bcf_object_to_array_locals_genex), 0, 0, 1, 1},
  {&__pyx_n_s_bcguz, __pyx_k_bcguz, sizeof(__pyx_k_bcguz), 0, 0, 1, 1},
  {&__pyx_n_s_bcguz0123456789ex, __pyx_k_bcguz0123456789ex, sizeof(__pyx_k_bcguz0123456789ex), 0, 0, 1, 1},
  {&__pyx_kp_s_cannot_convert_deleted_record_to, __pyx_k_cannot_convert_deleted_record_to, sizeof(__pyx_k_cannot_convert_deleted_record_to), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_create_VariantHeader, __pyx_k_cannot_create_VariantHeader, sizeof(__pyx_k_cannot_create_VariantHeader), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_create_VariantRecord, __pyx_k_cannot_create_VariantRecord, sizeof(__pyx_k_cannot_create_VariantRecord), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_create_VariantRecordSampl, __pyx_k_cannot_create_VariantRecordSampl, sizeof(__pyx_k_cannot_create_VariantRecordSampl), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_fetch_from_Variantfile_op, __pyx_k_cannot_fetch_from_Variantfile_op, sizeof(__pyx_k_cannot_fetch_from_Variantfile_op), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_find_metadata_key, __pyx_k_cannot_find_metadata_key, sizeof(__pyx_k_cannot_find_metadata_key), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_iterate_over_Variantfile, __pyx_k_cannot_iterate_over_Variantfile, sizeof(__pyx_k_cannot_iterate_over_Variantfile), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_set_null_allele, __pyx_k_cannot_set_null_allele, sizeof(__pyx_k_cannot_set_null_allele), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_set_null_alt_allele, __pyx_k_cannot_set_null_alt_allele, sizeof(__pyx_k_cannot_set_null_alt_allele), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_subset_samples_after_fetc, __pyx_k_cannot_subset_samples_after_fetc, sizeof(__pyx_k_cannot_subset_samples_after_fetc), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_subset_samples_from_Varia, __pyx_k_cannot_subset_samples_from_Varia, sizeof(__pyx_k_cannot_subset_samples_from_Varia), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_write_to_a_Variantfile_op, __pyx_k_cannot_write_to_a_Variantfile_op, sizeof(__pyx_k_cannot_write_to_a_Variantfile_op), 0, 0, 1, 0},
  {&__pyx_n_s_char_array_to_tuple_locals_genex, __pyx_k_char_array_to_tuple_locals_genex, sizeof(__pyx_k_char_array_to_tuple_locals_genex), 0, 0, 1, 1},
  {&__pyx_n_s_check_truncation, __pyx_k_check_truncation, sizeof(__pyx_k_check_truncation), 0, 0, 1, 1},
  {&__pyx_n_s_chr, __pyx_k_chr, sizeof(__pyx_k_chr), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_contig, __pyx_k_contig, sizeof(__pyx_k_contig), 0, 0, 1, 1},
  {&__pyx_kp_s_contig_must_be_specified, __pyx_k_contig_must_be_specified, sizeof(__pyx_k_contig_must_be_specified), 0, 0, 1, 0},
  {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1},
  {&__pyx_kp_s_could_not_open_file_mode, __pyx_k_could_not_open_file_mode, sizeof(__pyx_k_could_not_open_file_mode), 0, 0, 1, 0},
  {&__pyx_kp_s_could_not_open_variant_file, __pyx_k_could_not_open_variant_file, sizeof(__pyx_k_could_not_open_variant_file), 0, 0, 1, 0},
  {&__pyx_kp_s_could_not_open_variant_file_2, __pyx_k_could_not_open_variant_file_2, sizeof(__pyx_k_could_not_open_variant_file_2), 0, 0, 1, 0},
  {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1},
  {&__pyx_n_s_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 1, 1},
  {&__pyx_n_s_description, __pyx_k_description, sizeof(__pyx_k_description), 0, 0, 1, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_drop_samples, __pyx_k_drop_samples, sizeof(__pyx_k_drop_samples), 0, 0, 1, 1},
  {&__pyx_kp_s_dst_header_must_not_be_None, __pyx_k_dst_header_must_not_be_None, sizeof(__pyx_k_dst_header_must_not_be_None), 0, 0, 1, 0},
  {&__pyx_n_s_duplicate_filehandle, __pyx_k_duplicate_filehandle, sizeof(__pyx_k_duplicate_filehandle), 0, 0, 1, 1},
  {&__pyx_kp_s_either_value_or_items_must_be_sp, __pyx_k_either_value_or_items_must_be_sp, sizeof(__pyx_k_either_value_or_items_must_be_sp), 0, 0, 1, 0},
  {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
  {&__pyx_n_s_endswith, __pyx_k_endswith, sizeof(__pyx_k_endswith), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_kp_s_error_in_bcf_subset_format, __pyx_k_error_in_bcf_subset_format, sizeof(__pyx_k_error_in_bcf_subset_format), 0, 0, 1, 0},
  {&__pyx_kp_s_error_in_vcf_parse, __pyx_k_error_in_vcf_parse, sizeof(__pyx_k_error_in_vcf_parse), 0, 0, 1, 0},
  {&__pyx_n_s_fetch, __pyx_k_fetch, sizeof(__pyx_k_fetch), 0, 0, 1, 1},
  {&__pyx_kp_s_fetch_requires_an_index, __pyx_k_fetch_requires_an_index, sizeof(__pyx_k_fetch_requires_an_index), 0, 0, 1, 0},
  {&__pyx_kp_s_file_does_not_have_valid_header, __pyx_k_file_does_not_have_valid_header, sizeof(__pyx_k_file_does_not_have_valid_header), 0, 0, 1, 0},
  {&__pyx_n_s_filename, __pyx_k_filename, sizeof(__pyx_k_filename), 0, 0, 1, 1},
  {&__pyx_n_s_filter, __pyx_k_filter, sizeof(__pyx_k_filter), 0, 0, 1, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
  {&__pyx_kp_s_genotype_is_only_valid_as_a_form, __pyx_k_genotype_is_only_valid_as_a_form, sizeof(__pyx_k_genotype_is_only_valid_as_a_form), 0, 0, 1, 0},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_get_reference_name, __pyx_k_get_reference_name, sizeof(__pyx_k_get_reference_name), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_kp_s_gz, __pyx_k_gz, sizeof(__pyx_k_gz), 0, 0, 1, 0},
  {&__pyx_n_s_hash, __pyx_k_hash, sizeof(__pyx_k_hash), 0, 0, 1, 1},
  {&__pyx_n_s_header, __pyx_k_header, sizeof(__pyx_k_header), 0, 0, 1, 1},
  {&__pyx_kp_s_header_must_not_be_None, __pyx_k_header_must_not_be_None, sizeof(__pyx_k_header_must_not_be_None), 0, 0, 1, 0},
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  {&__pyx_n_s_ignore_truncation, __pyx_k_ignore_truncation, sizeof(__pyx_k_ignore_truncation), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_index_filename, __pyx_k_index_filename, sizeof(__pyx_k_index_filename), 0, 0, 1, 1},
  {&__pyx_n_s_info, __pyx_k_info, sizeof(__pyx_k_info), 0, 0, 1, 1},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_kp_s_invalid_FORMAT, __pyx_k_invalid_FORMAT, sizeof(__pyx_k_invalid_FORMAT), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_VariantHeader, __pyx_k_invalid_VariantHeader, sizeof(__pyx_k_invalid_VariantHeader), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_VariantRecord, __pyx_k_invalid_VariantRecord, sizeof(__pyx_k_invalid_VariantRecord), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_character_found, __pyx_k_invalid_character_found, sizeof(__pyx_k_invalid_character_found), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_contig, __pyx_k_invalid_contig, sizeof(__pyx_k_invalid_contig), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_contig_2, __pyx_k_invalid_contig_2, sizeof(__pyx_k_invalid_contig_2), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_contig_id, __pyx_k_invalid_contig_id, sizeof(__pyx_k_invalid_contig_id), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_contig_index, __pyx_k_invalid_contig_index, sizeof(__pyx_k_invalid_contig_index), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_file_mode_is_it_VCF_BCF, __pyx_k_invalid_file_mode_is_it_VCF_BCF, sizeof(__pyx_k_invalid_file_mode_is_it_VCF_BCF), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_filter_index, __pyx_k_invalid_filter_index, sizeof(__pyx_k_invalid_filter_index), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_header_line, __pyx_k_invalid_header_line, sizeof(__pyx_k_invalid_header_line), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_header_record_index, __pyx_k_invalid_header_record_index, sizeof(__pyx_k_invalid_header_record_index), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_key, __pyx_k_invalid_key, sizeof(__pyx_k_invalid_key), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_metadata_id, __pyx_k_invalid_metadata_id, sizeof(__pyx_k_invalid_metadata_id), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_metadata_type, __pyx_k_invalid_metadata_type, sizeof(__pyx_k_invalid_metadata_type), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_mode_options, __pyx_k_invalid_mode_options, sizeof(__pyx_k_invalid_mode_options), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_number_of_columns, __pyx_k_invalid_number_of_columns, sizeof(__pyx_k_invalid_number_of_columns), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_reference_id, __pyx_k_invalid_reference_id, sizeof(__pyx_k_invalid_reference_id), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_sample_index, __pyx_k_invalid_sample_index, sizeof(__pyx_k_invalid_sample_index), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_sample_name, __pyx_k_invalid_sample_name, sizeof(__pyx_k_invalid_sample_name), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_tag, __pyx_k_invalid_tag, sizeof(__pyx_k_invalid_tag), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_value_for_Float_format, __pyx_k_invalid_value_for_Float_format, sizeof(__pyx_k_invalid_value_for_Float_format), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_value_for_Integer_format, __pyx_k_invalid_value_for_Integer_format, sizeof(__pyx_k_invalid_value_for_Integer_format), 0, 0, 1, 0},
  {&__pyx_n_s_is_open, __pyx_k_is_open, sizeof(__pyx_k_is_open), 0, 0, 1, 1},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_n_s_iter, __pyx_k_iter, sizeof(__pyx_k_iter), 0, 0, 1, 1},
  {&__pyx_n_s_iteritems, __pyx_k_iteritems, sizeof(__pyx_k_iteritems), 0, 0, 1, 1},
  {&__pyx_n_s_itervalues, __pyx_k_itervalues, sizeof(__pyx_k_itervalues), 0, 0, 1, 1},
  {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
  {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
  {&__pyx_kp_s_limits_violated, __pyx_k_limits_violated, sizeof(__pyx_k_limits_violated), 0, 0, 1, 0},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_kp_s_missing_d_requested_samples, __pyx_k_missing_d_requested_samples, sizeof(__pyx_k_missing_d_requested_samples), 0, 0, 1, 0},
  {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
  {&__pyx_kp_s_mode_contains_conflicting_format, __pyx_k_mode_contains_conflicting_format, sizeof(__pyx_k_mode_contains_conflicting_format), 0, 0, 1, 0},
  {&__pyx_kp_s_mode_must_begin_with_r_w_or_a, __pyx_k_mode_must_begin_with_r_w_or_a, sizeof(__pyx_k_mode_must_begin_with_r_w_or_a), 0, 0, 1, 0},
  {&__pyx_kp_s_must_set_at_least_2_alleles, __pyx_k_must_set_at_least_2_alleles, sizeof(__pyx_k_must_set_at_least_2_alleles), 0, 0, 1, 0},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_n_s_new_record, __pyx_k_new_record, sizeof(__pyx_k_new_record), 0, 0, 1, 1},
  {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
  {&__pyx_n_s_number, __pyx_k_number, sizeof(__pyx_k_number), 0, 0, 1, 1},
  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
  {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
  {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 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_phased, __pyx_k_phased, sizeof(__pyx_k_phased), 0, 0, 1, 1},
  {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
  {&__pyx_n_s_pysam_libcbcf, __pyx_k_pysam_libcbcf, sizeof(__pyx_k_pysam_libcbcf), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_BaseIndex, __pyx_k_pyx_unpickle_BaseIndex, sizeof(__pyx_k_pyx_unpickle_BaseIndex), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_VariantContig, __pyx_k_pyx_unpickle_VariantContig, sizeof(__pyx_k_pyx_unpickle_VariantContig), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_VariantHeaderCont, __pyx_k_pyx_unpickle_VariantHeaderCont, sizeof(__pyx_k_pyx_unpickle_VariantHeaderCont), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_VariantHeaderMeta, __pyx_k_pyx_unpickle_VariantHeaderMeta, sizeof(__pyx_k_pyx_unpickle_VariantHeaderMeta), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_VariantHeaderReco, __pyx_k_pyx_unpickle_VariantHeaderReco, sizeof(__pyx_k_pyx_unpickle_VariantHeaderReco), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_VariantHeaderSamp, __pyx_k_pyx_unpickle_VariantHeaderSamp, sizeof(__pyx_k_pyx_unpickle_VariantHeaderSamp), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_VariantMetadata, __pyx_k_pyx_unpickle_VariantMetadata, sizeof(__pyx_k_pyx_unpickle_VariantMetadata), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_VariantRecordFilt, __pyx_k_pyx_unpickle_VariantRecordFilt, sizeof(__pyx_k_pyx_unpickle_VariantRecordFilt), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_VariantRecordForm, __pyx_k_pyx_unpickle_VariantRecordForm, sizeof(__pyx_k_pyx_unpickle_VariantRecordForm), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_VariantRecordInfo, __pyx_k_pyx_unpickle_VariantRecordInfo, sizeof(__pyx_k_pyx_unpickle_VariantRecordInfo), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_VariantRecordSamp, __pyx_k_pyx_unpickle_VariantRecordSamp, sizeof(__pyx_k_pyx_unpickle_VariantRecordSamp), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_VariantRecordSamp_2, __pyx_k_pyx_unpickle_VariantRecordSamp_2, sizeof(__pyx_k_pyx_unpickle_VariantRecordSamp_2), 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_qual, __pyx_k_qual, sizeof(__pyx_k_qual), 0, 0, 1, 1},
  {&__pyx_n_b_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 0, 1},
  {&__pyx_n_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_record, __pyx_k_record, sizeof(__pyx_k_record), 0, 0, 1, 1},
  {&__pyx_kp_s_record_must_not_be_None, __pyx_k_record_must_not_be_None, sizeof(__pyx_k_record_must_not_be_None), 0, 0, 1, 0},
  {&__pyx_n_s_records, __pyx_k_records, sizeof(__pyx_k_records), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1},
  {&__pyx_kp_s_ref_allele_must_not_be_null, __pyx_k_ref_allele_must_not_be_null, sizeof(__pyx_k_ref_allele_must_not_be_null), 0, 0, 1, 0},
  {&__pyx_n_s_reference, __pyx_k_reference, sizeof(__pyx_k_reference), 0, 0, 1, 1},
  {&__pyx_n_s_region, __pyx_k_region, sizeof(__pyx_k_region), 0, 0, 1, 1},
  {&__pyx_n_s_remap, __pyx_k_remap, sizeof(__pyx_k_remap), 0, 0, 1, 1},
  {&__pyx_n_s_reopen, __pyx_k_reopen, sizeof(__pyx_k_reopen), 0, 0, 1, 1},
  {&__pyx_n_s_reversed, __pyx_k_reversed, sizeof(__pyx_k_reversed), 0, 0, 1, 1},
  {&__pyx_n_s_rwa, __pyx_k_rwa, sizeof(__pyx_k_rwa), 0, 0, 1, 1},
  {&__pyx_kp_s_sample_must_not_be_None, __pyx_k_sample_must_not_be_None, sizeof(__pyx_k_sample_must_not_be_None), 0, 0, 1, 0},
  {&__pyx_n_s_samples, __pyx_k_samples, sizeof(__pyx_k_samples), 0, 0, 1, 1},
  {&__pyx_n_s_seek, __pyx_k_seek, sizeof(__pyx_k_seek), 0, 0, 1, 1},
  {&__pyx_kp_s_self_iter_cannot_be_converted_to, __pyx_k_self_iter_cannot_be_converted_to, sizeof(__pyx_k_self_iter_cannot_be_converted_to), 0, 0, 1, 0},
  {&__pyx_kp_s_self_ptr_cannot_be_converted_to, __pyx_k_self_ptr_cannot_be_converted_to, sizeof(__pyx_k_self_ptr_cannot_be_converted_to), 0, 0, 1, 0},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_startswith, __pyx_k_startswith, sizeof(__pyx_k_startswith), 0, 0, 1, 1},
  {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
  {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  {&__pyx_kp_s_tabix_index_required, __pyx_k_tabix_index_required, sizeof(__pyx_k_tabix_index_required), 0, 0, 1, 0},
  {&__pyx_n_s_tell, __pyx_k_tell, sizeof(__pyx_k_tell), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_kp_s_this_class_cannot_be_instantiate, __pyx_k_this_class_cannot_be_instantiate, sizeof(__pyx_k_this_class_cannot_be_instantiate), 0, 0, 1, 0},
  {&__pyx_n_s_threads, __pyx_k_threads, sizeof(__pyx_k_threads), 0, 0, 1, 1},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_kp_s_truncated_file, __pyx_k_truncated_file, sizeof(__pyx_k_truncated_file), 0, 0, 1, 0},
  {&__pyx_n_s_type, __pyx_k_type, sizeof(__pyx_k_type), 0, 0, 1, 1},
  {&__pyx_kp_s_unable_to_allocate_BCF_record, __pyx_k_unable_to_allocate_BCF_record, sizeof(__pyx_k_unable_to_allocate_BCF_record), 0, 0, 1, 0},
  {&__pyx_kp_s_unable_to_fetch, __pyx_k_unable_to_fetch, sizeof(__pyx_k_unable_to_fetch), 0, 0, 1, 0},
  {&__pyx_kp_s_unable_to_fetch_next_record, __pyx_k_unable_to_fetch_next_record, sizeof(__pyx_k_unable_to_fetch_next_record), 0, 0, 1, 0},
  {&__pyx_kp_s_unknown_INFO, __pyx_k_unknown_INFO, sizeof(__pyx_k_unknown_INFO), 0, 0, 1, 0},
  {&__pyx_kp_s_unknown_format, __pyx_k_unknown_format, sizeof(__pyx_k_unknown_format), 0, 0, 1, 0},
  {&__pyx_kp_s_unknown_mode, __pyx_k_unknown_mode, sizeof(__pyx_k_unknown_mode), 0, 0, 1, 0},
  {&__pyx_kp_s_unknown_type_specified, __pyx_k_unknown_type_specified, sizeof(__pyx_k_unknown_type_specified), 0, 0, 1, 0},
  {&__pyx_kp_s_unsupported_header_type_code, __pyx_k_unsupported_header_type_code, sizeof(__pyx_k_unsupported_header_type_code), 0, 0, 1, 0},
  {&__pyx_kp_s_unsupported_info_type_code, __pyx_k_unsupported_info_type_code, sizeof(__pyx_k_unsupported_info_type_code), 0, 0, 1, 0},
  {&__pyx_kp_s_unsupported_type, __pyx_k_unsupported_type, sizeof(__pyx_k_unsupported_type), 0, 0, 1, 0},
  {&__pyx_kp_s_unsupported_types, __pyx_k_unsupported_types, sizeof(__pyx_k_unsupported_types), 0, 0, 1, 0},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_s_upper, __pyx_k_upper, sizeof(__pyx_k_upper), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_kp_s_value_expected_to_be_scalar_give, __pyx_k_value_expected_to_be_scalar_give, sizeof(__pyx_k_value_expected_to_be_scalar_give), 0, 0, 1, 0},
  {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
  {&__pyx_kp_s_values_expected_to_be_tuple_give, __pyx_k_values_expected_to_be_tuple_give, sizeof(__pyx_k_values_expected_to_be_tuple_give), 0, 0, 1, 0},
  {&__pyx_kp_s_vcf_format_failed, __pyx_k_vcf_format_failed, sizeof(__pyx_k_vcf_format_failed), 0, 0, 1, 0},
  {&__pyx_n_b_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 0, 1},
  {&__pyx_n_s_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 1, 1},
  {&__pyx_n_s_wb, __pyx_k_wb, sizeof(__pyx_k_wb), 0, 0, 1, 1},
  {&__pyx_n_s_wb0, __pyx_k_wb0, sizeof(__pyx_k_wb0), 0, 0, 1, 1},
  {&__pyx_n_s_wbu, __pyx_k_wbu, sizeof(__pyx_k_wbu), 0, 0, 1, 1},
  {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
  {&__pyx_n_s_wz, __pyx_k_wz, sizeof(__pyx_k_wz), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 134, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 188, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 227, __pyx_L1_error)
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 313, __pyx_L1_error)
  __pyx_builtin_chr = __Pyx_GetBuiltinName(__pyx_n_s_chr); if (!__pyx_builtin_chr) __PYX_ERR(0, 542, __pyx_L1_error)
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 677, __pyx_L1_error)
  __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(0, 1430, __pyx_L1_error)
  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 2058, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 2088, __pyx_L1_error)
  __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s_NotImplemented); if (!__pyx_builtin_NotImplemented) __PYX_ERR(0, 2322, __pyx_L1_error)
  __pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_n_s_reversed); if (!__pyx_builtin_reversed) __PYX_ERR(0, 2410, __pyx_L1_error)
  __pyx_builtin_IOError = __Pyx_GetBuiltinName(__pyx_n_s_IOError); if (!__pyx_builtin_IOError) __PYX_ERR(0, 3783, __pyx_L1_error)
  __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 3797, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "pysam/libcbcf.pyx":227
 * 
 *     if sample < 0:
 *         raise ValueError('genotype is only valid as a format field')             # <<<<<<<<<<<<<<
 * 
 *     cdef int32_t *gt_arr = NULL
 */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_genotype_is_only_valid_as_a_form); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 227, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "pysam/libcbcf.pyx":285
 *                 # Otherwise, copy the entire block
 *                 b = datac[:n]
 *             value = tuple(v.decode('ascii') if v and v != bcf_str_missing else None for v in b.split(b','))             # <<<<<<<<<<<<<<
 *     else:
 *         value = []
 */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_ascii); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "pysam/libcbcf.pyx":313
 *                 value.append(dataf[i] if not bcf_float_is_missing(dataf[i]) else None)
 *         else:
 *             raise TypeError('unsupported info type code')             # <<<<<<<<<<<<<<
 * 
 *     # FIXME: Need to know length?  Report errors?  Pad with missing values?  Not clear what to do.
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_unsupported_info_type_code); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "pysam/libcbcf.pyx":322
 *             value = ()
 *         else:
 *             value = (None,)*count             # <<<<<<<<<<<<<<
 *     elif scalar and len(value) == 1:
 *         value = value[0]
 */
  __pyx_tuple__5 = PyTuple_New(1); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_tuple__5, 0, Py_None);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "pysam/libcbcf.pyx":382
 *             bcf_float_set(dataf + i, bcf_float_vector_end)
 *     else:
 *         raise TypeError('unsupported type')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_unsupported_type); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "pysam/libcbcf.pyx":392
 * 
 *     if n <= 0:
 *         raise ValueError('Cannot create empty array')             # <<<<<<<<<<<<<<
 * 
 *     if type == BCF_HT_STR:
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_empty_array); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "pysam/libcbcf.pyx":410
 *             bcf_float_set(dataf + i, bcf_float_missing if not vlen else bcf_float_vector_end)
 *     else:
 *         raise TypeError('unsupported header type code')             # <<<<<<<<<<<<<<
 * 
 *     return value
 */
  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_unsupported_header_type_code); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "pysam/libcbcf.pyx":477
 *             bcf_float_set(dst_dataf + i, bcf_float_missing if not vlen else bcf_float_vector_end)
 *     else:
 *         raise TypeError('unsupported types')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_unsupported_types); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "pysam/libcbcf.pyx":482
 * cdef bcf_get_value_count(VariantRecord record, int hl_type, int id, ssize_t *count, int *scalar, int sample):
 *     if record is None:
 *         raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 */
  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_record_must_not_be_None); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 482, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "pysam/libcbcf.pyx":488
 * 
 *     if not check_header_id(hdr, hl_type, id):
 *         raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *     cdef int length = bcf_hdr_id2length(hdr, hl_type, id)
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "pysam/libcbcf.pyx":510
 *         count[0] = -1
 *     else:
 *         raise ValueError('Unknown format length')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_Unknown_format_length); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "pysam/libcbcf.pyx":515
 * cdef object bcf_info_get_value(VariantRecord record, const bcf_info_t *z):
 *     if record is None:
 *         raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 */
  __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_record_must_not_be_None); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "pysam/libcbcf.pyx":544
 *             value = force_str(chr(z.v1.i))
 *         else:
 *             raise TypeError('unsupported info type code')             # <<<<<<<<<<<<<<
 * 
 *         if not scalar and value != ():
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_unsupported_info_type_code); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "pysam/libcbcf.pyx":560
 * 
 *     if record is None:
 *         raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *     bcf_get_value_count(record, hl_type, id, value_count, scalar, sample)
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_record_must_not_be_None); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "pysam/libcbcf.pyx":584
 *         for v in values:
 *             if not(v is None or isinstance(v, (float, int))):
 *                 raise TypeError('invalid value for Float format')             # <<<<<<<<<<<<<<
 *     elif ht_type == BCF_HT_INT:
 *         for v in values:
 */
  __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_invalid_value_for_Float_format); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "pysam/libcbcf.pyx":588
 *         for v in values:
 *             if not(v is None or (isinstance(v, (float, int)) and int(v) == v)):
 *                 raise TypeError('invalid value for Integer format')             # <<<<<<<<<<<<<<
 *         for v in values:
 *             if not(v is None or bcf_int32_missing < v <= INT32_MAX):
 */
  __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_invalid_value_for_Integer_format); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "pysam/libcbcf.pyx":591
 *         for v in values:
 *             if not(v is None or bcf_int32_missing < v <= INT32_MAX):
 *                 raise ValueError('Integer value too small/large to store in VCF/BCF')             # <<<<<<<<<<<<<<
 *     elif ht_type == BCF_HT_STR:
 *         values = b','.join(force_bytes(v) if v is not None else b'' for v in values)
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_Integer_value_too_small_large_to); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "pysam/libcbcf.pyx":596
 *     elif ht_type == BCF_HT_FLAG:
 *         if values[0] not in (True, False, None, 1, 0):
 *             raise ValueError('Flag values must be: True, False, None, 1, 0')             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError('unsupported type')
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_Flag_values_must_be_True_False_N); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 596, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "pysam/libcbcf.pyx":598
 *             raise ValueError('Flag values must be: True, False, None, 1, 0')
 *     else:
 *         raise TypeError('unsupported type')             # <<<<<<<<<<<<<<
 * 
 *     realloc[0] = 0
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_unsupported_type); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "pysam/libcbcf.pyx":621
 * cdef bcf_encode_alleles(VariantRecord record, values):
 *     if record is None:
 *         raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf1_t *r = record.ptr
 */
  __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_record_must_not_be_None); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "pysam/libcbcf.pyx":646
 *                     break
 *             else:
 *                 raise ValueError('Unknown allele')             # <<<<<<<<<<<<<<
 *         else:
 *             i = value
 */
  __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_Unknown_allele); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "pysam/libcbcf.pyx":650
 *             i = value
 *             if not (0 <= i < nalleles):
 *                 raise ValueError('Invalid allele index')             # <<<<<<<<<<<<<<
 *             gt_values.append(bcf_gt_unphased(i))
 * 
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_Invalid_allele_index); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 650, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "pysam/libcbcf.pyx":658
 * cdef bcf_info_set_value(VariantRecord record, key, value):
 *     if record is None:
 *         raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_record_must_not_be_None); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 658, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "pysam/libcbcf.pyx":666
 * 
 *     if bcf_unpack(r, BCF_UN_INFO) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef bytes bkey = force_bytes(key)
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "pysam/libcbcf.pyx":680
 * 
 *     if not check_header_id(hdr, BCF_HL_INFO, info_id):
 *         raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *     info_type = bcf_hdr_id2type(hdr, BCF_HL_INFO, info_id)
 */
  __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "pysam/libcbcf.pyx":691
 *     if info_type == BCF_HT_FLAG:
 *         if bcf_update_info(hdr, r, bkey, NULL, bool(values[0]), info_type) < 0:
 *             raise ValueError('Unable to update INFO values')             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_update_INFO_values); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 691, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "pysam/libcbcf.pyx":738
 *         dst_type = BCF_BT_CHAR
 *     else:
 *         raise ValueError('Unsupported INFO type')             # <<<<<<<<<<<<<<
 * 
 *     bcf_object_to_array(values, valp, dst_type, alloc_len, vlen)
 */
  __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_Unsupported_INFO_type); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);

  /* "pysam/libcbcf.pyx":743
 * 
 *     if bcf_update_info(hdr, r, bkey, valp, <int>alloc_len, info_type) < 0:
 *         raise ValueError('Unable to update INFO values')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_update_INFO_values); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 743, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);

  /* "pysam/libcbcf.pyx":748
 * cdef bcf_info_del_value(VariantRecord record, key):
 *     if record is None:
 *         raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = record.header.ptr
 */
  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_record_must_not_be_None); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 748, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "pysam/libcbcf.pyx":756
 * 
 *     if bcf_unpack(r, BCF_UN_INFO) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef bytes bkey = force_bytes(key)
 */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "pysam/libcbcf.pyx":771
 *         null_value = None
 *     else:
 *         null_value = (None,)*value_count             # <<<<<<<<<<<<<<
 * 
 *     bcf_info_set_value(record, bkey, null_value)
 */
  __pyx_tuple__33 = PyTuple_New(1); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_tuple__33, 0, Py_None);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "pysam/libcbcf.pyx":778
 * cdef bcf_format_get_value(VariantRecordSample sample, key):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_sample_must_not_be_None); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 778, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);

  /* "pysam/libcbcf.pyx":786
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef bytes bkey = force_bytes(key)
 */
  __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);

  /* "pysam/libcbcf.pyx":806
 *         return ()
 *     else:
 *         return (None,)*count             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__36 = PyTuple_New(1); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 806, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_tuple__36, 0, Py_None);
  __Pyx_GIVEREF(__pyx_tuple__36);

  /* "pysam/libcbcf.pyx":811
 * cdef bcf_format_set_value(VariantRecordSample sample, key, value):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     if key == 'phased':
 */
  __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_sample_must_not_be_None); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);

  /* "pysam/libcbcf.pyx":826
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef bytes bkey = force_bytes(key)
 */
  __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 826, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "pysam/libcbcf.pyx":843
 * 
 *     if not check_header_id(hdr, BCF_HL_FMT, fmt_id):
 *         raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *     fmt_type = bcf_hdr_id2type(hdr, BCF_HL_FMT, fmt_id)
 */
  __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 843, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);

  /* "pysam/libcbcf.pyx":848
 * 
 *     if fmt_type == BCF_HT_FLAG:
 *         raise ValueError('Flag types are not allowed on FORMATs')             # <<<<<<<<<<<<<<
 * 
 *     if is_gt_fmt(hdr, fmt_id):
 */
  __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_Flag_types_are_not_allowed_on_FO); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "pysam/libcbcf.pyx":888
 *         dst_size = sizeof(char) * alloc_len
 *     else:
 *         raise ValueError('Unsupported FORMAT type')             # <<<<<<<<<<<<<<
 * 
 *     if fmt and n > 1:
 */
  __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_Unsupported_FORMAT_type); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "pysam/libcbcf.pyx":899
 * 
 *     if bcf_update_format(hdr, r, bkey, valp, <int>(n*alloc_len), fmt_type) < 0:
 *         raise ValueError('Unable to update format values')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_update_format_values); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "pysam/libcbcf.pyx":904
 * cdef bcf_format_del_value(VariantRecordSample sample, key):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_sample_must_not_be_None); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 904, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "pysam/libcbcf.pyx":912
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef bytes bkey = force_bytes(key)
 */
  __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);

  /* "pysam/libcbcf.pyx":927
 *         null_value = None
 *     else:
 *         null_value = (None,)*value_count             # <<<<<<<<<<<<<<
 * 
 *     bcf_format_set_value(sample, bkey, null_value)
 */
  __pyx_tuple__45 = PyTuple_New(1); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_tuple__45, 0, Py_None);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "pysam/libcbcf.pyx":934
 * cdef bcf_format_get_allele_indices(VariantRecordSample sample):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
  __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_sample_must_not_be_None); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 934, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);

  /* "pysam/libcbcf.pyx":941
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:
 */
  __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);

  /* "pysam/libcbcf.pyx":994
 * cdef bcf_format_get_alleles(VariantRecordSample sample):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
  __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_sample_must_not_be_None); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);

  /* "pysam/libcbcf.pyx":1001
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef int32_t nalleles = r.n_allele
 */
  __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 1001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);

  /* "pysam/libcbcf.pyx":1045
 * cdef bint bcf_sample_get_phased(VariantRecordSample sample):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
  __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_sample_must_not_be_None); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 1045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "pysam/libcbcf.pyx":1052
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:
 */
  __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 1052, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);

  /* "pysam/libcbcf.pyx":1108
 * cdef bcf_sample_set_phased(VariantRecordSample sample, bint phased):
 *     if sample is None:
 *         raise ValueError('sample must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = sample.record.header.ptr
 */
  __pyx_tuple__52 = PyTuple_Pack(1, __pyx_kp_s_sample_must_not_be_None); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 1108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);

  /* "pysam/libcbcf.pyx":1115
 * 
 *     if bcf_unpack(r, BCF_UN_ALL) < 0:
 *         raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     if sample.index < 0 or sample.index >= n or not r.n_fmt:
 */
  __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 1115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);

  /* "pysam/libcbcf.pyx":1124
 * 
 *     if not gt0 or not fmt0.n:
 *         raise ValueError('Cannot set phased before genotype is set')             # <<<<<<<<<<<<<<
 * 
 *     cdef int8_t  *data8
 */
  __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_phased_before_genotyp); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 1124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);

  /* "pysam/libcbcf.pyx":1179
 *             if info and info.vptr:
 *                 if bcf_update_info(hdr, record.ptr, b'END', NULL, 0, info.type) < 0:
 *                     raise ValueError('Unable to delete END')             # <<<<<<<<<<<<<<
 *     else:
 *         # Create END header, if not present
 */
  __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_delete_END); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 1179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);

  /* "pysam/libcbcf.pyx":1183
 *         # Create END header, if not present
 *         if end_id < 0:
 *             record.header.info.add('END', number=1, type='Integer', description='Stop position of the interval')             # <<<<<<<<<<<<<<
 * 
 *         # Update to reflect stop position
 */
  __pyx_tuple__56 = PyTuple_Pack(1, __pyx_n_s_END); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(0, 1183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);

  /* "pysam/libcbcf.pyx":1208
 * cdef bcf_header_remove_hrec(VariantHeader header, int i):
 *     if header is None:
 *         raise ValueError('header must not be None')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hdr_t *hdr = header.ptr
 */
  __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_s_header_must_not_be_None); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 1208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);

  /* "pysam/libcbcf.pyx":1213
 * 
 *     if i < 0 or i >= hdr.nhrec:
 *         raise ValueError('Invalid header record index')             # <<<<<<<<<<<<<<
 * 
 *     cdef bcf_hrec_t *hrec = hdr.hrec[i]
 */
  __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header_record_index); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(0, 1213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);

  /* "pysam/libcbcf.pyx":1232
 *     """header record from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 1232, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);

  /* "pysam/libcbcf.pyx":1282
 *                 if r.keys[i] and r.keys[i] == bkey:
 *                     return charptr_to_str(r.vals[i]) if r.vals[i] else None
 *         raise KeyError('cannot find metadata key')             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_s_cannot_find_metadata_key); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 1282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);

  /* "pysam/libcbcf.pyx":1375
 * 
 *         if not r:
 *             raise ValueError('cannot convert deleted record to str')             # <<<<<<<<<<<<<<
 * 
 *         cdef kstring_t hrec_str
 */
  __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_s_cannot_convert_deleted_record_to); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 1375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);

  /* "pysam/libcbcf.pyx":1404
 * cdef VariantHeaderRecord makeVariantHeaderRecord(VariantHeader header, bcf_hrec_t *hdr):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     if not hdr:
 */
  __pyx_tuple__65 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantHeader); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 1404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);

  /* "pysam/libcbcf.pyx":1419
 *     """sequence of :class:`VariantHeaderRecord` object from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);

  /* "pysam/libcbcf.pyx":1430
 *         cdef int32_t i = index
 *         if i < 0 or i >= self.header.ptr.nhrec:
 *             raise IndexError('invalid header record index')             # <<<<<<<<<<<<<<
 *         return makeVariantHeaderRecord(self.header, self.header.ptr.hrec[i])
 * 
 */
  __pyx_tuple__67 = PyTuple_Pack(1, __pyx_kp_s_invalid_header_record_index); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 1430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__67);
  __Pyx_GIVEREF(__pyx_tuple__67);

  /* "pysam/libcbcf.pyx":1443
 * cdef VariantHeaderRecords makeVariantHeaderRecords(VariantHeader header):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantHeaderRecords records = VariantHeaderRecords.__new__(VariantHeaderRecords)
 */
  __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantHeader); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(0, 1443, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);

  /* "pysam/libcbcf.pyx":1453
 *     """filter, info or format metadata record from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 1453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);

  /* "pysam/libcbcf.pyx":1473
 * 
 *         if not check_header_id(hdr, self.type, self.id):
 *             raise ValueError('Invalid header id')             # <<<<<<<<<<<<<<
 * 
 *         if self.type == BCF_HL_FLT:
 */
  __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header_id); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(0, 1473, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);

  /* "pysam/libcbcf.pyx":1491
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         if not check_header_id(hdr, self.type, self.id):
 *             raise ValueError('Invalid header id')             # <<<<<<<<<<<<<<
 * 
 *         if self.type == BCF_HL_FLT:
 */
  __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header_id); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(0, 1491, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_GIVEREF(__pyx_tuple__72);

  /* "pysam/libcbcf.pyx":1500
 *     def description(self):
 *         """metadata description (or None if not set)"""
 *         descr = self.record.get('Description')             # <<<<<<<<<<<<<<
 *         if descr:
 *             descr = descr.strip('"')
 */
  __pyx_tuple__73 = PyTuple_Pack(1, __pyx_n_s_Description); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 1500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);

  /* "pysam/libcbcf.pyx":1502
 *         descr = self.record.get('Description')
 *         if descr:
 *             descr = descr.strip('"')             # <<<<<<<<<<<<<<
 *         return force_str(descr)
 * 
 */
  __pyx_tuple__75 = PyTuple_Pack(1, __pyx_kp_s__74); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(0, 1502, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);

  /* "pysam/libcbcf.pyx":1510
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 *         if not check_header_id(hdr, self.type, self.id):
 *             raise ValueError('Invalid header id')             # <<<<<<<<<<<<<<
 *         cdef bcf_hrec_t *hrec = hdr.id[BCF_DT_ID][self.id].val.hrec[self.type]
 *         if not hrec:
 */
  __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header_id); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 1510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);

  /* "pysam/libcbcf.pyx":1524
 * cdef VariantMetadata makeVariantMetadata(VariantHeader header, int type, int id):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     if type != BCF_HL_FLT and type != BCF_HL_INFO and type != BCF_HL_FMT:
 */
  __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantHeader); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(0, 1524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__77);
  __Pyx_GIVEREF(__pyx_tuple__77);

  /* "pysam/libcbcf.pyx":1527
 * 
 *     if type != BCF_HL_FLT and type != BCF_HL_INFO and type != BCF_HL_FMT:
 *         raise ValueError('invalid metadata type')             # <<<<<<<<<<<<<<
 * 
 *     if id < 0 or id >= header.ptr.n[BCF_DT_ID]:
 */
  __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_s_invalid_metadata_type); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(0, 1527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);

  /* "pysam/libcbcf.pyx":1530
 * 
 *     if id < 0 or id >= header.ptr.n[BCF_DT_ID]:
 *         raise ValueError('invalid metadata id')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantMetadata meta = VariantMetadata.__new__(VariantMetadata)
 */
  __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_s_invalid_metadata_id); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 1530, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);

  /* "pysam/libcbcf.pyx":1543
 *     """mapping from filter, info or format name to :class:`VariantMetadata` object"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def add(self, id, number, type, description, **kwargs):
 */
  __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 1543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);

  /* "pysam/libcbcf.pyx":1552
 *         if self.type == BCF_HL_FLT:
 *             if number is not None:
 *                 raise ValueError('Number must be None when adding a filter')             # <<<<<<<<<<<<<<
 *             if type is not None:
 *                 raise ValueError('Type must be None when adding a filter')
 */
  __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_Number_must_be_None_when_adding); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 1552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);

  /* "pysam/libcbcf.pyx":1554
 *                 raise ValueError('Number must be None when adding a filter')
 *             if type is not None:
 *                 raise ValueError('Type must be None when adding a filter')             # <<<<<<<<<<<<<<
 * 
 *             items = [('ID', id), ('Description', description)]
 */
  __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_s_Type_must_be_None_when_adding_a); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 1554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__82);
  __Pyx_GIVEREF(__pyx_tuple__82);

  /* "pysam/libcbcf.pyx":1682
 * cdef VariantHeaderMetadata makeVariantHeaderMetadata(VariantHeader header, int32_t type):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantHeaderMetadata meta = VariantHeaderMetadata.__new__(VariantHeaderMetadata)
 */
  __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantHeader); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(0, 1682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);

  /* "pysam/libcbcf.pyx":1694
 *     """contig metadata from a :class:`VariantHeader`"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 1694, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__84);
  __Pyx_GIVEREF(__pyx_tuple__84);

  /* "pysam/libcbcf.pyx":1729
 * cdef VariantContig makeVariantContig(VariantHeader header, int id):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     if id < 0 or id >= header.ptr.n[BCF_DT_CTG]:
 */
  __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantHeader); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(0, 1729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_GIVEREF(__pyx_tuple__85);

  /* "pysam/libcbcf.pyx":1732
 * 
 *     if id < 0 or id >= header.ptr.n[BCF_DT_CTG]:
 *         raise ValueError('invalid contig id')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantContig contig = VariantContig.__new__(VariantContig)
 */
  __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_s_invalid_contig_id); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(0, 1732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);

  /* "pysam/libcbcf.pyx":1744
 *     """mapping from contig name or index to :class:`VariantContig` object."""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_tuple__87 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 1744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);

  /* "pysam/libcbcf.pyx":1763
 *             index = key
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:
 *                 raise IndexError('invalid contig index')             # <<<<<<<<<<<<<<
 *             return makeVariantContig(self.header, index)
 * 
 */
  __pyx_tuple__88 = PyTuple_Pack(1, __pyx_kp_s_invalid_contig_index); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 1763, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__88);
  __Pyx_GIVEREF(__pyx_tuple__88);

  /* "pysam/libcbcf.pyx":1787
 *             index = key
 *             if index < 0 or index >= hdr.n[BCF_DT_CTG]:
 *                 raise IndexError('invalid contig index')             # <<<<<<<<<<<<<<
 *             ckey = hdr.id[BCF_DT_CTG][self.id].key
 *         else:
 */
  __pyx_tuple__89 = PyTuple_Pack(1, __pyx_kp_s_invalid_contig_index); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 1787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);

  /* "pysam/libcbcf.pyx":1866
 *         items = [('ID', id)]
 *         items += kwargs.items()
 *         self.header.add_meta('contig', items=items)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__90 = PyTuple_Pack(1, __pyx_n_s_contig); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(0, 1866, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__90);
  __Pyx_GIVEREF(__pyx_tuple__90);

  /* "pysam/libcbcf.pyx":1871
 * cdef VariantHeaderContigs makeVariantHeaderContigs(VariantHeader header):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantHeaderContigs contigs = VariantHeaderContigs.__new__(VariantHeaderContigs)
 */
  __pyx_tuple__91 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantHeader); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(0, 1871, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);

  /* "pysam/libcbcf.pyx":1882
 *     """sequence of sample names from a :class:`VariantHeader` object"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_tuple__92 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(0, 1882, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__92);
  __Pyx_GIVEREF(__pyx_tuple__92);

  /* "pysam/libcbcf.pyx":1896
 * 
 *         if i < 0 or i >= n:
 *             raise IndexError('invalid sample index')             # <<<<<<<<<<<<<<
 * 
 *         return charptr_to_str(hdr.samples[i])
 */
  __pyx_tuple__93 = PyTuple_Pack(1, __pyx_kp_s_invalid_sample_index); if (unlikely(!__pyx_tuple__93)) __PYX_ERR(0, 1896, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__93);
  __Pyx_GIVEREF(__pyx_tuple__93);

  /* "pysam/libcbcf.pyx":1927
 * cdef VariantHeaderSamples makeVariantHeaderSamples(VariantHeader header):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantHeaderSamples samples = VariantHeaderSamples.__new__(VariantHeaderSamples)
 */
  __pyx_tuple__94 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantHeader); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(0, 1927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__94);
  __Pyx_GIVEREF(__pyx_tuple__94);

  /* "pysam/libcbcf.pyx":1949
 *         self.ptr = bcf_hdr_init(b'w')
 *         if not self.ptr:
 *             raise ValueError('cannot create VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_tuple__95 = PyTuple_Pack(1, __pyx_kp_s_cannot_create_VariantHeader); if (unlikely(!__pyx_tuple__95)) __PYX_ERR(0, 1949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__95);
  __Pyx_GIVEREF(__pyx_tuple__95);

  /* "pysam/libcbcf.pyx":1964
 *     def merge(self, VariantHeader header):
 *         if header is None:
 *             raise ValueError('header must not be None')             # <<<<<<<<<<<<<<
 *         bcf_hdr_merge(self.ptr, header.ptr)
 * 
 */
  __pyx_tuple__96 = PyTuple_Pack(1, __pyx_kp_s_header_must_not_be_None); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(0, 1964, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__96);
  __Pyx_GIVEREF(__pyx_tuple__96);

  /* "pysam/libcbcf.pyx":2058
 * 
 *         if not rec:
 *             raise MemoryError('unable to allocate BCF record')             # <<<<<<<<<<<<<<
 * 
 *         rec.ptr.n_sample = bcf_hdr_nsamples(self.ptr)
 */
  __pyx_tuple__97 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_BCF_record); if (unlikely(!__pyx_tuple__97)) __PYX_ERR(0, 2058, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__97);
  __Pyx_GIVEREF(__pyx_tuple__97);

  /* "pysam/libcbcf.pyx":2090
 *             for i, sample in enumerate(samples):
 *                 if 'GT' in sample:
 *                     rec.samples[i]['GT'] = sample.pop('GT')             # <<<<<<<<<<<<<<
 *                 rec.samples[i].update(sample)
 * 
 */
  __pyx_tuple__98 = PyTuple_Pack(1, __pyx_n_s_GT); if (unlikely(!__pyx_tuple__98)) __PYX_ERR(0, 2090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);

  /* "pysam/libcbcf.pyx":2098
 *         """Add an existing :class:`VariantHeaderRecord` to this header"""
 *         if record is None:
 *             raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_hrec_t *hrec = bcf_hrec_dup(record.ptr)
 */
  __pyx_tuple__99 = PyTuple_Pack(1, __pyx_kp_s_record_must_not_be_None); if (unlikely(!__pyx_tuple__99)) __PYX_ERR(0, 2098, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__99);
  __Pyx_GIVEREF(__pyx_tuple__99);

  /* "pysam/libcbcf.pyx":2111
 *         bline = force_bytes(line)
 *         if bcf_hdr_append(self.ptr, bline) < 0:
 *             raise ValueError('invalid header line')             # <<<<<<<<<<<<<<
 * 
 *         if self.ptr.dirty:
 */
  __pyx_tuple__100 = PyTuple_Pack(1, __pyx_kp_s_invalid_header_line); if (unlikely(!__pyx_tuple__100)) __PYX_ERR(0, 2111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);

  /* "pysam/libcbcf.pyx":2119
 *         """Add metadata to this header"""
 *         if not ((value is not None) ^ (items is not None)):
 *             raise ValueError('either value or items must be specified')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_hrec_t *hrec = <bcf_hrec_t*>calloc(1, sizeof(bcf_hrec_t))
 */
  __pyx_tuple__101 = PyTuple_Pack(1, __pyx_kp_s_either_value_or_items_must_be_sp); if (unlikely(!__pyx_tuple__101)) __PYX_ERR(0, 2119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__101);
  __Pyx_GIVEREF(__pyx_tuple__101);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__102 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__102)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__102);
  __Pyx_GIVEREF(__pyx_tuple__102);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__103 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__103)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__103);
  __Pyx_GIVEREF(__pyx_tuple__103);

  /* "pysam/libcbcf.pyx":2158
 * cdef VariantHeader makeVariantHeader(bcf_hdr_t *hdr):
 *     if not hdr:
 *         raise ValueError('cannot create VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantHeader header = VariantHeader.__new__(VariantHeader)
 */
  __pyx_tuple__104 = PyTuple_Pack(1, __pyx_kp_s_cannot_create_VariantHeader); if (unlikely(!__pyx_tuple__104)) __PYX_ERR(0, 2158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__104);
  __Pyx_GIVEREF(__pyx_tuple__104);

  /* "pysam/libcbcf.pyx":2192
 *        filter index or name to :class:`VariantMetadata` object"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_tuple__105 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__105)) __PYX_ERR(0, 2192, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__105);
  __Pyx_GIVEREF(__pyx_tuple__105);

  /* "pysam/libcbcf.pyx":2210
 * 
 *             if index < 0 or index >= n:
 *                 raise IndexError('invalid filter index')             # <<<<<<<<<<<<<<
 * 
 *             id = r.d.flt[index]
 */
  __pyx_tuple__106 = PyTuple_Pack(1, __pyx_kp_s_invalid_filter_index); if (unlikely(!__pyx_tuple__106)) __PYX_ERR(0, 2210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);

  /* "pysam/libcbcf.pyx":2252
 * 
 *             if index < 0 or index >= n:
 *                 raise IndexError('invalid filter index')             # <<<<<<<<<<<<<<
 * 
 *             id = r.d.flt[index]
 */
  __pyx_tuple__107 = PyTuple_Pack(1, __pyx_kp_s_invalid_filter_index); if (unlikely(!__pyx_tuple__107)) __PYX_ERR(0, 2252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__107);
  __Pyx_GIVEREF(__pyx_tuple__107);

  /* "pysam/libcbcf.pyx":2342
 * cdef VariantRecordFilter makeVariantRecordFilter(VariantRecord record):
 *     if not record:
 *         raise ValueError('invalid VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantRecordFilter filter = VariantRecordFilter.__new__(VariantRecordFilter)
 */
  __pyx_tuple__108 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantRecord); if (unlikely(!__pyx_tuple__108)) __PYX_ERR(0, 2342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__108);
  __Pyx_GIVEREF(__pyx_tuple__108);

  /* "pysam/libcbcf.pyx":2354
 *        presented as mapping from format name to :class:`VariantMetadata` object."""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_tuple__109 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__109)) __PYX_ERR(0, 2354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__109);
  __Pyx_GIVEREF(__pyx_tuple__109);

  /* "pysam/libcbcf.pyx":2399
 * 
 *         if bcf_update_format(hdr, r, bkey, fmt.p, 0, fmt.type) < 0:
 *             raise ValueError('Unable to delete FORMAT')             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
  __pyx_tuple__110 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_delete_FORMAT); if (unlikely(!__pyx_tuple__110)) __PYX_ERR(0, 2399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__110);
  __Pyx_GIVEREF(__pyx_tuple__110);

  /* "pysam/libcbcf.pyx":2415
 *                 key = bcf_hdr_int2id(hdr, BCF_DT_ID, fmt.id)
 *                 if bcf_update_format(hdr, r, key, fmt.p, 0, fmt.type) < 0:
 *                     raise ValueError('Unable to delete FORMAT')             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_tuple__111 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_delete_FORMAT); if (unlikely(!__pyx_tuple__111)) __PYX_ERR(0, 2415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__111);
  __Pyx_GIVEREF(__pyx_tuple__111);

  /* "pysam/libcbcf.pyx":2476
 * cdef VariantRecordFormat makeVariantRecordFormat(VariantRecord record):
 *     if not record:
 *         raise ValueError('invalid VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantRecordFormat format = VariantRecordFormat.__new__(VariantRecordFormat)
 */
  __pyx_tuple__112 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantRecord); if (unlikely(!__pyx_tuple__112)) __PYX_ERR(0, 2476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__112);
  __Pyx_GIVEREF(__pyx_tuple__112);

  /* "pysam/libcbcf.pyx":2490
 * 
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_tuple__113 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__113)) __PYX_ERR(0, 2490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__113);
  __Pyx_GIVEREF(__pyx_tuple__113);

  /* "pysam/libcbcf.pyx":2500
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_info):
 */
  __pyx_tuple__114 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__114)) __PYX_ERR(0, 2500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__114);
  __Pyx_GIVEREF(__pyx_tuple__114);

  /* "pysam/libcbcf.pyx":2518
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_info):
 */
  __pyx_tuple__115 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__115)) __PYX_ERR(0, 2518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__115);
  __Pyx_GIVEREF(__pyx_tuple__115);

  /* "pysam/libcbcf.pyx":2533
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_tuple__116 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__116)) __PYX_ERR(0, 2533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__116);
  __Pyx_GIVEREF(__pyx_tuple__116);

  /* "pysam/libcbcf.pyx":2538
 * 
 *         if strcmp(bkey, b'END') == 0:
 *             raise KeyError('END is a reserved attribute; access is via record.stop')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 */
  __pyx_tuple__117 = PyTuple_Pack(1, __pyx_kp_s_END_is_a_reserved_attribute_acce); if (unlikely(!__pyx_tuple__117)) __PYX_ERR(0, 2538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__117);
  __Pyx_GIVEREF(__pyx_tuple__117);

  /* "pysam/libcbcf.pyx":2549
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):
 *             raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *         # Handle type=Flag values
 */
  __pyx_tuple__118 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header); if (unlikely(!__pyx_tuple__118)) __PYX_ERR(0, 2549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__118);
  __Pyx_GIVEREF(__pyx_tuple__118);

  /* "pysam/libcbcf.pyx":2564
 * 
 *         if strcmp(bkey, b'END') == 0:
 *             raise KeyError('END is a reserved attribute; access is via record.stop')             # <<<<<<<<<<<<<<
 * 
 *         if bcf_unpack(self.record.ptr, BCF_UN_INFO) < 0:
 */
  __pyx_tuple__119 = PyTuple_Pack(1, __pyx_kp_s_END_is_a_reserved_attribute_acce); if (unlikely(!__pyx_tuple__119)) __PYX_ERR(0, 2564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__119);
  __Pyx_GIVEREF(__pyx_tuple__119);

  /* "pysam/libcbcf.pyx":2567
 * 
 *         if bcf_unpack(self.record.ptr, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         bcf_info_set_value(self.record, key, value)
 */
  __pyx_tuple__120 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__120)) __PYX_ERR(0, 2567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__120);
  __Pyx_GIVEREF(__pyx_tuple__120);

  /* "pysam/libcbcf.pyx":2577
 *         cdef bytes bkey = force_bytes(key)
 *         if strcmp(bkey, b'END') == 0:
 *             raise KeyError('END is a reserved attribute; access is via record.stop')             # <<<<<<<<<<<<<<
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 */
  __pyx_tuple__121 = PyTuple_Pack(1, __pyx_kp_s_END_is_a_reserved_attribute_acce); if (unlikely(!__pyx_tuple__121)) __PYX_ERR(0, 2577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__121);
  __Pyx_GIVEREF(__pyx_tuple__121);

  /* "pysam/libcbcf.pyx":2580
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_info_t *info = bcf_get_info(hdr, r, bkey)
 */
  __pyx_tuple__122 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__122)) __PYX_ERR(0, 2580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__122);
  __Pyx_GIVEREF(__pyx_tuple__122);

  /* "pysam/libcbcf.pyx":2591
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):
 *             raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *         # Handle flags
 */
  __pyx_tuple__123 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header); if (unlikely(!__pyx_tuple__123)) __PYX_ERR(0, 2591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__123);
  __Pyx_GIVEREF(__pyx_tuple__123);

  /* "pysam/libcbcf.pyx":2601
 * 
 *         if bcf_update_info(hdr, r, bkey, NULL, 0, info.type) < 0:
 *             raise ValueError('Unable to delete INFO')             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
  __pyx_tuple__124 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_delete_INFO); if (unlikely(!__pyx_tuple__124)) __PYX_ERR(0, 2601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__124);
  __Pyx_GIVEREF(__pyx_tuple__124);

  /* "pysam/libcbcf.pyx":2612
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_info):
 */
  __pyx_tuple__125 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__125)) __PYX_ERR(0, 2612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__125);
  __Pyx_GIVEREF(__pyx_tuple__125);

  /* "pysam/libcbcf.pyx":2621
 *                     continue
 *                 if bcf_update_info(hdr, r, key, NULL, 0, info.type) < 0:
 *                     raise ValueError('Unable to delete INFO')             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_tuple__126 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_delete_INFO); if (unlikely(!__pyx_tuple__126)) __PYX_ERR(0, 2621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__126);
  __Pyx_GIVEREF(__pyx_tuple__126);

  /* "pysam/libcbcf.pyx":2631
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_info):
 */
  __pyx_tuple__127 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__127)) __PYX_ERR(0, 2631, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__127);
  __Pyx_GIVEREF(__pyx_tuple__127);

  /* "pysam/libcbcf.pyx":2646
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_tuple__128 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__128)) __PYX_ERR(0, 2646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__128);
  __Pyx_GIVEREF(__pyx_tuple__128);

  /* "pysam/libcbcf.pyx":2659
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):
 *             raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *         # Handle flags
 */
  __pyx_tuple__129 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header); if (unlikely(!__pyx_tuple__129)) __PYX_ERR(0, 2659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__129);
  __Pyx_GIVEREF(__pyx_tuple__129);

  /* "pysam/libcbcf.pyx":2675
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_tuple__130 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__130)) __PYX_ERR(0, 2675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__130);
  __Pyx_GIVEREF(__pyx_tuple__130);

  /* "pysam/libcbcf.pyx":2699
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_info):
 */
  __pyx_tuple__131 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__131)) __PYX_ERR(0, 2699, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__131);
  __Pyx_GIVEREF(__pyx_tuple__131);

  /* "pysam/libcbcf.pyx":2717
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_info):
 */
  __pyx_tuple__132 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__132)) __PYX_ERR(0, 2717, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__132);
  __Pyx_GIVEREF(__pyx_tuple__132);

  /* "pysam/libcbcf.pyx":2758
 * 
 *         if bcf_unpack(r, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         cdef bytes bkey = force_bytes(key)
 */
  __pyx_tuple__134 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__134)) __PYX_ERR(0, 2758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__134);
  __Pyx_GIVEREF(__pyx_tuple__134);

  /* "pysam/libcbcf.pyx":2772
 * 
 *         if not check_header_id(hdr, BCF_HL_INFO, info_id):
 *             raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 * 
 *         # Handle flags
 */
  __pyx_tuple__135 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header); if (unlikely(!__pyx_tuple__135)) __PYX_ERR(0, 2772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__135);
  __Pyx_GIVEREF(__pyx_tuple__135);

  /* "pysam/libcbcf.pyx":2786
 * 
 *         if bcf_update_info(hdr, r, bkey, NULL, 0, info.type) < 0:
 *             raise ValueError('Unable to delete INFO')             # <<<<<<<<<<<<<<
 * 
 *         return value
 */
  __pyx_tuple__136 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_delete_INFO); if (unlikely(!__pyx_tuple__136)) __PYX_ERR(0, 2786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__136);
  __Pyx_GIVEREF(__pyx_tuple__136);

  /* "pysam/libcbcf.pyx":2811
 * cdef VariantRecordInfo makeVariantRecordInfo(VariantRecord record):
 *     if not record:
 *         raise ValueError('invalid VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantRecordInfo info = VariantRecordInfo.__new__(VariantRecordInfo)
 */
  __pyx_tuple__137 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantRecord); if (unlikely(!__pyx_tuple__137)) __PYX_ERR(0, 2811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__137);
  __Pyx_GIVEREF(__pyx_tuple__137);

  /* "pysam/libcbcf.pyx":2822
 *     """mapping from sample index or name to :class:`VariantRecordSample` object."""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_tuple__138 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__138)) __PYX_ERR(0, 2822, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__138);
  __Pyx_GIVEREF(__pyx_tuple__138);

  /* "pysam/libcbcf.pyx":2847
 * 
 *         if sample_index < 0 or sample_index >= n:
 *             raise IndexError('invalid sample index')             # <<<<<<<<<<<<<<
 * 
 *         return makeVariantRecordSample(self.record, sample_index)
 */
  __pyx_tuple__139 = PyTuple_Pack(1, __pyx_kp_s_invalid_sample_index); if (unlikely(!__pyx_tuple__139)) __PYX_ERR(0, 2847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__139);
  __Pyx_GIVEREF(__pyx_tuple__139);

  /* "pysam/libcbcf.pyx":2960
 * cdef VariantRecordSamples makeVariantRecordSamples(VariantRecord record):
 *     if not record:
 *         raise ValueError('invalid VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantRecordSamples samples = VariantRecordSamples.__new__(
 */
  __pyx_tuple__141 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantRecord); if (unlikely(!__pyx_tuple__141)) __PYX_ERR(0, 2960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__141);
  __Pyx_GIVEREF(__pyx_tuple__141);

  /* "pysam/libcbcf.pyx":2972
 *     """Variant record"""
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_tuple__142 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__142)) __PYX_ERR(0, 2972, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__142);
  __Pyx_GIVEREF(__pyx_tuple__142);

  /* "pysam/libcbcf.pyx":2985
 *     def translate(self, VariantHeader dst_header):
 *         if dst_header is None:
 *             raise ValueError('dst_header must not be None')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_hdr_t *src_hdr = self.header.ptr
 */
  __pyx_tuple__143 = PyTuple_Pack(1, __pyx_kp_s_dst_header_must_not_be_None); if (unlikely(!__pyx_tuple__143)) __PYX_ERR(0, 2985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__143);
  __Pyx_GIVEREF(__pyx_tuple__143);

  /* "pysam/libcbcf.pyx":3008
 *         cdef int r = value
 *         if r < 0 or r >= hdr.n[BCF_DT_CTG] or not hdr.id[BCF_DT_CTG][r].val:
 *             raise ValueError('invalid reference id')             # <<<<<<<<<<<<<<
 *         self.ptr.rid = r
 * 
 */
  __pyx_tuple__144 = PyTuple_Pack(1, __pyx_kp_s_invalid_reference_id); if (unlikely(!__pyx_tuple__144)) __PYX_ERR(0, 3008, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__144);
  __Pyx_GIVEREF(__pyx_tuple__144);

  /* "pysam/libcbcf.pyx":3017
 *         cdef int rid = self.ptr.rid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 *             raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 * 
 */
  __pyx_tuple__145 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header); if (unlikely(!__pyx_tuple__145)) __PYX_ERR(0, 3017, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__145);
  __Pyx_GIVEREF(__pyx_tuple__145);

  /* "pysam/libcbcf.pyx":3026
 *         cdef khint_t k = kh_get_vdict(d, bchrom)
 *         if k == kh_end(d):
 *             raise ValueError('Invalid chromosome/contig')             # <<<<<<<<<<<<<<
 *         self.ptr.rid = kh_val_vdict(d, k).id
 * 
 */
  __pyx_tuple__146 = PyTuple_Pack(1, __pyx_kp_s_Invalid_chromosome_contig); if (unlikely(!__pyx_tuple__146)) __PYX_ERR(0, 3026, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__146);
  __Pyx_GIVEREF(__pyx_tuple__146);

  /* "pysam/libcbcf.pyx":3035
 *         cdef int rid = self.ptr.rid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 *             raise ValueError('Invalid header')             # <<<<<<<<<<<<<<
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 * 
 */
  __pyx_tuple__147 = PyTuple_Pack(1, __pyx_kp_s_Invalid_header); if (unlikely(!__pyx_tuple__147)) __PYX_ERR(0, 3035, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__147);
  __Pyx_GIVEREF(__pyx_tuple__147);

  /* "pysam/libcbcf.pyx":3044
 *         cdef khint_t k = kh_get_vdict(d, bchrom)
 *         if k == kh_end(d):
 *             raise ValueError('Invalid chromosome/contig')             # <<<<<<<<<<<<<<
 *         self.ptr.rid = kh_val_vdict(d, k).id
 * 
 */
  __pyx_tuple__148 = PyTuple_Pack(1, __pyx_kp_s_Invalid_chromosome_contig); if (unlikely(!__pyx_tuple__148)) __PYX_ERR(0, 3044, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__148);
  __Pyx_GIVEREF(__pyx_tuple__148);

  /* "pysam/libcbcf.pyx":3056
 *         cdef int p = value
 *         if p < 1:
 *             raise ValueError('Position must be positive')             # <<<<<<<<<<<<<<
 *         self.ptr.pos = p - 1
 *         bcf_sync_end(self)
 */
  __pyx_tuple__149 = PyTuple_Pack(1, __pyx_kp_s_Position_must_be_positive); if (unlikely(!__pyx_tuple__149)) __PYX_ERR(0, 3056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__149);
  __Pyx_GIVEREF(__pyx_tuple__149);

  /* "pysam/libcbcf.pyx":3069
 *         cdef int s = value
 *         if s < 0:
 *             raise ValueError('Start coordinate must be non-negative')             # <<<<<<<<<<<<<<
 *         self.ptr.pos = s
 *         bcf_sync_end(self)
 */
  __pyx_tuple__150 = PyTuple_Pack(1, __pyx_kp_s_Start_coordinate_must_be_non_neg); if (unlikely(!__pyx_tuple__150)) __PYX_ERR(0, 3069, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__150);
  __Pyx_GIVEREF(__pyx_tuple__150);

  /* "pysam/libcbcf.pyx":3082
 *         cdef int s = value
 *         if s < 0:
 *             raise ValueError('Stop coordinate must be non-negative')             # <<<<<<<<<<<<<<
 *         self.ptr.rlen = s - self.ptr.pos
 *         bcf_sync_end(self)
 */
  __pyx_tuple__151 = PyTuple_Pack(1, __pyx_kp_s_Stop_coordinate_must_be_non_nega); if (unlikely(!__pyx_tuple__151)) __PYX_ERR(0, 3082, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__151);
  __Pyx_GIVEREF(__pyx_tuple__151);

  /* "pysam/libcbcf.pyx":3123
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         return bcf_str_cache_get_charptr(r.d.id) if r.d.id != b'.' else None
 * 
 */
  __pyx_tuple__152 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__152)) __PYX_ERR(0, 3123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__152);
  __Pyx_GIVEREF(__pyx_tuple__152);

  /* "pysam/libcbcf.pyx":3130
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         cdef char *idstr = NULL
 *         if value is not None:
 */
  __pyx_tuple__153 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__153)) __PYX_ERR(0, 3130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__153);
  __Pyx_GIVEREF(__pyx_tuple__153);

  /* "pysam/libcbcf.pyx":3136
 *             idstr = bid
 *         if bcf_update_id(self.header.ptr, self.ptr, idstr) < 0:
 *             raise ValueError('Error updating id')             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_tuple__154 = PyTuple_Pack(1, __pyx_kp_s_Error_updating_id); if (unlikely(!__pyx_tuple__154)) __PYX_ERR(0, 3136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__154);
  __Pyx_GIVEREF(__pyx_tuple__154);

  /* "pysam/libcbcf.pyx":3143
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         return charptr_to_str(r.d.allele[0]) if r.d.allele else None
 * 
 */
  __pyx_tuple__155 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__155)) __PYX_ERR(0, 3143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__155);
  __Pyx_GIVEREF(__pyx_tuple__155);

  /* "pysam/libcbcf.pyx":3150
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         #FIXME: Set alleles directly -- this is stupid
 *         if not value:
 */
  __pyx_tuple__156 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__156)) __PYX_ERR(0, 3150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__156);
  __Pyx_GIVEREF(__pyx_tuple__156);

  /* "pysam/libcbcf.pyx":3153
 *         #FIXME: Set alleles directly -- this is stupid
 *         if not value:
 *             raise ValueError('ref allele must not be null')             # <<<<<<<<<<<<<<
 *         value = force_bytes(value)
 *         if r.d.allele and r.n_allele:
 */
  __pyx_tuple__157 = PyTuple_Pack(1, __pyx_kp_s_ref_allele_must_not_be_null); if (unlikely(!__pyx_tuple__157)) __PYX_ERR(0, 3153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__157);
  __Pyx_GIVEREF(__pyx_tuple__157);

  /* "pysam/libcbcf.pyx":3168
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         if not r.d.allele:
 *             return None
 */
  __pyx_tuple__158 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__158)) __PYX_ERR(0, 3168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__158);
  __Pyx_GIVEREF(__pyx_tuple__158);

  /* "pysam/libcbcf.pyx":3186
 * 
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         values = [force_bytes(v) for v in values]
 */
  __pyx_tuple__159 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__159)) __PYX_ERR(0, 3186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__159);
  __Pyx_GIVEREF(__pyx_tuple__159);

  /* "pysam/libcbcf.pyx":3191
 * 
 *         if len(values) < 2:
 *             raise ValueError('must set at least 2 alleles')             # <<<<<<<<<<<<<<
 * 
 *         if b'' in values:
 */
  __pyx_tuple__160 = PyTuple_Pack(1, __pyx_kp_s_must_set_at_least_2_alleles); if (unlikely(!__pyx_tuple__160)) __PYX_ERR(0, 3191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__160);
  __Pyx_GIVEREF(__pyx_tuple__160);

  /* "pysam/libcbcf.pyx":3194
 * 
 *         if b'' in values:
 *             raise ValueError('cannot set null allele')             # <<<<<<<<<<<<<<
 * 
 *         value = b','.join(values)
 */
  __pyx_tuple__161 = PyTuple_Pack(1, __pyx_kp_s_cannot_set_null_allele); if (unlikely(!__pyx_tuple__161)) __PYX_ERR(0, 3194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__161);
  __Pyx_GIVEREF(__pyx_tuple__161);

  /* "pysam/libcbcf.pyx":3199
 * 
 *         if bcf_update_alleles_str(self.header.ptr, r, value) < 0:
 *             raise ValueError('Error updating alleles')             # <<<<<<<<<<<<<<
 * 
 *         # Reset rlen if alternate allele isn't symbolic, otherwise used cached
 */
  __pyx_tuple__162 = PyTuple_Pack(1, __pyx_kp_s_Error_updating_alleles); if (unlikely(!__pyx_tuple__162)) __PYX_ERR(0, 3199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__162);
  __Pyx_GIVEREF(__pyx_tuple__162);

  /* "pysam/libcbcf.pyx":3213
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         if r.n_allele < 2 or not r.d.allele:
 *             return None
 */
  __pyx_tuple__163 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__163)) __PYX_ERR(0, 3213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__163);
  __Pyx_GIVEREF(__pyx_tuple__163);

  /* "pysam/libcbcf.pyx":3228
 *         cdef bcf1_t *r = self.ptr
 *         if bcf_unpack(r, BCF_UN_STR) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         value = [force_bytes(v) for v in value]
 *         if b'' in value:
 */
  __pyx_tuple__164 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__164)) __PYX_ERR(0, 3228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__164);
  __Pyx_GIVEREF(__pyx_tuple__164);

  /* "pysam/libcbcf.pyx":3231
 *         value = [force_bytes(v) for v in value]
 *         if b'' in value:
 *             raise ValueError('cannot set null alt allele')             # <<<<<<<<<<<<<<
 *         ref  = [r.d.allele[0] if r.d.allele and r.n_allele else b'.']
 *         self.alleles = ref + value
 */
  __pyx_tuple__165 = PyTuple_Pack(1, __pyx_kp_s_cannot_set_null_alt_allele); if (unlikely(!__pyx_tuple__165)) __PYX_ERR(0, 3231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__165);
  __Pyx_GIVEREF(__pyx_tuple__165);

  /* "pysam/libcbcf.pyx":3239
 *         """filter information (see :class:`VariantRecordFilter`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_FLT) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         return makeVariantRecordFilter(self)
 * 
 */
  __pyx_tuple__166 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__166)) __PYX_ERR(0, 3239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__166);
  __Pyx_GIVEREF(__pyx_tuple__166);

  /* "pysam/libcbcf.pyx":3246
 *         """info data (see :class:`VariantRecordInfo`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_INFO) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         return makeVariantRecordInfo(self)
 * 
 */
  __pyx_tuple__167 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__167)) __PYX_ERR(0, 3246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__167);
  __Pyx_GIVEREF(__pyx_tuple__167);

  /* "pysam/libcbcf.pyx":3253
 *         """sample format metadata (see :class:`VariantRecordFormat`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_FMT) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         return makeVariantRecordFormat(self)
 * 
 */
  __pyx_tuple__168 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__168)) __PYX_ERR(0, 3253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__168);
  __Pyx_GIVEREF(__pyx_tuple__168);

  /* "pysam/libcbcf.pyx":3260
 *         """sample data (see :class:`VariantRecordSamples`)"""
 *         if bcf_unpack(self.ptr, BCF_UN_ALL) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 *         return makeVariantRecordSamples(self)
 * 
 */
  __pyx_tuple__169 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__169)) __PYX_ERR(0, 3260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__169);
  __Pyx_GIVEREF(__pyx_tuple__169);

  /* "pysam/libcbcf.pyx":3299
 *             if line.m:
 *                 free(line.s)
 *             raise ValueError('vcf_format failed')             # <<<<<<<<<<<<<<
 * 
 *         # Strip CR/LF?
 */
  __pyx_tuple__170 = PyTuple_Pack(1, __pyx_kp_s_vcf_format_failed); if (unlikely(!__pyx_tuple__170)) __PYX_ERR(0, 3299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__170);
  __Pyx_GIVEREF(__pyx_tuple__170);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__171 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__171)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__171);
  __Pyx_GIVEREF(__pyx_tuple__171);

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__172 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__172)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__172);
  __Pyx_GIVEREF(__pyx_tuple__172);

  /* "pysam/libcbcf.pyx":3318
 * cdef VariantRecord makeVariantRecord(VariantHeader header, bcf1_t *r):
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     if not r:
 */
  __pyx_tuple__173 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantHeader); if (unlikely(!__pyx_tuple__173)) __PYX_ERR(0, 3318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__173);
  __Pyx_GIVEREF(__pyx_tuple__173);

  /* "pysam/libcbcf.pyx":3321
 * 
 *     if not r:
 *         raise ValueError('cannot create VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *     if r.errcode:
 */
  __pyx_tuple__174 = PyTuple_Pack(1, __pyx_kp_s_cannot_create_VariantRecord); if (unlikely(!__pyx_tuple__174)) __PYX_ERR(0, 3321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__174);
  __Pyx_GIVEREF(__pyx_tuple__174);

  /* "pysam/libcbcf.pyx":3363
 *     """
 *     def __init__(self, *args, **kwargs):
 *         raise TypeError('this class cannot be instantiated from Python')             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_tuple__176 = PyTuple_Pack(1, __pyx_kp_s_this_class_cannot_be_instantiate); if (unlikely(!__pyx_tuple__176)) __PYX_ERR(0, 3363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__176);
  __Pyx_GIVEREF(__pyx_tuple__176);

  /* "pysam/libcbcf.pyx":3373
 * 
 *         if self.index < 0 or self.index >= n:
 *             raise ValueError('invalid sample index')             # <<<<<<<<<<<<<<
 * 
 *         return charptr_to_str(hdr.samples[self.index])
 */
  __pyx_tuple__177 = PyTuple_Pack(1, __pyx_kp_s_invalid_sample_index); if (unlikely(!__pyx_tuple__177)) __PYX_ERR(0, 3373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__177);
  __Pyx_GIVEREF(__pyx_tuple__177);

  /* "pysam/libcbcf.pyx":3418
 * 
 *         if bcf_unpack(r, BCF_UN_FMT) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_fmt):
 */
  __pyx_tuple__178 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__178)) __PYX_ERR(0, 3418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__178);
  __Pyx_GIVEREF(__pyx_tuple__178);

  /* "pysam/libcbcf.pyx":3431
 * 
 *         if bcf_unpack(r, BCF_UN_FMT) < 0:
 *             raise ValueError('Error unpacking VariantRecord')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(r.n_fmt):
 */
  __pyx_tuple__179 = PyTuple_Pack(1, __pyx_kp_s_Error_unpacking_VariantRecord); if (unlikely(!__pyx_tuple__179)) __PYX_ERR(0, 3431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__179);
  __Pyx_GIVEREF(__pyx_tuple__179);

  /* "pysam/libcbcf.pyx":3549
 * cdef VariantRecordSample makeVariantRecordSample(VariantRecord record, int32_t sample_index):
 *     if not record or sample_index < 0:
 *         raise ValueError('cannot create VariantRecordSample')             # <<<<<<<<<<<<<<
 * 
 *     cdef VariantRecordSample sample = VariantRecordSample.__new__(VariantRecordSample)
 */
  __pyx_tuple__181 = PyTuple_Pack(1, __pyx_kp_s_cannot_create_VariantRecordSampl); if (unlikely(!__pyx_tuple__181)) __PYX_ERR(0, 3549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__181);
  __Pyx_GIVEREF(__pyx_tuple__181);

  /* "pysam/libcbcf.pyx":3660
 * 
 *         if not self.ptr:
 *             raise ValueError('Invalid index object')             # <<<<<<<<<<<<<<
 * 
 *         cdef int n
 */
  __pyx_tuple__183 = PyTuple_Pack(1, __pyx_kp_s_Invalid_index_object); if (unlikely(!__pyx_tuple__183)) __PYX_ERR(0, 3660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__183);
  __Pyx_GIVEREF(__pyx_tuple__183);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__184 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__184)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__184);
  __Pyx_GIVEREF(__pyx_tuple__184);

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__185 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__185)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__185);
  __Pyx_GIVEREF(__pyx_tuple__185);

  /* "pysam/libcbcf.pyx":3682
 * 
 *     if not header:
 *         raise ValueError('invalid VariantHeader')             # <<<<<<<<<<<<<<
 * 
 *     cdef BCFIndex index = BCFIndex.__new__(BCFIndex)
 */
  __pyx_tuple__186 = PyTuple_Pack(1, __pyx_kp_s_invalid_VariantHeader); if (unlikely(!__pyx_tuple__186)) __PYX_ERR(0, 3682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__186);
  __Pyx_GIVEREF(__pyx_tuple__186);

  /* "pysam/libcbcf.pyx":3699
 * 
 *         if not self.ptr:
 *             raise ValueError('Invalid index object')             # <<<<<<<<<<<<<<
 * 
 *         cdef int n
 */
  __pyx_tuple__187 = PyTuple_Pack(1, __pyx_kp_s_Invalid_index_object); if (unlikely(!__pyx_tuple__187)) __PYX_ERR(0, 3699, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__187);
  __Pyx_GIVEREF(__pyx_tuple__187);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__188 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__188)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__188);
  __Pyx_GIVEREF(__pyx_tuple__188);

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__189 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__189)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__189);
  __Pyx_GIVEREF(__pyx_tuple__189);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__190 = PyTuple_Pack(1, __pyx_kp_s_self_iter_cannot_be_converted_to); if (unlikely(!__pyx_tuple__190)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__190);
  __Pyx_GIVEREF(__pyx_tuple__190);

  /* "(tree fragment)":4
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__191 = PyTuple_Pack(1, __pyx_kp_s_self_iter_cannot_be_converted_to); if (unlikely(!__pyx_tuple__191)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__191);
  __Pyx_GIVEREF(__pyx_tuple__191);

  /* "pysam/libcbcf.pyx":3750
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):
 *         if bcf is None:
 *             raise ValueError('bcf must not be None')             # <<<<<<<<<<<<<<
 * 
 *         if contig is None:
 */
  __pyx_tuple__192 = PyTuple_Pack(1, __pyx_kp_s_bcf_must_not_be_None); if (unlikely(!__pyx_tuple__192)) __PYX_ERR(0, 3750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__192);
  __Pyx_GIVEREF(__pyx_tuple__192);

  /* "pysam/libcbcf.pyx":3753
 * 
 *         if contig is None:
 *             raise ValueError('contig must be specified')             # <<<<<<<<<<<<<<
 * 
 *         if not isinstance(bcf.index, BCFIndex):
 */
  __pyx_tuple__193 = PyTuple_Pack(1, __pyx_kp_s_contig_must_be_specified); if (unlikely(!__pyx_tuple__193)) __PYX_ERR(0, 3753, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__193);
  __Pyx_GIVEREF(__pyx_tuple__193);

  /* "pysam/libcbcf.pyx":3756
 * 
 *         if not isinstance(bcf.index, BCFIndex):
 *             raise ValueError('bcf index required')             # <<<<<<<<<<<<<<
 * 
 *         cdef BCFIndex index = bcf.index
 */
  __pyx_tuple__194 = PyTuple_Pack(1, __pyx_kp_s_bcf_index_required); if (unlikely(!__pyx_tuple__194)) __PYX_ERR(0, 3756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__194);
  __Pyx_GIVEREF(__pyx_tuple__194);

  /* "pysam/libcbcf.pyx":3802
 * 
 *         if not record:
 *             raise MemoryError('unable to allocate BCF record')             # <<<<<<<<<<<<<<
 * 
 *         record.pos = -1
 */
  __pyx_tuple__195 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_BCF_record); if (unlikely(!__pyx_tuple__195)) __PYX_ERR(0, 3802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__195);
  __Pyx_GIVEREF(__pyx_tuple__195);

  /* "pysam/libcbcf.pyx":3818
 *                 raise StopIteration
 *             elif ret == -2:
 *                 raise IOError('truncated file')             # <<<<<<<<<<<<<<
 *             elif errno:
 *                 raise IOError(errno, strerror(errno))
 */
  __pyx_tuple__196 = PyTuple_Pack(1, __pyx_kp_s_truncated_file); if (unlikely(!__pyx_tuple__196)) __PYX_ERR(0, 3818, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__196);
  __Pyx_GIVEREF(__pyx_tuple__196);

  /* "pysam/libcbcf.pyx":3822
 *                 raise IOError(errno, strerror(errno))
 *             else:
 *                 raise IOError('unable to fetch next record')             # <<<<<<<<<<<<<<
 * 
 *         ret = bcf_subset_format(self.bcf.header.ptr, record)
 */
  __pyx_tuple__197 = PyTuple_Pack(1, __pyx_kp_s_unable_to_fetch_next_record); if (unlikely(!__pyx_tuple__197)) __PYX_ERR(0, 3822, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__197);
  __Pyx_GIVEREF(__pyx_tuple__197);

  /* "pysam/libcbcf.pyx":3828
 *         if ret < 0:
 *             _stop_BCFIterator(self, record)
 *             raise ValueError('error in bcf_subset_format')             # <<<<<<<<<<<<<<
 * 
 *         return makeVariantRecord(self.bcf.header, record)
 */
  __pyx_tuple__198 = PyTuple_Pack(1, __pyx_kp_s_error_in_bcf_subset_format); if (unlikely(!__pyx_tuple__198)) __PYX_ERR(0, 3828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__198);
  __Pyx_GIVEREF(__pyx_tuple__198);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__199 = PyTuple_Pack(1, __pyx_kp_s_self_iter_cannot_be_converted_to); if (unlikely(!__pyx_tuple__199)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__199);
  __Pyx_GIVEREF(__pyx_tuple__199);

  /* "(tree fragment)":4
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.iter cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__200 = PyTuple_Pack(1, __pyx_kp_s_self_iter_cannot_be_converted_to); if (unlikely(!__pyx_tuple__200)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__200);
  __Pyx_GIVEREF(__pyx_tuple__200);

  /* "pysam/libcbcf.pyx":3841
 *     def __init__(self, VariantFile bcf, contig=None, start=None, stop=None, reopen=True):
 *         if bcf is None:
 *             raise ValueError('bcf must not be None')             # <<<<<<<<<<<<<<
 * 
 *         if not isinstance(bcf.index, TabixIndex):
 */
  __pyx_tuple__201 = PyTuple_Pack(1, __pyx_kp_s_bcf_must_not_be_None); if (unlikely(!__pyx_tuple__201)) __PYX_ERR(0, 3841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__201);
  __Pyx_GIVEREF(__pyx_tuple__201);

  /* "pysam/libcbcf.pyx":3844
 * 
 *         if not isinstance(bcf.index, TabixIndex):
 *             raise ValueError('tabix index required')             # <<<<<<<<<<<<<<
 * 
 *         cdef TabixIndex index = bcf.index
 */
  __pyx_tuple__202 = PyTuple_Pack(1, __pyx_kp_s_tabix_index_required); if (unlikely(!__pyx_tuple__202)) __PYX_ERR(0, 3844, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__202);
  __Pyx_GIVEREF(__pyx_tuple__202);

  /* "pysam/libcbcf.pyx":3904
 *                 raise StopIteration
 *             elif ret == -2:
 *                 raise IOError('truncated file')             # <<<<<<<<<<<<<<
 *             elif errno:
 *                 raise IOError(errno, strerror(errno))
 */
  __pyx_tuple__203 = PyTuple_Pack(1, __pyx_kp_s_truncated_file); if (unlikely(!__pyx_tuple__203)) __PYX_ERR(0, 3904, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__203);
  __Pyx_GIVEREF(__pyx_tuple__203);

  /* "pysam/libcbcf.pyx":3908
 *                 raise IOError(errno, strerror(errno))
 *             else:
 *                 raise IOError('unable to fetch next record')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf1_t *record = bcf_init1()
 */
  __pyx_tuple__204 = PyTuple_Pack(1, __pyx_kp_s_unable_to_fetch_next_record); if (unlikely(!__pyx_tuple__204)) __PYX_ERR(0, 3908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__204);
  __Pyx_GIVEREF(__pyx_tuple__204);

  /* "pysam/libcbcf.pyx":3913
 * 
 *         if not record:
 *             raise MemoryError('unable to allocate BCF record')             # <<<<<<<<<<<<<<
 * 
 *         record.pos = -1
 */
  __pyx_tuple__205 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_BCF_record); if (unlikely(!__pyx_tuple__205)) __PYX_ERR(0, 3913, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__205);
  __Pyx_GIVEREF(__pyx_tuple__205);

  /* "pysam/libcbcf.pyx":3924
 *         if ret < 0:
 *             bcf_destroy1(record)
 *             raise ValueError('error in vcf_parse')             # <<<<<<<<<<<<<<
 * 
 *         return makeVariantRecord(self.bcf.header, record)
 */
  __pyx_tuple__206 = PyTuple_Pack(1, __pyx_kp_s_error_in_vcf_parse); if (unlikely(!__pyx_tuple__206)) __PYX_ERR(0, 3924, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__206);
  __Pyx_GIVEREF(__pyx_tuple__206);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__207 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__207)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__207);
  __Pyx_GIVEREF(__pyx_tuple__207);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__208 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__208)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__208);
  __Pyx_GIVEREF(__pyx_tuple__208);

  /* "pysam/libcbcf.pyx":4060
 *     def __iter__(self):
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         if self.htsfile.is_write:
 */
  __pyx_tuple__209 = PyTuple_Pack(1, __pyx_kp_s_I_O_operation_on_closed_file); if (unlikely(!__pyx_tuple__209)) __PYX_ERR(0, 4060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__209);
  __Pyx_GIVEREF(__pyx_tuple__209);

  /* "pysam/libcbcf.pyx":4063
 * 
 *         if self.htsfile.is_write:
 *             raise ValueError('cannot iterate over Variantfile opened for writing')             # <<<<<<<<<<<<<<
 * 
 *         self.is_reading = 1
 */
  __pyx_tuple__210 = PyTuple_Pack(1, __pyx_kp_s_cannot_iterate_over_Variantfile); if (unlikely(!__pyx_tuple__210)) __PYX_ERR(0, 4063, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__210);
  __Pyx_GIVEREF(__pyx_tuple__210);

  /* "pysam/libcbcf.pyx":4073
 * 
 *         if not record:
 *             raise MemoryError('unable to allocate BCF record')             # <<<<<<<<<<<<<<
 * 
 *         record.pos = -1
 */
  __pyx_tuple__211 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_BCF_record); if (unlikely(!__pyx_tuple__211)) __PYX_ERR(0, 4073, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__211);
  __Pyx_GIVEREF(__pyx_tuple__211);

  /* "pysam/libcbcf.pyx":4087
 *                 raise StopIteration
 *             elif ret == -2:
 *                 raise IOError('truncated file')             # <<<<<<<<<<<<<<
 *             elif errno:
 *                 raise IOError(errno, strerror(errno))
 */
  __pyx_tuple__212 = PyTuple_Pack(1, __pyx_kp_s_truncated_file); if (unlikely(!__pyx_tuple__212)) __PYX_ERR(0, 4087, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__212);
  __Pyx_GIVEREF(__pyx_tuple__212);

  /* "pysam/libcbcf.pyx":4091
 *                 raise IOError(errno, strerror(errno))
 *             else:
 *                 raise IOError('unable to fetch next record')             # <<<<<<<<<<<<<<
 * 
 *         return makeVariantRecord(self.header, record)
 */
  __pyx_tuple__213 = PyTuple_Pack(1, __pyx_kp_s_unable_to_fetch_next_record); if (unlikely(!__pyx_tuple__213)) __PYX_ERR(0, 4091, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__213);
  __Pyx_GIVEREF(__pyx_tuple__213);

  /* "pysam/libcbcf.pyx":4106
 * 
 *         if not vars.htsfile:
 *             raise ValueError('Cannot re-open htsfile')             # <<<<<<<<<<<<<<
 * 
 *         # minimize overhead by re-using header and index.  This approach is
 */
  __pyx_tuple__214 = PyTuple_Pack(1, __pyx_kp_s_Cannot_re_open_htsfile); if (unlikely(!__pyx_tuple__214)) __PYX_ERR(0, 4106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__214);
  __Pyx_GIVEREF(__pyx_tuple__214);

  /* "pysam/libcbcf.pyx":4159
 *             # to bgzf_read (https://github.com/samtools/htslib/blob/1.7/bgzf.c#L888)
 *             # Better to avoid this (for now) than to produce seemingly correct results.
 *             raise ValueError('Cannot add extra threads when "ignore_truncation" is True')             # <<<<<<<<<<<<<<
 *         self.threads = threads
 * 
 */
  __pyx_tuple__215 = PyTuple_Pack(1, __pyx_kp_s_Cannot_add_extra_threads_when_ig); if (unlikely(!__pyx_tuple__215)) __PYX_ERR(0, 4159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__215);
  __Pyx_GIVEREF(__pyx_tuple__215);

  /* "pysam/libcbcf.pyx":4167
 * 
 *         if not mode or mode[0] not in 'rwa':
 *             raise ValueError('mode must begin with r, w or a')             # <<<<<<<<<<<<<<
 * 
 *         self.duplicate_filehandle = duplicate_filehandle
 */
  __pyx_tuple__216 = PyTuple_Pack(1, __pyx_kp_s_mode_must_begin_with_r_w_or_a); if (unlikely(!__pyx_tuple__216)) __PYX_ERR(0, 4167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__216);
  __Pyx_GIVEREF(__pyx_tuple__216);

  /* "pysam/libcbcf.pyx":4171
 *         self.duplicate_filehandle = duplicate_filehandle
 * 
 *         format_modes = [m for m in mode[1:] if m in 'bcguz']             # <<<<<<<<<<<<<<
 *         if len(format_modes) > 1:
 *             raise ValueError('mode contains conflicting format specifiers: {}'.format(''.join(format_modes)))
 */
  __pyx_slice__217 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__217)) __PYX_ERR(0, 4171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__217);
  __Pyx_GIVEREF(__pyx_slice__217);

  /* "pysam/libcbcf.pyx":4175
 *             raise ValueError('mode contains conflicting format specifiers: {}'.format(''.join(format_modes)))
 * 
 *         invalid_modes = [m for m in mode[1:] if m not in 'bcguz0123456789ex']             # <<<<<<<<<<<<<<
 *         if invalid_modes:
 *             raise ValueError('invalid mode options: {}'.format(''.join(invalid_modes)))
 */
  __pyx_slice__218 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__218)) __PYX_ERR(0, 4175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__218);
  __Pyx_GIVEREF(__pyx_slice__218);

  /* "pysam/libcbcf.pyx":4181
 *         # Autodetect mode from filename
 *         if mode == 'w' and isinstance(filename, str):
 *             if filename.endswith('.gz'):             # <<<<<<<<<<<<<<
 *                 mode = 'wz'
 *             elif filename.endswith('.bcf'):
 */
  __pyx_tuple__219 = PyTuple_Pack(1, __pyx_kp_s_gz); if (unlikely(!__pyx_tuple__219)) __PYX_ERR(0, 4181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__219);
  __Pyx_GIVEREF(__pyx_tuple__219);

  /* "pysam/libcbcf.pyx":4183
 *             if filename.endswith('.gz'):
 *                 mode = 'wz'
 *             elif filename.endswith('.bcf'):             # <<<<<<<<<<<<<<
 *                 mode = 'wb'
 * 
 */
  __pyx_tuple__220 = PyTuple_Pack(1, __pyx_kp_s_bcf_2); if (unlikely(!__pyx_tuple__220)) __PYX_ERR(0, 4183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__220);
  __Pyx_GIVEREF(__pyx_tuple__220);

  /* "pysam/libcbcf.pyx":4212
 *         self.header_written = False
 * 
 *         if mode.startswith(b'w'):             # <<<<<<<<<<<<<<
 *             # open file for writing
 *             if index_filename is not None:
 */
  __pyx_tuple__222 = PyTuple_Pack(1, __pyx_n_b_w); if (unlikely(!__pyx_tuple__222)) __PYX_ERR(0, 4212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__222);
  __Pyx_GIVEREF(__pyx_tuple__222);

  /* "pysam/libcbcf.pyx":4215
 *             # open file for writing
 *             if index_filename is not None:
 *                 raise ValueError('Cannot specify an index filename when writing a VCF/BCF file')             # <<<<<<<<<<<<<<
 * 
 *             # header structure (used for writing)
 */
  __pyx_tuple__223 = PyTuple_Pack(1, __pyx_kp_s_Cannot_specify_an_index_filename); if (unlikely(!__pyx_tuple__223)) __PYX_ERR(0, 4215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__223);
  __Pyx_GIVEREF(__pyx_tuple__223);

  /* "pysam/libcbcf.pyx":4230
 *                 raise ValueError("could not open file `{}` (mode='{}')".format(filename, mode))
 * 
 *         elif mode.startswith(b'r'):             # <<<<<<<<<<<<<<
 *             # open file for reading
 *             self.htsfile = self._open_htsfile()
 */
  __pyx_tuple__224 = PyTuple_Pack(1, __pyx_n_b_r); if (unlikely(!__pyx_tuple__224)) __PYX_ERR(0, 4230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__224);
  __Pyx_GIVEREF(__pyx_tuple__224);

  /* "pysam/libcbcf.pyx":4289
 *         """
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */
  __pyx_tuple__225 = PyTuple_Pack(1, __pyx_kp_s_I_O_operation_on_closed_file); if (unlikely(!__pyx_tuple__225)) __PYX_ERR(0, 4289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__225);
  __Pyx_GIVEREF(__pyx_tuple__225);

  /* "pysam/libcbcf.pyx":4303
 *         """
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         cdef vdict_t *d = <vdict_t*>self.header.ptr.dict[BCF_DT_CTG]
 */
  __pyx_tuple__226 = PyTuple_Pack(1, __pyx_kp_s_I_O_operation_on_closed_file); if (unlikely(!__pyx_tuple__226)) __PYX_ERR(0, 4303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__226);
  __Pyx_GIVEREF(__pyx_tuple__226);

  /* "pysam/libcbcf.pyx":4315
 *         """
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         cdef bcf_hdr_t *hdr = self.header.ptr
 */
  __pyx_tuple__227 = PyTuple_Pack(1, __pyx_kp_s_I_O_operation_on_closed_file); if (unlikely(!__pyx_tuple__227)) __PYX_ERR(0, 4315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__227);
  __Pyx_GIVEREF(__pyx_tuple__227);

  /* "pysam/libcbcf.pyx":4320
 *         cdef int rid = tid
 *         if rid < 0 or rid >= hdr.n[BCF_DT_CTG]:
 *             raise ValueError('Invalid tid')             # <<<<<<<<<<<<<<
 *         return bcf_str_cache_get_charptr(bcf_hdr_id2name(hdr, rid))
 * 
 */
  __pyx_tuple__228 = PyTuple_Pack(1, __pyx_kp_s_Invalid_tid); if (unlikely(!__pyx_tuple__228)) __PYX_ERR(0, 4320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__228);
  __Pyx_GIVEREF(__pyx_tuple__228);

  /* "pysam/libcbcf.pyx":4345
 *         """
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         if self.htsfile.is_write:
 */
  __pyx_tuple__229 = PyTuple_Pack(1, __pyx_kp_s_I_O_operation_on_closed_file); if (unlikely(!__pyx_tuple__229)) __PYX_ERR(0, 4345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__229);
  __Pyx_GIVEREF(__pyx_tuple__229);

  /* "pysam/libcbcf.pyx":4348
 * 
 *         if self.htsfile.is_write:
 *             raise ValueError('cannot fetch from Variantfile opened for writing')             # <<<<<<<<<<<<<<
 * 
 *         if contig is None and region is None:
 */
  __pyx_tuple__230 = PyTuple_Pack(1, __pyx_kp_s_cannot_fetch_from_Variantfile_op); if (unlikely(!__pyx_tuple__230)) __PYX_ERR(0, 4348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__230);
  __Pyx_GIVEREF(__pyx_tuple__230);

  /* "pysam/libcbcf.pyx":4357
 * 
 *         if not self.index:
 *             raise ValueError('fetch requires an index')             # <<<<<<<<<<<<<<
 * 
 *         _, tid, start, stop = self.parse_region(contig, start, stop, region,
 */
  __pyx_tuple__231 = PyTuple_Pack(1, __pyx_kp_s_fetch_requires_an_index); if (unlikely(!__pyx_tuple__231)) __PYX_ERR(0, 4357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__231);
  __Pyx_GIVEREF(__pyx_tuple__231);

  /* "pysam/libcbcf.pyx":4382
 *         """
 *         if record is None:
 *             raise ValueError('record must not be None')             # <<<<<<<<<<<<<<
 * 
 *         if not self.is_open:
 */
  __pyx_tuple__232 = PyTuple_Pack(1, __pyx_kp_s_record_must_not_be_None); if (unlikely(!__pyx_tuple__232)) __PYX_ERR(0, 4382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__232);
  __Pyx_GIVEREF(__pyx_tuple__232);

  /* "pysam/libcbcf.pyx":4385
 * 
 *         if not self.is_open:
 *             return ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         if not self.htsfile.is_write:
 */
  __pyx_tuple__233 = PyTuple_Pack(1, __pyx_kp_s_I_O_operation_on_closed_file); if (unlikely(!__pyx_tuple__233)) __PYX_ERR(0, 4385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__233);
  __Pyx_GIVEREF(__pyx_tuple__233);

  /* "pysam/libcbcf.pyx":4388
 * 
 *         if not self.htsfile.is_write:
 *             raise ValueError('cannot write to a Variantfile opened for reading')             # <<<<<<<<<<<<<<
 * 
 *         if not self.header_written:
 */
  __pyx_tuple__234 = PyTuple_Pack(1, __pyx_kp_s_cannot_write_to_a_Variantfile_op); if (unlikely(!__pyx_tuple__234)) __PYX_ERR(0, 4388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__234);
  __Pyx_GIVEREF(__pyx_tuple__234);

  /* "pysam/libcbcf.pyx":4422
 *         """
 *         if not self.is_open:
 *             raise ValueError('I/O operation on closed file')             # <<<<<<<<<<<<<<
 * 
 *         if self.htsfile.is_write:
 */
  __pyx_tuple__235 = PyTuple_Pack(1, __pyx_kp_s_I_O_operation_on_closed_file); if (unlikely(!__pyx_tuple__235)) __PYX_ERR(0, 4422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__235);
  __Pyx_GIVEREF(__pyx_tuple__235);

  /* "pysam/libcbcf.pyx":4425
 * 
 *         if self.htsfile.is_write:
 *             raise ValueError('cannot subset samples from Variantfile opened for writing')             # <<<<<<<<<<<<<<
 * 
 *         if self.is_reading:
 */
  __pyx_tuple__236 = PyTuple_Pack(1, __pyx_kp_s_cannot_subset_samples_from_Varia); if (unlikely(!__pyx_tuple__236)) __PYX_ERR(0, 4425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__236);
  __Pyx_GIVEREF(__pyx_tuple__236);

  /* "pysam/libcbcf.pyx":4428
 * 
 *         if self.is_reading:
 *             raise ValueError('cannot subset samples after fetching records')             # <<<<<<<<<<<<<<
 * 
 *         self.header._subset_samples(include_samples)
 */
  __pyx_tuple__237 = PyTuple_Pack(1, __pyx_kp_s_cannot_subset_samples_after_fetc); if (unlikely(!__pyx_tuple__237)) __PYX_ERR(0, 4428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__237);
  __Pyx_GIVEREF(__pyx_tuple__237);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__238 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__238)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__238);
  __Pyx_GIVEREF(__pyx_tuple__238);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__239 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__239)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__239);
  __Pyx_GIVEREF(__pyx_tuple__239);

  /* "pysam/libcbcf.pyx":115
 * 
 * cdef int MAX_POS = (1 << 31) - 1
 * cdef tuple VALUE_TYPES = ('Flag', 'Integer', 'Float', 'String')             # <<<<<<<<<<<<<<
 * cdef tuple METADATA_TYPES = ('FILTER', 'INFO', 'FORMAT', 'CONTIG', 'STRUCTURED', 'GENERIC')
 * cdef tuple METADATA_LENGTHS = ('FIXED', 'VARIABLE', 'A', 'G', 'R')
 */
  __pyx_tuple__252 = PyTuple_Pack(4, __pyx_n_s_Flag, __pyx_n_s_Integer, __pyx_n_s_Float, __pyx_n_s_String); if (unlikely(!__pyx_tuple__252)) __PYX_ERR(0, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__252);
  __Pyx_GIVEREF(__pyx_tuple__252);

  /* "pysam/libcbcf.pyx":116
 * cdef int MAX_POS = (1 << 31) - 1
 * cdef tuple VALUE_TYPES = ('Flag', 'Integer', 'Float', 'String')
 * cdef tuple METADATA_TYPES = ('FILTER', 'INFO', 'FORMAT', 'CONTIG', 'STRUCTURED', 'GENERIC')             # <<<<<<<<<<<<<<
 * cdef tuple METADATA_LENGTHS = ('FIXED', 'VARIABLE', 'A', 'G', 'R')
 * 
 */
  __pyx_tuple__253 = PyTuple_Pack(6, __pyx_n_s_FILTER, __pyx_n_s_INFO, __pyx_n_s_FORMAT, __pyx_n_s_CONTIG, __pyx_n_s_STRUCTURED, __pyx_n_s_GENERIC); if (unlikely(!__pyx_tuple__253)) __PYX_ERR(0, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__253);
  __Pyx_GIVEREF(__pyx_tuple__253);

  /* "pysam/libcbcf.pyx":117
 * cdef tuple VALUE_TYPES = ('Flag', 'Integer', 'Float', 'String')
 * cdef tuple METADATA_TYPES = ('FILTER', 'INFO', 'FORMAT', 'CONTIG', 'STRUCTURED', 'GENERIC')
 * cdef tuple METADATA_LENGTHS = ('FIXED', 'VARIABLE', 'A', 'G', 'R')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__254 = PyTuple_Pack(5, __pyx_n_s_FIXED, __pyx_n_s_VARIABLE, __pyx_n_s_A, __pyx_n_s_G, __pyx_n_s_R); if (unlikely(!__pyx_tuple__254)) __PYX_ERR(0, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__254);
  __Pyx_GIVEREF(__pyx_tuple__254);

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantHeaderRecords(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_tuple__255 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__255)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__255);
  __Pyx_GIVEREF(__pyx_tuple__255);
  __pyx_codeobj__240 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__255, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_VariantHeaderReco, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__240)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__256 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__256)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__256);
  __Pyx_GIVEREF(__pyx_tuple__256);
  __pyx_codeobj__241 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__256, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_VariantMetadata, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__241)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__257 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__257)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__257);
  __Pyx_GIVEREF(__pyx_tuple__257);
  __pyx_codeobj__242 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__257, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_VariantHeaderMeta, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__242)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__258 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__258)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__258);
  __Pyx_GIVEREF(__pyx_tuple__258);
  __pyx_codeobj__243 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__258, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_VariantContig, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__243)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__259 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__259)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__259);
  __Pyx_GIVEREF(__pyx_tuple__259);
  __pyx_codeobj__244 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__259, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_VariantHeaderCont, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__244)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__260 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__260)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__260);
  __Pyx_GIVEREF(__pyx_tuple__260);
  __pyx_codeobj__245 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__260, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_VariantHeaderSamp, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__245)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__261 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__261)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__261);
  __Pyx_GIVEREF(__pyx_tuple__261);
  __pyx_codeobj__246 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__261, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_VariantRecordFilt, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__246)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__262 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__262)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__262);
  __Pyx_GIVEREF(__pyx_tuple__262);
  __pyx_codeobj__247 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__262, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_VariantRecordForm, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__247)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__263 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__263)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__263);
  __Pyx_GIVEREF(__pyx_tuple__263);
  __pyx_codeobj__248 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__263, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_VariantRecordInfo, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__248)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__264 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__264)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__264);
  __Pyx_GIVEREF(__pyx_tuple__264);
  __pyx_codeobj__249 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__264, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_VariantRecordSamp, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__249)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__265 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__265)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__265);
  __Pyx_GIVEREF(__pyx_tuple__265);
  __pyx_codeobj__250 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__265, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_VariantRecordSamp_2, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__250)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__266 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__266)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__266);
  __Pyx_GIVEREF(__pyx_tuple__266);
  __pyx_codeobj__251 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__266, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_BaseIndex, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__251)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyBytes_Type_split.type = (PyObject*)&PyBytes_Type;
  __pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type;
  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_10091417 = PyInt_FromLong(10091417L); if (unlikely(!__pyx_int_10091417)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_97976187 = PyInt_FromLong(97976187L); if (unlikely(!__pyx_int_97976187)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_164668780 = PyInt_FromLong(164668780L); if (unlikely(!__pyx_int_164668780)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_199651019 = PyInt_FromLong(199651019L); if (unlikely(!__pyx_int_199651019)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_227765731 = PyInt_FromLong(227765731L); if (unlikely(!__pyx_int_227765731)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_232881935 = PyInt_FromLong(232881935L); if (unlikely(!__pyx_int_232881935)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_248899179 = PyInt_FromLong(248899179L); if (unlikely(!__pyx_int_248899179)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_4294967294 = PyInt_FromString((char *)"4294967294", 0, 0); if (unlikely(!__pyx_int_4294967294)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_modinit_global_init_code(void); /*proto*/
static int __Pyx_modinit_variable_export_code(void); /*proto*/
static int __Pyx_modinit_function_export_code(void); /*proto*/
static int __Pyx_modinit_type_init_code(void); /*proto*/
static int __Pyx_modinit_type_import_code(void); /*proto*/
static int __Pyx_modinit_variable_import_code(void); /*proto*/
static int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __pyx_v_5pysam_7libcbcf_VALUE_TYPES = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_5pysam_7libcbcf_METADATA_TYPES = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_5pysam_7libcbcf_METADATA_LENGTHS = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_5pysam_7libcbcf__nothing = Py_None; Py_INCREF(Py_None);
  __pyx_v_5pysam_7libcbcf_bcf_str_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  __pyx_vtabptr_5pysam_7libcbcf_VariantHeader = &__pyx_vtable_5pysam_7libcbcf_VariantHeader;
  __pyx_vtable_5pysam_7libcbcf_VariantHeader._subset_samples = (PyObject *(*)(struct __pyx_obj_5pysam_7libcbcf_VariantHeader *, PyObject *))__pyx_f_5pysam_7libcbcf_13VariantHeader__subset_samples;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantHeader) < 0) __PYX_ERR(0, 1935, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantHeader.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantHeader.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantHeader.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantHeader.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_5pysam_7libcbcf_VariantHeader.tp_dict, __pyx_vtabptr_5pysam_7libcbcf_VariantHeader) < 0) __PYX_ERR(0, 1935, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "VariantHeader", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantHeader) < 0) __PYX_ERR(0, 1935, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantHeader) < 0) __PYX_ERR(0, 1935, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantHeader = &__pyx_type_5pysam_7libcbcf_VariantHeader;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantHeaderRecord) < 0) __PYX_ERR(0, 1229, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantHeaderRecord.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantHeaderRecord.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantHeaderRecord.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantHeaderRecord.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_5pysam_7libcbcf_VariantHeaderRecord, "__getitem__"); if (unlikely(!wrapper)) __PYX_ERR(0, 1229, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_5pysam_7libcbcf_19VariantHeaderRecord_6__getitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_5pysam_7libcbcf_19VariantHeaderRecord_6__getitem__.doc = __pyx_doc_5pysam_7libcbcf_19VariantHeaderRecord_6__getitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5pysam_7libcbcf_19VariantHeaderRecord_6__getitem__;
    }
  }
  #endif
  if (PyObject_SetAttrString(__pyx_m, "VariantHeaderRecord", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantHeaderRecord) < 0) __PYX_ERR(0, 1229, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantHeaderRecord) < 0) __PYX_ERR(0, 1229, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantHeaderRecord = &__pyx_type_5pysam_7libcbcf_VariantHeaderRecord;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantHeaderRecords) < 0) __PYX_ERR(0, 1416, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantHeaderRecords.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantHeaderRecords.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantHeaderRecords.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantHeaderRecords.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "VariantHeaderRecords", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantHeaderRecords) < 0) __PYX_ERR(0, 1416, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantHeaderRecords) < 0) __PYX_ERR(0, 1416, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantHeaderRecords = &__pyx_type_5pysam_7libcbcf_VariantHeaderRecords;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantHeaderContigs) < 0) __PYX_ERR(0, 1741, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantHeaderContigs.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantHeaderContigs.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantHeaderContigs.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantHeaderContigs.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "VariantHeaderContigs", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantHeaderContigs) < 0) __PYX_ERR(0, 1741, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantHeaderContigs) < 0) __PYX_ERR(0, 1741, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantHeaderContigs = &__pyx_type_5pysam_7libcbcf_VariantHeaderContigs;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantHeaderSamples) < 0) __PYX_ERR(0, 1879, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantHeaderSamples.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantHeaderSamples.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantHeaderSamples.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantHeaderSamples.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "VariantHeaderSamples", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantHeaderSamples) < 0) __PYX_ERR(0, 1879, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantHeaderSamples) < 0) __PYX_ERR(0, 1879, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantHeaderSamples = &__pyx_type_5pysam_7libcbcf_VariantHeaderSamples;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantContig) < 0) __PYX_ERR(0, 1691, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantContig.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantContig.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantContig.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantContig.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "VariantContig", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantContig) < 0) __PYX_ERR(0, 1691, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantContig) < 0) __PYX_ERR(0, 1691, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantContig = &__pyx_type_5pysam_7libcbcf_VariantContig;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantMetadata) < 0) __PYX_ERR(0, 1450, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantMetadata.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantMetadata.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantMetadata.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantMetadata.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "VariantMetadata", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantMetadata) < 0) __PYX_ERR(0, 1450, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantMetadata) < 0) __PYX_ERR(0, 1450, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantMetadata = &__pyx_type_5pysam_7libcbcf_VariantMetadata;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantHeaderMetadata) < 0) __PYX_ERR(0, 1540, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantHeaderMetadata.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantHeaderMetadata.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantHeaderMetadata.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantHeaderMetadata.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "VariantHeaderMetadata", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantHeaderMetadata) < 0) __PYX_ERR(0, 1540, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantHeaderMetadata) < 0) __PYX_ERR(0, 1540, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantHeaderMetadata = &__pyx_type_5pysam_7libcbcf_VariantHeaderMetadata;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantRecord) < 0) __PYX_ERR(0, 2969, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantRecord.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantRecord.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantRecord.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantRecord.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "VariantRecord", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantRecord) < 0) __PYX_ERR(0, 2969, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantRecord) < 0) __PYX_ERR(0, 2969, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantRecord = &__pyx_type_5pysam_7libcbcf_VariantRecord;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantRecordFilter) < 0) __PYX_ERR(0, 2188, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantRecordFilter.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantRecordFilter.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantRecordFilter.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantRecordFilter.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "VariantRecordFilter", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantRecordFilter) < 0) __PYX_ERR(0, 2188, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantRecordFilter) < 0) __PYX_ERR(0, 2188, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantRecordFilter = &__pyx_type_5pysam_7libcbcf_VariantRecordFilter;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantRecordFormat) < 0) __PYX_ERR(0, 2350, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantRecordFormat.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantRecordFormat.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantRecordFormat.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantRecordFormat.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "VariantRecordFormat", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantRecordFormat) < 0) __PYX_ERR(0, 2350, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantRecordFormat) < 0) __PYX_ERR(0, 2350, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantRecordFormat = &__pyx_type_5pysam_7libcbcf_VariantRecordFormat;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantRecordInfo) < 0) __PYX_ERR(0, 2485, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantRecordInfo.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantRecordInfo.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantRecordInfo.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantRecordInfo.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "VariantRecordInfo", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantRecordInfo) < 0) __PYX_ERR(0, 2485, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantRecordInfo) < 0) __PYX_ERR(0, 2485, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantRecordInfo = &__pyx_type_5pysam_7libcbcf_VariantRecordInfo;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantRecordSamples) < 0) __PYX_ERR(0, 2819, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantRecordSamples.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantRecordSamples.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantRecordSamples.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantRecordSamples.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "VariantRecordSamples", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantRecordSamples) < 0) __PYX_ERR(0, 2819, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantRecordSamples) < 0) __PYX_ERR(0, 2819, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantRecordSamples = &__pyx_type_5pysam_7libcbcf_VariantRecordSamples;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantRecordSample) < 0) __PYX_ERR(0, 3357, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantRecordSample.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantRecordSample.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantRecordSample.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantRecordSample.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "VariantRecordSample", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantRecordSample) < 0) __PYX_ERR(0, 3357, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantRecordSample) < 0) __PYX_ERR(0, 3357, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantRecordSample = &__pyx_type_5pysam_7libcbcf_VariantRecordSample;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_BaseIndex) < 0) __PYX_ERR(0, 3564, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_BaseIndex.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_BaseIndex.tp_dictoffset && __pyx_type_5pysam_7libcbcf_BaseIndex.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_BaseIndex.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "BaseIndex", (PyObject *)&__pyx_type_5pysam_7libcbcf_BaseIndex) < 0) __PYX_ERR(0, 3564, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_BaseIndex) < 0) __PYX_ERR(0, 3564, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_BaseIndex = &__pyx_type_5pysam_7libcbcf_BaseIndex;
  __pyx_type_5pysam_7libcbcf_BCFIndex.tp_base = __pyx_ptype_5pysam_7libcbcf_BaseIndex;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_BCFIndex) < 0) __PYX_ERR(0, 3653, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_BCFIndex.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_BCFIndex.tp_dictoffset && __pyx_type_5pysam_7libcbcf_BCFIndex.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_BCFIndex.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "BCFIndex", (PyObject *)&__pyx_type_5pysam_7libcbcf_BCFIndex) < 0) __PYX_ERR(0, 3653, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_BCFIndex) < 0) __PYX_ERR(0, 3653, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_BCFIndex = &__pyx_type_5pysam_7libcbcf_BCFIndex;
  __pyx_type_5pysam_7libcbcf_TabixIndex.tp_base = __pyx_ptype_5pysam_7libcbcf_BaseIndex;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_TabixIndex) < 0) __PYX_ERR(0, 3692, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_TabixIndex.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_TabixIndex.tp_dictoffset && __pyx_type_5pysam_7libcbcf_TabixIndex.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_TabixIndex.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "TabixIndex", (PyObject *)&__pyx_type_5pysam_7libcbcf_TabixIndex) < 0) __PYX_ERR(0, 3692, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_TabixIndex) < 0) __PYX_ERR(0, 3692, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_TabixIndex = &__pyx_type_5pysam_7libcbcf_TabixIndex;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_BaseIterator) < 0) __PYX_ERR(0, 3733, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_BaseIterator.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_BaseIterator.tp_dictoffset && __pyx_type_5pysam_7libcbcf_BaseIterator.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_BaseIterator.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "BaseIterator", (PyObject *)&__pyx_type_5pysam_7libcbcf_BaseIterator) < 0) __PYX_ERR(0, 3733, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_BaseIterator) < 0) __PYX_ERR(0, 3733, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_BaseIterator = &__pyx_type_5pysam_7libcbcf_BaseIterator;
  __pyx_type_5pysam_7libcbcf_BCFIterator.tp_base = __pyx_ptype_5pysam_7libcbcf_BaseIterator;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_BCFIterator) < 0) __PYX_ERR(0, 3747, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_BCFIterator.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_BCFIterator.tp_dictoffset && __pyx_type_5pysam_7libcbcf_BCFIterator.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_BCFIterator.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "BCFIterator", (PyObject *)&__pyx_type_5pysam_7libcbcf_BCFIterator) < 0) __PYX_ERR(0, 3747, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_BCFIterator) < 0) __PYX_ERR(0, 3747, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_BCFIterator = &__pyx_type_5pysam_7libcbcf_BCFIterator;
  __pyx_type_5pysam_7libcbcf_TabixIterator.tp_base = __pyx_ptype_5pysam_7libcbcf_BaseIterator;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_TabixIterator) < 0) __PYX_ERR(0, 3833, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_TabixIterator.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_TabixIterator.tp_dictoffset && __pyx_type_5pysam_7libcbcf_TabixIterator.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_TabixIterator.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "TabixIterator", (PyObject *)&__pyx_type_5pysam_7libcbcf_TabixIterator) < 0) __PYX_ERR(0, 3833, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_TabixIterator) < 0) __PYX_ERR(0, 3833, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_TabixIterator = &__pyx_type_5pysam_7libcbcf_TabixIterator;
  __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(0, 1, __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(0, 1, __pyx_L1_error)
  __pyx_vtabptr_5pysam_7libcbcf_VariantFile = &__pyx_vtable_5pysam_7libcbcf_VariantFile;
  __pyx_vtable_5pysam_7libcbcf_VariantFile.__pyx_base = *__pyx_vtabptr_5pysam_10libchtslib_HTSFile;
  __pyx_vtable_5pysam_7libcbcf_VariantFile.write = (int (*)(struct __pyx_obj_5pysam_7libcbcf_VariantFile *, struct __pyx_obj_5pysam_7libcbcf_VariantRecord *, int __pyx_skip_dispatch))__pyx_f_5pysam_7libcbcf_11VariantFile_write;
  __pyx_type_5pysam_7libcbcf_VariantFile.tp_base = __pyx_ptype_5pysam_10libchtslib_HTSFile;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf_VariantFile) < 0) __PYX_ERR(0, 3935, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf_VariantFile.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf_VariantFile.tp_dictoffset && __pyx_type_5pysam_7libcbcf_VariantFile.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf_VariantFile.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_5pysam_7libcbcf_VariantFile.tp_dict, __pyx_vtabptr_5pysam_7libcbcf_VariantFile) < 0) __PYX_ERR(0, 3935, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "VariantFile", (PyObject *)&__pyx_type_5pysam_7libcbcf_VariantFile) < 0) __PYX_ERR(0, 3935, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5pysam_7libcbcf_VariantFile) < 0) __PYX_ERR(0, 3935, __pyx_L1_error)
  __pyx_ptype_5pysam_7libcbcf_VariantFile = &__pyx_type_5pysam_7libcbcf_VariantFile;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple) < 0) __PYX_ERR(0, 250, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct____pyx_f_5pysam_7libcbcf_char_array_to_tuple;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_1_genexpr) < 0) __PYX_ERR(0, 254, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_1_genexpr.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_1_genexpr.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_1_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_1_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_1_genexpr = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_1_genexpr;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object) < 0) __PYX_ERR(0, 260, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_2___pyx_f_5pysam_7libcbcf_bcf_array_to_object;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_3_genexpr) < 0) __PYX_ERR(0, 285, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_3_genexpr.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_3_genexpr.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_3_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_3_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_3_genexpr = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_3_genexpr;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array) < 0) __PYX_ERR(0, 331, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_4___pyx_f_5pysam_7libcbcf_bcf_object_to_array;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_5_genexpr) < 0) __PYX_ERR(0, 343, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_5_genexpr.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_5_genexpr.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_5_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_5_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_5_genexpr = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_5_genexpr;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values) < 0) __PYX_ERR(0, 554, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_6___pyx_f_5pysam_7libcbcf_bcf_check_values;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_7_genexpr) < 0) __PYX_ERR(0, 593, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_7_genexpr.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_7_genexpr.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_7_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_7_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_7_genexpr = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_7_genexpr;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_8___get__) < 0) __PYX_ERR(0, 1255, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_8___get__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_8___get__.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_8___get__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_8___get__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_8___get__ = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_8___get__;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_9_genexpr) < 0) __PYX_ERR(0, 1261, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_9_genexpr.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_9_genexpr.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_9_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_9_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_9_genexpr = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_9_genexpr;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_10___iter__) < 0) __PYX_ERR(0, 1284, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_10___iter__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_10___iter__.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_10___iter__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_10___iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_10___iter__ = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_10___iter__;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_11_itervalues) < 0) __PYX_ERR(0, 1312, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_11_itervalues.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_11_itervalues.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_11_itervalues.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_11_itervalues.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_11_itervalues = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_11_itervalues;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_12_iteritems) < 0) __PYX_ERR(0, 1322, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_12_iteritems.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_12_iteritems.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_12_iteritems.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_12_iteritems.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_12_iteritems = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_12_iteritems;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_13___iter__) < 0) __PYX_ERR(0, 1433, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_13___iter__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_13___iter__.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_13___iter__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_13___iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_13___iter__ = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_13___iter__;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_14___iter__) < 0) __PYX_ERR(0, 1623, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_14___iter__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_14___iter__.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_14___iter__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_14___iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_14___iter__ = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_14___iter__;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_15_itervalues) < 0) __PYX_ERR(0, 1652, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_15_itervalues.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_15_itervalues.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_15_itervalues.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_15_itervalues.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_15_itervalues = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_15_itervalues;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_16_iteritems) < 0) __PYX_ERR(0, 1657, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_16_iteritems.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_16_iteritems.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_16_iteritems.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_16_iteritems.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_16_iteritems = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_16_iteritems;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_17___iter__) < 0) __PYX_ERR(0, 1803, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_17___iter__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_17___iter__.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_17___iter__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_17___iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_17___iter__ = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_17___iter__;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_18_itervalues) < 0) __PYX_ERR(0, 1832, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_18_itervalues.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_18_itervalues.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_18_itervalues.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_18_itervalues.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_18_itervalues = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_18_itervalues;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_19_iteritems) < 0) __PYX_ERR(0, 1837, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_19_iteritems.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_19_iteritems.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_19_iteritems.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_19_iteritems.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_19_iteritems = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_19_iteritems;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_20___iter__) < 0) __PYX_ERR(0, 1900, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_20___iter__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_20___iter__.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_20___iter__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_20___iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_20___iter__ = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_20___iter__;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_21___iter__) < 0) __PYX_ERR(0, 2273, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_21___iter__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_21___iter__.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_21___iter__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_21___iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_21___iter__ = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_21___iter__;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_22_itervalues) < 0) __PYX_ERR(0, 2298, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_22_itervalues.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_22_itervalues.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_22_itervalues.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_22_itervalues.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_22_itervalues = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_22_itervalues;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_23_iteritems) < 0) __PYX_ERR(0, 2303, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_23_iteritems.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_23_iteritems.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_23_iteritems.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_23_iteritems.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_23_iteritems = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_23_iteritems;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_24___iter__) < 0) __PYX_ERR(0, 2417, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_24___iter__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_24___iter__.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_24___iter__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_24___iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_24___iter__ = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_24___iter__;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_25_itervalues) < 0) __PYX_ERR(0, 2446, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_25_itervalues.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_25_itervalues.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_25_itervalues.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_25_itervalues.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_25_itervalues = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_25_itervalues;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_26_iteritems) < 0) __PYX_ERR(0, 2451, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_26_iteritems.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_26_iteritems.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_26_iteritems.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_26_iteritems.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_26_iteritems = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_26_iteritems;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_27___iter__) < 0) __PYX_ERR(0, 2623, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_27___iter__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_27___iter__.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_27___iter__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_27___iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_27___iter__ = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_27___iter__;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_28_itervalues) < 0) __PYX_ERR(0, 2690, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_28_itervalues.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_28_itervalues.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_28_itervalues.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_28_itervalues.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_28_itervalues = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_28_itervalues;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_29_iteritems) < 0) __PYX_ERR(0, 2708, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_29_iteritems.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_29_iteritems.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_29_iteritems.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_29_iteritems.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_29_iteritems = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_29_iteritems;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_30___iter__) < 0) __PYX_ERR(0, 2851, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_30___iter__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_30___iter__.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_30___iter__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_30___iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_30___iter__ = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_30___iter__;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_31_itervalues) < 0) __PYX_ERR(0, 2888, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_31_itervalues.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_31_itervalues.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_31_itervalues.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_31_itervalues.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_31_itervalues = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_31_itervalues;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_32_iteritems) < 0) __PYX_ERR(0, 2897, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_32_iteritems.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_32_iteritems.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_32_iteritems.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_32_iteritems.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_32_iteritems = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_32_iteritems;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_33___iter__) < 0) __PYX_ERR(0, 3459, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_33___iter__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_33___iter__.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_33___iter__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_33___iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_33___iter__ = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_33___iter__;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_34_itervalues) < 0) __PYX_ERR(0, 3488, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_34_itervalues.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_34_itervalues.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_34_itervalues.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_34_itervalues.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_34_itervalues = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_34_itervalues;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_35_iteritems) < 0) __PYX_ERR(0, 3493, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_35_iteritems.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_35_iteritems.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_35_iteritems.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_35_iteritems.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_35_iteritems = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_35_iteritems;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_36_itervalues) < 0) __PYX_ERR(0, 3603, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_36_itervalues.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_36_itervalues.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_36_itervalues.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_36_itervalues.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_36_itervalues = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_36_itervalues;
  if (PyType_Ready(&__pyx_type_5pysam_7libcbcf___pyx_scope_struct_37_iteritems) < 0) __PYX_ERR(0, 3608, __pyx_L1_error)
  __pyx_type_5pysam_7libcbcf___pyx_scope_struct_37_iteritems.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pysam_7libcbcf___pyx_scope_struct_37_iteritems.tp_dictoffset && __pyx_type_5pysam_7libcbcf___pyx_scope_struct_37_iteritems.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5pysam_7libcbcf___pyx_scope_struct_37_iteritems.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_5pysam_7libcbcf___pyx_scope_struct_37_iteritems = &__pyx_type_5pysam_7libcbcf___pyx_scope_struct_37_iteritems;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
  #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(4, 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(5, 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(6, 15, __pyx_L1_error)
  __pyx_ptype_7cpython_5array_array = __Pyx_ImportType("array", "array", sizeof(arrayobject), 0); if (unlikely(!__pyx_ptype_7cpython_5array_array)) __PYX_ERR(3, 58, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("pysam.libcutils"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "charptr_to_str", (void (**)(void))&__pyx_f_5pysam_9libcutils_charptr_to_str, "PyObject *(char const *, struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "charptr_to_str_w_len", (void (**)(void))&__pyx_f_5pysam_9libcutils_charptr_to_str_w_len, "PyObject *(char const *, size_t, struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str_w_len *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "force_str", (void (**)(void))&__pyx_f_5pysam_9libcutils_force_str, "PyObject *(PyObject *, struct __pyx_opt_args_5pysam_9libcutils_force_str *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "force_bytes", (void (**)(void))&__pyx_f_5pysam_9libcutils_force_bytes, "PyObject *(PyObject *, struct __pyx_opt_args_5pysam_9libcutils_force_bytes *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "encode_filename", (void (**)(void))&__pyx_f_5pysam_9libcutils_encode_filename, "PyObject *(PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "from_string_and_size", (void (**)(void))&__pyx_f_5pysam_9libcutils_from_string_and_size, "PyObject *(char const *, size_t)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}


#if PY_MAJOR_VERSION < 3
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC void
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#else
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initlibcbcf(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initlibcbcf(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_libcbcf(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_libcbcf(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        result = PyDict_SetItemString(moddict, to_name, value);
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static int __pyx_pymod_exec_libcbcf(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #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("__Pyx_PyMODINIT_FUNC PyInit_libcbcf(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_AsyncGen_USED
  if (__pyx_AsyncGen_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 CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("libcbcf", __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)
  #endif
  __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)
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __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_pysam__libcbcf) {
    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, "pysam.libcbcf")) {
      if (unlikely(PyDict_SetItemString(modules, "pysam.libcbcf", __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 type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  (void)__Pyx_modinit_function_export_code();
  if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
  if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
  (void)__Pyx_modinit_variable_import_code();
  if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __Pyx_TraceCall("__Pyx_PyMODINIT_FUNC PyInit_libcbcf(void)", __pyx_f[0], 1, 0, __PYX_ERR(0, 1, __pyx_L1_error));

  /* "pysam/libcbcf.pyx":84
 * from __future__ import division, print_function
 * 
 * import os             # <<<<<<<<<<<<<<
 * import sys
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 84, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":85
 * 
 * import os
 * import sys             # <<<<<<<<<<<<<<
 * 
 * from libc.errno  cimport errno, EPIPE
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 85, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":104
 * 
 * 
 * __all__ = ['VariantFile',             # <<<<<<<<<<<<<<
 *            'VariantHeader',
 *            'VariantHeaderRecord',
 */
  __pyx_t_1 = PyList_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_VariantFile);
  __Pyx_GIVEREF(__pyx_n_s_VariantFile);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_VariantFile);
  __Pyx_INCREF(__pyx_n_s_VariantHeader);
  __Pyx_GIVEREF(__pyx_n_s_VariantHeader);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_VariantHeader);
  __Pyx_INCREF(__pyx_n_s_VariantHeaderRecord);
  __Pyx_GIVEREF(__pyx_n_s_VariantHeaderRecord);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_VariantHeaderRecord);
  __Pyx_INCREF(__pyx_n_s_VariantRecord);
  __Pyx_GIVEREF(__pyx_n_s_VariantRecord);
  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_VariantRecord);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":114
 * ########################################################################
 * 
 * cdef int MAX_POS = (1 << 31) - 1             # <<<<<<<<<<<<<<
 * cdef tuple VALUE_TYPES = ('Flag', 'Integer', 'Float', 'String')
 * cdef tuple METADATA_TYPES = ('FILTER', 'INFO', 'FORMAT', 'CONTIG', 'STRUCTURED', 'GENERIC')
 */
  __pyx_v_5pysam_7libcbcf_MAX_POS = 0x7FFFFFFF;

  /* "pysam/libcbcf.pyx":115
 * 
 * cdef int MAX_POS = (1 << 31) - 1
 * cdef tuple VALUE_TYPES = ('Flag', 'Integer', 'Float', 'String')             # <<<<<<<<<<<<<<
 * cdef tuple METADATA_TYPES = ('FILTER', 'INFO', 'FORMAT', 'CONTIG', 'STRUCTURED', 'GENERIC')
 * cdef tuple METADATA_LENGTHS = ('FIXED', 'VARIABLE', 'A', 'G', 'R')
 */
  __Pyx_INCREF(__pyx_tuple__252);
  __Pyx_XGOTREF(__pyx_v_5pysam_7libcbcf_VALUE_TYPES);
  __Pyx_DECREF_SET(__pyx_v_5pysam_7libcbcf_VALUE_TYPES, __pyx_tuple__252);
  __Pyx_GIVEREF(__pyx_tuple__252);

  /* "pysam/libcbcf.pyx":116
 * cdef int MAX_POS = (1 << 31) - 1
 * cdef tuple VALUE_TYPES = ('Flag', 'Integer', 'Float', 'String')
 * cdef tuple METADATA_TYPES = ('FILTER', 'INFO', 'FORMAT', 'CONTIG', 'STRUCTURED', 'GENERIC')             # <<<<<<<<<<<<<<
 * cdef tuple METADATA_LENGTHS = ('FIXED', 'VARIABLE', 'A', 'G', 'R')
 * 
 */
  __Pyx_INCREF(__pyx_tuple__253);
  __Pyx_XGOTREF(__pyx_v_5pysam_7libcbcf_METADATA_TYPES);
  __Pyx_DECREF_SET(__pyx_v_5pysam_7libcbcf_METADATA_TYPES, __pyx_tuple__253);
  __Pyx_GIVEREF(__pyx_tuple__253);

  /* "pysam/libcbcf.pyx":117
 * cdef tuple VALUE_TYPES = ('Flag', 'Integer', 'Float', 'String')
 * cdef tuple METADATA_TYPES = ('FILTER', 'INFO', 'FORMAT', 'CONTIG', 'STRUCTURED', 'GENERIC')
 * cdef tuple METADATA_LENGTHS = ('FIXED', 'VARIABLE', 'A', 'G', 'R')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_INCREF(__pyx_tuple__254);
  __Pyx_XGOTREF(__pyx_v_5pysam_7libcbcf_METADATA_LENGTHS);
  __Pyx_DECREF_SET(__pyx_v_5pysam_7libcbcf_METADATA_LENGTHS, __pyx_tuple__254);
  __Pyx_GIVEREF(__pyx_tuple__254);

  /* "pysam/libcbcf.pyx":134
 * ########################################################################
 * 
 * cdef object _nothing = object()             # <<<<<<<<<<<<<<
 * 
 * ########################################################################
 */
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_object); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(__pyx_v_5pysam_7libcbcf__nothing);
  __Pyx_DECREF_SET(__pyx_v_5pysam_7libcbcf__nothing, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":141
 * ########################################################################
 * 
 * cdef dict bcf_str_cache = {}             # <<<<<<<<<<<<<<
 * 
 * cdef inline bcf_str_cache_get_charptr(const char* s):
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(__pyx_v_5pysam_7libcbcf_bcf_str_cache);
  __Pyx_DECREF_SET(__pyx_v_5pysam_7libcbcf_bcf_str_cache, ((PyObject*)__pyx_t_1));
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":1356
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         try:
 *             value = self[key]
 */
  __Pyx_INCREF(__pyx_v_5pysam_7libcbcf__nothing);
  __pyx_k__61 = __pyx_v_5pysam_7libcbcf__nothing;
  __Pyx_GIVEREF(__pyx_v_5pysam_7libcbcf__nothing);

  /* "pysam/libcbcf.pyx":1367
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 *     __hash__ = None             # <<<<<<<<<<<<<<
 * 
 *     #TODO: implement __richcmp__
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderRecord->tp_dict, __pyx_n_s_hash, Py_None) < 0) __PYX_ERR(0, 1367, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_5pysam_7libcbcf_VariantHeaderRecord);

  /* "pysam/libcbcf.pyx":1438
 *             yield makeVariantHeaderRecord(self.header, self.header.ptr.hrec[i])
 * 
 *     __hash__ = None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderRecords->tp_dict, __pyx_n_s_hash, Py_None) < 0) __PYX_ERR(0, 1438, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_5pysam_7libcbcf_VariantHeaderRecords);

  /* "pysam/libcbcf.pyx":1675
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 *     __hash__ = None             # <<<<<<<<<<<<<<
 * 
 *     #TODO: implement __richcmp__
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderMetadata->tp_dict, __pyx_n_s_hash, Py_None) < 0) __PYX_ERR(0, 1675, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_5pysam_7libcbcf_VariantHeaderMetadata);

  /* "pysam/libcbcf.pyx":1855
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 *     __hash__ = None             # <<<<<<<<<<<<<<
 * 
 *     #TODO: implement __richcmp__
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderContigs->tp_dict, __pyx_n_s_hash, Py_None) < 0) __PYX_ERR(0, 1855, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_5pysam_7libcbcf_VariantHeaderContigs);

  /* "pysam/libcbcf.pyx":1916
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 *     __hash__ = None             # <<<<<<<<<<<<<<
 * 
 *     #TODO: implement __richcmp__
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantHeaderSamples->tp_dict, __pyx_n_s_hash, Py_None) < 0) __PYX_ERR(0, 1916, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_5pysam_7libcbcf_VariantHeaderSamples);

  /* "pysam/libcbcf.pyx":2335
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 *     __hash__ = None             # <<<<<<<<<<<<<<
 * 
 *     #TODO: implement __richcmp__
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordFilter->tp_dict, __pyx_n_s_hash, Py_None) < 0) __PYX_ERR(0, 2335, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_5pysam_7libcbcf_VariantRecordFilter);

  /* "pysam/libcbcf.pyx":2469
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 *     __hash__ = None             # <<<<<<<<<<<<<<
 * 
 *     #TODO: implement __richcmp__
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordFormat->tp_dict, __pyx_n_s_hash, Py_None) < 0) __PYX_ERR(0, 2469, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_5pysam_7libcbcf_VariantRecordFormat);

  /* "pysam/libcbcf.pyx":2753
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         cdef bcf_hdr_t *hdr = self.record.header.ptr
 *         cdef bcf1_t *r = self.record.ptr
 */
  __Pyx_INCREF(__pyx_v_5pysam_7libcbcf__nothing);
  __pyx_k__133 = __pyx_v_5pysam_7libcbcf__nothing;
  __Pyx_GIVEREF(__pyx_v_5pysam_7libcbcf__nothing);

  /* "pysam/libcbcf.pyx":2806
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 *     __hash__ = None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordInfo->tp_dict, __pyx_n_s_hash, Py_None) < 0) __PYX_ERR(0, 2806, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_5pysam_7libcbcf_VariantRecordInfo);

  /* "pysam/libcbcf.pyx":2930
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         try:
 *             value = self[key]
 */
  __Pyx_INCREF(__pyx_v_5pysam_7libcbcf__nothing);
  __pyx_k__140 = __pyx_v_5pysam_7libcbcf__nothing;
  __Pyx_GIVEREF(__pyx_v_5pysam_7libcbcf__nothing);

  /* "pysam/libcbcf.pyx":2955
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 *     __hash__ = None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordSamples->tp_dict, __pyx_n_s_hash, Py_None) < 0) __PYX_ERR(0, 2955, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_5pysam_7libcbcf_VariantRecordSamples);

  /* "pysam/libcbcf.pyx":3522
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         try:
 *             value = self[key]
 */
  __Pyx_INCREF(__pyx_v_5pysam_7libcbcf__nothing);
  __pyx_k__180 = __pyx_v_5pysam_7libcbcf__nothing;
  __Pyx_GIVEREF(__pyx_v_5pysam_7libcbcf__nothing);

  /* "pysam/libcbcf.pyx":3544
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 *     __hash__ = None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5pysam_7libcbcf_VariantRecordSample->tp_dict, __pyx_n_s_hash, Py_None) < 0) __PYX_ERR(0, 3544, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_5pysam_7libcbcf_VariantRecordSample);

  /* "pysam/libcbcf.pyx":3637
 *                 self[k] = v
 * 
 *     def pop(self, key, default=_nothing):             # <<<<<<<<<<<<<<
 *         try:
 *             value = self[key]
 */
  __Pyx_INCREF(__pyx_v_5pysam_7libcbcf__nothing);
  __pyx_k__182 = __pyx_v_5pysam_7libcbcf__nothing;
  __Pyx_GIVEREF(__pyx_v_5pysam_7libcbcf__nothing);

  /* "pysam/libcbcf.pyx":3648
 * 
 *     # Mappings are not hashable by default, but subclasses can change this
 *     __hash__ = None             # <<<<<<<<<<<<<<
 * 
 *     #TODO: implement __richcmp__
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5pysam_7libcbcf_BaseIndex->tp_dict, __pyx_n_s_hash, Py_None) < 0) __PYX_ERR(0, 3648, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_5pysam_7libcbcf_BaseIndex);

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantHeaderRecords(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pysam_7libcbcf_1__pyx_unpickle_VariantHeaderRecords, NULL, __pyx_n_s_pysam_libcbcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_VariantHeaderReco, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantHeaderRecords__set_state(<VariantHeaderRecords> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderRecords__set_state(VariantHeaderRecords __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pysam_7libcbcf_3__pyx_unpickle_VariantMetadata, NULL, __pyx_n_s_pysam_libcbcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_VariantMetadata, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantHeaderMetadata(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xed5e66b:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pysam_7libcbcf_5__pyx_unpickle_VariantHeaderMetadata, NULL, __pyx_n_s_pysam_libcbcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_VariantHeaderMeta, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantHeaderMetadata__set_state(<VariantHeaderMetadata> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderMetadata__set_state(VariantHeaderMetadata __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]; __pyx_result.type = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pysam_7libcbcf_7__pyx_unpickle_VariantContig, NULL, __pyx_n_s_pysam_libcbcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_VariantContig, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantHeaderContigs(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x099fb99:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pysam_7libcbcf_9__pyx_unpickle_VariantHeaderContigs, NULL, __pyx_n_s_pysam_libcbcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_VariantHeaderCont, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantHeaderContigs__set_state(<VariantHeaderContigs> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantHeaderContigs__set_state(VariantHeaderContigs __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.header = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pysam_7libcbcf_11__pyx_unpickle_VariantHeaderSamples, NULL, __pyx_n_s_pysam_libcbcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_VariantHeaderSamp, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordFilter(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pysam_7libcbcf_13__pyx_unpickle_VariantRecordFilter, NULL, __pyx_n_s_pysam_libcbcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_VariantRecordFilt, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordFilter__set_state(<VariantRecordFilter> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordFilter__set_state(VariantRecordFilter __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pysam_7libcbcf_15__pyx_unpickle_VariantRecordFormat, NULL, __pyx_n_s_pysam_libcbcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_VariantRecordForm, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordInfo(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xde17f0f:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pysam_7libcbcf_17__pyx_unpickle_VariantRecordInfo, NULL, __pyx_n_s_pysam_libcbcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_VariantRecordInfo, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordInfo__set_state(<VariantRecordInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordInfo__set_state(VariantRecordInfo __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.record = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pysam_7libcbcf_19__pyx_unpickle_VariantRecordSamples, NULL, __pyx_n_s_pysam_libcbcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_VariantRecordSamp, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VariantRecordSample(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x5d6ff7b:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pysam_7libcbcf_21__pyx_unpickle_VariantRecordSample, NULL, __pyx_n_s_pysam_libcbcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_VariantRecordSamp_2, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_VariantRecordSample__set_state(<VariantRecordSample> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VariantRecordSample__set_state(VariantRecordSample __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.index = __pyx_state[0]; __pyx_result.record = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pysam_7libcbcf_23__pyx_unpickle_BaseIndex, NULL, __pyx_n_s_pysam_libcbcf); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_BaseIndex, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysam/libcbcf.pyx":1
 * # cython: embedsignature=True             # <<<<<<<<<<<<<<
 * # cython: profile=True
 * ###############################################################################
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "array.pxd":161
 *     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)
 */
  __Pyx_TraceReturn(Py_None, 0);

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init pysam.libcbcf", 0, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init pysam.libcbcf");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #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

/* PyObjectGetAttrStr */
#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);
}
#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;
}

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

/* Profile */
#if CYTHON_PROFILE
static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
                                   PyFrameObject** frame,
                                   PyThreadState* tstate,
                                   const char *funcname,
                                   const char *srcfile,
                                   int firstlineno) {
    PyObject *type, *value, *traceback;
    int retval;
    if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) {
        if (*code == NULL) {
            *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno);
            if (*code == NULL) return 0;
        }
        *frame = PyFrame_New(
            tstate,                          /*PyThreadState *tstate*/
            *code,                           /*PyCodeObject *code*/
            __pyx_d,                  /*PyObject *globals*/
            0                                /*PyObject *locals*/
        );
        if (*frame == NULL) return 0;
        if (CYTHON_TRACE && (*frame)->f_trace == NULL) {
            Py_INCREF(Py_None);
            (*frame)->f_trace = Py_None;
        }
#if PY_VERSION_HEX < 0x030400B1
    } else {
        (*frame)->f_tstate = tstate;
#endif
    }
      __Pyx_PyFrame_SetLineNumber(*frame, firstlineno);
    retval = 1;
    tstate->tracing++;
    tstate->use_tracing = 0;
    __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
    #if CYTHON_TRACE
    if (tstate->c_tracefunc)
        retval = tstate->c_tracefunc(tstate->c_traceobj, *frame, PyTrace_CALL, NULL) == 0;
    if (retval && tstate->c_profilefunc)
    #endif
        retval = tstate->c_profilefunc(tstate->c_profileobj, *frame, PyTrace_CALL, NULL) == 0;
    tstate->use_tracing = (tstate->c_profilefunc ||
                           (CYTHON_TRACE && tstate->c_tracefunc));
    tstate->tracing--;
    if (retval) {
        __Pyx_ErrRestoreInState(tstate, type, value, traceback);
        return tstate->use_tracing && retval;
    } else {
        Py_XDECREF(type);
        Py_XDECREF(value);
        Py_XDECREF(traceback);
        return -1;
    }
}
static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyCodeObject *py_code = 0;
    #if PY_MAJOR_VERSION < 3
    py_funcname = PyString_FromString(funcname);
    py_srcfile = PyString_FromString(srcfile);
    #else
    py_funcname = PyUnicode_FromString(funcname);
    py_srcfile = PyUnicode_FromString(srcfile);
    #endif
    if (!py_funcname | !py_srcfile) goto bad;
    py_code = PyCode_New(
        0,
        #if PY_MAJOR_VERSION >= 3
        0,
        #endif
        0,
        0,
        CO_OPTIMIZED | CO_NEWLOCALS,
        __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,*/
        firstlineno,
        __pyx_empty_bytes      /*PyObject *lnotab*/
    );
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return py_code;
}
#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;
}

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

/* 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
                    }
                    CYTHON_FALLTHROUGH;
                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
                    }
                    CYTHON_FALLTHROUGH;
                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
                    }
                    CYTHON_FALLTHROUGH;
                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
                    }
                    CYTHON_FALLTHROUGH;
                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
                    }
                    CYTHON_FALLTHROUGH;
                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
                    }
                    CYTHON_FALLTHROUGH;
                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

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

/* 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 (cause) {
        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 = __Pyx_PyThreadState_Current;
        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

/* GetException */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
#endif
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if PY_VERSION_HEX >= 0x030700A3
    tmp_type = tstate->exc_state.exc_type;
    tmp_value = tstate->exc_state.exc_value;
    tmp_tb = tstate->exc_state.exc_traceback;
    tstate->exc_state.exc_type = local_type;
    tstate->exc_state.exc_value = local_value;
    tstate->exc_state.exc_traceback = local_tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* 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;
    #if PY_VERSION_HEX >= 0x030700A3
    tmp_type = tstate->exc_state.exc_type;
    tmp_value = tstate->exc_state.exc_value;
    tmp_tb = tstate->exc_state.exc_traceback;
    tstate->exc_state.exc_type = *type;
    tstate->exc_state.exc_value = *value;
    tstate->exc_state.exc_traceback = *tb;
    #else
    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;
    #endif
    *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

/* SaveResetException */
  #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if PY_VERSION_HEX >= 0x030700A3
    *type = tstate->exc_state.exc_type;
    *value = tstate->exc_state.exc_value;
    *tb = tstate->exc_state.exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if PY_VERSION_HEX >= 0x030700A3
    tmp_type = tstate->exc_state.exc_type;
    tmp_value = tstate->exc_state.exc_value;
    tmp_tb = tstate->exc_state.exc_traceback;
    tstate->exc_state.exc_type = type;
    tstate->exc_state.exc_value = value;
    tstate->exc_state.exc_traceback = tb;
    #else
    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;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* None */
  static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

/* UnpackUnboundCMethod */
  static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
    }
#endif
    return 0;
}

/* CallUnboundCMethod1 */
  #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
    if (likely(cfunc->func)) {
        int flag = cfunc->flag;
        if (flag == METH_O) {
            return (*(cfunc->func))(self, arg);
        } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
            if (PY_VERSION_HEX >= 0x030700A0) {
                return (*(__Pyx_PyCFunctionFast)cfunc->func)(self, &arg, 1);
            } else {
                return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, &arg, 1, NULL);
            }
        } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
            return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, &arg, 1, NULL);
        }
    }
    return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 0, arg);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 1, arg);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(2, self, arg);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* 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);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
    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());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
    }
}
#endif

/* 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 = __Pyx_PyThreadState_Current;
    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
#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
    if (likely(PyCFunction_Check(func))) {
        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

/* PyObjectCallMethod1 */
  static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = NULL;
#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);
            result = __Pyx_PyObject_Call(function, args, NULL);
            Py_DECREF(args);
            Py_DECREF(function);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallOneArg(method, arg);
    goto done;
done:
    return result;
}
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method, *result;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) return NULL;
    result = __Pyx__PyObject_CallMethod1(method, arg);
    Py_DECREF(method);
    return result;
}

/* append */
  static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

/* GetItemInt */
  static 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
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_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
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_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));
}

/* StringJoin */
  #if !CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
    return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
}
#endif

/* 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;
#if CYTHON_USE_UNICODE_INTERNALS
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            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
}

/* UnicodeEquals */
  static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        #if PY_MAJOR_VERSION < 3
        Py_XDECREF(owned_ref);
        #endif
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

/* PyObjectSetAttrStr */
  #if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#endif

/* KeywordStringCheck */
  static 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_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;
}

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

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

/* ObjectGetItem */
  #if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
    PyObject *runerr;
    Py_ssize_t key_value;
    PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
    if (unlikely(!(m && m->sq_item))) {
        PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
        return NULL;
    }
    key_value = __Pyx_PyIndex_AsSsize_t(index);
    if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
        return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
    }
    if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
        PyErr_Clear();
        PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
    }
    return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
    PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
    if (likely(m && m->mp_subscript)) {
        return m->mp_subscript(obj, key);
    }
    return __Pyx_PyObject_GetIndex(obj, key);
}
#endif

/* PyErrExceptionMatches */
  #if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#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) || __Pyx_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

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

/* 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");
}

/* IterFinish */
    static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_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
}

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

/* CallUnboundCMethod0 */
    static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_ASSUME_SAFE_MACROS
    args = PyTuple_New(1);
    if (unlikely(!args)) goto bad;
    Py_INCREF(self);
    PyTuple_SET_ITEM(args, 0, self);
#else
    args = PyTuple_Pack(1, self);
    if (unlikely(!args)) goto bad;
#endif
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    Py_DECREF(args);
bad:
    return result;
}

/* py_dict_items */
    static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
    if (PY_MAJOR_VERSION >= 3)
        return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_items, d);
    else
        return PyDict_Items(d);
}

/* GetAttr */
    static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* GetAttr3 */
    static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    Py_INCREF(d);
    return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}

/* GetModuleGlobalName */
    static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    if (likely(result)) {
        Py_INCREF(result);
    } else if (unlikely(PyErr_Occurred())) {
        result = NULL;
    } else {
#else
    result = PyDict_GetItem(__pyx_d, name);
    if (likely(result)) {
        Py_INCREF(result);
    } else {
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

/* ArgTypeTest */
        static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

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

/* CallUnboundCMethod2 */
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
    if (likely(cfunc->func)) {
        PyObject *args[2] = {arg1, arg2};
        if (cfunc->flag == METH_FASTCALL) {
            #if PY_VERSION_HEX >= 0x030700A0
            return (*(__Pyx_PyCFunctionFast)cfunc->func)(self, args, 2);
            #else
            return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, args, 2, NULL);
            #endif
        }
        #if PY_VERSION_HEX >= 0x030700A0
        if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
            return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, args, 2, NULL);
        #endif
    }
    return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 0, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 1, arg2);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(3);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 1, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 2, arg2);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(3, self, arg1, arg2);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* py_dict_pop */
        static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B3
    if ((1)) {
        return _PyDict_Pop(d, key, default_value);
    } else
#endif
    if (default_value) {
        return __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_pop, d, key, default_value);
    } else {
        return __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_pop, d, key);
    }
}

/* SetItemInt */
        static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
                                               CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return -1;
                    PyErr_Clear();
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
#else
    if (is_list || PySequence_Check(o)) {
#endif
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

/* 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
                    }
                    CYTHON_FALLTHROUGH;
                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
                    }
                    CYTHON_FALLTHROUGH;
                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
                    }
                    CYTHON_FALLTHROUGH;
                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
                    }
                    CYTHON_FALLTHROUGH;
                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
                    }
                    CYTHON_FALLTHROUGH;
                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
                    }
                    CYTHON_FALLTHROUGH;
                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

/* 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(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* SliceObject */
          static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_USE_TYPE_SLOTS
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    goto bad;
                PyErr_Clear();
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_USE_TYPE_SLOTS
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* 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_MAJOR_VERSION < 3
    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, '.')) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            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_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
          static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* HasAttr */
          static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* CallNextTpDealloc */
          static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_dealloc != current_tp_dealloc)
        type = type->tp_base;
    while (type && type->tp_dealloc == current_tp_dealloc)
        type = type->tp_base;
    if (type)
        type->tp_dealloc(obj);
}

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

/* PyObject_GenericGetAttrNoDict */
          #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* PyObject_GenericGetAttr */
          #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
    if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif

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

/* SetupReduce */
          static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
#else
    if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
            ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
            ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto GOOD;
BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

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

/* CLineInTraceback */
          #ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
      use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (PyObject_Not(use_cline) != 0) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* 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;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    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(
        tstate,            /*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_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);
    }
}

/* 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_int32_t(int32_t value) {
    const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int32_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int32_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int32_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int32_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(int32_t),
                                     little, !is_unsigned);
    }
}

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

/* CIntToPy */
          static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int8_t(int8_t value) {
    const int8_t neg_one = (int8_t) -1, const_zero = (int8_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int8_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int8_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int8_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int8_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int8_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(int8_t),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
          static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int16_t(int16_t value) {
    const int16_t neg_one = (int16_t) -1, const_zero = (int16_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int16_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int16_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int16_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int16_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int16_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(int16_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);
    }
}

/* CIntToPy */
          static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value) {
    const uint8_t neg_one = (uint8_t) -1, const_zero = (uint8_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(uint8_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(uint8_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint8_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(uint8_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint8_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(uint8_t),
                                     little, !is_unsigned);
    }
}

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

/* 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 int32_t __Pyx_PyInt_As_int32_t(PyObject *x) {
    const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int32_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int32_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int32_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 (int32_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int32_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) >= 2 * PyLong_SHIFT) {
                            return (int32_t) (((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) >= 3 * PyLong_SHIFT) {
                            return (int32_t) (((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_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(int32_t) >= 4 * PyLong_SHIFT) {
                            return (int32_t) (((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_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 (int32_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int32_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int32_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 (int32_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int32_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int32_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int32_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int32_t) (((int32_t)-1)*(((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int32_t) ((((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int32_t) (((int32_t)-1)*(((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int32_t) ((((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_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(int32_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int32_t) (((int32_t)-1)*(((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_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(int32_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int32_t) ((((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int32_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int32_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int32_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int32_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
            int32_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 (int32_t) -1;
        }
    } else {
        int32_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int32_t) -1;
        val = __Pyx_PyInt_As_int32_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int32_t");
    return (int32_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int32_t");
    return (int32_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;
}

/* CIntFromPy */
          static CYTHON_INLINE int8_t __Pyx_PyInt_As_int8_t(PyObject *x) {
    const int8_t neg_one = (int8_t) -1, const_zero = (int8_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int8_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int8_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int8_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 (int8_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int8_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(int8_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int8_t) >= 2 * PyLong_SHIFT) {
                            return (int8_t) (((((int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int8_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int8_t) >= 3 * PyLong_SHIFT) {
                            return (int8_t) (((((((int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int8_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int8_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(int8_t) >= 4 * PyLong_SHIFT) {
                            return (int8_t) (((((((((int8_t)digits[3]) << PyLong_SHIFT) | (int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_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 (int8_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int8_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int8_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int8_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int8_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 (int8_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int8_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int8_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int8_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int8_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int8_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int8_t) (((int8_t)-1)*(((((int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int8_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int8_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int8_t) ((((((int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int8_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int8_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int8_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int8_t) (((int8_t)-1)*(((((((int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int8_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int8_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int8_t) ((((((((int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int8_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int8_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(int8_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int8_t) (((int8_t)-1)*(((((((((int8_t)digits[3]) << PyLong_SHIFT) | (int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int8_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int8_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(int8_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int8_t) ((((((((((int8_t)digits[3]) << PyLong_SHIFT) | (int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int8_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int8_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int8_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int8_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
            int8_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 (int8_t) -1;
        }
    } else {
        int8_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int8_t) -1;
        val = __Pyx_PyInt_As_int8_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int8_t");
    return (int8_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int8_t");
    return (int8_t) -1;
}

/* CIntFromPy */
          static CYTHON_INLINE int16_t __Pyx_PyInt_As_int16_t(PyObject *x) {
    const int16_t neg_one = (int16_t) -1, const_zero = (int16_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int16_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int16_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int16_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 (int16_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int16_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(int16_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) >= 2 * PyLong_SHIFT) {
                            return (int16_t) (((((int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int16_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) >= 3 * PyLong_SHIFT) {
                            return (int16_t) (((((((int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int16_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_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(int16_t) >= 4 * PyLong_SHIFT) {
                            return (int16_t) (((((((((int16_t)digits[3]) << PyLong_SHIFT) | (int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_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 (int16_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int16_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int16_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int16_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int16_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 (int16_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int16_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int16_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int16_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int16_t) (((int16_t)-1)*(((((int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int16_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int16_t) ((((((int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int16_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int16_t) (((int16_t)-1)*(((((((int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int16_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int16_t) ((((((((int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int16_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_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(int16_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int16_t) (((int16_t)-1)*(((((((((int16_t)digits[3]) << PyLong_SHIFT) | (int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int16_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_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(int16_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int16_t) ((((((((((int16_t)digits[3]) << PyLong_SHIFT) | (int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int16_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int16_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int16_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int16_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
            int16_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 (int16_t) -1;
        }
    } else {
        int16_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int16_t) -1;
        val = __Pyx_PyInt_As_int16_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int16_t");
    return (int16_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int16_t");
    return (int16_t) -1;
}

/* CIntFromPy */
          static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *x) {
    const uint32_t neg_one = (uint32_t) -1, const_zero = (uint32_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(uint32_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(uint32_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (uint32_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 (uint32_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(uint32_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) >= 2 * PyLong_SHIFT) {
                            return (uint32_t) (((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) >= 3 * PyLong_SHIFT) {
                            return (uint32_t) (((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_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(uint32_t) >= 4 * PyLong_SHIFT) {
                            return (uint32_t) (((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_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 (uint32_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(uint32_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint32_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 (uint32_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(uint32_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(uint32_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(uint32_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint32_t) (((uint32_t)-1)*(((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint32_t) ((((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint32_t) (((uint32_t)-1)*(((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint32_t) ((((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_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(uint32_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint32_t) (((uint32_t)-1)*(((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_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(uint32_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint32_t) ((((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(uint32_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint32_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
            uint32_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 (uint32_t) -1;
        }
    } else {
        uint32_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (uint32_t) -1;
        val = __Pyx_PyInt_As_uint32_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to uint32_t");
    return (uint32_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to uint32_t");
    return (uint32_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;
}

/* FastTypeChecks */
          #if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

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

/* CoroutineBase */
          #include <structmember.h>
#include <frameobject.h>
#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __Pyx_ErrFetch(&et, &ev, &tb);
    if (!et) {
        Py_XDECREF(tb);
        Py_XDECREF(ev);
        Py_INCREF(Py_None);
        *pvalue = Py_None;
        return 0;
    }
    if (likely(et == PyExc_StopIteration)) {
        if (!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 (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            value = ev;
        }
        if (likely(value)) {
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
    } else if (!__Pyx_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;
}
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);
}
#define __Pyx_Coroutine_AlreadyRunningError(gen)  (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
    const char *msg;
    if (0) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
        msg = "coroutine already executing";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
        msg = "async generator already executing";
    #endif
    } else {
        msg = "generator already executing";
    }
    PyErr_SetString(PyExc_ValueError, msg);
}
#define __Pyx_Coroutine_NotStartedError(gen)  (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
    const char *msg;
    if (0) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check(gen)) {
        msg = "can't send non-None value to a just-started coroutine";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact(gen)) {
        msg = "can't send non-None value to a just-started async generator";
    #endif
    } else {
        msg = "can't send non-None value to a just-started generator";
    }
    PyErr_SetString(PyExc_TypeError, msg);
}
#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing)  (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
    #ifdef __Pyx_Coroutine_USED
    if (!closing && __Pyx_Coroutine_Check(gen)) {
        PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
    } else
    #endif
    if (value) {
        #ifdef __Pyx_AsyncGen_USED
        if (__Pyx_AsyncGen_CheckExact(gen))
            PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
        else
        #endif
        PyErr_SetNone(PyExc_StopIteration);
    }
}
static
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
    __Pyx_PyThreadState_declare
    PyThreadState *tstate;
    PyObject *retval;
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            return __Pyx_Coroutine_NotStartedError((PyObject*)self);
        }
    }
    if (unlikely(self->resume_label == -1)) {
        return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
    }
#if CYTHON_FAST_THREAD_STATE
    __Pyx_PyThreadState_assign
    tstate = __pyx_tstate;
#else
    tstate = __Pyx_PyThreadState_Current;
#endif
    if (self->exc_type) {
#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(tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = tstate->frame;
        }
#endif
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(self);
        __Pyx_ExceptionSave(&self->exc_type, &self->exc_value, &self->exc_traceback);
    }
    self->is_running = 1;
    retval = self->body((PyObject *) self, tstate, value);
    self->is_running = 0;
    return retval;
}
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self) {
    if (likely(self->exc_traceback)) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
#else
        PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
        PyFrameObject *f = tb->tb_frame;
        Py_CLEAR(f->f_back);
#endif
    }
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
    if (unlikely(!retval)) {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        if (!__Pyx_PyErr_Occurred()) {
            PyObject *exc = PyExc_StopIteration;
            #ifdef __Pyx_AsyncGen_USED
            if (__Pyx_AsyncGen_CheckExact(gen))
                exc = __Pyx_PyExc_StopAsyncIteration;
            #endif
            __Pyx_PyErr_SetNone(exc);
        }
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
    ret = __Pyx_Coroutine_SendEx(gen, val, 0);
    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(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    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_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_AsyncGen_USED
        if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
            ret = __Pyx_async_gen_asend_send(yf, value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyCoro_CheckExact(yf)) {
            ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : 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, 0);
    }
    return __Pyx_Coroutine_MethodReturn(self, 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_Check(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    if (__Pyx_CoroutineAwait_CheckExact(yf)) {
        retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_AsyncGen_USED
    if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
        retval = __Pyx_async_gen_asend_close(yf, NULL);
    } else
    if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
        retval = __Pyx_async_gen_athrow_close(yf, NULL);
    } 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(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Next(yf);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = _PyGen_Send((PyGenObject*)yf, NULL);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, Py_None);
        } 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, 0);
}
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(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    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, 1);
    if (unlikely(retval)) {
        const char *msg;
        Py_DECREF(retval);
        if ((0)) {
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_Coroutine_Check(self)) {
            msg = "coroutine ignored GeneratorExit";
        #endif
        #ifdef __Pyx_AsyncGen_USED
        } else if (__Pyx_AsyncGen_CheckExact(self)) {
#if PY_VERSION_HEX < 0x03060000
            msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
#else
            msg = "async generator ignored GeneratorExit";
#endif
        #endif
        } else {
            msg = "generator ignored GeneratorExit";
        }
        PyErr_SetString(PyExc_RuntimeError, msg);
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
        if (raised_exception) PyErr_Clear();
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
                                        PyObject *args, int close_on_genexit) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
            goto throw_here;
        }
        gen->is_running = 1;
        if (0
        #ifdef __Pyx_Generator_USED
            || __Pyx_Generator_CheckExact(yf)
        #endif
        #ifdef __Pyx_Coroutine_USED
            || __Pyx_Coroutine_Check(yf)
        #endif
            ) {
            ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
            ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
        #endif
        } else {
            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;
            }
            if (likely(args)) {
                ret = PyObject_CallObject(meth, args);
            } else {
                ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
            }
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Coroutine_FinishDelegation(gen);
        }
        return __Pyx_Coroutine_MethodReturn(self, ret);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    PyObject *typ;
    PyObject *val = NULL;
    PyObject *tb = NULL;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
}
static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
    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);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
    }
#endif
    Py_CLEAR(gen->gi_code);
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    Py_CLEAR(gen->gi_modulename);
    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 && CYTHON_USE_TP_FINALIZE
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (self->ob_refcnt > 0)
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        /* We have to handle this case for asynchronous generators
           right here, because this code has to be between UNTRACK
           and GC_Del. */
        Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
    }
#endif
    __Pyx_Coroutine_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    __Pyx_PyThreadState_declare
    if (gen->resume_label < 0) {
        return;
    }
#if !CYTHON_USE_TP_FINALIZE
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
        PyObject *finalizer = agen->ag_finalizer;
        if (finalizer && !agen->ag_closed) {
            PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
            if (unlikely(!res)) {
                PyErr_WriteUnraisable(self);
            } else {
                Py_DECREF(res);
            }
            __Pyx_ErrRestore(error_type, error_value, error_traceback);
            return;
        }
    }
#endif
    if (unlikely(gen->resume_label == 0 && !error_value)) {
#ifdef __Pyx_Coroutine_USED
#ifdef __Pyx_Generator_USED
    if (!__Pyx_Generator_CheckExact(self))
#endif
        {
        PyObject_GC_UnTrack(self);
#if PY_MAJOR_VERSION >= 3  || defined(PyErr_WarnFormat)
        if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
            PyErr_WriteUnraisable(self);
#else
        {PyObject *msg;
        char *cmsg;
        #if CYTHON_COMPILING_IN_PYPY
        msg = NULL;
        cmsg = (char*) "coroutine was never awaited";
        #else
        char *cname;
        PyObject *qualname;
        qualname = gen->gi_qualname;
        cname = PyString_AS_STRING(qualname);
        msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
        if (unlikely(!msg)) {
            PyErr_Clear();
            cmsg = (char*) "coroutine was never awaited";
        } else {
            cmsg = PyString_AS_STRING(msg);
        }
        #endif
        if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
            PyErr_WriteUnraisable(self);
        Py_XDECREF(msg);}
#endif
        PyObject_GC_Track(self);
        }
#endif
    } else {
        PyObject *res = __Pyx_Coroutine_Close(self);
        if (unlikely(!res)) {
            if (PyErr_Occurred())
                PyErr_WriteUnraisable(self);
        } else {
            Py_DECREF(res);
        }
    }
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if !CYTHON_USE_TP_FINALIZE
    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 *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
    if (unlikely(!gen))
        return NULL;
    return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
}
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    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;
    Py_XINCREF(code);
    gen->gi_code = code;
    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 */
              #ifndef CYTHON_REGISTER_ABCS
#define CYTHON_REGISTER_ABCS 1
#endif
#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 (CYTHON_REGISTER_ABCS && !abc_patched) {
        PyObject *module;
        module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
        if (!module) {
            PyErr_WriteUnraisable(NULL);
            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
                    ((PY_MAJOR_VERSION >= 3) ?
                        "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")},
    {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
    {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 CYTHON_USE_TP_FINALIZE
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if CYTHON_USE_TP_FINALIZE
    __Pyx_Coroutine_del,
#elif PY_VERSION_HEX >= 0x030400a1
    0,
#endif
};
static int __pyx_Generator_init(void) {
    __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
    __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

/* FunctionImport */
              #ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#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;
        if (PyObject_Hash(*t->p) == -1)
            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 const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    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
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(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
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __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)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } 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 PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
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 (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(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 = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  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_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
