/* Generated by Cython 0.16 on Fri Jun 22 14:51:24 2012 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02040000
    #error Cython requires Python 2.4+.
#else
#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif

#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif

#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif

#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif

#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif

#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyCFunction_Call PyObject_Call
#else
  #define __Pyx_PyCFunction_Call PyCFunction_Call
#endif

#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  #define __PYX_BUILD_PY_SSIZE_T "i"
#else
  #define __PYX_BUILD_PY_SSIZE_T "n"
#endif

#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
  #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)

  typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
  typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif

#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6
  #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
#endif

#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif

#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif


#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_GET_LENGTH)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#else
  #define CYTHON_PEP393_ENABLED 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]))
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif

#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)

#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif

#if PY_VERSION_HEX < 0x03020000
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif

#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif

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

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

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__MACS2__IO__cPeakIO
#define __PYX_HAVE_API__MACS2__IO__cPeakIO
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


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

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

typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

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

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

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

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))

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


static const char *__pyx_f[] = {
  "cPeakIO.pyx",
};

/*--- Type declarations ---*/
struct __pyx_defaults;
typedef struct __pyx_defaults __pyx_defaults;
struct __pyx_defaults1;
typedef struct __pyx_defaults1 __pyx_defaults1;
struct __pyx_defaults2;
typedef struct __pyx_defaults2 __pyx_defaults2;
struct __pyx_defaults3;
typedef struct __pyx_defaults3 __pyx_defaults3;
struct __pyx_defaults4;
typedef struct __pyx_defaults4 __pyx_defaults4;
struct __pyx_defaults5;
typedef struct __pyx_defaults5 __pyx_defaults5;
struct __pyx_defaults6;
typedef struct __pyx_defaults6 __pyx_defaults6;
struct __pyx_defaults7;
typedef struct __pyx_defaults7 __pyx_defaults7;
struct __pyx_defaults8;
typedef struct __pyx_defaults8 __pyx_defaults8;
struct __pyx_defaults9;
typedef struct __pyx_defaults9 __pyx_defaults9;
struct __pyx_defaults10;
typedef struct __pyx_defaults10 __pyx_defaults10;
struct __pyx_defaults {
  PyObject *__pyx_arg_print_func;
  PyObject *__pyx_arg_trackline;
};
struct __pyx_defaults1 {
  PyObject *__pyx_arg_print_func;
  PyObject *__pyx_arg_trackline;
};
struct __pyx_defaults2 {
  PyObject *__pyx_arg_trackline;
};
struct __pyx_defaults3 {
  PyObject *__pyx_arg_trackline;
};
struct __pyx_defaults4 {
  PyObject *__pyx_arg_trackline;
};
struct __pyx_defaults5 {
  PyObject *__pyx_arg_print_func;
  PyObject *__pyx_arg_trackline;
};
struct __pyx_defaults6 {
  PyObject *__pyx_arg_print_func;
  PyObject *__pyx_arg_trackline;
};
struct __pyx_defaults7 {
  PyObject *__pyx_arg_trackline;
};
struct __pyx_defaults8 {
  PyObject *__pyx_arg_trackline;
};
struct __pyx_defaults9 {
  PyObject *__pyx_arg_trackline;
};
struct __pyx_defaults10 {
  PyObject *__pyx_arg_trackline;
};
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          if (acquire_gil) { \
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
              PyGILState_Release(__pyx_gilstate_save); \
          } else { \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext() \
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

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

#ifndef CYTHON_PROFILE
  #define CYTHON_PROFILE 1
#endif
#ifndef CYTHON_PROFILE_REUSE_FRAME
  #define CYTHON_PROFILE_REUSE_FRAME 0
#endif
#if CYTHON_PROFILE
  #include "compile.h"
  #include "frameobject.h"
  #include "traceback.h"
  #if CYTHON_PROFILE_REUSE_FRAME
    #define CYTHON_FRAME_MODIFIER static
    #define CYTHON_FRAME_DEL
  #else
    #define CYTHON_FRAME_MODIFIER
    #define CYTHON_FRAME_DEL Py_DECREF(__pyx_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_TraceCall(funcname, srcfile, firstlineno)                            \
  if (unlikely(PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc)) {      \
      __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, funcname, srcfile, firstlineno);  \
  }
  #define __Pyx_TraceException()                                                           \
  if (unlikely(__Pyx_use_tracing( && PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc) {  \
      PyObject *exc_info = __Pyx_GetExceptionTuple();                                      \
      if (exc_info) {                                                                      \
          PyThreadState_GET()->c_profilefunc(                                              \
              PyThreadState_GET()->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);  \
          Py_DECREF(exc_info);                                                             \
      }                                                                                    \
  }
  #define __Pyx_TraceReturn(result)                                                  \
  if (unlikely(__Pyx_use_tracing) && PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc) {  \
      PyThreadState_GET()->c_profilefunc(                                            \
          PyThreadState_GET()->c_profileobj, __pyx_frame, PyTrace_RETURN, (PyObject*)result);     \
      CYTHON_FRAME_DEL;                                                               \
  }
  static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno); /*proto*/
  static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, const char *funcname, const char *srcfile, int firstlineno); /*proto*/
#else
  #define __Pyx_TraceDeclarations
  #define __Pyx_TraceCall(funcname, srcfile, firstlineno)
  #define __Pyx_TraceException()
  #define __Pyx_TraceReturn(result)
#endif /* CYTHON_PROFILE */

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

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

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

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

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

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

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

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

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

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

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

static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */
#define __Pyx_PyObject_AsDouble(obj) \
((likely(PyFloat_CheckExact(obj))) ? \
 PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))

static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void);

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

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

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

static CYTHON_INLINE void __Pyx_RaiseImportError(PyObject *name);

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

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

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

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static CYTHON_INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/

static int __Pyx_check_binary_version(void);

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

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

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


/* Module declarations from 'MACS2.IO.cPeakIO' */
static PyObject *__pyx_f_5MACS2_2IO_7cPeakIO_subpeak_letters(int); /*proto*/
#define __Pyx_MODULE_NAME "MACS2.IO.cPeakIO"
int __pyx_module_is_main_MACS2__IO__cPeakIO = 0;

/* Implementation of 'MACS2.IO.cPeakIO' */
static PyObject *__pyx_builtin_print;
static PyObject *__pyx_builtin_chr;
static PyObject *__pyx_builtin_sorted;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_StopIteration;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_2add(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_chromosome, long __pyx_v_start, long __pyx_v_end, long __pyx_v_summit, double __pyx_v_peak_score, int __pyx_v_pileup, double __pyx_v_pscore, double __pyx_v_fold_change, double __pyx_v_qscore); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_4filter_pscore(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_pscore_cut); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_6filter_qscore(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_qscore_cut); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_8filter_fc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fc_low, PyObject *__pyx_v_fc_up); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_10total(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_30__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_12_to_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, PyObject *__pyx_v_print_func, PyObject *__pyx_v_trackline); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_32__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_14_to_summits_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, PyObject *__pyx_v_print_func, PyObject *__pyx_v_trackline); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_16tobed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_18to_summits_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_34__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_20write_to_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, PyObject *__pyx_v_trackline); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_36__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_22write_to_summit_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, PyObject *__pyx_v_trackline); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_38__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_24write_to_narrowPeak(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_score_column, PyObject *__pyx_v_trackline); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_26write_to_xls(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_ofhd, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_28overlap_with_other_peaks(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_peaks2, double __pyx_v_cover); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6Region___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6Region_2add_loc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_chrom, int __pyx_v_start, int __pyx_v_end); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6Region_4sort(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6Region_6merge_overlap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6Region_8write_to_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_2add(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_chromosome, long __pyx_v_start, long __pyx_v_end, long __pyx_v_summit, double __pyx_v_diff_score, int __pyx_v_pileup, double __pyx_v_pscore, double __pyx_v_fold_change, double __pyx_v_qscore); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_4filter_pscore(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_pscore_cut); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_6filter_qscore(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_qscore_cut); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_8filter_fc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fc_low, PyObject *__pyx_v_fc_up); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_10total(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_26__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_12_to_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, PyObject *__pyx_v_print_func, PyObject *__pyx_v_trackline); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_28__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_14_to_summits_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, PyObject *__pyx_v_print_func, PyObject *__pyx_v_trackline); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_16tobed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_18to_summits_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_30__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_20write_to_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, CYTHON_UNUSED PyObject *__pyx_v_name, CYTHON_UNUSED PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, CYTHON_UNUSED PyObject *__pyx_v_trackline); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_32__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_22write_to_summit_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, CYTHON_UNUSED PyObject *__pyx_v_name, CYTHON_UNUSED PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, CYTHON_UNUSED PyObject *__pyx_v_trackline); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_34__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_24write_to_narrowPeak(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_score_column, PyObject *__pyx_v_trackline); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO_2add(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, char *__pyx_v_chromosome, long __pyx_v_start, long __pyx_v_end, long __pyx_v_score, long __pyx_v_thickStart, long __pyx_v_thickEnd, long __pyx_v_blockNum, char *__pyx_v_blockSizes, char *__pyx_v_blockStarts); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO_4total(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO_8__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO_6write_to_gappedPeak(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_trackline); /* proto */
static char __pyx_k_1[] = "%s_peak_";
static char __pyx_k_2[] = "%s";
static char __pyx_k_3[] = "\"";
static char __pyx_k_4[] = "\\\"";
static char __pyx_k_7[] = "track name=\"%s (peaks)\" description=\"%s\" visibility=1\n";
static char __pyx_k_8[] = "track name=MACS description=Unknown";
static char __pyx_k_11[] = "%s\t%d\t%d\t%s%d%s\t%.2f\n";
static char __pyx_k_12[] = "%s\t%d\t%d\t%s%d\t%.2f\n";
static char __pyx_k_15[] = "track name=\"%s (summits)\" description=\"%s\" visibility=1\n";
static char __pyx_k_18[] = "track type=narrowPeak name=\"%s\" description=\"%s\" nextItemButton=on\n";
static char __pyx_k_19[] = "%s\t%d\t%d\t%s%d\t%d\t.\t%.2f\t%.2f\t%.2f\t%d\n";
static char __pyx_k_20[] = "\t";
static char __pyx_k_21[] = "-log10(pvalue)";
static char __pyx_k_22[] = "-log10(qvalue)";
static char __pyx_k_25[] = "\n";
static char __pyx_k_27[] = "%s%d%s";
static char __pyx_k_28[] = "%s\t%d\t%d\t%d";
static char __pyx_k_29[] = "\t%d";
static char __pyx_k_30[] = "\t%.2f";
static char __pyx_k_31[] = "\t%s";
static char __pyx_k_33[] = "%s%d";
static char __pyx_k_35[] = "_Region__flag_sorted";
static char __pyx_k_36[] = "%s\t%d\t%d\n";
static char __pyx_k_45[] = "";
static char __pyx_k_46[] = "track name=\"%s\" description=\"%s\" type=bed nextItemButton=on\n";
static char __pyx_k_47[] = "%s\t%d\t%d\t%s%d\t%d\t.\t%d\t%d\t0\t%d\t%s\t%s\n";
static char __pyx_k_48[] = "Module for PeakIO IO classes.\n\nCopyright (c) 2010,2011 Tao Liu <taoliu@jimmy.harvard.edu>\n\nThis code is free software; you can redistribute it and/or modify it\nunder the terms of the Artistic License (see the file COPYING included\nwith the distribution).\n\n@status:  experimental\n@version: $Revision$\n@author:  Tao Liu\n@contact: taoliu@jimmy.harvard.edu\n";
static char __pyx_k_49[] = "MACS2.Constants";
static char __pyx_k_50[] = "*";
static char __pyx_k_51[] = "PeakIO $Revision$";
static char __pyx_k_52[] = "Tao Liu <taoliu@jimmy.harvard.edu>";
static char __pyx_k_53[] = "PeakIO class";
static char __pyx_k_56[] = "/Users/taoliu/Codes/Git/MACS_original/MACS/MACS2/IO/cPeakIO.pyx";
static char __pyx_k_57[] = "MACS2.IO.cPeakIO";
static char __pyx_k_88[] = "overlap_with_other_peaks";
static char __pyx_k_89[] = "IO for peak information.\n\n    ";
static char __pyx_k__a[] = "a";
static char __pyx_k__i[] = "i";
static char __pyx_k__j[] = "j";
static char __pyx_k__k[] = "k";
static char __pyx_k__p[] = "p";
static char __pyx_k__x[] = "x";
static char __pyx_k_100[] = "For plain region of chrom, start and end\n    ";
static char __pyx_k_128[] = "IO for differential peak information.\n\n    ";
static char __pyx_k_137[] = "IO for broad peak information.\n\n    ";
static char __pyx_k__fc[] = "fc";
static char __pyx_k__r1[] = "r1";
static char __pyx_k__r2[] = "r2";
static char __pyx_k__add[] = "add";
static char __pyx_k__chr[] = "chr";
static char __pyx_k__end[] = "end";
static char __pyx_k__fhd[] = "fhd";
static char __pyx_k__key[] = "key";
static char __pyx_k__MACS[] = "MACS";
static char __pyx_k__chrs[] = "chrs";
static char __pyx_k__desc[] = "desc";
static char __pyx_k__join[] = "join";
static char __pyx_k__keys[] = "keys";
static char __pyx_k__name[] = "name";
static char __pyx_k__next[] = "next";
static char __pyx_k__ofhd[] = "ofhd";
static char __pyx_k__peak[] = "peak";
static char __pyx_k__self[] = "self";
static char __pyx_k__sort[] = "sort";
static char __pyx_k__chrom[] = "chrom";
static char __pyx_k__chrs1[] = "chrs1";
static char __pyx_k__chrs2[] = "chrs2";
static char __pyx_k__count[] = "count";
static char __pyx_k__cover[] = "cover";
static char __pyx_k__fc_up[] = "fc_up";
static char __pyx_k__group[] = "group";
static char __pyx_k__peak_[] = "peak_";
static char __pyx_k__peaks[] = "peaks";
static char __pyx_k__print[] = "print";
static char __pyx_k__range[] = "range";
static char __pyx_k__rl1_k[] = "rl1_k";
static char __pyx_k__rl2_k[] = "rl2_k";
static char __pyx_k__score[] = "score";
static char __pyx_k__start[] = "start";
static char __pyx_k__tmp_n[] = "tmp_n";
static char __pyx_k__tobed[] = "tobed";
static char __pyx_k__total[] = "total";
static char __pyx_k__write[] = "write";
static char __pyx_k__PeakIO[] = "PeakIO";
static char __pyx_k__Region[] = "Region";
static char __pyx_k__append[] = "append";
static char __pyx_k__fc_low[] = "fc_low";
static char __pyx_k__length[] = "length";
static char __pyx_k__n_peak[] = "n_peak";
static char __pyx_k__peaks1[] = "peaks1";
static char __pyx_k__peaks2[] = "peaks2";
static char __pyx_k__pileup[] = "pileup";
static char __pyx_k__pscore[] = "pscore";
static char __pyx_k__qscore[] = "qscore";
static char __pyx_k__region[] = "region";
static char __pyx_k__sorted[] = "sorted";
static char __pyx_k__summit[] = "summit";
static char __pyx_k____doc__[] = "__doc__";
static char __pyx_k___to_bed[] = "_to_bed";
static char __pyx_k__add_loc[] = "add_loc";
static char __pyx_k__groupby[] = "groupby";
static char __pyx_k__has_key[] = "has_key";
static char __pyx_k__regions[] = "regions";
static char __pyx_k__replace[] = "replace";
static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__blockNum[] = "blockNum";
static char __pyx_k__n_append[] = "n_append";
static char __pyx_k__operator[] = "operator";
static char __pyx_k__peakname[] = "peakname";
static char __pyx_k__summit_p[] = "summit_p";
static char __pyx_k__thickEnd[] = "thickEnd";
static char __pyx_k__enumerate[] = "enumerate";
static char __pyx_k__filter_fc[] = "filter_fc";
static char __pyx_k__itertools[] = "itertools";
static char __pyx_k__new_peaks[] = "new_peaks";
static char __pyx_k__total_num[] = "total_num";
static char __pyx_k__trackline[] = "trackline";
static char __pyx_k__DiffPeakIO[] = "DiffPeakIO";
static char __pyx_k____author__[] = "__author__";
static char __pyx_k__abs_summit[] = "abs_summit";
static char __pyx_k__blockSizes[] = "blockSizes";
static char __pyx_k__chromosome[] = "chromosome";
static char __pyx_k__diff_score[] = "diff_score";
static char __pyx_k__itemgetter[] = "itemgetter";
static char __pyx_k__peak_score[] = "peak_score";
static char __pyx_k__peakprefix[] = "peakprefix";
static char __pyx_k__print_func[] = "print_func";
static char __pyx_k__pscore_cut[] = "pscore_cut";
static char __pyx_k__qscore_cut[] = "qscore_cut";
static char __pyx_k__thickStart[] = "thickStart";
static char __pyx_k__BroadPeakIO[] = "BroadPeakIO";
static char __pyx_k____version__[] = "__version__";
static char __pyx_k__blockStarts[] = "blockStarts";
static char __pyx_k__description[] = "description";
static char __pyx_k__fold_change[] = "fold_change";
static char __pyx_k__name_prefix[] = "name_prefix";
static char __pyx_k__new_regions[] = "new_regions";
static char __pyx_k__prev_region[] = "prev_region";
static char __pyx_k__regions_chr[] = "regions_chr";
static char __pyx_k__these_peaks[] = "these_peaks";
static char __pyx_k__e_new_region[] = "e_new_region";
static char __pyx_k__s_new_region[] = "s_new_region";
static char __pyx_k__score_column[] = "score_column";
static char __pyx_k__write_to_bed[] = "write_to_bed";
static char __pyx_k__write_to_xls[] = "write_to_xls";
static char __pyx_k__StopIteration[] = "StopIteration";
static char __pyx_k__filter_pscore[] = "filter_pscore";
static char __pyx_k__filter_qscore[] = "filter_qscore";
static char __pyx_k__merge_overlap[] = "merge_overlap";
static char __pyx_k__trackcontents[] = "trackcontents";
static char __pyx_k__to_summits_bed[] = "to_summits_bed";
static char __pyx_k___to_summits_bed[] = "_to_summits_bed";
static char __pyx_k__fold_enrichment[] = "fold_enrichment";
static char __pyx_k__write_to_gappedPeak[] = "write_to_gappedPeak";
static char __pyx_k__write_to_narrowPeak[] = "write_to_narrowPeak";
static char __pyx_k__write_to_summit_bed[] = "write_to_summit_bed";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_100;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_s_12;
static PyObject *__pyx_kp_s_128;
static PyObject *__pyx_kp_s_137;
static PyObject *__pyx_kp_s_15;
static PyObject *__pyx_kp_s_18;
static PyObject *__pyx_kp_s_19;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_kp_s_20;
static PyObject *__pyx_kp_s_21;
static PyObject *__pyx_kp_s_22;
static PyObject *__pyx_kp_s_25;
static PyObject *__pyx_kp_s_27;
static PyObject *__pyx_kp_s_28;
static PyObject *__pyx_kp_s_29;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_30;
static PyObject *__pyx_kp_s_31;
static PyObject *__pyx_kp_s_33;
static PyObject *__pyx_n_s_35;
static PyObject *__pyx_kp_s_36;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_46;
static PyObject *__pyx_kp_s_47;
static PyObject *__pyx_n_s_49;
static PyObject *__pyx_n_s_50;
static PyObject *__pyx_kp_s_51;
static PyObject *__pyx_kp_s_52;
static PyObject *__pyx_kp_s_53;
static PyObject *__pyx_kp_s_56;
static PyObject *__pyx_n_s_57;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_n_s_88;
static PyObject *__pyx_kp_s_89;
static PyObject *__pyx_n_s__BroadPeakIO;
static PyObject *__pyx_n_s__DiffPeakIO;
static PyObject *__pyx_n_s__MACS;
static PyObject *__pyx_n_s__PeakIO;
static PyObject *__pyx_n_s__Region;
static PyObject *__pyx_n_s__StopIteration;
static PyObject *__pyx_n_s____author__;
static PyObject *__pyx_n_s____doc__;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s____version__;
static PyObject *__pyx_n_s___to_bed;
static PyObject *__pyx_n_s___to_summits_bed;
static PyObject *__pyx_n_s__a;
static PyObject *__pyx_n_s__abs_summit;
static PyObject *__pyx_n_s__add;
static PyObject *__pyx_n_s__add_loc;
static PyObject *__pyx_n_s__append;
static PyObject *__pyx_n_s__blockNum;
static PyObject *__pyx_n_s__blockSizes;
static PyObject *__pyx_n_s__blockStarts;
static PyObject *__pyx_n_s__chr;
static PyObject *__pyx_n_s__chrom;
static PyObject *__pyx_n_s__chromosome;
static PyObject *__pyx_n_s__chrs;
static PyObject *__pyx_n_s__chrs1;
static PyObject *__pyx_n_s__chrs2;
static PyObject *__pyx_n_s__count;
static PyObject *__pyx_n_s__cover;
static PyObject *__pyx_n_s__desc;
static PyObject *__pyx_n_s__description;
static PyObject *__pyx_n_s__diff_score;
static PyObject *__pyx_n_s__e_new_region;
static PyObject *__pyx_n_s__end;
static PyObject *__pyx_n_s__enumerate;
static PyObject *__pyx_n_s__fc;
static PyObject *__pyx_n_s__fc_low;
static PyObject *__pyx_n_s__fc_up;
static PyObject *__pyx_n_s__fhd;
static PyObject *__pyx_n_s__filter_fc;
static PyObject *__pyx_n_s__filter_pscore;
static PyObject *__pyx_n_s__filter_qscore;
static PyObject *__pyx_n_s__fold_change;
static PyObject *__pyx_n_s__fold_enrichment;
static PyObject *__pyx_n_s__group;
static PyObject *__pyx_n_s__groupby;
static PyObject *__pyx_n_s__has_key;
static PyObject *__pyx_n_s__i;
static PyObject *__pyx_n_s__itemgetter;
static PyObject *__pyx_n_s__itertools;
static PyObject *__pyx_n_s__j;
static PyObject *__pyx_n_s__join;
static PyObject *__pyx_n_s__k;
static PyObject *__pyx_n_s__key;
static PyObject *__pyx_n_s__keys;
static PyObject *__pyx_n_s__length;
static PyObject *__pyx_n_s__merge_overlap;
static PyObject *__pyx_n_s__n_append;
static PyObject *__pyx_n_s__n_peak;
static PyObject *__pyx_n_s__name;
static PyObject *__pyx_n_s__name_prefix;
static PyObject *__pyx_n_s__new_peaks;
static PyObject *__pyx_n_s__new_regions;
static PyObject *__pyx_n_s__next;
static PyObject *__pyx_n_s__ofhd;
static PyObject *__pyx_n_s__operator;
static PyObject *__pyx_n_s__p;
static PyObject *__pyx_n_s__peak;
static PyObject *__pyx_n_s__peak_;
static PyObject *__pyx_n_s__peak_score;
static PyObject *__pyx_n_s__peakname;
static PyObject *__pyx_n_s__peakprefix;
static PyObject *__pyx_n_s__peaks;
static PyObject *__pyx_n_s__peaks1;
static PyObject *__pyx_n_s__peaks2;
static PyObject *__pyx_n_s__pileup;
static PyObject *__pyx_n_s__prev_region;
static PyObject *__pyx_n_s__print;
static PyObject *__pyx_n_s__print_func;
static PyObject *__pyx_n_s__pscore;
static PyObject *__pyx_n_s__pscore_cut;
static PyObject *__pyx_n_s__qscore;
static PyObject *__pyx_n_s__qscore_cut;
static PyObject *__pyx_n_s__r1;
static PyObject *__pyx_n_s__r2;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__region;
static PyObject *__pyx_n_s__regions;
static PyObject *__pyx_n_s__regions_chr;
static PyObject *__pyx_n_s__replace;
static PyObject *__pyx_n_s__rl1_k;
static PyObject *__pyx_n_s__rl2_k;
static PyObject *__pyx_n_s__s_new_region;
static PyObject *__pyx_n_s__score;
static PyObject *__pyx_n_s__score_column;
static PyObject *__pyx_n_s__self;
static PyObject *__pyx_n_s__sort;
static PyObject *__pyx_n_s__sorted;
static PyObject *__pyx_n_s__start;
static PyObject *__pyx_n_s__summit;
static PyObject *__pyx_n_s__summit_p;
static PyObject *__pyx_n_s__these_peaks;
static PyObject *__pyx_n_s__thickEnd;
static PyObject *__pyx_n_s__thickStart;
static PyObject *__pyx_n_s__tmp_n;
static PyObject *__pyx_n_s__to_summits_bed;
static PyObject *__pyx_n_s__tobed;
static PyObject *__pyx_n_s__total;
static PyObject *__pyx_n_s__total_num;
static PyObject *__pyx_n_s__trackcontents;
static PyObject *__pyx_n_s__trackline;
static PyObject *__pyx_n_s__write;
static PyObject *__pyx_n_s__write_to_bed;
static PyObject *__pyx_n_s__write_to_gappedPeak;
static PyObject *__pyx_n_s__write_to_narrowPeak;
static PyObject *__pyx_n_s__write_to_summit_bed;
static PyObject *__pyx_n_s__write_to_xls;
static PyObject *__pyx_n_s__x;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_10;
static PyObject *__pyx_k_tuple_5;
static PyObject *__pyx_k_tuple_6;
static PyObject *__pyx_k_tuple_9;
static PyObject *__pyx_k_tuple_10;
static PyObject *__pyx_k_tuple_13;
static PyObject *__pyx_k_tuple_14;
static PyObject *__pyx_k_tuple_16;
static PyObject *__pyx_k_tuple_17;
static PyObject *__pyx_k_tuple_23;
static PyObject *__pyx_k_tuple_24;
static PyObject *__pyx_k_tuple_26;
static PyObject *__pyx_k_tuple_32;
static PyObject *__pyx_k_tuple_34;
static PyObject *__pyx_k_tuple_37;
static PyObject *__pyx_k_tuple_38;
static PyObject *__pyx_k_tuple_39;
static PyObject *__pyx_k_tuple_40;
static PyObject *__pyx_k_tuple_41;
static PyObject *__pyx_k_tuple_42;
static PyObject *__pyx_k_tuple_43;
static PyObject *__pyx_k_tuple_44;
static PyObject *__pyx_k_tuple_54;
static PyObject *__pyx_k_tuple_58;
static PyObject *__pyx_k_tuple_60;
static PyObject *__pyx_k_tuple_62;
static PyObject *__pyx_k_tuple_64;
static PyObject *__pyx_k_tuple_66;
static PyObject *__pyx_k_tuple_67;
static PyObject *__pyx_k_tuple_69;
static PyObject *__pyx_k_tuple_71;
static PyObject *__pyx_k_tuple_73;
static PyObject *__pyx_k_tuple_75;
static PyObject *__pyx_k_tuple_77;
static PyObject *__pyx_k_tuple_79;
static PyObject *__pyx_k_tuple_81;
static PyObject *__pyx_k_tuple_83;
static PyObject *__pyx_k_tuple_85;
static PyObject *__pyx_k_tuple_86;
static PyObject *__pyx_k_tuple_90;
static PyObject *__pyx_k_tuple_92;
static PyObject *__pyx_k_tuple_94;
static PyObject *__pyx_k_tuple_96;
static PyObject *__pyx_k_tuple_98;
static PyObject *__pyx_k_tuple_101;
static PyObject *__pyx_k_tuple_103;
static PyObject *__pyx_k_tuple_105;
static PyObject *__pyx_k_tuple_107;
static PyObject *__pyx_k_tuple_109;
static PyObject *__pyx_k_tuple_111;
static PyObject *__pyx_k_tuple_112;
static PyObject *__pyx_k_tuple_114;
static PyObject *__pyx_k_tuple_116;
static PyObject *__pyx_k_tuple_118;
static PyObject *__pyx_k_tuple_120;
static PyObject *__pyx_k_tuple_122;
static PyObject *__pyx_k_tuple_124;
static PyObject *__pyx_k_tuple_126;
static PyObject *__pyx_k_tuple_129;
static PyObject *__pyx_k_tuple_131;
static PyObject *__pyx_k_tuple_133;
static PyObject *__pyx_k_tuple_135;
static PyObject *__pyx_k_codeobj_55;
static PyObject *__pyx_k_codeobj_59;
static PyObject *__pyx_k_codeobj_61;
static PyObject *__pyx_k_codeobj_63;
static PyObject *__pyx_k_codeobj_65;
static PyObject *__pyx_k_codeobj_68;
static PyObject *__pyx_k_codeobj_70;
static PyObject *__pyx_k_codeobj_72;
static PyObject *__pyx_k_codeobj_74;
static PyObject *__pyx_k_codeobj_76;
static PyObject *__pyx_k_codeobj_78;
static PyObject *__pyx_k_codeobj_80;
static PyObject *__pyx_k_codeobj_82;
static PyObject *__pyx_k_codeobj_84;
static PyObject *__pyx_k_codeobj_87;
static PyObject *__pyx_k_codeobj_91;
static PyObject *__pyx_k_codeobj_93;
static PyObject *__pyx_k_codeobj_95;
static PyObject *__pyx_k_codeobj_97;
static PyObject *__pyx_k_codeobj_99;
static PyObject *__pyx_k_codeobj_102;
static PyObject *__pyx_k_codeobj_104;
static PyObject *__pyx_k_codeobj_106;
static PyObject *__pyx_k_codeobj_108;
static PyObject *__pyx_k_codeobj_110;
static PyObject *__pyx_k_codeobj_113;
static PyObject *__pyx_k_codeobj_115;
static PyObject *__pyx_k_codeobj_117;
static PyObject *__pyx_k_codeobj_119;
static PyObject *__pyx_k_codeobj_121;
static PyObject *__pyx_k_codeobj_123;
static PyObject *__pyx_k_codeobj_125;
static PyObject *__pyx_k_codeobj_127;
static PyObject *__pyx_k_codeobj_130;
static PyObject *__pyx_k_codeobj_132;
static PyObject *__pyx_k_codeobj_134;
static PyObject *__pyx_k_codeobj_136;

/* "MACS2/IO/cPeakIO.pyx":38
 * # Misc functions
 * # ------------------------------------
 * cdef subpeak_letters( int i):             # <<<<<<<<<<<<<<
 *     if i < 26:
 *         return chr(97+i)
 */

static PyObject *__pyx_f_5MACS2_2IO_7cPeakIO_subpeak_letters(int __pyx_v_i) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("subpeak_letters", 0);
  __Pyx_TraceCall("subpeak_letters", __pyx_f[0], 38);

  /* "MACS2/IO/cPeakIO.pyx":39
 * # ------------------------------------
 * cdef subpeak_letters( int i):
 *     if i < 26:             # <<<<<<<<<<<<<<
 *         return chr(97+i)
 *     else:
 */
  __pyx_t_1 = (__pyx_v_i < 26);
  if (__pyx_t_1) {

    /* "MACS2/IO/cPeakIO.pyx":40
 * cdef subpeak_letters( int i):
 *     if i < 26:
 *         return chr(97+i)             # <<<<<<<<<<<<<<
 *     else:
 *         return subpeak_letters(i / 26) + chr(97 + (i % 26))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyInt_FromLong((97 + __pyx_v_i)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_chr, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "MACS2/IO/cPeakIO.pyx":42
 *         return chr(97+i)
 *     else:
 *         return subpeak_letters(i / 26) + chr(97 + (i % 26))             # <<<<<<<<<<<<<<
 * 
 * # ------------------------------------
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_f_5MACS2_2IO_7cPeakIO_subpeak_letters(__Pyx_div_long(__pyx_v_i, 26)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyInt_FromLong((97 + __Pyx_mod_long(__pyx_v_i, 26))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_chr, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.subpeak_letters", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_1__init__, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO___init__(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":52
 *     """
 * 
 *     def __init__ (self):             # <<<<<<<<<<<<<<
 *         self.peaks = {}
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 52);

  /* "MACS2/IO/cPeakIO.pyx":53
 * 
 *     def __init__ (self):
 *         self.peaks = {}             # <<<<<<<<<<<<<<
 * 
 *     def add (self, str chromosome, long start, long end, long summit = 0,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__peaks, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_3add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_2add[] = "items:\n        start:start\n        end:end,\n        length:end-start,\n        summit:summit,\n        score:peak_score,\n        pileup:pileup,\n        pscore:pscore,\n        fc:fold_change,\n        qscore:qscore\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_3add = {__Pyx_NAMESTR("add"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_3add, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_2add)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_3add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_chromosome = 0;
  long __pyx_v_start;
  long __pyx_v_end;
  long __pyx_v_summit;
  double __pyx_v_peak_score;
  int __pyx_v_pileup;
  double __pyx_v_pscore;
  double __pyx_v_fold_change;
  double __pyx_v_qscore;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__chromosome,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__summit,&__pyx_n_s__peak_score,&__pyx_n_s__pileup,&__pyx_n_s__pscore,&__pyx_n_s__fold_change,&__pyx_n_s__qscore,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__chromosome);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 0, 4, 10, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 0, 4, 10, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
        if (likely(values[3])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 0, 4, 10, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__summit);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__peak_score);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pileup);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pscore);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fold_change);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__qscore);
          if (value) { values[9] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[4]) {
      } else {
        __pyx_v_summit = ((long)((long)0));
      }
      if (values[5]) {
      } else {

        /* "MACS2/IO/cPeakIO.pyx":56
 * 
 *     def add (self, str chromosome, long start, long end, long summit = 0,
 *              double peak_score=0, int pileup=0,             # <<<<<<<<<<<<<<
 *              double pscore=0, double fold_change=0, double qscore=0):
 *         """items:
 */
        __pyx_v_peak_score = ((double)((double)0.0));
      }
      if (values[6]) {
      } else {
        __pyx_v_pileup = ((int)((int)0));
      }
      if (values[7]) {
      } else {

        /* "MACS2/IO/cPeakIO.pyx":57
 *     def add (self, str chromosome, long start, long end, long summit = 0,
 *              double peak_score=0, int pileup=0,
 *              double pscore=0, double fold_change=0, double qscore=0):             # <<<<<<<<<<<<<<
 *         """items:
 *         start:start
 */
        __pyx_v_pscore = ((double)((double)0.0));
      }
      if (values[8]) {
      } else {
        __pyx_v_fold_change = ((double)((double)0.0));
      }
      if (values[9]) {
      } else {
        __pyx_v_qscore = ((double)((double)0.0));
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_chromosome = ((PyObject*)values[1]);
    __pyx_v_start = __Pyx_PyInt_AsLong(values[2]); if (unlikely((__pyx_v_start == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_end = __Pyx_PyInt_AsLong(values[3]); if (unlikely((__pyx_v_end == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[4]) {
      __pyx_v_summit = __Pyx_PyInt_AsLong(values[4]); if (unlikely((__pyx_v_summit == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_summit = ((long)((long)0));
    }
    if (values[5]) {
      __pyx_v_peak_score = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_peak_score == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_peak_score = ((double)((double)0.0));
    }
    if (values[6]) {
      __pyx_v_pileup = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_pileup == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_pileup = ((int)((int)0));
    }
    if (values[7]) {
      __pyx_v_pscore = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_pscore == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_pscore = ((double)((double)0.0));
    }
    if (values[8]) {
      __pyx_v_fold_change = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_fold_change == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_fold_change = ((double)((double)0.0));
    }
    if (values[9]) {
      __pyx_v_qscore = __pyx_PyFloat_AsDouble(values[9]); if (unlikely((__pyx_v_qscore == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_qscore = ((double)((double)0.0));
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 0, 4, 10, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chromosome), (&PyString_Type), 1, "chromosome", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_2add(__pyx_self, __pyx_v_self, __pyx_v_chromosome, __pyx_v_start, __pyx_v_end, __pyx_v_summit, __pyx_v_peak_score, __pyx_v_pileup, __pyx_v_pscore, __pyx_v_fold_change, __pyx_v_qscore);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":55
 *         self.peaks = {}
 * 
 *     def add (self, str chromosome, long start, long end, long summit = 0,             # <<<<<<<<<<<<<<
 *              double peak_score=0, int pileup=0,
 *              double pscore=0, double fold_change=0, double qscore=0):
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_2add(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_chromosome, long __pyx_v_start, long __pyx_v_end, long __pyx_v_summit, double __pyx_v_peak_score, int __pyx_v_pileup, double __pyx_v_pscore, double __pyx_v_fold_change, double __pyx_v_qscore) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("add", 0);
  __Pyx_TraceCall("add", __pyx_f[0], 55);

  /* "MACS2/IO/cPeakIO.pyx":69
 *         qscore:qscore
 *         """
 *         if not self.peaks.has_key(chromosome):             # <<<<<<<<<<<<<<
 *             self.peaks[chromosome]=[]
 *         self.peaks[chromosome].append({"start":start,
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__has_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_chromosome));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_chromosome));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_chromosome));
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = (!__pyx_t_4);
  if (__pyx_t_5) {

    /* "MACS2/IO/cPeakIO.pyx":70
 *         """
 *         if not self.peaks.has_key(chromosome):
 *             self.peaks[chromosome]=[]             # <<<<<<<<<<<<<<
 *         self.peaks[chromosome].append({"start":start,
 *                                        "end":end,
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyObject_SetItem(__pyx_t_1, ((PyObject *)__pyx_v_chromosome), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "MACS2/IO/cPeakIO.pyx":71
 *         if not self.peaks.has_key(chromosome):
 *             self.peaks[chromosome]=[]
 *         self.peaks[chromosome].append({"start":start,             # <<<<<<<<<<<<<<
 *                                        "end":end,
 *                                        "length":end-start,
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_GetItem(__pyx_t_3, ((PyObject *)__pyx_v_chromosome)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_2 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__start), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":72
 *             self.peaks[chromosome]=[]
 *         self.peaks[chromosome].append({"start":start,
 *                                        "end":end,             # <<<<<<<<<<<<<<
 *                                        "length":end-start,
 *                                        "summit":summit,
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__end), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":73
 *         self.peaks[chromosome].append({"start":start,
 *                                        "end":end,
 *                                        "length":end-start,             # <<<<<<<<<<<<<<
 *                                        "summit":summit,
 *                                        "score":peak_score,
 */
  __pyx_t_2 = PyInt_FromLong((__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__length), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":74
 *                                        "end":end,
 *                                        "length":end-start,
 *                                        "summit":summit,             # <<<<<<<<<<<<<<
 *                                        "score":peak_score,
 *                                        "pileup":pileup,
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_summit); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__summit), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":75
 *                                        "length":end-start,
 *                                        "summit":summit,
 *                                        "score":peak_score,             # <<<<<<<<<<<<<<
 *                                        "pileup":pileup,
 *                                        "pscore":pscore,
 */
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_peak_score); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__score), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":76
 *                                        "summit":summit,
 *                                        "score":peak_score,
 *                                        "pileup":pileup,             # <<<<<<<<<<<<<<
 *                                        "pscore":pscore,
 *                                        "fc":fold_change,
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_pileup); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__pileup), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":77
 *                                        "score":peak_score,
 *                                        "pileup":pileup,
 *                                        "pscore":pscore,             # <<<<<<<<<<<<<<
 *                                        "fc":fold_change,
 *                                        "qscore":qscore})
 */
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_pscore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__pscore), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":78
 *                                        "pileup":pileup,
 *                                        "pscore":pscore,
 *                                        "fc":fold_change,             # <<<<<<<<<<<<<<
 *                                        "qscore":qscore})
 * 
 */
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_fold_change); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__fc), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":79
 *                                        "pscore":pscore,
 *                                        "fc":fold_change,
 *                                        "qscore":qscore})             # <<<<<<<<<<<<<<
 * 
 *     def filter_pscore (self, double pscore_cut ):
 */
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_qscore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__qscore), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_1, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_5filter_pscore(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_5filter_pscore = {__Pyx_NAMESTR("filter_pscore"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_5filter_pscore, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_5filter_pscore(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  double __pyx_v_pscore_cut;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__pscore_cut,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("filter_pscore (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pscore_cut);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("filter_pscore", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "filter_pscore") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_pscore_cut = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_pscore_cut == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("filter_pscore", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.filter_pscore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_4filter_pscore(__pyx_self, __pyx_v_self, __pyx_v_pscore_cut);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":81
 *                                        "qscore":qscore})
 * 
 *     def filter_pscore (self, double pscore_cut ):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_4filter_pscore(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_pscore_cut) {
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_new_peaks = NULL;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("filter_pscore", 0);
  __Pyx_TraceCall("filter_pscore", __pyx_f[0], 81);

  /* "MACS2/IO/cPeakIO.pyx":84
 *         cdef str chrom
 * 
 *         peaks = self.peaks             # <<<<<<<<<<<<<<
 *         new_peaks = {}
 *         chrs = sorted(peaks.keys())
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":85
 * 
 *         peaks = self.peaks
 *         new_peaks = {}             # <<<<<<<<<<<<<<
 *         chrs = sorted(peaks.keys())
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_new_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":86
 *         peaks = self.peaks
 *         new_peaks = {}
 *         chrs = sorted(peaks.keys())             # <<<<<<<<<<<<<<
 * 
 *         for chrom in chrs:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_peaks, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_chrs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":88
 *         chrs = sorted(peaks.keys())
 * 
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             new_peaks[chrom]=[p for p in peaks[chrom] if p["pscore"] >= pscore_cut]
 *         self.peaks = new_peaks
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_2 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_chrom));
    __pyx_v_chrom = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "MACS2/IO/cPeakIO.pyx":89
 * 
 *         for chrom in chrs:
 *             new_peaks[chrom]=[p for p in peaks[chrom] if p["pscore"] >= pscore_cut]             # <<<<<<<<<<<<<<
 *         self.peaks = new_peaks
 * 
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_GetItem(__pyx_v_peaks, ((PyObject *)__pyx_v_chrom)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
      __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    for (;;) {
      if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_6)) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++;
      } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_6)) {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++;
      } else {
        __pyx_t_5 = __pyx_t_8(__pyx_t_6);
        if (unlikely(!__pyx_t_5)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF(__pyx_v_p);
      __pyx_v_p = __pyx_t_5;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__pscore)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = PyFloat_FromDouble(__pyx_v_pscore_cut); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyObject_RichCompare(__pyx_t_5, __pyx_t_9, Py_GE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (__pyx_t_11) {
        if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_v_p))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (PyDict_SetItem(((PyObject *)__pyx_v_new_peaks), ((PyObject *)__pyx_v_chrom), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":90
 *         for chrom in chrs:
 *             new_peaks[chrom]=[p for p in peaks[chrom] if p["pscore"] >= pscore_cut]
 *         self.peaks = new_peaks             # <<<<<<<<<<<<<<
 * 
 *     def filter_qscore (self, double qscore_cut ):
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__peaks, ((PyObject *)__pyx_v_new_peaks)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.filter_pscore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_new_peaks);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_7filter_qscore(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_7filter_qscore = {__Pyx_NAMESTR("filter_qscore"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_7filter_qscore, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_7filter_qscore(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  double __pyx_v_qscore_cut;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__qscore_cut,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("filter_qscore (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__qscore_cut);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("filter_qscore", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "filter_qscore") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_qscore_cut = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_qscore_cut == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("filter_qscore", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.filter_qscore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_6filter_qscore(__pyx_self, __pyx_v_self, __pyx_v_qscore_cut);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":92
 *         self.peaks = new_peaks
 * 
 *     def filter_qscore (self, double qscore_cut ):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_6filter_qscore(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_qscore_cut) {
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_new_peaks = NULL;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("filter_qscore", 0);
  __Pyx_TraceCall("filter_qscore", __pyx_f[0], 92);

  /* "MACS2/IO/cPeakIO.pyx":95
 *         cdef str chrom
 * 
 *         peaks = self.peaks             # <<<<<<<<<<<<<<
 *         new_peaks = {}
 *         chrs = sorted(peaks.keys())
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":96
 * 
 *         peaks = self.peaks
 *         new_peaks = {}             # <<<<<<<<<<<<<<
 *         chrs = sorted(peaks.keys())
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_new_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":97
 *         peaks = self.peaks
 *         new_peaks = {}
 *         chrs = sorted(peaks.keys())             # <<<<<<<<<<<<<<
 * 
 *         for chrom in chrs:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_peaks, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_chrs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":99
 *         chrs = sorted(peaks.keys())
 * 
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             new_peaks[chrom]=[p for p in peaks[chrom] if p["qscore"] >= qscore_cut]
 *         self.peaks = new_peaks
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_2 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_chrom));
    __pyx_v_chrom = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "MACS2/IO/cPeakIO.pyx":100
 * 
 *         for chrom in chrs:
 *             new_peaks[chrom]=[p for p in peaks[chrom] if p["qscore"] >= qscore_cut]             # <<<<<<<<<<<<<<
 *         self.peaks = new_peaks
 * 
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_GetItem(__pyx_v_peaks, ((PyObject *)__pyx_v_chrom)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
      __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    for (;;) {
      if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_6)) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++;
      } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_6)) {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++;
      } else {
        __pyx_t_5 = __pyx_t_8(__pyx_t_6);
        if (unlikely(!__pyx_t_5)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF(__pyx_v_p);
      __pyx_v_p = __pyx_t_5;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__qscore)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = PyFloat_FromDouble(__pyx_v_qscore_cut); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyObject_RichCompare(__pyx_t_5, __pyx_t_9, Py_GE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (__pyx_t_11) {
        if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_v_p))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (PyDict_SetItem(((PyObject *)__pyx_v_new_peaks), ((PyObject *)__pyx_v_chrom), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":101
 *         for chrom in chrs:
 *             new_peaks[chrom]=[p for p in peaks[chrom] if p["qscore"] >= qscore_cut]
 *         self.peaks = new_peaks             # <<<<<<<<<<<<<<
 * 
 *     def filter_fc (self, fc_low, fc_up=None ):
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__peaks, ((PyObject *)__pyx_v_new_peaks)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.filter_qscore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_new_peaks);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_9filter_fc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_8filter_fc[] = "Filter peaks in a given fc range.\n\n        If fc_low and fc_up is assigned, the peaks with fc in [fc_low,fc_up)\n        \n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_9filter_fc = {__Pyx_NAMESTR("filter_fc"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_9filter_fc, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_8filter_fc)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_9filter_fc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fc_low = 0;
  PyObject *__pyx_v_fc_up = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fc_low,&__pyx_n_s__fc_up,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("filter_fc (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[3] = {0,0,0};

    /* "MACS2/IO/cPeakIO.pyx":103
 *         self.peaks = new_peaks
 * 
 *     def filter_fc (self, fc_low, fc_up=None ):             # <<<<<<<<<<<<<<
 *         """Filter peaks in a given fc range.
 * 
 */
    values[2] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fc_low);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("filter_fc", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fc_up);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "filter_fc") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_fc_low = values[1];
    __pyx_v_fc_up = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("filter_fc", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.filter_fc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_8filter_fc(__pyx_self, __pyx_v_self, __pyx_v_fc_low, __pyx_v_fc_up);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_8filter_fc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fc_low, PyObject *__pyx_v_fc_up) {
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_new_peaks = NULL;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_chrom = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_r = NULL;
  __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)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("filter_fc", 0);
  __Pyx_TraceCall("filter_fc", __pyx_f[0], 103);

  /* "MACS2/IO/cPeakIO.pyx":109
 * 
 *         """
 *         peaks = self.peaks             # <<<<<<<<<<<<<<
 *         new_peaks = {}
 *         chrs = peaks.keys()
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":110
 *         """
 *         peaks = self.peaks
 *         new_peaks = {}             # <<<<<<<<<<<<<<
 *         chrs = peaks.keys()
 *         chrs.sort()
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_new_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":111
 *         peaks = self.peaks
 *         new_peaks = {}
 *         chrs = peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         if fc_up:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_peaks, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_chrs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":112
 *         new_peaks = {}
 *         chrs = peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         if fc_up:
 *             for chrom in chrs:
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":113
 *         chrs = peaks.keys()
 *         chrs.sort()
 *         if fc_up:             # <<<<<<<<<<<<<<
 *             for chrom in chrs:
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low and p["fc"]<fc_up]
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_fc_up); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "MACS2/IO/cPeakIO.pyx":114
 *         chrs.sort()
 *         if fc_up:
 *             for chrom in chrs:             # <<<<<<<<<<<<<<
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low and p["fc"]<fc_up]
 *         else:
 */
    if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
      __pyx_t_1 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_1)) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
      } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
      } else {
        __pyx_t_2 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF(__pyx_v_chrom);
      __pyx_v_chrom = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "MACS2/IO/cPeakIO.pyx":115
 *         if fc_up:
 *             for chrom in chrs:
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low and p["fc"]<fc_up]             # <<<<<<<<<<<<<<
 *         else:
 *             for chrom in chrs:
 */
      __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyObject_GetItem(__pyx_v_peaks, __pyx_v_chrom); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
        __pyx_t_7 = __pyx_t_6; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
      } else {
        __pyx_t_8 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_9 = Py_TYPE(__pyx_t_7)->tp_iternext;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      for (;;) {
        if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_7)) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_7)) break;
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++;
        } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_7)) {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++;
        } else {
          __pyx_t_6 = __pyx_t_9(__pyx_t_7);
          if (unlikely(!__pyx_t_6)) {
            if (PyErr_Occurred()) {
              if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_XDECREF(__pyx_v_p);
        __pyx_v_p = __pyx_t_6;
        __pyx_t_6 = 0;
        __pyx_t_6 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__fc)); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_10 = PyObject_RichCompare(__pyx_t_6, __pyx_v_fc_low, Py_GE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (__pyx_t_3) {
          __pyx_t_10 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__fc)); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_6 = PyObject_RichCompare(__pyx_t_10, __pyx_v_fc_up, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_12 = __pyx_t_11;
        } else {
          __pyx_t_12 = __pyx_t_3;
        }
        if (__pyx_t_12) {
          if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_v_p))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          goto __pyx_L8;
        }
        __pyx_L8:;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (PyDict_SetItem(((PyObject *)__pyx_v_new_peaks), __pyx_v_chrom, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "MACS2/IO/cPeakIO.pyx":117
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low and p["fc"]<fc_up]
 *         else:
 *             for chrom in chrs:             # <<<<<<<<<<<<<<
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low]
 *         self.peaks = new_peaks
 */
    if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
      __pyx_t_1 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_1)) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
      } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
      } else {
        __pyx_t_2 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF(__pyx_v_chrom);
      __pyx_v_chrom = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "MACS2/IO/cPeakIO.pyx":118
 *         else:
 *             for chrom in chrs:
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low]             # <<<<<<<<<<<<<<
 *         self.peaks = new_peaks
 * 
 */
      __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = PyObject_GetItem(__pyx_v_peaks, __pyx_v_chrom); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (PyList_CheckExact(__pyx_t_7) || PyTuple_CheckExact(__pyx_t_7)) {
        __pyx_t_6 = __pyx_t_7; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
      } else {
        __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      for (;;) {
        if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_6)) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break;
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++;
        } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_6)) {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++;
        } else {
          __pyx_t_7 = __pyx_t_9(__pyx_t_6);
          if (unlikely(!__pyx_t_7)) {
            if (PyErr_Occurred()) {
              if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_XDECREF(__pyx_v_p);
        __pyx_v_p = __pyx_t_7;
        __pyx_t_7 = 0;
        __pyx_t_7 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__fc)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_10 = PyObject_RichCompare(__pyx_t_7, __pyx_v_fc_low, Py_GE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (__pyx_t_12) {
          if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_v_p))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          goto __pyx_L13;
        }
        __pyx_L13:;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (PyDict_SetItem(((PyObject *)__pyx_v_new_peaks), __pyx_v_chrom, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "MACS2/IO/cPeakIO.pyx":119
 *             for chrom in chrs:
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low]
 *         self.peaks = new_peaks             # <<<<<<<<<<<<<<
 * 
 *     def total (self):
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__peaks, ((PyObject *)__pyx_v_new_peaks)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.filter_fc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_new_peaks);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_11total(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_11total = {__Pyx_NAMESTR("total"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_11total, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_11total(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("total (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_10total(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":121
 *         self.peaks = new_peaks
 * 
 *     def total (self):             # <<<<<<<<<<<<<<
 *         peaks = self.peaks
 *         chrs = peaks.keys()
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_10total(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_chrom = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("total", 0);
  __Pyx_TraceCall("total", __pyx_f[0], 121);

  /* "MACS2/IO/cPeakIO.pyx":122
 * 
 *     def total (self):
 *         peaks = self.peaks             # <<<<<<<<<<<<<<
 *         chrs = peaks.keys()
 *         chrs.sort()
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":123
 *     def total (self):
 *         peaks = self.peaks
 *         chrs = peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         x = 0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_peaks, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_chrs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":124
 *         peaks = self.peaks
 *         chrs = peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         x = 0
 *         for chrom in chrs:
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":125
 *         chrs = peaks.keys()
 *         chrs.sort()
 *         x = 0             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             x += len(peaks[chrom])
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_x = __pyx_int_0;

  /* "MACS2/IO/cPeakIO.pyx":126
 *         chrs.sort()
 *         x = 0
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             x += len(peaks[chrom])
 *         return x
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_1 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_chrom);
    __pyx_v_chrom = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "MACS2/IO/cPeakIO.pyx":127
 *         x = 0
 *         for chrom in chrs:
 *             x += len(peaks[chrom])             # <<<<<<<<<<<<<<
 *         return x
 * 
 */
    __pyx_t_2 = PyObject_GetItem(__pyx_v_peaks, __pyx_v_chrom); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_x, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_6;
    __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":128
 *         for chrom in chrs:
 *             x += len(peaks[chrom])
 *         return x             # <<<<<<<<<<<<<<
 * 
 *     def _to_bed(self, name_prefix="%s_peak_", name="MACS",
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_x);
  __pyx_r = __pyx_v_x;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.total", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":130
 *         return x
 * 
 *     def _to_bed(self, name_prefix="%s_peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                 description="%s", score_column="score",
 *                 print_func=print, trackline=False):
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_30__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_TraceCall("__defaults__", __pyx_f[0], 130);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_1)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_kp_s_1)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_1)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_print_func);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_print_func);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_print_func);
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_trackline);
  PyTuple_SET_ITEM(__pyx_t_1, 5, __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_trackline);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_trackline);
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_13_to_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_12_to_bed[] = "\n        generalization of tobed and write_to_bed\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_13_to_bed = {__Pyx_NAMESTR("_to_bed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_13_to_bed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_12_to_bed)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_13_to_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_name_prefix = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_description = 0;
  PyObject *__pyx_v_score_column = 0;
  PyObject *__pyx_v_print_func = 0;
  PyObject *__pyx_v_trackline = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__name_prefix,&__pyx_n_s__name,&__pyx_n_s__description,&__pyx_n_s__score_column,&__pyx_n_s__print_func,&__pyx_n_s__trackline,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_to_bed (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[7] = {0,0,0,0,0,0,0};
    __pyx_defaults *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self);
    values[1] = ((PyObject *)((PyObject*)__pyx_kp_s_1));
    values[2] = ((PyObject *)((PyObject*)__pyx_n_s__MACS));
    values[3] = ((PyObject *)((PyObject*)__pyx_kp_s_2));
    values[4] = ((PyObject *)((PyObject*)__pyx_n_s__score));
    values[5] = __pyx_dynamic_args->__pyx_arg_print_func;
    values[6] = __pyx_dynamic_args->__pyx_arg_trackline;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name_prefix);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__description);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__score_column);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__print_func);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trackline);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_to_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_name_prefix = values[1];
    __pyx_v_name = values[2];
    __pyx_v_description = values[3];
    __pyx_v_score_column = values[4];
    __pyx_v_print_func = values[5];
    __pyx_v_trackline = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_to_bed", 0, 1, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO._to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_12_to_bed(__pyx_self, __pyx_v_self, __pyx_v_name_prefix, __pyx_v_name, __pyx_v_description, __pyx_v_score_column, __pyx_v_print_func, __pyx_v_trackline);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_12_to_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, PyObject *__pyx_v_print_func, PyObject *__pyx_v_trackline) {
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_n_peak = NULL;
  PyObject *__pyx_v_peakprefix = NULL;
  PyObject *__pyx_v_desc = NULL;
  PyObject *__pyx_v_trackcontents = NULL;
  PyObject *__pyx_v_chrom = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_end = NULL;
  PyObject *__pyx_v_group = NULL;
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_peak = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  PyObject *(*__pyx_t_14)(PyObject *);
  PyObject *(*__pyx_t_15)(PyObject *);
  Py_ssize_t __pyx_t_16;
  int __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("_to_bed", 0);
  __Pyx_TraceCall("_to_bed", __pyx_f[0], 130);

  /* "MACS2/IO/cPeakIO.pyx":136
 *         generalization of tobed and write_to_bed
 *         """
 *         chrs = self.peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         n_peak = 0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_chrs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":137
 *         """
 *         chrs = self.peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":138
 *         chrs = self.peaks.keys()
 *         chrs.sort()
 *         n_peak = 0             # <<<<<<<<<<<<<<
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_n_peak = __pyx_int_0;

  /* "MACS2/IO/cPeakIO.pyx":139
 *         chrs.sort()
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name             # <<<<<<<<<<<<<<
 *         except: peakprefix = name_prefix
 *         try: desc = description % name
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {
      __pyx_t_2 = PyNumber_Remainder(__pyx_v_name_prefix, __pyx_v_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_peakprefix = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "MACS2/IO/cPeakIO.pyx":140
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix             # <<<<<<<<<<<<<<
 *         try: desc = description % name
 *         except: desc = description
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO._to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_name_prefix);
      __Pyx_XDECREF(__pyx_v_peakprefix);
      __pyx_v_peakprefix = __pyx_v_name_prefix;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L10_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":141
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 *         try: desc = description % name             # <<<<<<<<<<<<<<
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {
      __pyx_t_6 = PyNumber_Remainder(__pyx_v_description, __pyx_v_name); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_v_desc = __pyx_t_6;
      __pyx_t_6 = 0;
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L20_try_end;
    __pyx_L13_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "MACS2/IO/cPeakIO.pyx":142
 *         except: peakprefix = name_prefix
 *         try: desc = description % name
 *         except: desc = description             # <<<<<<<<<<<<<<
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 *         if trackline:
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO._to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_description);
      __Pyx_XDECREF(__pyx_v_desc);
      __pyx_v_desc = __pyx_v_description;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L14_exception_handled;
    }
    __pyx_L15_except_error:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L14_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    __pyx_L20_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":143
 *         try: desc = description % name
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))             # <<<<<<<<<<<<<<
 *         if trackline:
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_name, __pyx_n_s__replace); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_desc, __pyx_n_s__replace); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_1 = 0;
  __pyx_t_6 = 0;
  __pyx_v_trackcontents = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":144
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 *         if trackline:             # <<<<<<<<<<<<<<
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_trackline); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_7) {

    /* "MACS2/IO/cPeakIO.pyx":145
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 *         if trackline:
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)             # <<<<<<<<<<<<<<
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      /*try:*/ {
        __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), ((PyObject *)__pyx_v_trackcontents)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_2));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
        __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L31_try_end;
      __pyx_L24_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "MACS2/IO/cPeakIO.pyx":146
 *         if trackline:
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 */
      /*except:*/ {
        __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO._to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_6, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_8 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L25_exception_handled;
      }
      __pyx_L26_except_error:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L1_error;
      __pyx_L25_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      __pyx_L31_try_end:;
    }
    goto __pyx_L23;
  }
  __pyx_L23:;

  /* "MACS2/IO/cPeakIO.pyx":147
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_1 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_1); __pyx_t_9 = 0;
    __pyx_t_10 = NULL;
  } else {
    __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_10 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++;
    } else if (!__pyx_t_10 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++;
    } else {
      __pyx_t_6 = __pyx_t_10(__pyx_t_1);
      if (unlikely(!__pyx_t_6)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF(__pyx_v_chrom);
    __pyx_v_chrom = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "MACS2/IO/cPeakIO.pyx":148
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 peaks = list(group)
 */
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__groupby); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = PyObject_GetItem(__pyx_t_2, __pyx_v_chrom); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
    __pyx_t_11 = __Pyx_GetName(__pyx_m, __pyx_n_s__itemgetter); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__key), __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    if (PyList_CheckExact(__pyx_t_12) || PyTuple_CheckExact(__pyx_t_12)) {
      __pyx_t_8 = __pyx_t_12; __Pyx_INCREF(__pyx_t_8); __pyx_t_13 = 0;
      __pyx_t_14 = NULL;
    } else {
      __pyx_t_13 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_14 = Py_TYPE(__pyx_t_8)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    for (;;) {
      if (!__pyx_t_14 && PyList_CheckExact(__pyx_t_8)) {
        if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_8)) break;
        __pyx_t_12 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_13); __Pyx_INCREF(__pyx_t_12); __pyx_t_13++;
      } else if (!__pyx_t_14 && PyTuple_CheckExact(__pyx_t_8)) {
        if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_13); __Pyx_INCREF(__pyx_t_12); __pyx_t_13++;
      } else {
        __pyx_t_12 = __pyx_t_14(__pyx_t_8);
        if (unlikely(!__pyx_t_12)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_12);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
        PyObject* sequence = __pyx_t_12;
        if (likely(PyTuple_CheckExact(sequence))) {
          if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
            if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
            if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_15 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_2)) goto __pyx_L38_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_6 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_6)) goto __pyx_L38_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L39_unpacking_done;
        __pyx_L38_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
        if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L39_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_end);
      __pyx_v_end = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_v_group);
      __pyx_v_group = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "MACS2/IO/cPeakIO.pyx":149
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1             # <<<<<<<<<<<<<<
 *                 peaks = list(group)
 *                 if len(peaks) > 1:
 */
      __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_n_peak, __pyx_int_1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_v_n_peak);
      __pyx_v_n_peak = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "MACS2/IO/cPeakIO.pyx":150
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1
 *                 peaks = list(group)             # <<<<<<<<<<<<<<
 *                 if len(peaks) > 1:
 *                     for i, peak in enumerate(peaks):
 */
      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_v_group);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_group);
      __Pyx_GIVEREF(__pyx_v_group);
      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
      __Pyx_XDECREF(((PyObject *)__pyx_v_peaks));
      __pyx_v_peaks = ((PyObject*)__pyx_t_6);
      __pyx_t_6 = 0;

      /* "MACS2/IO/cPeakIO.pyx":151
 *                 n_peak += 1
 *                 peaks = list(group)
 *                 if len(peaks) > 1:             # <<<<<<<<<<<<<<
 *                     for i, peak in enumerate(peaks):
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,subpeak_letters(i),peak[score_column]))
 */
      __pyx_t_16 = PyList_GET_SIZE(((PyObject *)__pyx_v_peaks)); 
      __pyx_t_7 = (__pyx_t_16 > 1);
      if (__pyx_t_7) {

        /* "MACS2/IO/cPeakIO.pyx":152
 *                 peaks = list(group)
 *                 if len(peaks) > 1:
 *                     for i, peak in enumerate(peaks):             # <<<<<<<<<<<<<<
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,subpeak_letters(i),peak[score_column]))
 *                 else:
 */
        __Pyx_INCREF(__pyx_int_0);
        __pyx_t_6 = __pyx_int_0;
        __pyx_t_12 = ((PyObject *)__pyx_v_peaks); __Pyx_INCREF(__pyx_t_12); __pyx_t_16 = 0;
        for (;;) {
          if (__pyx_t_16 >= PyList_GET_SIZE(__pyx_t_12)) break;
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_16); __Pyx_INCREF(__pyx_t_2); __pyx_t_16++;
          __Pyx_XDECREF(__pyx_v_peak);
          __pyx_v_peak = __pyx_t_2;
          __pyx_t_2 = 0;
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_XDECREF(__pyx_v_i);
          __pyx_v_i = __pyx_t_6;
          __pyx_t_2 = PyNumber_Add(__pyx_t_6, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6);
          __pyx_t_6 = __pyx_t_2;
          __pyx_t_2 = 0;

          /* "MACS2/IO/cPeakIO.pyx":153
 *                 if len(peaks) > 1:
 *                     for i, peak in enumerate(peaks):
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,subpeak_letters(i),peak[score_column]))             # <<<<<<<<<<<<<<
 *                 else:
 *                     peak = peaks[0]
 */
          __pyx_t_2 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__start)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_11 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__end)); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_17 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_18 = __pyx_f_5MACS2_2IO_7cPeakIO_subpeak_letters(__pyx_t_17); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_19 = PyObject_GetItem(__pyx_v_peak, __pyx_v_score_column); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_20 = PyTuple_New(7); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_20);
          __Pyx_INCREF(__pyx_v_chrom);
          PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_chrom);
          __Pyx_GIVEREF(__pyx_v_chrom);
          PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_20, 2, __pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_11);
          __Pyx_INCREF(__pyx_v_peakprefix);
          PyTuple_SET_ITEM(__pyx_t_20, 3, __pyx_v_peakprefix);
          __Pyx_GIVEREF(__pyx_v_peakprefix);
          __Pyx_INCREF(__pyx_v_n_peak);
          PyTuple_SET_ITEM(__pyx_t_20, 4, __pyx_v_n_peak);
          __Pyx_GIVEREF(__pyx_v_n_peak);
          PyTuple_SET_ITEM(__pyx_t_20, 5, __pyx_t_18);
          __Pyx_GIVEREF(__pyx_t_18);
          PyTuple_SET_ITEM(__pyx_t_20, 6, __pyx_t_19);
          __Pyx_GIVEREF(__pyx_t_19);
          __pyx_t_2 = 0;
          __pyx_t_11 = 0;
          __pyx_t_18 = 0;
          __pyx_t_19 = 0;
          __pyx_t_19 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), ((PyObject *)__pyx_t_20)); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_19));
          __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
          __pyx_t_20 = PyTuple_New(1); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_20);
          PyTuple_SET_ITEM(__pyx_t_20, 0, ((PyObject *)__pyx_t_19));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_19));
          __pyx_t_19 = 0;
          __pyx_t_19 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_t_20), NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        }
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L40;
      }
      /*else*/ {

        /* "MACS2/IO/cPeakIO.pyx":155
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,subpeak_letters(i),peak[score_column]))
 *                 else:
 *                     peak = peaks[0]             # <<<<<<<<<<<<<<
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,peak[score_column]))
 * 
 */
        __pyx_t_6 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_peaks), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_XDECREF(__pyx_v_peak);
        __pyx_v_peak = __pyx_t_6;
        __pyx_t_6 = 0;

        /* "MACS2/IO/cPeakIO.pyx":156
 *                 else:
 *                     peak = peaks[0]
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,peak[score_column]))             # <<<<<<<<<<<<<<
 * 
 *     def _to_summits_bed(self, name_prefix="%s_peak_", name="MACS",
 */
        __pyx_t_6 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__start)); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_12 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__end)); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_19 = PyObject_GetItem(__pyx_v_peak, __pyx_v_score_column); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __pyx_t_20 = PyTuple_New(6); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_INCREF(__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_20, 2, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_12);
        __Pyx_INCREF(__pyx_v_peakprefix);
        PyTuple_SET_ITEM(__pyx_t_20, 3, __pyx_v_peakprefix);
        __Pyx_GIVEREF(__pyx_v_peakprefix);
        __Pyx_INCREF(__pyx_v_n_peak);
        PyTuple_SET_ITEM(__pyx_t_20, 4, __pyx_v_n_peak);
        __Pyx_GIVEREF(__pyx_v_n_peak);
        PyTuple_SET_ITEM(__pyx_t_20, 5, __pyx_t_19);
        __Pyx_GIVEREF(__pyx_t_19);
        __pyx_t_6 = 0;
        __pyx_t_12 = 0;
        __pyx_t_19 = 0;
        __pyx_t_19 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), ((PyObject *)__pyx_t_20)); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_19));
        __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
        __pyx_t_20 = PyTuple_New(1); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_20);
        PyTuple_SET_ITEM(__pyx_t_20, 0, ((PyObject *)__pyx_t_19));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_19));
        __pyx_t_19 = 0;
        __pyx_t_19 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_t_20), NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      }
      __pyx_L40:;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO._to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_n_peak);
  __Pyx_XDECREF(__pyx_v_peakprefix);
  __Pyx_XDECREF(__pyx_v_desc);
  __Pyx_XDECREF(__pyx_v_trackcontents);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_end);
  __Pyx_XDECREF(__pyx_v_group);
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_peak);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":158
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,peak[score_column]))
 * 
 *     def _to_summits_bed(self, name_prefix="%s_peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                         description = "%s", score_column="score",
 *                         print_func=print, trackline=False):
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_32__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_TraceCall("__defaults__", __pyx_f[0], 158);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_1)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_kp_s_1)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_1)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_print_func);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_print_func);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_print_func);
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_trackline);
  PyTuple_SET_ITEM(__pyx_t_1, 5, __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_trackline);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_trackline);
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_15_to_summits_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_14_to_summits_bed[] = " \n        generalization of to_summits_bed and write_to_summit_bed\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_15_to_summits_bed = {__Pyx_NAMESTR("_to_summits_bed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_15_to_summits_bed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_14_to_summits_bed)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_15_to_summits_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_name_prefix = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_description = 0;
  PyObject *__pyx_v_score_column = 0;
  PyObject *__pyx_v_print_func = 0;
  PyObject *__pyx_v_trackline = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__name_prefix,&__pyx_n_s__name,&__pyx_n_s__description,&__pyx_n_s__score_column,&__pyx_n_s__print_func,&__pyx_n_s__trackline,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_to_summits_bed (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[7] = {0,0,0,0,0,0,0};
    __pyx_defaults1 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self);
    values[1] = ((PyObject *)((PyObject*)__pyx_kp_s_1));
    values[2] = ((PyObject *)((PyObject*)__pyx_n_s__MACS));
    values[3] = ((PyObject *)((PyObject*)__pyx_kp_s_2));
    values[4] = ((PyObject *)((PyObject*)__pyx_n_s__score));
    values[5] = __pyx_dynamic_args->__pyx_arg_print_func;
    values[6] = __pyx_dynamic_args->__pyx_arg_trackline;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name_prefix);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__description);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__score_column);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__print_func);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trackline);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_to_summits_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_name_prefix = values[1];
    __pyx_v_name = values[2];
    __pyx_v_description = values[3];
    __pyx_v_score_column = values[4];
    __pyx_v_print_func = values[5];
    __pyx_v_trackline = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_to_summits_bed", 0, 1, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO._to_summits_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_14_to_summits_bed(__pyx_self, __pyx_v_self, __pyx_v_name_prefix, __pyx_v_name, __pyx_v_description, __pyx_v_score_column, __pyx_v_print_func, __pyx_v_trackline);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_14_to_summits_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, PyObject *__pyx_v_print_func, PyObject *__pyx_v_trackline) {
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_n_peak = NULL;
  PyObject *__pyx_v_peakprefix = NULL;
  PyObject *__pyx_v_desc = NULL;
  PyObject *__pyx_v_trackcontents = NULL;
  PyObject *__pyx_v_chrom = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_end = NULL;
  PyObject *__pyx_v_group = NULL;
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_peak = NULL;
  PyObject *__pyx_v_summit_p = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  PyObject *(*__pyx_t_14)(PyObject *);
  PyObject *(*__pyx_t_15)(PyObject *);
  Py_ssize_t __pyx_t_16;
  int __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("_to_summits_bed", 0);
  __Pyx_TraceCall("_to_summits_bed", __pyx_f[0], 158);

  /* "MACS2/IO/cPeakIO.pyx":164
 *         generalization of to_summits_bed and write_to_summit_bed
 *         """
 *         chrs = self.peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         n_peak = 0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_chrs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":165
 *         """
 *         chrs = self.peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":166
 *         chrs = self.peaks.keys()
 *         chrs.sort()
 *         n_peak = 0             # <<<<<<<<<<<<<<
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_n_peak = __pyx_int_0;

  /* "MACS2/IO/cPeakIO.pyx":167
 *         chrs.sort()
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name             # <<<<<<<<<<<<<<
 *         except: peakprefix = name_prefix
 *         try: desc = description % name
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {
      __pyx_t_2 = PyNumber_Remainder(__pyx_v_name_prefix, __pyx_v_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_peakprefix = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "MACS2/IO/cPeakIO.pyx":168
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix             # <<<<<<<<<<<<<<
 *         try: desc = description % name
 *         except: desc = description
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO._to_summits_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_name_prefix);
      __Pyx_XDECREF(__pyx_v_peakprefix);
      __pyx_v_peakprefix = __pyx_v_name_prefix;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L10_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":169
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 *         try: desc = description % name             # <<<<<<<<<<<<<<
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {
      __pyx_t_6 = PyNumber_Remainder(__pyx_v_description, __pyx_v_name); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_v_desc = __pyx_t_6;
      __pyx_t_6 = 0;
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L20_try_end;
    __pyx_L13_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "MACS2/IO/cPeakIO.pyx":170
 *         except: peakprefix = name_prefix
 *         try: desc = description % name
 *         except: desc = description             # <<<<<<<<<<<<<<
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 *         if trackline:
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO._to_summits_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_description);
      __Pyx_XDECREF(__pyx_v_desc);
      __pyx_v_desc = __pyx_v_description;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L14_exception_handled;
    }
    __pyx_L15_except_error:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L14_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    __pyx_L20_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":171
 *         try: desc = description % name
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))             # <<<<<<<<<<<<<<
 *         if trackline:
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_name, __pyx_n_s__replace); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_desc, __pyx_n_s__replace); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_1 = 0;
  __pyx_t_6 = 0;
  __pyx_v_trackcontents = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":172
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 *         if trackline:             # <<<<<<<<<<<<<<
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_trackline); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_7) {

    /* "MACS2/IO/cPeakIO.pyx":173
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 *         if trackline:
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)             # <<<<<<<<<<<<<<
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      /*try:*/ {
        __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)__pyx_v_trackcontents)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_2));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
        __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L31_try_end;
      __pyx_L24_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "MACS2/IO/cPeakIO.pyx":174
 *         if trackline:
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 */
      /*except:*/ {
        __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO._to_summits_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_6, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_8 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_k_tuple_16), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L25_exception_handled;
      }
      __pyx_L26_except_error:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L1_error;
      __pyx_L25_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      __pyx_L31_try_end:;
    }
    goto __pyx_L23;
  }
  __pyx_L23:;

  /* "MACS2/IO/cPeakIO.pyx":175
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_1 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_1); __pyx_t_9 = 0;
    __pyx_t_10 = NULL;
  } else {
    __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_10 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++;
    } else if (!__pyx_t_10 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++;
    } else {
      __pyx_t_6 = __pyx_t_10(__pyx_t_1);
      if (unlikely(!__pyx_t_6)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF(__pyx_v_chrom);
    __pyx_v_chrom = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "MACS2/IO/cPeakIO.pyx":176
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 peaks = list(group)
 */
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__groupby); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = PyObject_GetItem(__pyx_t_2, __pyx_v_chrom); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
    __pyx_t_11 = __Pyx_GetName(__pyx_m, __pyx_n_s__itemgetter); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_k_tuple_17), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__key), __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    if (PyList_CheckExact(__pyx_t_12) || PyTuple_CheckExact(__pyx_t_12)) {
      __pyx_t_8 = __pyx_t_12; __Pyx_INCREF(__pyx_t_8); __pyx_t_13 = 0;
      __pyx_t_14 = NULL;
    } else {
      __pyx_t_13 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_14 = Py_TYPE(__pyx_t_8)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    for (;;) {
      if (!__pyx_t_14 && PyList_CheckExact(__pyx_t_8)) {
        if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_8)) break;
        __pyx_t_12 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_13); __Pyx_INCREF(__pyx_t_12); __pyx_t_13++;
      } else if (!__pyx_t_14 && PyTuple_CheckExact(__pyx_t_8)) {
        if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_13); __Pyx_INCREF(__pyx_t_12); __pyx_t_13++;
      } else {
        __pyx_t_12 = __pyx_t_14(__pyx_t_8);
        if (unlikely(!__pyx_t_12)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_12);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
        PyObject* sequence = __pyx_t_12;
        if (likely(PyTuple_CheckExact(sequence))) {
          if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
            if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
            if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_15 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_2)) goto __pyx_L38_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_6 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_6)) goto __pyx_L38_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L39_unpacking_done;
        __pyx_L38_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
        if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L39_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_end);
      __pyx_v_end = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_v_group);
      __pyx_v_group = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "MACS2/IO/cPeakIO.pyx":177
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1             # <<<<<<<<<<<<<<
 *                 peaks = list(group)
 *                 if len(peaks) > 1:
 */
      __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_n_peak, __pyx_int_1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_v_n_peak);
      __pyx_v_n_peak = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "MACS2/IO/cPeakIO.pyx":178
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1
 *                 peaks = list(group)             # <<<<<<<<<<<<<<
 *                 if len(peaks) > 1:
 *                     for i, peak in enumerate(peaks):
 */
      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_v_group);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_group);
      __Pyx_GIVEREF(__pyx_v_group);
      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
      __Pyx_XDECREF(((PyObject *)__pyx_v_peaks));
      __pyx_v_peaks = ((PyObject*)__pyx_t_6);
      __pyx_t_6 = 0;

      /* "MACS2/IO/cPeakIO.pyx":179
 *                 n_peak += 1
 *                 peaks = list(group)
 *                 if len(peaks) > 1:             # <<<<<<<<<<<<<<
 *                     for i, peak in enumerate(peaks):
 *                         summit_p = peak["summit"]
 */
      __pyx_t_16 = PyList_GET_SIZE(((PyObject *)__pyx_v_peaks)); 
      __pyx_t_7 = (__pyx_t_16 > 1);
      if (__pyx_t_7) {

        /* "MACS2/IO/cPeakIO.pyx":180
 *                 peaks = list(group)
 *                 if len(peaks) > 1:
 *                     for i, peak in enumerate(peaks):             # <<<<<<<<<<<<<<
 *                         summit_p = peak["summit"]
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,summit_p,summit_p+1,peakprefix,n_peak,subpeak_letters(i),peak[score_column]))
 */
        __Pyx_INCREF(__pyx_int_0);
        __pyx_t_6 = __pyx_int_0;
        __pyx_t_12 = ((PyObject *)__pyx_v_peaks); __Pyx_INCREF(__pyx_t_12); __pyx_t_16 = 0;
        for (;;) {
          if (__pyx_t_16 >= PyList_GET_SIZE(__pyx_t_12)) break;
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_16); __Pyx_INCREF(__pyx_t_2); __pyx_t_16++;
          __Pyx_XDECREF(__pyx_v_peak);
          __pyx_v_peak = __pyx_t_2;
          __pyx_t_2 = 0;
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_XDECREF(__pyx_v_i);
          __pyx_v_i = __pyx_t_6;
          __pyx_t_2 = PyNumber_Add(__pyx_t_6, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6);
          __pyx_t_6 = __pyx_t_2;
          __pyx_t_2 = 0;

          /* "MACS2/IO/cPeakIO.pyx":181
 *                 if len(peaks) > 1:
 *                     for i, peak in enumerate(peaks):
 *                         summit_p = peak["summit"]             # <<<<<<<<<<<<<<
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,summit_p,summit_p+1,peakprefix,n_peak,subpeak_letters(i),peak[score_column]))
 *                 else:
 */
          __pyx_t_2 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__summit)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XDECREF(__pyx_v_summit_p);
          __pyx_v_summit_p = __pyx_t_2;
          __pyx_t_2 = 0;

          /* "MACS2/IO/cPeakIO.pyx":182
 *                     for i, peak in enumerate(peaks):
 *                         summit_p = peak["summit"]
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,summit_p,summit_p+1,peakprefix,n_peak,subpeak_letters(i),peak[score_column]))             # <<<<<<<<<<<<<<
 *                 else:
 *                     peak = peaks[0]
 */
          __pyx_t_2 = PyNumber_Add(__pyx_v_summit_p, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_17 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_11 = __pyx_f_5MACS2_2IO_7cPeakIO_subpeak_letters(__pyx_t_17); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, __pyx_v_score_column); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_19 = PyTuple_New(7); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_INCREF(__pyx_v_chrom);
          PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_v_chrom);
          __Pyx_GIVEREF(__pyx_v_chrom);
          __Pyx_INCREF(__pyx_v_summit_p);
          PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_v_summit_p);
          __Pyx_GIVEREF(__pyx_v_summit_p);
          PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __Pyx_INCREF(__pyx_v_peakprefix);
          PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_v_peakprefix);
          __Pyx_GIVEREF(__pyx_v_peakprefix);
          __Pyx_INCREF(__pyx_v_n_peak);
          PyTuple_SET_ITEM(__pyx_t_19, 4, __pyx_v_n_peak);
          __Pyx_GIVEREF(__pyx_v_n_peak);
          PyTuple_SET_ITEM(__pyx_t_19, 5, __pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_19, 6, __pyx_t_18);
          __Pyx_GIVEREF(__pyx_t_18);
          __pyx_t_2 = 0;
          __pyx_t_11 = 0;
          __pyx_t_18 = 0;
          __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), ((PyObject *)__pyx_t_19)); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_18));
          __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
          __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
          __pyx_t_18 = 0;
          __pyx_t_18 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        }
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L40;
      }
      /*else*/ {

        /* "MACS2/IO/cPeakIO.pyx":184
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,summit_p,summit_p+1,peakprefix,n_peak,subpeak_letters(i),peak[score_column]))
 *                 else:
 *                     peak = peaks[0]             # <<<<<<<<<<<<<<
 *                     summit_p = peak["summit"]
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,summit_p,summit_p+1,peakprefix,n_peak,peak[score_column]))
 */
        __pyx_t_6 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_peaks), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_XDECREF(__pyx_v_peak);
        __pyx_v_peak = __pyx_t_6;
        __pyx_t_6 = 0;

        /* "MACS2/IO/cPeakIO.pyx":185
 *                 else:
 *                     peak = peaks[0]
 *                     summit_p = peak["summit"]             # <<<<<<<<<<<<<<
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,summit_p,summit_p+1,peakprefix,n_peak,peak[score_column]))
 * 
 */
        __pyx_t_6 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__summit)); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_XDECREF(__pyx_v_summit_p);
        __pyx_v_summit_p = __pyx_t_6;
        __pyx_t_6 = 0;

        /* "MACS2/IO/cPeakIO.pyx":186
 *                     peak = peaks[0]
 *                     summit_p = peak["summit"]
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,summit_p,summit_p+1,peakprefix,n_peak,peak[score_column]))             # <<<<<<<<<<<<<<
 * 
 *     def tobed (self):
 */
        __pyx_t_6 = PyNumber_Add(__pyx_v_summit_p, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_12 = PyObject_GetItem(__pyx_v_peak, __pyx_v_score_column); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_18 = PyTuple_New(6); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_INCREF(__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_v_chrom);
        __Pyx_INCREF(__pyx_v_summit_p);
        PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_v_summit_p);
        __Pyx_GIVEREF(__pyx_v_summit_p);
        PyTuple_SET_ITEM(__pyx_t_18, 2, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_v_peakprefix);
        PyTuple_SET_ITEM(__pyx_t_18, 3, __pyx_v_peakprefix);
        __Pyx_GIVEREF(__pyx_v_peakprefix);
        __Pyx_INCREF(__pyx_v_n_peak);
        PyTuple_SET_ITEM(__pyx_t_18, 4, __pyx_v_n_peak);
        __Pyx_GIVEREF(__pyx_v_n_peak);
        PyTuple_SET_ITEM(__pyx_t_18, 5, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_12);
        __pyx_t_6 = 0;
        __pyx_t_12 = 0;
        __pyx_t_12 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), ((PyObject *)__pyx_t_18)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_12));
        __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
        __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        PyTuple_SET_ITEM(__pyx_t_18, 0, ((PyObject *)__pyx_t_12));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_12));
        __pyx_t_12 = 0;
        __pyx_t_12 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_t_18), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __pyx_L40:;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO._to_summits_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_n_peak);
  __Pyx_XDECREF(__pyx_v_peakprefix);
  __Pyx_XDECREF(__pyx_v_desc);
  __Pyx_XDECREF(__pyx_v_trackcontents);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_end);
  __Pyx_XDECREF(__pyx_v_group);
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_peak);
  __Pyx_XDECREF(__pyx_v_summit_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_17tobed(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_16tobed[] = "Print out peaks in BED5 format.\n\n        Five columns are chromosome, peak start, peak end, peak name, and peak height.\n\n        start:start\n        end:end,\n        length:end-start,\n        summit:summit,\n        score:peak_score,\n        pileup:pileup,\n        pscore:pvalue,\n        fc:fold_change,\n        qscore:qvalue\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_17tobed = {__Pyx_NAMESTR("tobed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_17tobed, METH_O, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_16tobed)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_17tobed(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tobed (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_16tobed(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":188
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,summit_p,summit_p+1,peakprefix,n_peak,peak[score_column]))
 * 
 *     def tobed (self):             # <<<<<<<<<<<<<<
 *         """Print out peaks in BED5 format.
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_16tobed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("tobed", 0);
  __Pyx_TraceCall("tobed", __pyx_f[0], 188);

  /* "MACS2/IO/cPeakIO.pyx":203
 *         qscore:qvalue
 *         """
 *         return self._to_bed(name_prefix="peak_", score_column="score")             # <<<<<<<<<<<<<<
 * 
 *     def to_summits_bed (self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___to_bed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__name_prefix), ((PyObject *)__pyx_n_s__peak_)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__score_column), ((PyObject *)__pyx_n_s__score)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.tobed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_19to_summits_bed(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_18to_summits_bed[] = "Print out peak summits in BED5 format.\n\n        Five columns are chromosome, summit start, summit end, peak name, and peak height.\n\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_19to_summits_bed = {__Pyx_NAMESTR("to_summits_bed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_19to_summits_bed, METH_O, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_18to_summits_bed)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_19to_summits_bed(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_summits_bed (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_18to_summits_bed(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":205
 *         return self._to_bed(name_prefix="peak_", score_column="score")
 * 
 *     def to_summits_bed (self):             # <<<<<<<<<<<<<<
 *         """Print out peak summits in BED5 format.
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_18to_summits_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("to_summits_bed", 0);
  __Pyx_TraceCall("to_summits_bed", __pyx_f[0], 205);

  /* "MACS2/IO/cPeakIO.pyx":211
 * 
 *         """
 *         return self._to_summits_bed(name_prefix="peak_", score_column="score")             # <<<<<<<<<<<<<<
 * 
 *     # these methods are very fast, specifying types is unnecessary
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___to_summits_bed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__name_prefix), ((PyObject *)__pyx_n_s__peak_)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__score_column), ((PyObject *)__pyx_n_s__score)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.to_summits_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":214
 * 
 *     # these methods are very fast, specifying types is unnecessary
 *     def write_to_bed (self, fhd, str name_prefix="peak_", str name="MACS",             # <<<<<<<<<<<<<<
 *                         str description = "%s", str score_column="score", trackline=True):
 *         """Write peaks in BED5 format in a file handler. Score (5th
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_34__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_TraceCall("__defaults__", __pyx_f[0], 214);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_self)->__pyx_arg_trackline);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_self)->__pyx_arg_trackline);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_self)->__pyx_arg_trackline);
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_21write_to_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_20write_to_bed[] = "Write peaks in BED5 format in a file handler. Score (5th\n        column) is decided by score_column setting. Check the\n        following list. Name column ( 4th column) is made by putting\n        name_prefix together with an ascending number.\n\n        Five columns are chromosome, peak start, peak end, peak name,\n        and peak score.\n\n        items in peak hash object:\n\n        start:start\n        end:end,\n        length:end-start,\n        summit:summit,\n        score:peak_score,\n        pileup:pileup,\n        pscore:pvalue,\n        fc:fold_change,\n        qscore:qvalue        \n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_21write_to_bed = {__Pyx_NAMESTR("write_to_bed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_21write_to_bed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_20write_to_bed)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_21write_to_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fhd = 0;
  PyObject *__pyx_v_name_prefix = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_description = 0;
  PyObject *__pyx_v_score_column = 0;
  PyObject *__pyx_v_trackline = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fhd,&__pyx_n_s__name_prefix,&__pyx_n_s__name,&__pyx_n_s__description,&__pyx_n_s__score_column,&__pyx_n_s__trackline,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_to_bed (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[7] = {0,0,0,0,0,0,0};
    __pyx_defaults2 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_self);
    values[2] = ((PyObject*)((PyObject*)__pyx_n_s__peak_));
    values[3] = ((PyObject*)((PyObject*)__pyx_n_s__MACS));
    values[4] = ((PyObject*)((PyObject*)__pyx_kp_s_2));
    values[5] = ((PyObject*)((PyObject*)__pyx_n_s__score));
    values[6] = __pyx_dynamic_args->__pyx_arg_trackline;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fhd);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_to_bed", 0, 2, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name_prefix);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__description);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__score_column);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trackline);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_to_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_fhd = values[1];
    __pyx_v_name_prefix = ((PyObject*)values[2]);
    __pyx_v_name = ((PyObject*)values[3]);
    __pyx_v_description = ((PyObject*)values[4]);
    __pyx_v_score_column = ((PyObject*)values[5]);
    __pyx_v_trackline = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_to_bed", 0, 2, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.write_to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name_prefix), (&PyString_Type), 1, "name_prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyString_Type), 1, "name", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_description), (&PyString_Type), 1, "description", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_score_column), (&PyString_Type), 1, "score_column", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_20write_to_bed(__pyx_self, __pyx_v_self, __pyx_v_fhd, __pyx_v_name_prefix, __pyx_v_name, __pyx_v_description, __pyx_v_score_column, __pyx_v_trackline);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_20write_to_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, PyObject *__pyx_v_trackline) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_to_bed", 0);
  __Pyx_TraceCall("write_to_bed", __pyx_f[0], 214);

  /* "MACS2/IO/cPeakIO.pyx":236
 *         qscore:qvalue
 *         """
 *         return self._to_bed(name_prefix=name_prefix, name=name,             # <<<<<<<<<<<<<<
 *                             description=description, score_column=score_column,
 *                             print_func=fhd.write, trackline=trackline)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___to_bed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__name_prefix), ((PyObject *)__pyx_v_name_prefix)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__name), ((PyObject *)__pyx_v_name)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":237
 *         """
 *         return self._to_bed(name_prefix=name_prefix, name=name,
 *                             description=description, score_column=score_column,             # <<<<<<<<<<<<<<
 *                             print_func=fhd.write, trackline=trackline)
 * 
 */
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__description), ((PyObject *)__pyx_v_description)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__score_column), ((PyObject *)__pyx_v_score_column)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":238
 *         return self._to_bed(name_prefix=name_prefix, name=name,
 *                             description=description, score_column=score_column,
 *                             print_func=fhd.write, trackline=trackline)             # <<<<<<<<<<<<<<
 * 
 *     def write_to_summit_bed (self, fhd, name_prefix="peak_", name="MACS",
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_fhd, __pyx_n_s__write); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__print_func), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__trackline), __pyx_v_trackline) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.write_to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":240
 *                             print_func=fhd.write, trackline=trackline)
 * 
 *     def write_to_summit_bed (self, fhd, name_prefix="peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                              description = "%s", score_column="score", trackline=True):
 *         """Write peak summits in BED5 format in a file handler. Score
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_36__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_TraceCall("__defaults__", __pyx_f[0], 240);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_self)->__pyx_arg_trackline);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_self)->__pyx_arg_trackline);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_self)->__pyx_arg_trackline);
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_23write_to_summit_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_22write_to_summit_bed[] = "Write peak summits in BED5 format in a file handler. Score\n        (5th column) is decided by score_column setting. Check the\n        following list. Name column ( 4th column) is made by putting\n        name_prefix together with an ascending number.\n\n        Five columns are chromosome, summit start, summit end, peak name, and peak score.\n\n        items in peak object:\n\n        start:start\n        end:end,\n        length:end-start,\n        summit:summit,\n        score:peak_score,\n        pileup:pileup,\n        pscore:pvalue,\n        fc:fold_change,\n        qscore:qvalue\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_23write_to_summit_bed = {__Pyx_NAMESTR("write_to_summit_bed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_23write_to_summit_bed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_22write_to_summit_bed)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_23write_to_summit_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fhd = 0;
  PyObject *__pyx_v_name_prefix = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_description = 0;
  PyObject *__pyx_v_score_column = 0;
  PyObject *__pyx_v_trackline = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fhd,&__pyx_n_s__name_prefix,&__pyx_n_s__name,&__pyx_n_s__description,&__pyx_n_s__score_column,&__pyx_n_s__trackline,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_to_summit_bed (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[7] = {0,0,0,0,0,0,0};
    __pyx_defaults3 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_self);
    values[2] = ((PyObject *)((PyObject*)__pyx_n_s__peak_));
    values[3] = ((PyObject *)((PyObject*)__pyx_n_s__MACS));
    values[4] = ((PyObject *)((PyObject*)__pyx_kp_s_2));
    values[5] = ((PyObject *)((PyObject*)__pyx_n_s__score));
    values[6] = __pyx_dynamic_args->__pyx_arg_trackline;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fhd);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_to_summit_bed", 0, 2, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name_prefix);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__description);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__score_column);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trackline);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_to_summit_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_fhd = values[1];
    __pyx_v_name_prefix = values[2];
    __pyx_v_name = values[3];
    __pyx_v_description = values[4];
    __pyx_v_score_column = values[5];
    __pyx_v_trackline = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_to_summit_bed", 0, 2, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.write_to_summit_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_22write_to_summit_bed(__pyx_self, __pyx_v_self, __pyx_v_fhd, __pyx_v_name_prefix, __pyx_v_name, __pyx_v_description, __pyx_v_score_column, __pyx_v_trackline);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_22write_to_summit_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, PyObject *__pyx_v_trackline) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_to_summit_bed", 0);
  __Pyx_TraceCall("write_to_summit_bed", __pyx_f[0], 240);

  /* "MACS2/IO/cPeakIO.pyx":261
 *         qscore:qvalue
 *         """
 *         return self._to_summits_bed(name_prefix=name_prefix, name=name,             # <<<<<<<<<<<<<<
 *                                     description=description, score_column=score_column,
 *                                     print_func=fhd.write, trackline=trackline)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___to_summits_bed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__name_prefix), __pyx_v_name_prefix) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__name), __pyx_v_name) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":262
 *         """
 *         return self._to_summits_bed(name_prefix=name_prefix, name=name,
 *                                     description=description, score_column=score_column,             # <<<<<<<<<<<<<<
 *                                     print_func=fhd.write, trackline=trackline)
 * 
 */
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__description), __pyx_v_description) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__score_column), __pyx_v_score_column) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":263
 *         return self._to_summits_bed(name_prefix=name_prefix, name=name,
 *                                     description=description, score_column=score_column,
 *                                     print_func=fhd.write, trackline=trackline)             # <<<<<<<<<<<<<<
 * 
 *     def write_to_narrowPeak (self, fhd, name_prefix="peak_", name="peak", score_column="score", trackline=True):
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_fhd, __pyx_n_s__write); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__print_func), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__trackline), __pyx_v_trackline) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.write_to_summit_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":265
 *                                     print_func=fhd.write, trackline=trackline)
 * 
 *     def write_to_narrowPeak (self, fhd, name_prefix="peak_", name="peak", score_column="score", trackline=True):             # <<<<<<<<<<<<<<
 *         """Print out peaks in narrowPeak format.
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_38__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_TraceCall("__defaults__", __pyx_f[0], 265);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__peak)));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)((PyObject*)__pyx_n_s__peak)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__peak)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_self)->__pyx_arg_trackline);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_self)->__pyx_arg_trackline);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_self)->__pyx_arg_trackline);
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_25write_to_narrowPeak(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_24write_to_narrowPeak[] = "Print out peaks in narrowPeak format.\n\n        This format is designed for ENCODE project, and basically a\n        BED6+4 format.\n\n        +-----------+------+----------------------------------------+\n        |field      |type  |description                             |\n        +-----------+------+----------------------------------------+\n        |chrom      |string|Name of the chromosome                  |\n        +-----------+------+----------------------------------------+\n        |chromStart |int   |The starting position of the feature in |\n        |           |      |the chromosome. The first base in a     |\n        |           |      |chromosome is numbered 0.               |\n        +-----------+------+----------------------------------------+\n        |chromEnd   |int   |The ending position of the feature in   |\n        |           |      |the chromosome or scaffold. The chromEnd|\n        |           |      |base is not included in the display of  |\n        |           |      |the feature.  For example, the first 100|\n        |           |      |bases of a chromosome are defined as    |\n        |           |      |chromStart=0, chromEnd=100, and span the|\n        |           |      |bases numbered 0-99.                    |\n        +-----------+------+----------------------------------------+\n        |name       |string|Name given to a region (preferably      |\n        |           |      |unique). Use '.' if no name is assigned.|\n        +-----------+------+----------------------------------------+\n        |score      |int   |Indicates how dark the peak will be     |\n        |(-logpvalue|      |displayed in the browser (1-1000). If   |\n        |in MACS2 * |      |'0', the DCC will assign this based on  |\n        |10)        |      |signal value. Ideally average           |\n        |           |      |signalValue per base spread between     |\n        |           |      |100-1000.                               |\n        +---------""--+------+----------------------------------------+\n        |strand     |char  |+/- to denote strand or orientation     |\n        |(always .) |      |(whenever applicable). Use '.' if no    |\n        |           |      |orientation is assigned.                |\n        +-----------+------+----------------------------------------+\n        |signalValue|float |Measurement of overall (usually,        |\n        |(fc)       |      |average) enrichment for the region.     |\n        +-----------+------+----------------------------------------+\n        |pValue     |float |Measurement of statistical signficance  |\n        |           |      |(-log10). Use -1 if no pValue is        |\n        |           |      |assigned.                               |\n        +-----------+------+----------------------------------------+\n        |qValue     |float |Measurement of statistical significance |\n        |           |      |using false discovery rate. Use -1 if no|\n        |           |      |qValue is assigned.                     |\n        +-----------+------+----------------------------------------+\n        |peak       |int   |Point-source called for this peak;      |\n        |           |      |0-based offset from chromStart. Use -1  |\n        |           |      |if no point-source called.              |\n        +-----------+------+----------------------------------------+\n        \n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_25write_to_narrowPeak = {__Pyx_NAMESTR("write_to_narrowPeak"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_25write_to_narrowPeak, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_24write_to_narrowPeak)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_25write_to_narrowPeak(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fhd = 0;
  PyObject *__pyx_v_name_prefix = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_score_column = 0;
  PyObject *__pyx_v_trackline = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fhd,&__pyx_n_s__name_prefix,&__pyx_n_s__name,&__pyx_n_s__score_column,&__pyx_n_s__trackline,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_to_narrowPeak (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[6] = {0,0,0,0,0,0};
    __pyx_defaults4 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_self);
    values[2] = ((PyObject *)((PyObject*)__pyx_n_s__peak_));
    values[3] = ((PyObject *)((PyObject*)__pyx_n_s__peak));
    values[4] = ((PyObject *)((PyObject*)__pyx_n_s__score));
    values[5] = __pyx_dynamic_args->__pyx_arg_trackline;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fhd);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_to_narrowPeak", 0, 2, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name_prefix);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__score_column);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trackline);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_to_narrowPeak") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_fhd = values[1];
    __pyx_v_name_prefix = values[2];
    __pyx_v_name = values[3];
    __pyx_v_score_column = values[4];
    __pyx_v_trackline = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_to_narrowPeak", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.write_to_narrowPeak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_24write_to_narrowPeak(__pyx_self, __pyx_v_self, __pyx_v_fhd, __pyx_v_name_prefix, __pyx_v_name, __pyx_v_score_column, __pyx_v_trackline);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_24write_to_narrowPeak(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_score_column, PyObject *__pyx_v_trackline) {
  int __pyx_v_n_peak;
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_peakprefix = NULL;
  PyObject *__pyx_v_peak = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_to_narrowPeak", 0);
  __Pyx_TraceCall("write_to_narrowPeak", __pyx_f[0], 265);

  /* "MACS2/IO/cPeakIO.pyx":322
 *         cdef str chrom
 * 
 *         chrs = self.peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         n_peak = 0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_chrs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":323
 * 
 *         chrs = self.peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":324
 *         chrs = self.peaks.keys()
 *         chrs.sort()
 *         n_peak = 0             # <<<<<<<<<<<<<<
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 */
  __pyx_v_n_peak = 0;

  /* "MACS2/IO/cPeakIO.pyx":325
 *         chrs.sort()
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name             # <<<<<<<<<<<<<<
 *         except: peakprefix = name_prefix
 *         if trackline:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {
      __pyx_t_2 = PyNumber_Remainder(__pyx_v_name_prefix, __pyx_v_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_peakprefix = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "MACS2/IO/cPeakIO.pyx":326
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix             # <<<<<<<<<<<<<<
 *         if trackline:
 *             fhd.write("track type=narrowPeak name=\"%s\" description=\"%s\" nextItemButton=on\n" % (name, name))
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.write_to_narrowPeak", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_name_prefix);
      __Pyx_XDECREF(__pyx_v_peakprefix);
      __pyx_v_peakprefix = __pyx_v_name_prefix;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L10_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":327
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 *         if trackline:             # <<<<<<<<<<<<<<
 *             fhd.write("track type=narrowPeak name=\"%s\" description=\"%s\" nextItemButton=on\n" % (name, name))
 *         for chrom in chrs:
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_trackline); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_7) {

    /* "MACS2/IO/cPeakIO.pyx":328
 *         except: peakprefix = name_prefix
 *         if trackline:
 *             fhd.write("track type=narrowPeak name=\"%s\" description=\"%s\" nextItemButton=on\n" % (name, name))             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             for peak in self.peaks[chrom]:
 */
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_fhd, __pyx_n_s__write); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_name);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_name);
    __Pyx_GIVEREF(__pyx_v_name);
    __Pyx_INCREF(__pyx_v_name);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_name);
    __Pyx_GIVEREF(__pyx_v_name);
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "MACS2/IO/cPeakIO.pyx":329
 *         if trackline:
 *             fhd.write("track type=narrowPeak name=\"%s\" description=\"%s\" nextItemButton=on\n" % (name, name))
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             for peak in self.peaks[chrom]:
 *                 n_peak += 1
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_2 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++;
    } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++;
    } else {
      __pyx_t_1 = __pyx_t_9(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_chrom));
    __pyx_v_chrom = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "MACS2/IO/cPeakIO.pyx":330
 *             fhd.write("track type=narrowPeak name=\"%s\" description=\"%s\" nextItemButton=on\n" % (name, name))
 *         for chrom in chrs:
 *             for peak in self.peaks[chrom]:             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 # items in peak: (peak start,peak end, peak length,
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyObject_GetItem(__pyx_t_1, ((PyObject *)__pyx_v_chrom)); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
      __pyx_t_1 = __pyx_t_6; __Pyx_INCREF(__pyx_t_1); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = Py_TYPE(__pyx_t_1)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    for (;;) {
      if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_1)) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++;
      } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_1)) {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++;
      } else {
        __pyx_t_6 = __pyx_t_11(__pyx_t_1);
        if (unlikely(!__pyx_t_6)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_XDECREF(__pyx_v_peak);
      __pyx_v_peak = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "MACS2/IO/cPeakIO.pyx":331
 *         for chrom in chrs:
 *             for peak in self.peaks[chrom]:
 *                 n_peak += 1             # <<<<<<<<<<<<<<
 *                 # items in peak: (peak start,peak end, peak length,
 *                 # peak summit, peak height, number of tags in peak
 */
      __pyx_v_n_peak = (__pyx_v_n_peak + 1);

      /* "MACS2/IO/cPeakIO.pyx":335
 *                 # peak summit, peak height, number of tags in peak
 *                 # region, peak pvalue, peak fold_enrichment, qvalue)
 *                 fhd.write( "%s\t%d\t%d\t%s%d\t%d\t.\t%.2f\t%.2f\t%.2f\t%d\n"             # <<<<<<<<<<<<<<
 *                            %
 *                            (chrom,peak["start"],peak["end"],peakprefix,n_peak,int(10*peak[score_column]),
 */
      __pyx_t_6 = PyObject_GetAttr(__pyx_v_fhd, __pyx_n_s__write); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);

      /* "MACS2/IO/cPeakIO.pyx":337
 *                 fhd.write( "%s\t%d\t%d\t%s%d\t%d\t.\t%.2f\t%.2f\t%.2f\t%d\n"
 *                            %
 *                            (chrom,peak["start"],peak["end"],peakprefix,n_peak,int(10*peak[score_column]),             # <<<<<<<<<<<<<<
 *                             peak["fc"],peak["pscore"],peak["qscore"],peak["summit"]-peak["start"]) )
 * 
 */
      __pyx_t_12 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__start)); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__end)); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = PyInt_FromLong(__pyx_v_n_peak); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_15 = PyObject_GetItem(__pyx_v_peak, __pyx_v_score_column); if (!__pyx_t_15) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = PyNumber_Multiply(__pyx_int_10, __pyx_t_15); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_16);
      __pyx_t_16 = 0;
      __pyx_t_16 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;

      /* "MACS2/IO/cPeakIO.pyx":338
 *                            %
 *                            (chrom,peak["start"],peak["end"],peakprefix,n_peak,int(10*peak[score_column]),
 *                             peak["fc"],peak["pscore"],peak["qscore"],peak["summit"]-peak["start"]) )             # <<<<<<<<<<<<<<
 * 
 *     def write_to_xls (self, ofhd, name_prefix="%s_peak_", name="MACS"):
 */
      __pyx_t_15 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__fc)); if (!__pyx_t_15) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_17 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__pscore)); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__qscore)); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_19 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__summit)); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_19);
      __pyx_t_20 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__start)); if (!__pyx_t_20) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_20);
      __pyx_t_21 = PyNumber_Subtract(__pyx_t_19, __pyx_t_20); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __pyx_t_20 = PyTuple_New(10); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_20);
      __Pyx_INCREF(((PyObject *)__pyx_v_chrom));
      PyTuple_SET_ITEM(__pyx_t_20, 0, ((PyObject *)__pyx_v_chrom));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_chrom));
      PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_20, 2, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      __Pyx_INCREF(__pyx_v_peakprefix);
      PyTuple_SET_ITEM(__pyx_t_20, 3, __pyx_v_peakprefix);
      __Pyx_GIVEREF(__pyx_v_peakprefix);
      PyTuple_SET_ITEM(__pyx_t_20, 4, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_20, 5, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_20, 6, __pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_20, 7, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_20, 8, __pyx_t_18);
      __Pyx_GIVEREF(__pyx_t_18);
      PyTuple_SET_ITEM(__pyx_t_20, 9, __pyx_t_21);
      __Pyx_GIVEREF(__pyx_t_21);
      __pyx_t_12 = 0;
      __pyx_t_13 = 0;
      __pyx_t_14 = 0;
      __pyx_t_16 = 0;
      __pyx_t_15 = 0;
      __pyx_t_17 = 0;
      __pyx_t_18 = 0;
      __pyx_t_21 = 0;
      __pyx_t_21 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_19), ((PyObject *)__pyx_t_20)); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_21));
      __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
      __pyx_t_20 = PyTuple_New(1); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_20);
      PyTuple_SET_ITEM(__pyx_t_20, 0, ((PyObject *)__pyx_t_21));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_21));
      __pyx_t_21 = 0;
      __pyx_t_21 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_20), NULL); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.write_to_narrowPeak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_peakprefix);
  __Pyx_XDECREF(__pyx_v_peak);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_27write_to_xls(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_26write_to_xls[] = "Save the peak results in a tab-delimited plain text file\n        with suffix .xls.\n        \n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_27write_to_xls = {__Pyx_NAMESTR("write_to_xls"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_27write_to_xls, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_26write_to_xls)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_27write_to_xls(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_ofhd = 0;
  PyObject *__pyx_v_name_prefix = 0;
  PyObject *__pyx_v_name = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__ofhd,&__pyx_n_s__name_prefix,&__pyx_n_s__name,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_to_xls (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[4] = {0,0,0,0};
    values[2] = ((PyObject *)((PyObject*)__pyx_kp_s_1));
    values[3] = ((PyObject *)((PyObject*)__pyx_n_s__MACS));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ofhd);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_to_xls", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name_prefix);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_to_xls") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_ofhd = values[1];
    __pyx_v_name_prefix = values[2];
    __pyx_v_name = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_to_xls", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.write_to_xls", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_26write_to_xls(__pyx_self, __pyx_v_self, __pyx_v_ofhd, __pyx_v_name_prefix, __pyx_v_name);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":340
 *                             peak["fc"],peak["pscore"],peak["qscore"],peak["summit"]-peak["start"]) )
 * 
 *     def write_to_xls (self, ofhd, name_prefix="%s_peak_", name="MACS"):             # <<<<<<<<<<<<<<
 *         """Save the peak results in a tab-delimited plain text file
 *         with suffix .xls.
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_26write_to_xls(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_ofhd, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name) {
  PyObject *__pyx_v_write = NULL;
  PyObject *__pyx_v_peakprefix = NULL;
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_n_peak = NULL;
  PyObject *__pyx_v_chrom = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_end = NULL;
  PyObject *__pyx_v_group = NULL;
  PyObject *__pyx_v_these_peaks = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_peak = NULL;
  PyObject *__pyx_v_peakname = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  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;
  Py_ssize_t __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *(*__pyx_t_14)(PyObject *);
  Py_ssize_t __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_to_xls", 0);
  __Pyx_TraceCall("write_to_xls", __pyx_f[0], 340);

  /* "MACS2/IO/cPeakIO.pyx":345
 * 
 *         """
 *         write = ofhd.write             # <<<<<<<<<<<<<<
 *         write("\t".join(("chr","start", "end",  "length",  "abs_summit", "pileup", "-log10(pvalue)", "fold_enrichment", "-log10(qvalue)", "name"))+"\n")
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_ofhd, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_write = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":346
 *         """
 *         write = ofhd.write
 *         write("\t".join(("chr","start", "end",  "length",  "abs_summit", "pileup", "-log10(pvalue)", "fold_enrichment", "-log10(qvalue)", "name"))+"\n")             # <<<<<<<<<<<<<<
 * 
 *         try: peakprefix = name_prefix % name
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_20), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_24), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(__pyx_t_2, ((PyObject *)__pyx_kp_s_25)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":348
 *         write("\t".join(("chr","start", "end",  "length",  "abs_summit", "pileup", "-log10(pvalue)", "fold_enrichment", "-log10(qvalue)", "name"))+"\n")
 * 
 *         try: peakprefix = name_prefix % name             # <<<<<<<<<<<<<<
 *         except: peakprefix = name_prefix
 * 
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {
      __pyx_t_1 = PyNumber_Remainder(__pyx_v_name_prefix, __pyx_v_name); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_peakprefix = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "MACS2/IO/cPeakIO.pyx":349
 * 
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix             # <<<<<<<<<<<<<<
 * 
 *         peaks = self.peaks
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.write_to_xls", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_name_prefix);
      __Pyx_XDECREF(__pyx_v_peakprefix);
      __pyx_v_peakprefix = __pyx_v_name_prefix;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L10_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":351
 *         except: peakprefix = name_prefix
 * 
 *         peaks = self.peaks             # <<<<<<<<<<<<<<
 *         chrs = peaks.keys()
 *         chrs.sort()
 */
  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_peaks = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "MACS2/IO/cPeakIO.pyx":352
 * 
 *         peaks = self.peaks
 *         chrs = peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         n_peak = 0
 */
  __pyx_t_6 = PyObject_GetAttr(__pyx_v_peaks, __pyx_n_s__keys); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_chrs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":353
 *         peaks = self.peaks
 *         chrs = peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         n_peak = 0
 *         for chrom in chrs:
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "MACS2/IO/cPeakIO.pyx":354
 *         chrs = peaks.keys()
 *         chrs.sort()
 *         n_peak = 0             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             for end, group in groupby(peaks[chrom], key=itemgetter("end")):
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_n_peak = __pyx_int_0;

  /* "MACS2/IO/cPeakIO.pyx":355
 *         chrs.sort()
 *         n_peak = 0
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             for end, group in groupby(peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_6 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_6)) {
      if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++;
    } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_6)) {
      if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++;
    } else {
      __pyx_t_2 = __pyx_t_8(__pyx_t_6);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_chrom);
    __pyx_v_chrom = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "MACS2/IO/cPeakIO.pyx":356
 *         n_peak = 0
 *         for chrom in chrs:
 *             for end, group in groupby(peaks[chrom], key=itemgetter("end")):             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 these_peaks = list(group)
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__groupby); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_GetItem(__pyx_v_peaks, __pyx_v_chrom); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__itemgetter); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_k_tuple_26), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__key), __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_9), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    if (PyList_CheckExact(__pyx_t_11) || PyTuple_CheckExact(__pyx_t_11)) {
      __pyx_t_1 = __pyx_t_11; __Pyx_INCREF(__pyx_t_1); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_12 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_13 = Py_TYPE(__pyx_t_1)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    for (;;) {
      if (!__pyx_t_13 && PyList_CheckExact(__pyx_t_1)) {
        if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_11 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_11); __pyx_t_12++;
      } else if (!__pyx_t_13 && PyTuple_CheckExact(__pyx_t_1)) {
        if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_11); __pyx_t_12++;
      } else {
        __pyx_t_11 = __pyx_t_13(__pyx_t_1);
        if (unlikely(!__pyx_t_11)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_11);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_11))) || (PyList_CheckExact(__pyx_t_11))) {
        PyObject* sequence = __pyx_t_11;
        if (likely(PyTuple_CheckExact(sequence))) {
          if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
            if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
            if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_10 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_10)->tp_iternext;
        index = 0; __pyx_t_9 = __pyx_t_14(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L17_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_9);
        index = 1; __pyx_t_2 = __pyx_t_14(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L17_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L18_unpacking_done;
        __pyx_L17_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
        if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L18_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_end);
      __pyx_v_end = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_v_group);
      __pyx_v_group = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "MACS2/IO/cPeakIO.pyx":357
 *         for chrom in chrs:
 *             for end, group in groupby(peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1             # <<<<<<<<<<<<<<
 *                 these_peaks = list(group)
 *                 if len(these_peaks) > 1:
 */
      __pyx_t_11 = PyNumber_InPlaceAdd(__pyx_v_n_peak, __pyx_int_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_v_n_peak);
      __pyx_v_n_peak = __pyx_t_11;
      __pyx_t_11 = 0;

      /* "MACS2/IO/cPeakIO.pyx":358
 *             for end, group in groupby(peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1
 *                 these_peaks = list(group)             # <<<<<<<<<<<<<<
 *                 if len(these_peaks) > 1:
 *                     for i, peak in enumerate(these_peaks):
 */
      __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_v_group);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_group);
      __Pyx_GIVEREF(__pyx_v_group);
      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
      __Pyx_XDECREF(((PyObject *)__pyx_v_these_peaks));
      __pyx_v_these_peaks = ((PyObject*)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "MACS2/IO/cPeakIO.pyx":359
 *                 n_peak += 1
 *                 these_peaks = list(group)
 *                 if len(these_peaks) > 1:             # <<<<<<<<<<<<<<
 *                     for i, peak in enumerate(these_peaks):
 *                         peakname = "%s%d%s" % (peakprefix, n_peak, subpeak_letters(i))
 */
      __pyx_t_15 = PyList_GET_SIZE(((PyObject *)__pyx_v_these_peaks)); 
      __pyx_t_16 = (__pyx_t_15 > 1);
      if (__pyx_t_16) {

        /* "MACS2/IO/cPeakIO.pyx":360
 *                 these_peaks = list(group)
 *                 if len(these_peaks) > 1:
 *                     for i, peak in enumerate(these_peaks):             # <<<<<<<<<<<<<<
 *                         peakname = "%s%d%s" % (peakprefix, n_peak, subpeak_letters(i))
 *                         #[start,end,end-start,summit,peak_height,number_tags,pvalue,fold_change,qvalue]
 */
        __Pyx_INCREF(__pyx_int_0);
        __pyx_t_2 = __pyx_int_0;
        __pyx_t_11 = ((PyObject *)__pyx_v_these_peaks); __Pyx_INCREF(__pyx_t_11); __pyx_t_15 = 0;
        for (;;) {
          if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_11)) break;
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_15); __Pyx_INCREF(__pyx_t_9); __pyx_t_15++;
          __Pyx_XDECREF(__pyx_v_peak);
          __pyx_v_peak = __pyx_t_9;
          __pyx_t_9 = 0;
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_XDECREF(__pyx_v_i);
          __pyx_v_i = __pyx_t_2;
          __pyx_t_9 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_2);
          __pyx_t_2 = __pyx_t_9;
          __pyx_t_9 = 0;

          /* "MACS2/IO/cPeakIO.pyx":361
 *                 if len(these_peaks) > 1:
 *                     for i, peak in enumerate(these_peaks):
 *                         peakname = "%s%d%s" % (peakprefix, n_peak, subpeak_letters(i))             # <<<<<<<<<<<<<<
 *                         #[start,end,end-start,summit,peak_height,number_tags,pvalue,fold_change,qvalue]
 *                         write("%s\t%d\t%d\t%d" % (chrom,peak["start"]+1,peak["end"],peak["length"]))
 */
          __pyx_t_17 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_9 = __pyx_f_5MACS2_2IO_7cPeakIO_subpeak_letters(__pyx_t_17); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_INCREF(__pyx_v_peakprefix);
          PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_peakprefix);
          __Pyx_GIVEREF(__pyx_v_peakprefix);
          __Pyx_INCREF(__pyx_v_n_peak);
          PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_n_peak);
          __Pyx_GIVEREF(__pyx_v_n_peak);
          PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_9);
          __pyx_t_9 = 0;
          __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_27), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_9));
          __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_v_peakname);
          __pyx_v_peakname = ((PyObject *)__pyx_t_9);
          __pyx_t_9 = 0;

          /* "MACS2/IO/cPeakIO.pyx":363
 *                         peakname = "%s%d%s" % (peakprefix, n_peak, subpeak_letters(i))
 *                         #[start,end,end-start,summit,peak_height,number_tags,pvalue,fold_change,qvalue]
 *                         write("%s\t%d\t%d\t%d" % (chrom,peak["start"]+1,peak["end"],peak["length"]))             # <<<<<<<<<<<<<<
 *                         write("\t%d" % (peak["summit"]+1)) # summit position
 *                         write("\t%.2f" % (peak["pileup"])) # pileup height at summit
 */
          __pyx_t_9 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__start)); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = PyNumber_Add(__pyx_t_9, __pyx_int_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__end)); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__length)); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_19 = PyTuple_New(4); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_INCREF(__pyx_v_chrom);
          PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_v_chrom);
          __Pyx_GIVEREF(__pyx_v_chrom);
          PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_t_18);
          __Pyx_GIVEREF(__pyx_t_18);
          __pyx_t_10 = 0;
          __pyx_t_9 = 0;
          __pyx_t_18 = 0;
          __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_28), ((PyObject *)__pyx_t_19)); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_18));
          __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
          __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
          __pyx_t_18 = 0;
          __pyx_t_18 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "MACS2/IO/cPeakIO.pyx":364
 *                         #[start,end,end-start,summit,peak_height,number_tags,pvalue,fold_change,qvalue]
 *                         write("%s\t%d\t%d\t%d" % (chrom,peak["start"]+1,peak["end"],peak["length"]))
 *                         write("\t%d" % (peak["summit"]+1)) # summit position             # <<<<<<<<<<<<<<
 *                         write("\t%.2f" % (peak["pileup"])) # pileup height at summit
 *                         write("\t%.2f" % (peak["pscore"])) # -log10pvalue at summit
 */
          __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__summit)); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_19 = PyNumber_Add(__pyx_t_18, __pyx_int_1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_29), __pyx_t_19); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_18));
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
          __pyx_t_18 = 0;
          __pyx_t_18 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "MACS2/IO/cPeakIO.pyx":365
 *                         write("%s\t%d\t%d\t%d" % (chrom,peak["start"]+1,peak["end"],peak["length"]))
 *                         write("\t%d" % (peak["summit"]+1)) # summit position
 *                         write("\t%.2f" % (peak["pileup"])) # pileup height at summit             # <<<<<<<<<<<<<<
 *                         write("\t%.2f" % (peak["pscore"])) # -log10pvalue at summit
 *                         write("\t%.2f" % (peak["fc"])) # fold change at summit
 */
          __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__pileup)); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_19 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), __pyx_t_18); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_19));
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          PyTuple_SET_ITEM(__pyx_t_18, 0, ((PyObject *)__pyx_t_19));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_19));
          __pyx_t_19 = 0;
          __pyx_t_19 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_18), NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

          /* "MACS2/IO/cPeakIO.pyx":366
 *                         write("\t%d" % (peak["summit"]+1)) # summit position
 *                         write("\t%.2f" % (peak["pileup"])) # pileup height at summit
 *                         write("\t%.2f" % (peak["pscore"])) # -log10pvalue at summit             # <<<<<<<<<<<<<<
 *                         write("\t%.2f" % (peak["fc"])) # fold change at summit
 *                         write("\t%.2f" % (peak["qscore"])) # -log10qvalue at summit
 */
          __pyx_t_19 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__pscore)); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), __pyx_t_19); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_18));
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
          __pyx_t_18 = 0;
          __pyx_t_18 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "MACS2/IO/cPeakIO.pyx":367
 *                         write("\t%.2f" % (peak["pileup"])) # pileup height at summit
 *                         write("\t%.2f" % (peak["pscore"])) # -log10pvalue at summit
 *                         write("\t%.2f" % (peak["fc"])) # fold change at summit             # <<<<<<<<<<<<<<
 *                         write("\t%.2f" % (peak["qscore"])) # -log10qvalue at summit
 *                         write("\t%s" % peakname)
 */
          __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__fc)); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_19 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), __pyx_t_18); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_19));
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          PyTuple_SET_ITEM(__pyx_t_18, 0, ((PyObject *)__pyx_t_19));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_19));
          __pyx_t_19 = 0;
          __pyx_t_19 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_18), NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

          /* "MACS2/IO/cPeakIO.pyx":368
 *                         write("\t%.2f" % (peak["pscore"])) # -log10pvalue at summit
 *                         write("\t%.2f" % (peak["fc"])) # fold change at summit
 *                         write("\t%.2f" % (peak["qscore"])) # -log10qvalue at summit             # <<<<<<<<<<<<<<
 *                         write("\t%s" % peakname)
 *                         write("\n")
 */
          __pyx_t_19 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__qscore)); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), __pyx_t_19); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_18));
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
          __pyx_t_18 = 0;
          __pyx_t_18 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "MACS2/IO/cPeakIO.pyx":369
 *                         write("\t%.2f" % (peak["fc"])) # fold change at summit
 *                         write("\t%.2f" % (peak["qscore"])) # -log10qvalue at summit
 *                         write("\t%s" % peakname)             # <<<<<<<<<<<<<<
 *                         write("\n")
 *                 else:
 */
          __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_31), __pyx_v_peakname); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_18));
          __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
          __pyx_t_18 = 0;
          __pyx_t_18 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "MACS2/IO/cPeakIO.pyx":370
 *                         write("\t%.2f" % (peak["qscore"])) # -log10qvalue at summit
 *                         write("\t%s" % peakname)
 *                         write("\n")             # <<<<<<<<<<<<<<
 *                 else:
 *                     peak = these_peaks[0]
 */
          __pyx_t_18 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_k_tuple_32), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L19;
      }
      /*else*/ {

        /* "MACS2/IO/cPeakIO.pyx":372
 *                         write("\n")
 *                 else:
 *                     peak = these_peaks[0]             # <<<<<<<<<<<<<<
 *                     peakname = "%s%d" % (peakprefix, n_peak)
 *                     #[start,end,end-start,summit,peak_height,number_tags,pvalue,fold_change,qvalue]
 */
        __pyx_t_2 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_these_peaks), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_XDECREF(__pyx_v_peak);
        __pyx_v_peak = __pyx_t_2;
        __pyx_t_2 = 0;

        /* "MACS2/IO/cPeakIO.pyx":373
 *                 else:
 *                     peak = these_peaks[0]
 *                     peakname = "%s%d" % (peakprefix, n_peak)             # <<<<<<<<<<<<<<
 *                     #[start,end,end-start,summit,peak_height,number_tags,pvalue,fold_change,qvalue]
 *                     write("%s\t%d\t%d\t%d" % (chrom,peak["start"]+1,peak["end"],peak["length"]))
 */
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_v_peakprefix);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_peakprefix);
        __Pyx_GIVEREF(__pyx_v_peakprefix);
        __Pyx_INCREF(__pyx_v_n_peak);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_n_peak);
        __Pyx_GIVEREF(__pyx_v_n_peak);
        __pyx_t_11 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_33), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_11));
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_v_peakname);
        __pyx_v_peakname = ((PyObject *)__pyx_t_11);
        __pyx_t_11 = 0;

        /* "MACS2/IO/cPeakIO.pyx":375
 *                     peakname = "%s%d" % (peakprefix, n_peak)
 *                     #[start,end,end-start,summit,peak_height,number_tags,pvalue,fold_change,qvalue]
 *                     write("%s\t%d\t%d\t%d" % (chrom,peak["start"]+1,peak["end"],peak["length"]))             # <<<<<<<<<<<<<<
 *                     write("\t%d" % (peak["summit"]+1)) # summit position
 *                     write("\t%.2f" % (peak["pileup"])) # pileup height at summit
 */
        __pyx_t_11 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__start)); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_2 = PyNumber_Add(__pyx_t_11, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__end)); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__length)); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_19 = PyTuple_New(4); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __Pyx_INCREF(__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_t_18);
        __Pyx_GIVEREF(__pyx_t_18);
        __pyx_t_2 = 0;
        __pyx_t_11 = 0;
        __pyx_t_18 = 0;
        __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_28), ((PyObject *)__pyx_t_19)); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_18));
        __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
        __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
        __pyx_t_18 = 0;
        __pyx_t_18 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

        /* "MACS2/IO/cPeakIO.pyx":376
 *                     #[start,end,end-start,summit,peak_height,number_tags,pvalue,fold_change,qvalue]
 *                     write("%s\t%d\t%d\t%d" % (chrom,peak["start"]+1,peak["end"],peak["length"]))
 *                     write("\t%d" % (peak["summit"]+1)) # summit position             # <<<<<<<<<<<<<<
 *                     write("\t%.2f" % (peak["pileup"])) # pileup height at summit
 *                     write("\t%.2f" % (peak["pscore"])) # -log10pvalue at summit
 */
        __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__summit)); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_19 = PyNumber_Add(__pyx_t_18, __pyx_int_1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_29), __pyx_t_19); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_18));
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
        __pyx_t_18 = 0;
        __pyx_t_18 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

        /* "MACS2/IO/cPeakIO.pyx":377
 *                     write("%s\t%d\t%d\t%d" % (chrom,peak["start"]+1,peak["end"],peak["length"]))
 *                     write("\t%d" % (peak["summit"]+1)) # summit position
 *                     write("\t%.2f" % (peak["pileup"])) # pileup height at summit             # <<<<<<<<<<<<<<
 *                     write("\t%.2f" % (peak["pscore"])) # -log10pvalue at summit
 *                     write("\t%.2f" % (peak["fc"])) # fold change at summit
 */
        __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__pileup)); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_19 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), __pyx_t_18); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_19));
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        PyTuple_SET_ITEM(__pyx_t_18, 0, ((PyObject *)__pyx_t_19));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_19));
        __pyx_t_19 = 0;
        __pyx_t_19 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_18), NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

        /* "MACS2/IO/cPeakIO.pyx":378
 *                     write("\t%d" % (peak["summit"]+1)) # summit position
 *                     write("\t%.2f" % (peak["pileup"])) # pileup height at summit
 *                     write("\t%.2f" % (peak["pscore"])) # -log10pvalue at summit             # <<<<<<<<<<<<<<
 *                     write("\t%.2f" % (peak["fc"])) # fold change at summit
 *                     write("\t%.2f" % (peak["qscore"])) # -log10qvalue at summit
 */
        __pyx_t_19 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__pscore)); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), __pyx_t_19); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_18));
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
        __pyx_t_18 = 0;
        __pyx_t_18 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

        /* "MACS2/IO/cPeakIO.pyx":379
 *                     write("\t%.2f" % (peak["pileup"])) # pileup height at summit
 *                     write("\t%.2f" % (peak["pscore"])) # -log10pvalue at summit
 *                     write("\t%.2f" % (peak["fc"])) # fold change at summit             # <<<<<<<<<<<<<<
 *                     write("\t%.2f" % (peak["qscore"])) # -log10qvalue at summit
 *                     write("\t%s" % peakname)
 */
        __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__fc)); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_19 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), __pyx_t_18); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_19));
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        PyTuple_SET_ITEM(__pyx_t_18, 0, ((PyObject *)__pyx_t_19));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_19));
        __pyx_t_19 = 0;
        __pyx_t_19 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_18), NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

        /* "MACS2/IO/cPeakIO.pyx":380
 *                     write("\t%.2f" % (peak["pscore"])) # -log10pvalue at summit
 *                     write("\t%.2f" % (peak["fc"])) # fold change at summit
 *                     write("\t%.2f" % (peak["qscore"])) # -log10qvalue at summit             # <<<<<<<<<<<<<<
 *                     write("\t%s" % peakname)
 *                     write("\n")
 */
        __pyx_t_19 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__qscore)); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), __pyx_t_19); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_18));
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
        __pyx_t_18 = 0;
        __pyx_t_18 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

        /* "MACS2/IO/cPeakIO.pyx":381
 *                     write("\t%.2f" % (peak["fc"])) # fold change at summit
 *                     write("\t%.2f" % (peak["qscore"])) # -log10qvalue at summit
 *                     write("\t%s" % peakname)             # <<<<<<<<<<<<<<
 *                     write("\n")
 *         return
 */
        __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_31), __pyx_v_peakname); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_18));
        __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
        __pyx_t_18 = 0;
        __pyx_t_18 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

        /* "MACS2/IO/cPeakIO.pyx":382
 *                     write("\t%.2f" % (peak["qscore"])) # -log10qvalue at summit
 *                     write("\t%s" % peakname)
 *                     write("\n")             # <<<<<<<<<<<<<<
 *         return
 * 
 */
        __pyx_t_18 = PyObject_Call(__pyx_v_write, ((PyObject *)__pyx_k_tuple_34), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      }
      __pyx_L19:;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "MACS2/IO/cPeakIO.pyx":383
 *                     write("\t%s" % peakname)
 *                     write("\n")
 *         return             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.write_to_xls", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_write);
  __Pyx_XDECREF(__pyx_v_peakprefix);
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_n_peak);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_end);
  __Pyx_XDECREF(__pyx_v_group);
  __Pyx_XDECREF(__pyx_v_these_peaks);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_peak);
  __Pyx_XDECREF(__pyx_v_peakname);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_29overlap_with_other_peaks(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_28overlap_with_other_peaks[] = "Peaks2 is a PeakIO object or dictionary with can be\n        initialzed as a PeakIO. check __init__ for PeakIO for detail.\n\n        return how many peaks are intersected by peaks2 by percentage\n        coverage on peaks2(if 50%, cover = 0.5).\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_29overlap_with_other_peaks = {__Pyx_NAMESTR("overlap_with_other_peaks"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_29overlap_with_other_peaks, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_6PeakIO_28overlap_with_other_peaks)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6PeakIO_29overlap_with_other_peaks(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_peaks2 = 0;
  double __pyx_v_cover;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__peaks2,&__pyx_n_s__cover,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("overlap_with_other_peaks (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__peaks2);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("overlap_with_other_peaks", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cover);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "overlap_with_other_peaks") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[2]) {
      } else {

        /* "MACS2/IO/cPeakIO.pyx":386
 * 
 * 
 *     def overlap_with_other_peaks (self, peaks2, double cover=0):             # <<<<<<<<<<<<<<
 *         """Peaks2 is a PeakIO object or dictionary with can be
 *         initialzed as a PeakIO. check __init__ for PeakIO for detail.
 */
        __pyx_v_cover = ((double)((double)0.0));
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_peaks2 = values[1];
    if (values[2]) {
      __pyx_v_cover = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_cover == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_cover = ((double)((double)0.0));
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("overlap_with_other_peaks", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.overlap_with_other_peaks", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_28overlap_with_other_peaks(__pyx_self, __pyx_v_self, __pyx_v_peaks2, __pyx_v_cover);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_28overlap_with_other_peaks(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_peaks2, double __pyx_v_cover) {
  int __pyx_v_total_num;
  PyObject *__pyx_v_chrs1 = 0;
  PyObject *__pyx_v_chrs2 = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_peaks1 = NULL;
  PyObject *__pyx_v_rl1_k = NULL;
  PyObject *__pyx_v_rl2_k = NULL;
  int __pyx_v_tmp_n;
  PyObject *__pyx_v_r1 = NULL;
  PyObject *__pyx_v_r2 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  double __pyx_t_14;
  int __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("overlap_with_other_peaks", 0);
  __Pyx_TraceCall("overlap_with_other_peaks", __pyx_f[0], 386);
  __Pyx_INCREF(__pyx_v_peaks2);

  /* "MACS2/IO/cPeakIO.pyx":397
 *         cdef str k
 * 
 *         peaks1 = self.peaks             # <<<<<<<<<<<<<<
 *         if isinstance(peaks2,PeakIO):
 *             peaks2 = peaks2.peaks
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_peaks1 = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":398
 * 
 *         peaks1 = self.peaks
 *         if isinstance(peaks2,PeakIO):             # <<<<<<<<<<<<<<
 *             peaks2 = peaks2.peaks
 *         total_num = 0
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__PeakIO); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_peaks2, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "MACS2/IO/cPeakIO.pyx":399
 *         peaks1 = self.peaks
 *         if isinstance(peaks2,PeakIO):
 *             peaks2 = peaks2.peaks             # <<<<<<<<<<<<<<
 *         total_num = 0
 *         chrs1 = peaks1.keys()
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_peaks2, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_v_peaks2);
    __pyx_v_peaks2 = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "MACS2/IO/cPeakIO.pyx":400
 *         if isinstance(peaks2,PeakIO):
 *             peaks2 = peaks2.peaks
 *         total_num = 0             # <<<<<<<<<<<<<<
 *         chrs1 = peaks1.keys()
 *         chrs2 = peaks2.keys()
 */
  __pyx_v_total_num = 0;

  /* "MACS2/IO/cPeakIO.pyx":401
 *             peaks2 = peaks2.peaks
 *         total_num = 0
 *         chrs1 = peaks1.keys()             # <<<<<<<<<<<<<<
 *         chrs2 = peaks2.keys()
 *         for k in chrs1:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_peaks1, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_chrs1 = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":402
 *         total_num = 0
 *         chrs1 = peaks1.keys()
 *         chrs2 = peaks2.keys()             # <<<<<<<<<<<<<<
 *         for k in chrs1:
 *             if not chrs2.count(k):
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_peaks2, __pyx_n_s__keys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_chrs2 = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":403
 *         chrs1 = peaks1.keys()
 *         chrs2 = peaks2.keys()
 *         for k in chrs1:             # <<<<<<<<<<<<<<
 *             if not chrs2.count(k):
 *                 continue
 */
  if (unlikely(((PyObject *)__pyx_v_chrs1) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_1 = ((PyObject *)__pyx_v_chrs1); __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
    if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_k));
    __pyx_v_k = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "MACS2/IO/cPeakIO.pyx":404
 *         chrs2 = peaks2.keys()
 *         for k in chrs1:
 *             if not chrs2.count(k):             # <<<<<<<<<<<<<<
 *                 continue
 *             rl1_k = iter(peaks1[k])
 */
    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_chrs2), __pyx_n_s__count); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_k));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_k));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_k));
    __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = (!__pyx_t_2);
    if (__pyx_t_7) {

      /* "MACS2/IO/cPeakIO.pyx":405
 *         for k in chrs1:
 *             if not chrs2.count(k):
 *                 continue             # <<<<<<<<<<<<<<
 *             rl1_k = iter(peaks1[k])
 *             rl2_k = iter(peaks2[k])
 */
      goto __pyx_L4_continue;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "MACS2/IO/cPeakIO.pyx":406
 *             if not chrs2.count(k):
 *                 continue
 *             rl1_k = iter(peaks1[k])             # <<<<<<<<<<<<<<
 *             rl2_k = iter(peaks2[k])
 *             tmp_n = False
 */
    __pyx_t_6 = PyObject_GetItem(__pyx_v_peaks1, ((PyObject *)__pyx_v_k)); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_v_rl1_k);
    __pyx_v_rl1_k = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "MACS2/IO/cPeakIO.pyx":407
 *                 continue
 *             rl1_k = iter(peaks1[k])
 *             rl2_k = iter(peaks2[k])             # <<<<<<<<<<<<<<
 *             tmp_n = False
 *             try:
 */
    __pyx_t_5 = PyObject_GetItem(__pyx_v_peaks2, ((PyObject *)__pyx_v_k)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_rl2_k);
    __pyx_v_rl2_k = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "MACS2/IO/cPeakIO.pyx":408
 *             rl1_k = iter(peaks1[k])
 *             rl2_k = iter(peaks2[k])
 *             tmp_n = False             # <<<<<<<<<<<<<<
 *             try:
 *                 r1 = rl1_k.next()
 */
    __pyx_v_tmp_n = 0;

    /* "MACS2/IO/cPeakIO.pyx":409
 *             rl2_k = iter(peaks2[k])
 *             tmp_n = False
 *             try:             # <<<<<<<<<<<<<<
 *                 r1 = rl1_k.next()
 *                 r2 = rl2_k.next()
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      /*try:*/ {

        /* "MACS2/IO/cPeakIO.pyx":410
 *             tmp_n = False
 *             try:
 *                 r1 = rl1_k.next()             # <<<<<<<<<<<<<<
 *                 r2 = rl2_k.next()
 *                 while (True):
 */
        __pyx_t_6 = PyObject_GetAttr(__pyx_v_rl1_k, __pyx_n_s__next); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_v_r1);
        __pyx_v_r1 = __pyx_t_5;
        __pyx_t_5 = 0;

        /* "MACS2/IO/cPeakIO.pyx":411
 *             try:
 *                 r1 = rl1_k.next()
 *                 r2 = rl2_k.next()             # <<<<<<<<<<<<<<
 *                 while (True):
 *                     if r2[0] < r1[1] and r1[0] < r2[1]:
 */
        __pyx_t_5 = PyObject_GetAttr(__pyx_v_rl2_k, __pyx_n_s__next); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_v_r2);
        __pyx_v_r2 = __pyx_t_6;
        __pyx_t_6 = 0;

        /* "MACS2/IO/cPeakIO.pyx":412
 *                 r1 = rl1_k.next()
 *                 r2 = rl2_k.next()
 *                 while (True):             # <<<<<<<<<<<<<<
 *                     if r2[0] < r1[1] and r1[0] < r2[1]:
 *                         a = sorted([r1[0],r1[1],r2[0],r2[1]])
 */
        while (1) {
          if (!1) break;

          /* "MACS2/IO/cPeakIO.pyx":413
 *                 r2 = rl2_k.next()
 *                 while (True):
 *                     if r2[0] < r1[1] and r1[0] < r2[1]:             # <<<<<<<<<<<<<<
 *                         a = sorted([r1[0],r1[1],r2[0],r2[1]])
 *                         if float(a[2]-a[1]+1)/r2[2] > cover:
 */
          __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_r2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_r1, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_t_5, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (__pyx_t_7) {
            __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_r1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_r2, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_t_5, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_11 = __pyx_t_2;
          } else {
            __pyx_t_11 = __pyx_t_7;
          }
          if (__pyx_t_11) {

            /* "MACS2/IO/cPeakIO.pyx":414
 *                 while (True):
 *                     if r2[0] < r1[1] and r1[0] < r2[1]:
 *                         a = sorted([r1[0],r1[1],r2[0],r2[1]])             # <<<<<<<<<<<<<<
 *                         if float(a[2]-a[1]+1)/r2[2] > cover:
 *                             if not tmp_n:
 */
            __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_r1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_r1, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_r2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_r2, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_13 = PyList_New(4); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_13);
            PyList_SET_ITEM(__pyx_t_13, 0, __pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_6);
            PyList_SET_ITEM(__pyx_t_13, 1, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_5);
            PyList_SET_ITEM(__pyx_t_13, 2, __pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_3);
            PyList_SET_ITEM(__pyx_t_13, 3, __pyx_t_12);
            __Pyx_GIVEREF(__pyx_t_12);
            __pyx_t_6 = 0;
            __pyx_t_5 = 0;
            __pyx_t_3 = 0;
            __pyx_t_12 = 0;
            __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_12);
            PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_t_13));
            __Pyx_GIVEREF(((PyObject *)__pyx_t_13));
            __pyx_t_13 = 0;
            __pyx_t_13 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
            if (!(likely(PyList_CheckExact(__pyx_t_13))||((__pyx_t_13) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_13)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_XDECREF(((PyObject *)__pyx_v_a));
            __pyx_v_a = ((PyObject*)__pyx_t_13);
            __pyx_t_13 = 0;

            /* "MACS2/IO/cPeakIO.pyx":415
 *                     if r2[0] < r1[1] and r1[0] < r2[1]:
 *                         a = sorted([r1[0],r1[1],r2[0],r2[1]])
 *                         if float(a[2]-a[1]+1)/r2[2] > cover:             # <<<<<<<<<<<<<<
 *                             if not tmp_n:
 *                                 total_num+=1
 */
            __pyx_t_13 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_a), 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_12 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_a), 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_3 = PyNumber_Subtract(__pyx_t_13, __pyx_t_12); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __pyx_t_12 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_14 = __Pyx_PyObject_AsDouble(__pyx_t_12); if (unlikely(__pyx_t_14 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __pyx_t_12 = PyFloat_FromDouble(__pyx_t_14); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_r2, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_13 = __Pyx_PyNumber_Divide(__pyx_t_12, __pyx_t_3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_3 = PyFloat_FromDouble(__pyx_v_cover); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_12 = PyObject_RichCompare(__pyx_t_13, __pyx_t_3, Py_GT); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (__pyx_t_11) {

              /* "MACS2/IO/cPeakIO.pyx":416
 *                         a = sorted([r1[0],r1[1],r2[0],r2[1]])
 *                         if float(a[2]-a[1]+1)/r2[2] > cover:
 *                             if not tmp_n:             # <<<<<<<<<<<<<<
 *                                 total_num+=1
 *                                 tmp_n = True
 */
              __pyx_t_11 = (!__pyx_v_tmp_n);
              if (__pyx_t_11) {

                /* "MACS2/IO/cPeakIO.pyx":417
 *                         if float(a[2]-a[1]+1)/r2[2] > cover:
 *                             if not tmp_n:
 *                                 total_num+=1             # <<<<<<<<<<<<<<
 *                                 tmp_n = True
 *                     if r1[1] < r2[1]:
 */
                __pyx_v_total_num = (__pyx_v_total_num + 1);

                /* "MACS2/IO/cPeakIO.pyx":418
 *                             if not tmp_n:
 *                                 total_num+=1
 *                                 tmp_n = True             # <<<<<<<<<<<<<<
 *                     if r1[1] < r2[1]:
 *                         r1 = rl1_k.next()
 */
                __pyx_v_tmp_n = 1;
                goto __pyx_L19;
              }
              __pyx_L19:;
              goto __pyx_L18;
            }
            __pyx_L18:;
            goto __pyx_L17;
          }
          __pyx_L17:;

          /* "MACS2/IO/cPeakIO.pyx":419
 *                                 total_num+=1
 *                                 tmp_n = True
 *                     if r1[1] < r2[1]:             # <<<<<<<<<<<<<<
 *                         r1 = rl1_k.next()
 *                         tmp_n = False
 */
          __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_r1, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_r2, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_13 = PyObject_RichCompare(__pyx_t_12, __pyx_t_3, Py_LT); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (__pyx_t_11) {

            /* "MACS2/IO/cPeakIO.pyx":420
 *                                 tmp_n = True
 *                     if r1[1] < r2[1]:
 *                         r1 = rl1_k.next()             # <<<<<<<<<<<<<<
 *                         tmp_n = False
 *                     else:
 */
            __pyx_t_13 = PyObject_GetAttr(__pyx_v_rl1_k, __pyx_n_s__next); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_3 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_v_r1);
            __pyx_v_r1 = __pyx_t_3;
            __pyx_t_3 = 0;

            /* "MACS2/IO/cPeakIO.pyx":421
 *                     if r1[1] < r2[1]:
 *                         r1 = rl1_k.next()
 *                         tmp_n = False             # <<<<<<<<<<<<<<
 *                     else:
 *                         r2 = rl2_k.next()
 */
            __pyx_v_tmp_n = 0;
            goto __pyx_L20;
          }
          /*else*/ {

            /* "MACS2/IO/cPeakIO.pyx":423
 *                         tmp_n = False
 *                     else:
 *                         r2 = rl2_k.next()             # <<<<<<<<<<<<<<
 *             except StopIteration:
 *                 continue
 */
            __pyx_t_3 = PyObject_GetAttr(__pyx_v_rl2_k, __pyx_n_s__next); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_13 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_v_r2);
            __pyx_v_r2 = __pyx_t_13;
            __pyx_t_13 = 0;
          }
          __pyx_L20:;
        }
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L14_try_end;
      __pyx_L7_error:;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "MACS2/IO/cPeakIO.pyx":424
 *                     else:
 *                         r2 = rl2_k.next()
 *             except StopIteration:             # <<<<<<<<<<<<<<
 *                 continue
 *         return total_num
 */
      __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_StopIteration);
      if (__pyx_t_15) {
        __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.overlap_with_other_peaks", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_13, &__pyx_t_3, &__pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_12);

        /* "MACS2/IO/cPeakIO.pyx":425
 *                         r2 = rl2_k.next()
 *             except StopIteration:
 *                 continue             # <<<<<<<<<<<<<<
 *         return total_num
 * 
 */
        goto __pyx_L22_except_continue;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L8_exception_handled;
        __pyx_L22_except_continue:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L13_try_continue;
      }
      __pyx_L9_except_error:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      goto __pyx_L1_error;
      __pyx_L13_try_continue:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      goto __pyx_L4_continue;
      __pyx_L8_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      __pyx_L14_try_end:;
    }
    __pyx_L4_continue:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":426
 *             except StopIteration:
 *                 continue
 *         return total_num             # <<<<<<<<<<<<<<
 * 
 * class Region:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_total_num); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.PeakIO.overlap_with_other_peaks", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrs1);
  __Pyx_XDECREF(__pyx_v_chrs2);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_peaks1);
  __Pyx_XDECREF(__pyx_v_rl1_k);
  __Pyx_XDECREF(__pyx_v_rl2_k);
  __Pyx_XDECREF(__pyx_v_r1);
  __Pyx_XDECREF(__pyx_v_r2);
  __Pyx_XDECREF(__pyx_v_peaks2);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6Region_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_1__init__, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6Region___init__(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":431
 *     """For plain region of chrom, start and end
 *     """
 *     def __init__ (self):             # <<<<<<<<<<<<<<
 *         self.regions= {}
 *         self.__flag_sorted = False
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6Region___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 431);

  /* "MACS2/IO/cPeakIO.pyx":432
 *     """
 *     def __init__ (self):
 *         self.regions= {}             # <<<<<<<<<<<<<<
 *         self.__flag_sorted = False
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__regions, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":433
 *     def __init__ (self):
 *         self.regions= {}
 *         self.__flag_sorted = False             # <<<<<<<<<<<<<<
 * 
 *     def add_loc ( self, str chrom, int start, int end ):
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s_35, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.Region.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_3add_loc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6Region_3add_loc = {__Pyx_NAMESTR("add_loc"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_3add_loc, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_3add_loc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_chrom = 0;
  int __pyx_v_start;
  int __pyx_v_end;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__chrom,&__pyx_n_s__start,&__pyx_n_s__end,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_loc (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__chrom);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_loc", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_loc", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
        if (likely(values[3])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_loc", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_loc") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_self = values[0];
    __pyx_v_chrom = ((PyObject*)values[1]);
    __pyx_v_start = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_loc", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.Region.add_loc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chrom), (&PyString_Type), 1, "chrom", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6Region_2add_loc(__pyx_self, __pyx_v_self, __pyx_v_chrom, __pyx_v_start, __pyx_v_end);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":435
 *         self.__flag_sorted = False
 * 
 *     def add_loc ( self, str chrom, int start, int end ):             # <<<<<<<<<<<<<<
 *         if self.regions.has_key(chrom):
 *             self.regions[chrom].append( (start,end) )
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6Region_2add_loc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_chrom, int __pyx_v_start, int __pyx_v_end) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("add_loc", 0);
  __Pyx_TraceCall("add_loc", __pyx_f[0], 435);

  /* "MACS2/IO/cPeakIO.pyx":436
 * 
 *     def add_loc ( self, str chrom, int start, int end ):
 *         if self.regions.has_key(chrom):             # <<<<<<<<<<<<<<
 *             self.regions[chrom].append( (start,end) )
 *         else:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__regions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__has_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_chrom));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_chrom));
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "MACS2/IO/cPeakIO.pyx":437
 *     def add_loc ( self, str chrom, int start, int end ):
 *         if self.regions.has_key(chrom):
 *             self.regions[chrom].append( (start,end) )             # <<<<<<<<<<<<<<
 *         else:
 *             self.regions[chrom] = [(start,end), ]
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__regions); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_GetItem(__pyx_t_3, ((PyObject *)__pyx_v_chrom)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_3 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_1, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "MACS2/IO/cPeakIO.pyx":439
 *             self.regions[chrom].append( (start,end) )
 *         else:
 *             self.regions[chrom] = [(start,end), ]             # <<<<<<<<<<<<<<
 *         self.__flag_sorted = False
 *         return
 */
    __pyx_t_2 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyList_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__regions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyObject_SetItem(__pyx_t_1, ((PyObject *)__pyx_v_chrom), ((PyObject *)__pyx_t_5)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  }
  __pyx_L3:;

  /* "MACS2/IO/cPeakIO.pyx":440
 *         else:
 *             self.regions[chrom] = [(start,end), ]
 *         self.__flag_sorted = False             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  __pyx_t_5 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s_35, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "MACS2/IO/cPeakIO.pyx":441
 *             self.regions[chrom] = [(start,end), ]
 *         self.__flag_sorted = False
 *         return             # <<<<<<<<<<<<<<
 * 
 *     def sort (self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.Region.add_loc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_5sort(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6Region_5sort = {__Pyx_NAMESTR("sort"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_5sort, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_5sort(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sort (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6Region_4sort(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":443
 *         return
 * 
 *     def sort (self):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6Region_4sort(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("sort", 0);
  __Pyx_TraceCall("sort", __pyx_f[0], 443);

  /* "MACS2/IO/cPeakIO.pyx":446
 *         cdef str chrom
 * 
 *         for chrom in self.regions.keys():             # <<<<<<<<<<<<<<
 *             self.regions[chrom].sort()
 *         self.__flag_sorted = True
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__regions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_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_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_chrom));
    __pyx_v_chrom = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "MACS2/IO/cPeakIO.pyx":447
 * 
 *         for chrom in self.regions.keys():
 *             self.regions[chrom].sort()             # <<<<<<<<<<<<<<
 *         self.__flag_sorted = True
 * 
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__regions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_GetItem(__pyx_t_1, ((PyObject *)__pyx_v_chrom)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":448
 *         for chrom in self.regions.keys():
 *             self.regions[chrom].sort()
 *         self.__flag_sorted = True             # <<<<<<<<<<<<<<
 * 
 *     def merge_overlap ( self ):
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s_35, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.Region.sort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_7merge_overlap(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6Region_7merge_overlap = {__Pyx_NAMESTR("merge_overlap"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_7merge_overlap, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_7merge_overlap(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("merge_overlap (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6Region_6merge_overlap(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":450
 *         self.__flag_sorted = True
 * 
 *     def merge_overlap ( self ):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 *         cdef int s_new_region, e_new_region, i, j
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6Region_6merge_overlap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_chrom = 0;
  int __pyx_v_s_new_region;
  int __pyx_v_e_new_region;
  int __pyx_v_i;
  PyObject *__pyx_v_regions = NULL;
  PyObject *__pyx_v_new_regions = NULL;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_n_append = NULL;
  PyObject *__pyx_v_prev_region = NULL;
  PyObject *__pyx_v_regions_chr = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("merge_overlap", 0);
  __Pyx_TraceCall("merge_overlap", __pyx_f[0], 450);

  /* "MACS2/IO/cPeakIO.pyx":454
 *         cdef int s_new_region, e_new_region, i, j
 * 
 *         if not self.__flag_sorted:             # <<<<<<<<<<<<<<
 *             self.sort()
 *         regions = self.regions
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_35); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (!__pyx_t_2);
  if (__pyx_t_3) {

    /* "MACS2/IO/cPeakIO.pyx":455
 * 
 *         if not self.__flag_sorted:
 *             self.sort()             # <<<<<<<<<<<<<<
 *         regions = self.regions
 *         new_regions = {}
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "MACS2/IO/cPeakIO.pyx":456
 *         if not self.__flag_sorted:
 *             self.sort()
 *         regions = self.regions             # <<<<<<<<<<<<<<
 *         new_regions = {}
 *         chrs = regions.keys()
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__regions); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_regions = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "MACS2/IO/cPeakIO.pyx":457
 *             self.sort()
 *         regions = self.regions
 *         new_regions = {}             # <<<<<<<<<<<<<<
 *         chrs = regions.keys()
 *         chrs.sort()
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_v_new_regions = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "MACS2/IO/cPeakIO.pyx":458
 *         regions = self.regions
 *         new_regions = {}
 *         chrs = regions.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         for i in range(len(chrs)):
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_regions, __pyx_n_s__keys); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_chrs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":459
 *         new_regions = {}
 *         chrs = regions.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         for i in range(len(chrs)):
 *             chrom = chrs[i]
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "MACS2/IO/cPeakIO.pyx":460
 *         chrs = regions.keys()
 *         chrs.sort()
 *         for i in range(len(chrs)):             # <<<<<<<<<<<<<<
 *             chrom = chrs[i]
 *         #for chrom in chrs:
 */
  __pyx_t_5 = PyObject_Length(__pyx_v_chrs); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
    __pyx_v_i = __pyx_t_6;

    /* "MACS2/IO/cPeakIO.pyx":461
 *         chrs.sort()
 *         for i in range(len(chrs)):
 *             chrom = chrs[i]             # <<<<<<<<<<<<<<
 *         #for chrom in chrs:
 *             new_regions[chrom]=[]
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_chrs, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_chrom));
    __pyx_v_chrom = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "MACS2/IO/cPeakIO.pyx":463
 *             chrom = chrs[i]
 *         #for chrom in chrs:
 *             new_regions[chrom]=[]             # <<<<<<<<<<<<<<
 *             n_append = new_regions[chrom].append
 *             prev_region = None
 */
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(((PyObject *)__pyx_v_new_regions), ((PyObject *)__pyx_v_chrom), ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;

    /* "MACS2/IO/cPeakIO.pyx":464
 *         #for chrom in chrs:
 *             new_regions[chrom]=[]
 *             n_append = new_regions[chrom].append             # <<<<<<<<<<<<<<
 *             prev_region = None
 *             regions_chr = regions[chrom]
 */
    __pyx_t_4 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_new_regions), ((PyObject *)__pyx_v_chrom)); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__append); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_v_n_append);
    __pyx_v_n_append = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "MACS2/IO/cPeakIO.pyx":465
 *             new_regions[chrom]=[]
 *             n_append = new_regions[chrom].append
 *             prev_region = None             # <<<<<<<<<<<<<<
 *             regions_chr = regions[chrom]
 *             for i in range(len(regions_chr)):
 */
    __Pyx_INCREF(Py_None);
    __Pyx_XDECREF(__pyx_v_prev_region);
    __pyx_v_prev_region = Py_None;

    /* "MACS2/IO/cPeakIO.pyx":466
 *             n_append = new_regions[chrom].append
 *             prev_region = None
 *             regions_chr = regions[chrom]             # <<<<<<<<<<<<<<
 *             for i in range(len(regions_chr)):
 *                 if not prev_region:
 */
    __pyx_t_1 = PyObject_GetItem(__pyx_v_regions, ((PyObject *)__pyx_v_chrom)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF(__pyx_v_regions_chr);
    __pyx_v_regions_chr = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "MACS2/IO/cPeakIO.pyx":467
 *             prev_region = None
 *             regions_chr = regions[chrom]
 *             for i in range(len(regions_chr)):             # <<<<<<<<<<<<<<
 *                 if not prev_region:
 *                     prev_region = regions_chr[i]
 */
    __pyx_t_7 = PyObject_Length(__pyx_v_regions_chr); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
      __pyx_v_i = __pyx_t_8;

      /* "MACS2/IO/cPeakIO.pyx":468
 *             regions_chr = regions[chrom]
 *             for i in range(len(regions_chr)):
 *                 if not prev_region:             # <<<<<<<<<<<<<<
 *                     prev_region = regions_chr[i]
 *                     continue
 */
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_prev_region); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = (!__pyx_t_3);
      if (__pyx_t_2) {

        /* "MACS2/IO/cPeakIO.pyx":469
 *             for i in range(len(regions_chr)):
 *                 if not prev_region:
 *                     prev_region = regions_chr[i]             # <<<<<<<<<<<<<<
 *                     continue
 *                 else:
 */
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_regions_chr, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_v_prev_region);
        __pyx_v_prev_region = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "MACS2/IO/cPeakIO.pyx":470
 *                 if not prev_region:
 *                     prev_region = regions_chr[i]
 *                     continue             # <<<<<<<<<<<<<<
 *                 else:
 *                     if regions_chr[i][0] <= prev_region[1]:
 */
        goto __pyx_L6_continue;
        goto __pyx_L8;
      }
      /*else*/ {

        /* "MACS2/IO/cPeakIO.pyx":472
 *                     continue
 *                 else:
 *                     if regions_chr[i][0] <= prev_region[1]:             # <<<<<<<<<<<<<<
 *                         s_new_region = prev_region[0]
 *                         e_new_region = regions_chr[i][1]
 */
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_regions_chr, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_prev_region, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_9 = PyObject_RichCompare(__pyx_t_4, __pyx_t_1, Py_LE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (__pyx_t_2) {

          /* "MACS2/IO/cPeakIO.pyx":473
 *                 else:
 *                     if regions_chr[i][0] <= prev_region[1]:
 *                         s_new_region = prev_region[0]             # <<<<<<<<<<<<<<
 *                         e_new_region = regions_chr[i][1]
 *                         prev_region = (s_new_region,e_new_region)
 */
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_prev_region, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_9); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_v_s_new_region = __pyx_t_10;

          /* "MACS2/IO/cPeakIO.pyx":474
 *                     if regions_chr[i][0] <= prev_region[1]:
 *                         s_new_region = prev_region[0]
 *                         e_new_region = regions_chr[i][1]             # <<<<<<<<<<<<<<
 *                         prev_region = (s_new_region,e_new_region)
 *                     else:
 */
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_regions_chr, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_9, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_v_e_new_region = __pyx_t_10;

          /* "MACS2/IO/cPeakIO.pyx":475
 *                         s_new_region = prev_region[0]
 *                         e_new_region = regions_chr[i][1]
 *                         prev_region = (s_new_region,e_new_region)             # <<<<<<<<<<<<<<
 *                     else:
 *                         n_append(prev_region)
 */
          __pyx_t_1 = PyInt_FromLong(__pyx_v_s_new_region); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_9 = PyInt_FromLong(__pyx_v_e_new_region); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_9);
          __pyx_t_1 = 0;
          __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_v_prev_region);
          __pyx_v_prev_region = ((PyObject *)__pyx_t_4);
          __pyx_t_4 = 0;
          goto __pyx_L9;
        }
        /*else*/ {

          /* "MACS2/IO/cPeakIO.pyx":477
 *                         prev_region = (s_new_region,e_new_region)
 *                     else:
 *                         n_append(prev_region)             # <<<<<<<<<<<<<<
 *                         prev_region = regions_chr[i]
 *             if prev_region:
 */
          __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_INCREF(__pyx_v_prev_region);
          PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_prev_region);
          __Pyx_GIVEREF(__pyx_v_prev_region);
          __pyx_t_9 = PyObject_Call(__pyx_v_n_append, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

          /* "MACS2/IO/cPeakIO.pyx":478
 *                     else:
 *                         n_append(prev_region)
 *                         prev_region = regions_chr[i]             # <<<<<<<<<<<<<<
 *             if prev_region:
 *                 n_append(prev_region)
 */
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_regions_chr, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_v_prev_region);
          __pyx_v_prev_region = __pyx_t_9;
          __pyx_t_9 = 0;
        }
        __pyx_L9:;
      }
      __pyx_L8:;
      __pyx_L6_continue:;
    }

    /* "MACS2/IO/cPeakIO.pyx":479
 *                         n_append(prev_region)
 *                         prev_region = regions_chr[i]
 *             if prev_region:             # <<<<<<<<<<<<<<
 *                 n_append(prev_region)
 *         self.regions = new_regions
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_prev_region); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_2) {

      /* "MACS2/IO/cPeakIO.pyx":480
 *                         prev_region = regions_chr[i]
 *             if prev_region:
 *                 n_append(prev_region)             # <<<<<<<<<<<<<<
 *         self.regions = new_regions
 *         self.sort()
 */
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_prev_region);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_prev_region);
      __Pyx_GIVEREF(__pyx_v_prev_region);
      __pyx_t_4 = PyObject_Call(__pyx_v_n_append, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L10;
    }
    __pyx_L10:;
  }

  /* "MACS2/IO/cPeakIO.pyx":481
 *             if prev_region:
 *                 n_append(prev_region)
 *         self.regions = new_regions             # <<<<<<<<<<<<<<
 *         self.sort()
 *         return True
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__regions, ((PyObject *)__pyx_v_new_regions)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":482
 *                 n_append(prev_region)
 *         self.regions = new_regions
 *         self.sort()             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__sort); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "MACS2/IO/cPeakIO.pyx":483
 *         self.regions = new_regions
 *         self.sort()
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def write_to_bed (self, fhd ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_9 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.Region.merge_overlap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_regions);
  __Pyx_XDECREF(__pyx_v_new_regions);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_n_append);
  __Pyx_XDECREF(__pyx_v_prev_region);
  __Pyx_XDECREF(__pyx_v_regions_chr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_9write_to_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_6Region_9write_to_bed = {__Pyx_NAMESTR("write_to_bed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_9write_to_bed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_6Region_9write_to_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fhd = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fhd,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_to_bed (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fhd);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_to_bed", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_to_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_fhd = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_to_bed", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.Region.write_to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_6Region_8write_to_bed(__pyx_self, __pyx_v_self, __pyx_v_fhd);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":485
 *         return True
 * 
 *     def write_to_bed (self, fhd ):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef str chrom
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_6Region_8write_to_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd) {
  int __pyx_v_i;
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_region = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_to_bed", 0);
  __Pyx_TraceCall("write_to_bed", __pyx_f[0], 485);

  /* "MACS2/IO/cPeakIO.pyx":489
 *         cdef str chrom
 * 
 *         chrs = self.regions.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         for i in range( len(chrs) ):
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__regions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_chrs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":490
 * 
 *         chrs = self.regions.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         for i in range( len(chrs) ):
 *             chrom = chrs[i]
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":491
 *         chrs = self.regions.keys()
 *         chrs.sort()
 *         for i in range( len(chrs) ):             # <<<<<<<<<<<<<<
 *             chrom = chrs[i]
 *             for region in self.regions[chrom]:
 */
  __pyx_t_3 = PyObject_Length(__pyx_v_chrs); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "MACS2/IO/cPeakIO.pyx":492
 *         chrs.sort()
 *         for i in range( len(chrs) ):
 *             chrom = chrs[i]             # <<<<<<<<<<<<<<
 *             for region in self.regions[chrom]:
 *                 fhd.write( "%s\t%d\t%d\n" % (chrom,region[0],region[1] ) )
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_chrs, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_chrom));
    __pyx_v_chrom = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "MACS2/IO/cPeakIO.pyx":493
 *         for i in range( len(chrs) ):
 *             chrom = chrs[i]
 *             for region in self.regions[chrom]:             # <<<<<<<<<<<<<<
 *                 fhd.write( "%s\t%d\t%d\n" % (chrom,region[0],region[1] ) )
 * 
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__regions); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_GetItem(__pyx_t_2, ((PyObject *)__pyx_v_chrom)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_2)) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
      } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_2)) {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
      } else {
        __pyx_t_1 = __pyx_t_6(__pyx_t_2);
        if (unlikely(!__pyx_t_1)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF(__pyx_v_region);
      __pyx_v_region = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "MACS2/IO/cPeakIO.pyx":494
 *             chrom = chrs[i]
 *             for region in self.regions[chrom]:
 *                 fhd.write( "%s\t%d\t%d\n" % (chrom,region[0],region[1] ) )             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_fhd, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_region, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_region, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(((PyObject *)__pyx_v_chrom));
      PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_v_chrom));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_chrom));
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      __pyx_t_7 = 0;
      __pyx_t_8 = 0;
      __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_36), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_8));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
      __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.Region.write_to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_region);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_1__init__, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO___init__(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":503
 *     """
 * 
 *     def __init__ (self):             # <<<<<<<<<<<<<<
 *         self.peaks = {}
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 503);

  /* "MACS2/IO/cPeakIO.pyx":504
 * 
 *     def __init__ (self):
 *         self.peaks = {}             # <<<<<<<<<<<<<<
 * 
 *     def add (self, str chromosome, long start, long end, long summit = 0,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__peaks, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_3add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_2add[] = "items:\n        start:start\n        end:end,\n        length:end-start,\n        summit:summit,                  # summit is where the highest pileup is in a differetnial region, or the common region for only condition A.\n        score:diff_score,               # diff score is the maximum of qscore in diff/common region, for A vs B and B vs A. If B vs A is bigger, put minus sign later.\n        pileup:pileup,                  # the highest pileup the summit.\n        pscore:pscore,                  # pscore is the maximum of pscore in diff/common region, for A vs B and B vs A. If B vs A is bigger, put minus sign later.\n        fc:fold_change,                 # fc is the maximum of foldchange in diff/common region, for A vs B and B vs A. If B vs A is bigger, put minus sign later.\n        qscore:qscore                   # qscore is the maximum of qscore in diff/common region, for A vs B and B vs A. If B vs A is bigger, put minus sign later.\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_3add = {__Pyx_NAMESTR("add"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_3add, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_2add)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_3add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_chromosome = 0;
  long __pyx_v_start;
  long __pyx_v_end;
  long __pyx_v_summit;
  double __pyx_v_diff_score;
  int __pyx_v_pileup;
  double __pyx_v_pscore;
  double __pyx_v_fold_change;
  double __pyx_v_qscore;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__chromosome,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__summit,&__pyx_n_s__diff_score,&__pyx_n_s__pileup,&__pyx_n_s__pscore,&__pyx_n_s__fold_change,&__pyx_n_s__qscore,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__chromosome);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 0, 4, 10, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 0, 4, 10, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
        if (likely(values[3])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 0, 4, 10, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__summit);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__diff_score);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pileup);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pscore);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fold_change);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__qscore);
          if (value) { values[9] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[4]) {
      } else {
        __pyx_v_summit = ((long)((long)0));
      }
      if (values[5]) {
      } else {

        /* "MACS2/IO/cPeakIO.pyx":507
 * 
 *     def add (self, str chromosome, long start, long end, long summit = 0,
 *              double diff_score=0, int pileup=0,             # <<<<<<<<<<<<<<
 *              double pscore=0, double fold_change=0, double qscore=0):
 *         """items:
 */
        __pyx_v_diff_score = ((double)((double)0.0));
      }
      if (values[6]) {
      } else {
        __pyx_v_pileup = ((int)((int)0));
      }
      if (values[7]) {
      } else {

        /* "MACS2/IO/cPeakIO.pyx":508
 *     def add (self, str chromosome, long start, long end, long summit = 0,
 *              double diff_score=0, int pileup=0,
 *              double pscore=0, double fold_change=0, double qscore=0):             # <<<<<<<<<<<<<<
 *         """items:
 *         start:start
 */
        __pyx_v_pscore = ((double)((double)0.0));
      }
      if (values[8]) {
      } else {
        __pyx_v_fold_change = ((double)((double)0.0));
      }
      if (values[9]) {
      } else {
        __pyx_v_qscore = ((double)((double)0.0));
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_chromosome = ((PyObject*)values[1]);
    __pyx_v_start = __Pyx_PyInt_AsLong(values[2]); if (unlikely((__pyx_v_start == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_end = __Pyx_PyInt_AsLong(values[3]); if (unlikely((__pyx_v_end == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[4]) {
      __pyx_v_summit = __Pyx_PyInt_AsLong(values[4]); if (unlikely((__pyx_v_summit == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_summit = ((long)((long)0));
    }
    if (values[5]) {
      __pyx_v_diff_score = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_diff_score == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_diff_score = ((double)((double)0.0));
    }
    if (values[6]) {
      __pyx_v_pileup = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_pileup == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_pileup = ((int)((int)0));
    }
    if (values[7]) {
      __pyx_v_pscore = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_pscore == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_pscore = ((double)((double)0.0));
    }
    if (values[8]) {
      __pyx_v_fold_change = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_fold_change == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_fold_change = ((double)((double)0.0));
    }
    if (values[9]) {
      __pyx_v_qscore = __pyx_PyFloat_AsDouble(values[9]); if (unlikely((__pyx_v_qscore == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_qscore = ((double)((double)0.0));
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 0, 4, 10, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chromosome), (&PyString_Type), 1, "chromosome", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_2add(__pyx_self, __pyx_v_self, __pyx_v_chromosome, __pyx_v_start, __pyx_v_end, __pyx_v_summit, __pyx_v_diff_score, __pyx_v_pileup, __pyx_v_pscore, __pyx_v_fold_change, __pyx_v_qscore);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":506
 *         self.peaks = {}
 * 
 *     def add (self, str chromosome, long start, long end, long summit = 0,             # <<<<<<<<<<<<<<
 *              double diff_score=0, int pileup=0,
 *              double pscore=0, double fold_change=0, double qscore=0):
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_2add(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_chromosome, long __pyx_v_start, long __pyx_v_end, long __pyx_v_summit, double __pyx_v_diff_score, int __pyx_v_pileup, double __pyx_v_pscore, double __pyx_v_fold_change, double __pyx_v_qscore) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("add", 0);
  __Pyx_TraceCall("add", __pyx_f[0], 506);

  /* "MACS2/IO/cPeakIO.pyx":520
 *         qscore:qscore                   # qscore is the maximum of qscore in diff/common region, for A vs B and B vs A. If B vs A is bigger, put minus sign later.
 *         """
 *         if not self.peaks.has_key(chromosome):             # <<<<<<<<<<<<<<
 *             self.peaks[chromosome]=[]
 *         self.peaks[chromosome].append({"start":start,
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__has_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_chromosome));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_chromosome));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_chromosome));
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = (!__pyx_t_4);
  if (__pyx_t_5) {

    /* "MACS2/IO/cPeakIO.pyx":521
 *         """
 *         if not self.peaks.has_key(chromosome):
 *             self.peaks[chromosome]=[]             # <<<<<<<<<<<<<<
 *         self.peaks[chromosome].append({"start":start,
 *                                        "end":end,
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyObject_SetItem(__pyx_t_1, ((PyObject *)__pyx_v_chromosome), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "MACS2/IO/cPeakIO.pyx":522
 *         if not self.peaks.has_key(chromosome):
 *             self.peaks[chromosome]=[]
 *         self.peaks[chromosome].append({"start":start,             # <<<<<<<<<<<<<<
 *                                        "end":end,
 *                                        "length":end-start,
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_GetItem(__pyx_t_3, ((PyObject *)__pyx_v_chromosome)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_2 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__start), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":523
 *             self.peaks[chromosome]=[]
 *         self.peaks[chromosome].append({"start":start,
 *                                        "end":end,             # <<<<<<<<<<<<<<
 *                                        "length":end-start,
 *                                        "summit":summit,
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__end), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":524
 *         self.peaks[chromosome].append({"start":start,
 *                                        "end":end,
 *                                        "length":end-start,             # <<<<<<<<<<<<<<
 *                                        "summit":summit,
 *                                        "score":diff_score,
 */
  __pyx_t_2 = PyInt_FromLong((__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__length), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":525
 *                                        "end":end,
 *                                        "length":end-start,
 *                                        "summit":summit,             # <<<<<<<<<<<<<<
 *                                        "score":diff_score,
 *                                        "pileup":pileup,
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_summit); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__summit), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":526
 *                                        "length":end-start,
 *                                        "summit":summit,
 *                                        "score":diff_score,             # <<<<<<<<<<<<<<
 *                                        "pileup":pileup,
 *                                        "pscore":pscore,
 */
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_diff_score); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__score), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":527
 *                                        "summit":summit,
 *                                        "score":diff_score,
 *                                        "pileup":pileup,             # <<<<<<<<<<<<<<
 *                                        "pscore":pscore,
 *                                        "fc":fold_change,
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_pileup); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__pileup), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":528
 *                                        "score":diff_score,
 *                                        "pileup":pileup,
 *                                        "pscore":pscore,             # <<<<<<<<<<<<<<
 *                                        "fc":fold_change,
 *                                        "qscore":qscore})
 */
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_pscore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__pscore), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":529
 *                                        "pileup":pileup,
 *                                        "pscore":pscore,
 *                                        "fc":fold_change,             # <<<<<<<<<<<<<<
 *                                        "qscore":qscore})
 * 
 */
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_fold_change); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__fc), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":530
 *                                        "pscore":pscore,
 *                                        "fc":fold_change,
 *                                        "qscore":qscore})             # <<<<<<<<<<<<<<
 * 
 *     def filter_pscore (self, double pscore_cut ):
 */
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_qscore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__qscore), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_1, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_5filter_pscore(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_5filter_pscore = {__Pyx_NAMESTR("filter_pscore"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_5filter_pscore, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_5filter_pscore(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  double __pyx_v_pscore_cut;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__pscore_cut,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("filter_pscore (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pscore_cut);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("filter_pscore", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "filter_pscore") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_pscore_cut = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_pscore_cut == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("filter_pscore", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.filter_pscore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_4filter_pscore(__pyx_self, __pyx_v_self, __pyx_v_pscore_cut);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":532
 *                                        "qscore":qscore})
 * 
 *     def filter_pscore (self, double pscore_cut ):             # <<<<<<<<<<<<<<
 *         peaks = self.peaks
 *         new_peaks = {}
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_4filter_pscore(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_pscore_cut) {
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_new_peaks = NULL;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_chrom = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("filter_pscore", 0);
  __Pyx_TraceCall("filter_pscore", __pyx_f[0], 532);

  /* "MACS2/IO/cPeakIO.pyx":533
 * 
 *     def filter_pscore (self, double pscore_cut ):
 *         peaks = self.peaks             # <<<<<<<<<<<<<<
 *         new_peaks = {}
 *         chrs = sorted(peaks.keys())
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":534
 *     def filter_pscore (self, double pscore_cut ):
 *         peaks = self.peaks
 *         new_peaks = {}             # <<<<<<<<<<<<<<
 *         chrs = sorted(peaks.keys())
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_new_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":535
 *         peaks = self.peaks
 *         new_peaks = {}
 *         chrs = sorted(peaks.keys())             # <<<<<<<<<<<<<<
 * 
 *         for chrom in chrs:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_peaks, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_chrs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":537
 *         chrs = sorted(peaks.keys())
 * 
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             new_peaks[chrom]=[p for p in peaks[chrom] if p["pscore"] >= pscore_cut]
 *         self.peaks = new_peaks
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_2 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_chrom);
    __pyx_v_chrom = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "MACS2/IO/cPeakIO.pyx":538
 * 
 *         for chrom in chrs:
 *             new_peaks[chrom]=[p for p in peaks[chrom] if p["pscore"] >= pscore_cut]             # <<<<<<<<<<<<<<
 *         self.peaks = new_peaks
 * 
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_GetItem(__pyx_v_peaks, __pyx_v_chrom); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
      __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    for (;;) {
      if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_6)) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++;
      } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_6)) {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++;
      } else {
        __pyx_t_5 = __pyx_t_8(__pyx_t_6);
        if (unlikely(!__pyx_t_5)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF(__pyx_v_p);
      __pyx_v_p = __pyx_t_5;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__pscore)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = PyFloat_FromDouble(__pyx_v_pscore_cut); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyObject_RichCompare(__pyx_t_5, __pyx_t_9, Py_GE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (__pyx_t_11) {
        if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_v_p))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (PyDict_SetItem(((PyObject *)__pyx_v_new_peaks), __pyx_v_chrom, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":539
 *         for chrom in chrs:
 *             new_peaks[chrom]=[p for p in peaks[chrom] if p["pscore"] >= pscore_cut]
 *         self.peaks = new_peaks             # <<<<<<<<<<<<<<
 * 
 *     def filter_qscore (self, double qscore_cut ):
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__peaks, ((PyObject *)__pyx_v_new_peaks)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.filter_pscore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_new_peaks);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_7filter_qscore(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_7filter_qscore = {__Pyx_NAMESTR("filter_qscore"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_7filter_qscore, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_7filter_qscore(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  double __pyx_v_qscore_cut;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__qscore_cut,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("filter_qscore (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__qscore_cut);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("filter_qscore", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "filter_qscore") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_qscore_cut = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_qscore_cut == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("filter_qscore", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.filter_qscore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_6filter_qscore(__pyx_self, __pyx_v_self, __pyx_v_qscore_cut);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":541
 *         self.peaks = new_peaks
 * 
 *     def filter_qscore (self, double qscore_cut ):             # <<<<<<<<<<<<<<
 *         peaks = self.peaks
 *         new_peaks = {}
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_6filter_qscore(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_qscore_cut) {
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_new_peaks = NULL;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_chrom = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("filter_qscore", 0);
  __Pyx_TraceCall("filter_qscore", __pyx_f[0], 541);

  /* "MACS2/IO/cPeakIO.pyx":542
 * 
 *     def filter_qscore (self, double qscore_cut ):
 *         peaks = self.peaks             # <<<<<<<<<<<<<<
 *         new_peaks = {}
 *         chrs = sorted(peaks.keys())
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":543
 *     def filter_qscore (self, double qscore_cut ):
 *         peaks = self.peaks
 *         new_peaks = {}             # <<<<<<<<<<<<<<
 *         chrs = sorted(peaks.keys())
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_new_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":544
 *         peaks = self.peaks
 *         new_peaks = {}
 *         chrs = sorted(peaks.keys())             # <<<<<<<<<<<<<<
 * 
 *         for chrom in chrs:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_peaks, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_chrs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":546
 *         chrs = sorted(peaks.keys())
 * 
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             new_peaks[chrom]=[p for p in peaks[chrom] if p["qscore"] >= qscore_cut]
 *         self.peaks = new_peaks
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_2 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_chrom);
    __pyx_v_chrom = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "MACS2/IO/cPeakIO.pyx":547
 * 
 *         for chrom in chrs:
 *             new_peaks[chrom]=[p for p in peaks[chrom] if p["qscore"] >= qscore_cut]             # <<<<<<<<<<<<<<
 *         self.peaks = new_peaks
 * 
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_GetItem(__pyx_v_peaks, __pyx_v_chrom); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
      __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    for (;;) {
      if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_6)) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++;
      } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_6)) {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++;
      } else {
        __pyx_t_5 = __pyx_t_8(__pyx_t_6);
        if (unlikely(!__pyx_t_5)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF(__pyx_v_p);
      __pyx_v_p = __pyx_t_5;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__qscore)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = PyFloat_FromDouble(__pyx_v_qscore_cut); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyObject_RichCompare(__pyx_t_5, __pyx_t_9, Py_GE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (__pyx_t_11) {
        if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_v_p))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (PyDict_SetItem(((PyObject *)__pyx_v_new_peaks), __pyx_v_chrom, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":548
 *         for chrom in chrs:
 *             new_peaks[chrom]=[p for p in peaks[chrom] if p["qscore"] >= qscore_cut]
 *         self.peaks = new_peaks             # <<<<<<<<<<<<<<
 * 
 *     def filter_fc (self, fc_low, fc_up=None ):
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__peaks, ((PyObject *)__pyx_v_new_peaks)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.filter_qscore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_new_peaks);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_9filter_fc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_8filter_fc[] = "Filter peaks in a given fc range.\n\n        If fc_low and fc_up is assigned, the peaks with fc in [fc_low,fc_up)\n        \n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_9filter_fc = {__Pyx_NAMESTR("filter_fc"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_9filter_fc, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_8filter_fc)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_9filter_fc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fc_low = 0;
  PyObject *__pyx_v_fc_up = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fc_low,&__pyx_n_s__fc_up,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("filter_fc (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[3] = {0,0,0};

    /* "MACS2/IO/cPeakIO.pyx":550
 *         self.peaks = new_peaks
 * 
 *     def filter_fc (self, fc_low, fc_up=None ):             # <<<<<<<<<<<<<<
 *         """Filter peaks in a given fc range.
 * 
 */
    values[2] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fc_low);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("filter_fc", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fc_up);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "filter_fc") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_fc_low = values[1];
    __pyx_v_fc_up = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("filter_fc", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.filter_fc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_8filter_fc(__pyx_self, __pyx_v_self, __pyx_v_fc_low, __pyx_v_fc_up);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_8filter_fc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fc_low, PyObject *__pyx_v_fc_up) {
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_new_peaks = NULL;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_chrom = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_r = NULL;
  __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)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("filter_fc", 0);
  __Pyx_TraceCall("filter_fc", __pyx_f[0], 550);

  /* "MACS2/IO/cPeakIO.pyx":556
 * 
 *         """
 *         peaks = self.peaks             # <<<<<<<<<<<<<<
 *         new_peaks = {}
 *         chrs = peaks.keys()
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":557
 *         """
 *         peaks = self.peaks
 *         new_peaks = {}             # <<<<<<<<<<<<<<
 *         chrs = peaks.keys()
 *         chrs.sort()
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_new_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":558
 *         peaks = self.peaks
 *         new_peaks = {}
 *         chrs = peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         if fc_up:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_peaks, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_chrs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":559
 *         new_peaks = {}
 *         chrs = peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         if fc_up:
 *             for chrom in chrs:
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":560
 *         chrs = peaks.keys()
 *         chrs.sort()
 *         if fc_up:             # <<<<<<<<<<<<<<
 *             for chrom in chrs:
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low and p["fc"]<fc_up]
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_fc_up); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "MACS2/IO/cPeakIO.pyx":561
 *         chrs.sort()
 *         if fc_up:
 *             for chrom in chrs:             # <<<<<<<<<<<<<<
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low and p["fc"]<fc_up]
 *         else:
 */
    if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
      __pyx_t_1 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_1)) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
      } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
      } else {
        __pyx_t_2 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF(__pyx_v_chrom);
      __pyx_v_chrom = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "MACS2/IO/cPeakIO.pyx":562
 *         if fc_up:
 *             for chrom in chrs:
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low and p["fc"]<fc_up]             # <<<<<<<<<<<<<<
 *         else:
 *             for chrom in chrs:
 */
      __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyObject_GetItem(__pyx_v_peaks, __pyx_v_chrom); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
        __pyx_t_7 = __pyx_t_6; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
      } else {
        __pyx_t_8 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_9 = Py_TYPE(__pyx_t_7)->tp_iternext;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      for (;;) {
        if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_7)) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_7)) break;
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++;
        } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_7)) {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++;
        } else {
          __pyx_t_6 = __pyx_t_9(__pyx_t_7);
          if (unlikely(!__pyx_t_6)) {
            if (PyErr_Occurred()) {
              if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_XDECREF(__pyx_v_p);
        __pyx_v_p = __pyx_t_6;
        __pyx_t_6 = 0;
        __pyx_t_6 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__fc)); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_10 = PyObject_RichCompare(__pyx_t_6, __pyx_v_fc_low, Py_GE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (__pyx_t_3) {
          __pyx_t_10 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__fc)); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_6 = PyObject_RichCompare(__pyx_t_10, __pyx_v_fc_up, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_12 = __pyx_t_11;
        } else {
          __pyx_t_12 = __pyx_t_3;
        }
        if (__pyx_t_12) {
          if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_v_p))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          goto __pyx_L8;
        }
        __pyx_L8:;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (PyDict_SetItem(((PyObject *)__pyx_v_new_peaks), __pyx_v_chrom, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "MACS2/IO/cPeakIO.pyx":564
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low and p["fc"]<fc_up]
 *         else:
 *             for chrom in chrs:             # <<<<<<<<<<<<<<
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low]
 *         self.peaks = new_peaks
 */
    if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
      __pyx_t_1 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_1)) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
      } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
      } else {
        __pyx_t_2 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF(__pyx_v_chrom);
      __pyx_v_chrom = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "MACS2/IO/cPeakIO.pyx":565
 *         else:
 *             for chrom in chrs:
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low]             # <<<<<<<<<<<<<<
 *         self.peaks = new_peaks
 * 
 */
      __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = PyObject_GetItem(__pyx_v_peaks, __pyx_v_chrom); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (PyList_CheckExact(__pyx_t_7) || PyTuple_CheckExact(__pyx_t_7)) {
        __pyx_t_6 = __pyx_t_7; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
      } else {
        __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      for (;;) {
        if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_6)) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break;
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++;
        } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_6)) {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++;
        } else {
          __pyx_t_7 = __pyx_t_9(__pyx_t_6);
          if (unlikely(!__pyx_t_7)) {
            if (PyErr_Occurred()) {
              if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_XDECREF(__pyx_v_p);
        __pyx_v_p = __pyx_t_7;
        __pyx_t_7 = 0;
        __pyx_t_7 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__fc)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_10 = PyObject_RichCompare(__pyx_t_7, __pyx_v_fc_low, Py_GE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (__pyx_t_12) {
          if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_v_p))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          goto __pyx_L13;
        }
        __pyx_L13:;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (PyDict_SetItem(((PyObject *)__pyx_v_new_peaks), __pyx_v_chrom, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "MACS2/IO/cPeakIO.pyx":566
 *             for chrom in chrs:
 *                 new_peaks[chrom]=[p for p in peaks[chrom] if p["fc"] >= fc_low]
 *         self.peaks = new_peaks             # <<<<<<<<<<<<<<
 * 
 *     def total (self):
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__peaks, ((PyObject *)__pyx_v_new_peaks)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.filter_fc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_new_peaks);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_11total(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_11total = {__Pyx_NAMESTR("total"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_11total, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_11total(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("total (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_10total(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":568
 *         self.peaks = new_peaks
 * 
 *     def total (self):             # <<<<<<<<<<<<<<
 *         peaks = self.peaks
 *         chrs = peaks.keys()
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_10total(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_chrom = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("total", 0);
  __Pyx_TraceCall("total", __pyx_f[0], 568);

  /* "MACS2/IO/cPeakIO.pyx":569
 * 
 *     def total (self):
 *         peaks = self.peaks             # <<<<<<<<<<<<<<
 *         chrs = peaks.keys()
 *         chrs.sort()
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":570
 *     def total (self):
 *         peaks = self.peaks
 *         chrs = peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         x = 0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_peaks, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_chrs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":571
 *         peaks = self.peaks
 *         chrs = peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         x = 0
 *         for chrom in chrs:
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":572
 *         chrs = peaks.keys()
 *         chrs.sort()
 *         x = 0             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             x += len(peaks[chrom])
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_x = __pyx_int_0;

  /* "MACS2/IO/cPeakIO.pyx":573
 *         chrs.sort()
 *         x = 0
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             x += len(peaks[chrom])
 *         return x
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_1 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_chrom);
    __pyx_v_chrom = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "MACS2/IO/cPeakIO.pyx":574
 *         x = 0
 *         for chrom in chrs:
 *             x += len(peaks[chrom])             # <<<<<<<<<<<<<<
 *         return x
 * 
 */
    __pyx_t_2 = PyObject_GetItem(__pyx_v_peaks, __pyx_v_chrom); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_x, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_6;
    __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":575
 *         for chrom in chrs:
 *             x += len(peaks[chrom])
 *         return x             # <<<<<<<<<<<<<<
 * 
 *     def _to_bed(self, name_prefix="%s_peak_", name="MACS",
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_x);
  __pyx_r = __pyx_v_x;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.total", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":577
 *         return x
 * 
 *     def _to_bed(self, name_prefix="%s_peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                 description="%s", score_column="score",
 *                 print_func=print, trackline=False):
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_26__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_TraceCall("__defaults__", __pyx_f[0], 577);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_1)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_kp_s_1)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_1)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_self)->__pyx_arg_print_func);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_self)->__pyx_arg_print_func);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_self)->__pyx_arg_print_func);
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_self)->__pyx_arg_trackline);
  PyTuple_SET_ITEM(__pyx_t_1, 5, __Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_self)->__pyx_arg_trackline);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_self)->__pyx_arg_trackline);
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_13_to_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_12_to_bed[] = "\n        generalization of tobed and write_to_bed\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_13_to_bed = {__Pyx_NAMESTR("_to_bed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_13_to_bed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_12_to_bed)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_13_to_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_name_prefix = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_description = 0;
  PyObject *__pyx_v_score_column = 0;
  PyObject *__pyx_v_print_func = 0;
  PyObject *__pyx_v_trackline = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__name_prefix,&__pyx_n_s__name,&__pyx_n_s__description,&__pyx_n_s__score_column,&__pyx_n_s__print_func,&__pyx_n_s__trackline,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_to_bed (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[7] = {0,0,0,0,0,0,0};
    __pyx_defaults5 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_self);
    values[1] = ((PyObject *)((PyObject*)__pyx_kp_s_1));
    values[2] = ((PyObject *)((PyObject*)__pyx_n_s__MACS));
    values[3] = ((PyObject *)((PyObject*)__pyx_kp_s_2));
    values[4] = ((PyObject *)((PyObject*)__pyx_n_s__score));
    values[5] = __pyx_dynamic_args->__pyx_arg_print_func;
    values[6] = __pyx_dynamic_args->__pyx_arg_trackline;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name_prefix);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__description);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__score_column);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__print_func);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trackline);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_to_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_name_prefix = values[1];
    __pyx_v_name = values[2];
    __pyx_v_description = values[3];
    __pyx_v_score_column = values[4];
    __pyx_v_print_func = values[5];
    __pyx_v_trackline = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_to_bed", 0, 1, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO._to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_12_to_bed(__pyx_self, __pyx_v_self, __pyx_v_name_prefix, __pyx_v_name, __pyx_v_description, __pyx_v_score_column, __pyx_v_print_func, __pyx_v_trackline);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_12_to_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, PyObject *__pyx_v_print_func, PyObject *__pyx_v_trackline) {
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_n_peak = NULL;
  PyObject *__pyx_v_peakprefix = NULL;
  PyObject *__pyx_v_desc = NULL;
  PyObject *__pyx_v_trackcontents = NULL;
  PyObject *__pyx_v_chrom = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_end = NULL;
  PyObject *__pyx_v_group = NULL;
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_peak = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  PyObject *(*__pyx_t_14)(PyObject *);
  PyObject *(*__pyx_t_15)(PyObject *);
  Py_ssize_t __pyx_t_16;
  int __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("_to_bed", 0);
  __Pyx_TraceCall("_to_bed", __pyx_f[0], 577);

  /* "MACS2/IO/cPeakIO.pyx":583
 *         generalization of tobed and write_to_bed
 *         """
 *         chrs = self.peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         n_peak = 0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_chrs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":584
 *         """
 *         chrs = self.peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":585
 *         chrs = self.peaks.keys()
 *         chrs.sort()
 *         n_peak = 0             # <<<<<<<<<<<<<<
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_n_peak = __pyx_int_0;

  /* "MACS2/IO/cPeakIO.pyx":586
 *         chrs.sort()
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name             # <<<<<<<<<<<<<<
 *         except: peakprefix = name_prefix
 *         try: desc = description % name
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {
      __pyx_t_2 = PyNumber_Remainder(__pyx_v_name_prefix, __pyx_v_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_peakprefix = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "MACS2/IO/cPeakIO.pyx":587
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix             # <<<<<<<<<<<<<<
 *         try: desc = description % name
 *         except: desc = description
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO._to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_name_prefix);
      __Pyx_XDECREF(__pyx_v_peakprefix);
      __pyx_v_peakprefix = __pyx_v_name_prefix;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L10_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":588
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 *         try: desc = description % name             # <<<<<<<<<<<<<<
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {
      __pyx_t_6 = PyNumber_Remainder(__pyx_v_description, __pyx_v_name); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_v_desc = __pyx_t_6;
      __pyx_t_6 = 0;
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L20_try_end;
    __pyx_L13_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "MACS2/IO/cPeakIO.pyx":589
 *         except: peakprefix = name_prefix
 *         try: desc = description % name
 *         except: desc = description             # <<<<<<<<<<<<<<
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 *         if trackline:
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO._to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_description);
      __Pyx_XDECREF(__pyx_v_desc);
      __pyx_v_desc = __pyx_v_description;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L14_exception_handled;
    }
    __pyx_L15_except_error:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L14_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    __pyx_L20_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":590
 *         try: desc = description % name
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))             # <<<<<<<<<<<<<<
 *         if trackline:
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_name, __pyx_n_s__replace); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_37), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_desc, __pyx_n_s__replace); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_38), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_1 = 0;
  __pyx_t_6 = 0;
  __pyx_v_trackcontents = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":591
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 *         if trackline:             # <<<<<<<<<<<<<<
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_trackline); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_7) {

    /* "MACS2/IO/cPeakIO.pyx":592
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 *         if trackline:
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)             # <<<<<<<<<<<<<<
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      /*try:*/ {
        __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), ((PyObject *)__pyx_v_trackcontents)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_2));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
        __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L31_try_end;
      __pyx_L24_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "MACS2/IO/cPeakIO.pyx":593
 *         if trackline:
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 */
      /*except:*/ {
        __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO._to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_6, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_8 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_k_tuple_39), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L25_exception_handled;
      }
      __pyx_L26_except_error:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L1_error;
      __pyx_L25_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      __pyx_L31_try_end:;
    }
    goto __pyx_L23;
  }
  __pyx_L23:;

  /* "MACS2/IO/cPeakIO.pyx":594
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_1 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_1); __pyx_t_9 = 0;
    __pyx_t_10 = NULL;
  } else {
    __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_10 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++;
    } else if (!__pyx_t_10 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++;
    } else {
      __pyx_t_6 = __pyx_t_10(__pyx_t_1);
      if (unlikely(!__pyx_t_6)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF(__pyx_v_chrom);
    __pyx_v_chrom = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "MACS2/IO/cPeakIO.pyx":595
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 peaks = list(group)
 */
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__groupby); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = PyObject_GetItem(__pyx_t_2, __pyx_v_chrom); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
    __pyx_t_11 = __Pyx_GetName(__pyx_m, __pyx_n_s__itemgetter); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_k_tuple_40), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__key), __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    if (PyList_CheckExact(__pyx_t_12) || PyTuple_CheckExact(__pyx_t_12)) {
      __pyx_t_8 = __pyx_t_12; __Pyx_INCREF(__pyx_t_8); __pyx_t_13 = 0;
      __pyx_t_14 = NULL;
    } else {
      __pyx_t_13 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_14 = Py_TYPE(__pyx_t_8)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    for (;;) {
      if (!__pyx_t_14 && PyList_CheckExact(__pyx_t_8)) {
        if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_8)) break;
        __pyx_t_12 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_13); __Pyx_INCREF(__pyx_t_12); __pyx_t_13++;
      } else if (!__pyx_t_14 && PyTuple_CheckExact(__pyx_t_8)) {
        if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_13); __Pyx_INCREF(__pyx_t_12); __pyx_t_13++;
      } else {
        __pyx_t_12 = __pyx_t_14(__pyx_t_8);
        if (unlikely(!__pyx_t_12)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_12);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
        PyObject* sequence = __pyx_t_12;
        if (likely(PyTuple_CheckExact(sequence))) {
          if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
            if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
            if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_15 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_2)) goto __pyx_L38_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_6 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_6)) goto __pyx_L38_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L39_unpacking_done;
        __pyx_L38_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
        if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L39_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_end);
      __pyx_v_end = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_v_group);
      __pyx_v_group = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "MACS2/IO/cPeakIO.pyx":596
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1             # <<<<<<<<<<<<<<
 *                 peaks = list(group)
 *                 if len(peaks) > 1:
 */
      __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_n_peak, __pyx_int_1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_v_n_peak);
      __pyx_v_n_peak = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "MACS2/IO/cPeakIO.pyx":597
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1
 *                 peaks = list(group)             # <<<<<<<<<<<<<<
 *                 if len(peaks) > 1:
 *                     for i, peak in enumerate(peaks):
 */
      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_v_group);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_group);
      __Pyx_GIVEREF(__pyx_v_group);
      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
      __Pyx_XDECREF(((PyObject *)__pyx_v_peaks));
      __pyx_v_peaks = ((PyObject*)__pyx_t_6);
      __pyx_t_6 = 0;

      /* "MACS2/IO/cPeakIO.pyx":598
 *                 n_peak += 1
 *                 peaks = list(group)
 *                 if len(peaks) > 1:             # <<<<<<<<<<<<<<
 *                     for i, peak in enumerate(peaks):
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,subpeak_letters(i),peak[score_column]))
 */
      __pyx_t_16 = PyList_GET_SIZE(((PyObject *)__pyx_v_peaks)); 
      __pyx_t_7 = (__pyx_t_16 > 1);
      if (__pyx_t_7) {

        /* "MACS2/IO/cPeakIO.pyx":599
 *                 peaks = list(group)
 *                 if len(peaks) > 1:
 *                     for i, peak in enumerate(peaks):             # <<<<<<<<<<<<<<
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,subpeak_letters(i),peak[score_column]))
 *                 else:
 */
        __Pyx_INCREF(__pyx_int_0);
        __pyx_t_6 = __pyx_int_0;
        __pyx_t_12 = ((PyObject *)__pyx_v_peaks); __Pyx_INCREF(__pyx_t_12); __pyx_t_16 = 0;
        for (;;) {
          if (__pyx_t_16 >= PyList_GET_SIZE(__pyx_t_12)) break;
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_16); __Pyx_INCREF(__pyx_t_2); __pyx_t_16++;
          __Pyx_XDECREF(__pyx_v_peak);
          __pyx_v_peak = __pyx_t_2;
          __pyx_t_2 = 0;
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_XDECREF(__pyx_v_i);
          __pyx_v_i = __pyx_t_6;
          __pyx_t_2 = PyNumber_Add(__pyx_t_6, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6);
          __pyx_t_6 = __pyx_t_2;
          __pyx_t_2 = 0;

          /* "MACS2/IO/cPeakIO.pyx":600
 *                 if len(peaks) > 1:
 *                     for i, peak in enumerate(peaks):
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,subpeak_letters(i),peak[score_column]))             # <<<<<<<<<<<<<<
 *                 else:
 *                     peak = peaks[0]
 */
          __pyx_t_2 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__start)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_11 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__end)); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_17 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_18 = __pyx_f_5MACS2_2IO_7cPeakIO_subpeak_letters(__pyx_t_17); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_19 = PyObject_GetItem(__pyx_v_peak, __pyx_v_score_column); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_20 = PyTuple_New(7); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_20);
          __Pyx_INCREF(__pyx_v_chrom);
          PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_chrom);
          __Pyx_GIVEREF(__pyx_v_chrom);
          PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_20, 2, __pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_11);
          __Pyx_INCREF(__pyx_v_peakprefix);
          PyTuple_SET_ITEM(__pyx_t_20, 3, __pyx_v_peakprefix);
          __Pyx_GIVEREF(__pyx_v_peakprefix);
          __Pyx_INCREF(__pyx_v_n_peak);
          PyTuple_SET_ITEM(__pyx_t_20, 4, __pyx_v_n_peak);
          __Pyx_GIVEREF(__pyx_v_n_peak);
          PyTuple_SET_ITEM(__pyx_t_20, 5, __pyx_t_18);
          __Pyx_GIVEREF(__pyx_t_18);
          PyTuple_SET_ITEM(__pyx_t_20, 6, __pyx_t_19);
          __Pyx_GIVEREF(__pyx_t_19);
          __pyx_t_2 = 0;
          __pyx_t_11 = 0;
          __pyx_t_18 = 0;
          __pyx_t_19 = 0;
          __pyx_t_19 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), ((PyObject *)__pyx_t_20)); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_19));
          __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
          __pyx_t_20 = PyTuple_New(1); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_20);
          PyTuple_SET_ITEM(__pyx_t_20, 0, ((PyObject *)__pyx_t_19));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_19));
          __pyx_t_19 = 0;
          __pyx_t_19 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_t_20), NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        }
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L40;
      }
      /*else*/ {

        /* "MACS2/IO/cPeakIO.pyx":602
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,subpeak_letters(i),peak[score_column]))
 *                 else:
 *                     peak = peaks[0]             # <<<<<<<<<<<<<<
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,peak[score_column]))
 * 
 */
        __pyx_t_6 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_peaks), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_XDECREF(__pyx_v_peak);
        __pyx_v_peak = __pyx_t_6;
        __pyx_t_6 = 0;

        /* "MACS2/IO/cPeakIO.pyx":603
 *                 else:
 *                     peak = peaks[0]
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,peak[score_column]))             # <<<<<<<<<<<<<<
 * 
 *     def _to_summits_bed(self, name_prefix="%s_peak_", name="MACS",
 */
        __pyx_t_6 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__start)); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_12 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__end)); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_19 = PyObject_GetItem(__pyx_v_peak, __pyx_v_score_column); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __pyx_t_20 = PyTuple_New(6); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_INCREF(__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_20, 2, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_12);
        __Pyx_INCREF(__pyx_v_peakprefix);
        PyTuple_SET_ITEM(__pyx_t_20, 3, __pyx_v_peakprefix);
        __Pyx_GIVEREF(__pyx_v_peakprefix);
        __Pyx_INCREF(__pyx_v_n_peak);
        PyTuple_SET_ITEM(__pyx_t_20, 4, __pyx_v_n_peak);
        __Pyx_GIVEREF(__pyx_v_n_peak);
        PyTuple_SET_ITEM(__pyx_t_20, 5, __pyx_t_19);
        __Pyx_GIVEREF(__pyx_t_19);
        __pyx_t_6 = 0;
        __pyx_t_12 = 0;
        __pyx_t_19 = 0;
        __pyx_t_19 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), ((PyObject *)__pyx_t_20)); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_19));
        __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
        __pyx_t_20 = PyTuple_New(1); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_20);
        PyTuple_SET_ITEM(__pyx_t_20, 0, ((PyObject *)__pyx_t_19));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_19));
        __pyx_t_19 = 0;
        __pyx_t_19 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_t_20), NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      }
      __pyx_L40:;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO._to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_n_peak);
  __Pyx_XDECREF(__pyx_v_peakprefix);
  __Pyx_XDECREF(__pyx_v_desc);
  __Pyx_XDECREF(__pyx_v_trackcontents);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_end);
  __Pyx_XDECREF(__pyx_v_group);
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_peak);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":605
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,peak[score_column]))
 * 
 *     def _to_summits_bed(self, name_prefix="%s_peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                         description = "%s", score_column="score",
 *                         print_func=print, trackline=False):
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_28__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_TraceCall("__defaults__", __pyx_f[0], 605);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_1)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_kp_s_1)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_1)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_self)->__pyx_arg_print_func);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_self)->__pyx_arg_print_func);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_self)->__pyx_arg_print_func);
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_self)->__pyx_arg_trackline);
  PyTuple_SET_ITEM(__pyx_t_1, 5, __Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_self)->__pyx_arg_trackline);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_self)->__pyx_arg_trackline);
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_15_to_summits_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_14_to_summits_bed[] = " \n        generalization of to_summits_bed and write_to_summit_bed\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_15_to_summits_bed = {__Pyx_NAMESTR("_to_summits_bed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_15_to_summits_bed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_14_to_summits_bed)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_15_to_summits_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_name_prefix = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_description = 0;
  PyObject *__pyx_v_score_column = 0;
  PyObject *__pyx_v_print_func = 0;
  PyObject *__pyx_v_trackline = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__name_prefix,&__pyx_n_s__name,&__pyx_n_s__description,&__pyx_n_s__score_column,&__pyx_n_s__print_func,&__pyx_n_s__trackline,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_to_summits_bed (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[7] = {0,0,0,0,0,0,0};
    __pyx_defaults6 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_self);
    values[1] = ((PyObject *)((PyObject*)__pyx_kp_s_1));
    values[2] = ((PyObject *)((PyObject*)__pyx_n_s__MACS));
    values[3] = ((PyObject *)((PyObject*)__pyx_kp_s_2));
    values[4] = ((PyObject *)((PyObject*)__pyx_n_s__score));
    values[5] = __pyx_dynamic_args->__pyx_arg_print_func;
    values[6] = __pyx_dynamic_args->__pyx_arg_trackline;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name_prefix);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__description);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__score_column);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__print_func);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trackline);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_to_summits_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_name_prefix = values[1];
    __pyx_v_name = values[2];
    __pyx_v_description = values[3];
    __pyx_v_score_column = values[4];
    __pyx_v_print_func = values[5];
    __pyx_v_trackline = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_to_summits_bed", 0, 1, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO._to_summits_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_14_to_summits_bed(__pyx_self, __pyx_v_self, __pyx_v_name_prefix, __pyx_v_name, __pyx_v_description, __pyx_v_score_column, __pyx_v_print_func, __pyx_v_trackline);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_14_to_summits_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, PyObject *__pyx_v_print_func, PyObject *__pyx_v_trackline) {
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_n_peak = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_peakprefix = NULL;
  PyObject *__pyx_v_desc = NULL;
  PyObject *__pyx_v_trackcontents = NULL;
  PyObject *__pyx_v_chrom = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_end = NULL;
  PyObject *__pyx_v_group = NULL;
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_peak = NULL;
  PyObject *__pyx_v_summit_p = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  PyObject *(*__pyx_t_14)(PyObject *);
  PyObject *(*__pyx_t_15)(PyObject *);
  Py_ssize_t __pyx_t_16;
  int __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("_to_summits_bed", 0);
  __Pyx_TraceCall("_to_summits_bed", __pyx_f[0], 605);

  /* "MACS2/IO/cPeakIO.pyx":611
 *         generalization of to_summits_bed and write_to_summit_bed
 *         """
 *         chrs = self.peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         n_peak = 0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_chrs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":612
 *         """
 *         chrs = self.peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":613
 *         chrs = self.peaks.keys()
 *         chrs.sort()
 *         n_peak = 0             # <<<<<<<<<<<<<<
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_n_peak = __pyx_int_0;

  /* "MACS2/IO/cPeakIO.pyx":614
 *         chrs.sort()
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name             # <<<<<<<<<<<<<<
 *         except: peakprefix = name_prefix
 *         try: desc = description % name
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {
      __pyx_t_2 = PyNumber_Remainder(__pyx_v_name_prefix, __pyx_v_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_peakprefix = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "MACS2/IO/cPeakIO.pyx":615
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix             # <<<<<<<<<<<<<<
 *         try: desc = description % name
 *         except: desc = description
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO._to_summits_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_name_prefix);
      __Pyx_XDECREF(__pyx_v_peakprefix);
      __pyx_v_peakprefix = __pyx_v_name_prefix;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L10_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":616
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 *         try: desc = description % name             # <<<<<<<<<<<<<<
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {
      __pyx_t_6 = PyNumber_Remainder(__pyx_v_description, __pyx_v_name); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_v_desc = __pyx_t_6;
      __pyx_t_6 = 0;
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L20_try_end;
    __pyx_L13_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "MACS2/IO/cPeakIO.pyx":617
 *         except: peakprefix = name_prefix
 *         try: desc = description % name
 *         except: desc = description             # <<<<<<<<<<<<<<
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 *         if trackline:
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO._to_summits_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_description);
      __Pyx_XDECREF(__pyx_v_desc);
      __pyx_v_desc = __pyx_v_description;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L14_exception_handled;
    }
    __pyx_L15_except_error:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L14_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    __pyx_L20_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":618
 *         try: desc = description % name
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))             # <<<<<<<<<<<<<<
 *         if trackline:
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_name, __pyx_n_s__replace); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_desc, __pyx_n_s__replace); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_42), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_1 = 0;
  __pyx_t_6 = 0;
  __pyx_v_trackcontents = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":619
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 *         if trackline:             # <<<<<<<<<<<<<<
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_trackline); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_7) {

    /* "MACS2/IO/cPeakIO.pyx":620
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))
 *         if trackline:
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)             # <<<<<<<<<<<<<<
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      /*try:*/ {
        __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)__pyx_v_trackcontents)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_2));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
        __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L31_try_end;
      __pyx_L24_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "MACS2/IO/cPeakIO.pyx":621
 *         if trackline:
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 */
      /*except:*/ {
        __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO._to_summits_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_6, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_8 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_k_tuple_43), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L25_exception_handled;
      }
      __pyx_L26_except_error:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L1_error;
      __pyx_L25_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      __pyx_L31_try_end:;
    }
    goto __pyx_L23;
  }
  __pyx_L23:;

  /* "MACS2/IO/cPeakIO.pyx":622
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_1 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_1); __pyx_t_9 = 0;
    __pyx_t_10 = NULL;
  } else {
    __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_10 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++;
    } else if (!__pyx_t_10 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++;
    } else {
      __pyx_t_6 = __pyx_t_10(__pyx_t_1);
      if (unlikely(!__pyx_t_6)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF(__pyx_v_chrom);
    __pyx_v_chrom = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "MACS2/IO/cPeakIO.pyx":623
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 peaks = list(group)
 */
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__groupby); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = PyObject_GetItem(__pyx_t_2, __pyx_v_chrom); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
    __pyx_t_11 = __Pyx_GetName(__pyx_m, __pyx_n_s__itemgetter); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_k_tuple_44), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__key), __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    if (PyList_CheckExact(__pyx_t_12) || PyTuple_CheckExact(__pyx_t_12)) {
      __pyx_t_8 = __pyx_t_12; __Pyx_INCREF(__pyx_t_8); __pyx_t_13 = 0;
      __pyx_t_14 = NULL;
    } else {
      __pyx_t_13 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_14 = Py_TYPE(__pyx_t_8)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    for (;;) {
      if (!__pyx_t_14 && PyList_CheckExact(__pyx_t_8)) {
        if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_8)) break;
        __pyx_t_12 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_13); __Pyx_INCREF(__pyx_t_12); __pyx_t_13++;
      } else if (!__pyx_t_14 && PyTuple_CheckExact(__pyx_t_8)) {
        if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_13); __Pyx_INCREF(__pyx_t_12); __pyx_t_13++;
      } else {
        __pyx_t_12 = __pyx_t_14(__pyx_t_8);
        if (unlikely(!__pyx_t_12)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_12);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
        PyObject* sequence = __pyx_t_12;
        if (likely(PyTuple_CheckExact(sequence))) {
          if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
            if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
            if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_15 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_2)) goto __pyx_L38_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_6 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_6)) goto __pyx_L38_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L39_unpacking_done;
        __pyx_L38_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
        if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L39_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_end);
      __pyx_v_end = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_v_group);
      __pyx_v_group = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "MACS2/IO/cPeakIO.pyx":624
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1             # <<<<<<<<<<<<<<
 *                 peaks = list(group)
 *                 if len(peaks) > 1:
 */
      __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_n_peak, __pyx_int_1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_v_n_peak);
      __pyx_v_n_peak = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "MACS2/IO/cPeakIO.pyx":625
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 *                 n_peak += 1
 *                 peaks = list(group)             # <<<<<<<<<<<<<<
 *                 if len(peaks) > 1:
 *                     for i, peak in enumerate(peaks):
 */
      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_v_group);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_group);
      __Pyx_GIVEREF(__pyx_v_group);
      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
      __Pyx_XDECREF(((PyObject *)__pyx_v_peaks));
      __pyx_v_peaks = ((PyObject*)__pyx_t_6);
      __pyx_t_6 = 0;

      /* "MACS2/IO/cPeakIO.pyx":626
 *                 n_peak += 1
 *                 peaks = list(group)
 *                 if len(peaks) > 1:             # <<<<<<<<<<<<<<
 *                     for i, peak in enumerate(peaks):
 *                         summit_p = peak["summit"]
 */
      __pyx_t_16 = PyList_GET_SIZE(((PyObject *)__pyx_v_peaks)); 
      __pyx_t_7 = (__pyx_t_16 > 1);
      if (__pyx_t_7) {

        /* "MACS2/IO/cPeakIO.pyx":627
 *                 peaks = list(group)
 *                 if len(peaks) > 1:
 *                     for i, peak in enumerate(peaks):             # <<<<<<<<<<<<<<
 *                         summit_p = peak["summit"]
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,summit_p,summit_p+1,name_prefix,n_peak,subpeak_letters(i),peak[score_column]))
 */
        __Pyx_INCREF(__pyx_int_0);
        __pyx_t_6 = __pyx_int_0;
        __pyx_t_12 = ((PyObject *)__pyx_v_peaks); __Pyx_INCREF(__pyx_t_12); __pyx_t_16 = 0;
        for (;;) {
          if (__pyx_t_16 >= PyList_GET_SIZE(__pyx_t_12)) break;
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_16); __Pyx_INCREF(__pyx_t_2); __pyx_t_16++;
          __Pyx_XDECREF(__pyx_v_peak);
          __pyx_v_peak = __pyx_t_2;
          __pyx_t_2 = 0;
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_XDECREF(__pyx_v_i);
          __pyx_v_i = __pyx_t_6;
          __pyx_t_2 = PyNumber_Add(__pyx_t_6, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6);
          __pyx_t_6 = __pyx_t_2;
          __pyx_t_2 = 0;

          /* "MACS2/IO/cPeakIO.pyx":628
 *                 if len(peaks) > 1:
 *                     for i, peak in enumerate(peaks):
 *                         summit_p = peak["summit"]             # <<<<<<<<<<<<<<
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,summit_p,summit_p+1,name_prefix,n_peak,subpeak_letters(i),peak[score_column]))
 *                 else:
 */
          __pyx_t_2 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__summit)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XDECREF(__pyx_v_summit_p);
          __pyx_v_summit_p = __pyx_t_2;
          __pyx_t_2 = 0;

          /* "MACS2/IO/cPeakIO.pyx":629
 *                     for i, peak in enumerate(peaks):
 *                         summit_p = peak["summit"]
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,summit_p,summit_p+1,name_prefix,n_peak,subpeak_letters(i),peak[score_column]))             # <<<<<<<<<<<<<<
 *                 else:
 *                     peak = peaks[0]
 */
          __pyx_t_2 = PyNumber_Add(__pyx_v_summit_p, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_17 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_11 = __pyx_f_5MACS2_2IO_7cPeakIO_subpeak_letters(__pyx_t_17); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, __pyx_v_score_column); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_19 = PyTuple_New(7); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_INCREF(__pyx_v_chrom);
          PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_v_chrom);
          __Pyx_GIVEREF(__pyx_v_chrom);
          __Pyx_INCREF(__pyx_v_summit_p);
          PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_v_summit_p);
          __Pyx_GIVEREF(__pyx_v_summit_p);
          PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __Pyx_INCREF(__pyx_v_name_prefix);
          PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_v_name_prefix);
          __Pyx_GIVEREF(__pyx_v_name_prefix);
          __Pyx_INCREF(__pyx_v_n_peak);
          PyTuple_SET_ITEM(__pyx_t_19, 4, __pyx_v_n_peak);
          __Pyx_GIVEREF(__pyx_v_n_peak);
          PyTuple_SET_ITEM(__pyx_t_19, 5, __pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_19, 6, __pyx_t_18);
          __Pyx_GIVEREF(__pyx_t_18);
          __pyx_t_2 = 0;
          __pyx_t_11 = 0;
          __pyx_t_18 = 0;
          __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), ((PyObject *)__pyx_t_19)); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_18));
          __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
          __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
          __pyx_t_18 = 0;
          __pyx_t_18 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        }
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L40;
      }
      /*else*/ {

        /* "MACS2/IO/cPeakIO.pyx":631
 *                         print_func("%s\t%d\t%d\t%s%d%s\t%.2f\n" % (chrom,summit_p,summit_p+1,name_prefix,n_peak,subpeak_letters(i),peak[score_column]))
 *                 else:
 *                     peak = peaks[0]             # <<<<<<<<<<<<<<
 *                     summit_p = peak["summit"]
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,summit_p,summit_p+1,name_prefix,n_peak,peak[score_column]))
 */
        __pyx_t_6 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_peaks), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_XDECREF(__pyx_v_peak);
        __pyx_v_peak = __pyx_t_6;
        __pyx_t_6 = 0;

        /* "MACS2/IO/cPeakIO.pyx":632
 *                 else:
 *                     peak = peaks[0]
 *                     summit_p = peak["summit"]             # <<<<<<<<<<<<<<
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,summit_p,summit_p+1,name_prefix,n_peak,peak[score_column]))
 * 
 */
        __pyx_t_6 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__summit)); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_XDECREF(__pyx_v_summit_p);
        __pyx_v_summit_p = __pyx_t_6;
        __pyx_t_6 = 0;

        /* "MACS2/IO/cPeakIO.pyx":633
 *                     peak = peaks[0]
 *                     summit_p = peak["summit"]
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,summit_p,summit_p+1,name_prefix,n_peak,peak[score_column]))             # <<<<<<<<<<<<<<
 * 
 *     def tobed (self):
 */
        __pyx_t_6 = PyNumber_Add(__pyx_v_summit_p, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_12 = PyObject_GetItem(__pyx_v_peak, __pyx_v_score_column); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_18 = PyTuple_New(6); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_INCREF(__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_v_chrom);
        __Pyx_INCREF(__pyx_v_summit_p);
        PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_v_summit_p);
        __Pyx_GIVEREF(__pyx_v_summit_p);
        PyTuple_SET_ITEM(__pyx_t_18, 2, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_v_name_prefix);
        PyTuple_SET_ITEM(__pyx_t_18, 3, __pyx_v_name_prefix);
        __Pyx_GIVEREF(__pyx_v_name_prefix);
        __Pyx_INCREF(__pyx_v_n_peak);
        PyTuple_SET_ITEM(__pyx_t_18, 4, __pyx_v_n_peak);
        __Pyx_GIVEREF(__pyx_v_n_peak);
        PyTuple_SET_ITEM(__pyx_t_18, 5, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_12);
        __pyx_t_6 = 0;
        __pyx_t_12 = 0;
        __pyx_t_12 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), ((PyObject *)__pyx_t_18)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_12));
        __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
        __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        PyTuple_SET_ITEM(__pyx_t_18, 0, ((PyObject *)__pyx_t_12));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_12));
        __pyx_t_12 = 0;
        __pyx_t_12 = PyObject_Call(__pyx_v_print_func, ((PyObject *)__pyx_t_18), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __pyx_L40:;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO._to_summits_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_n_peak);
  __Pyx_XDECREF(__pyx_v_peakprefix);
  __Pyx_XDECREF(__pyx_v_desc);
  __Pyx_XDECREF(__pyx_v_trackcontents);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_end);
  __Pyx_XDECREF(__pyx_v_group);
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_peak);
  __Pyx_XDECREF(__pyx_v_summit_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_17tobed(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_16tobed[] = "Print out peaks in BED5 format.\n\n        Five columns are chromosome, peak start, peak end, peak name, and peak height.\n\n        start:start\n        end:end,\n        length:end-start,\n        summit:summit,\n        score:peak_score,\n        pileup:pileup,\n        pscore:pvalue,\n        fc:fold_change,\n        qscore:qvalue\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_17tobed = {__Pyx_NAMESTR("tobed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_17tobed, METH_O, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_16tobed)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_17tobed(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tobed (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_16tobed(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":635
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,summit_p,summit_p+1,name_prefix,n_peak,peak[score_column]))
 * 
 *     def tobed (self):             # <<<<<<<<<<<<<<
 *         """Print out peaks in BED5 format.
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_16tobed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("tobed", 0);
  __Pyx_TraceCall("tobed", __pyx_f[0], 635);

  /* "MACS2/IO/cPeakIO.pyx":650
 *         qscore:qvalue
 *         """
 *         return self._to_bed(name_prefix="peak_", score_column="score")             # <<<<<<<<<<<<<<
 * 
 *     def to_summits_bed (self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___to_bed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__name_prefix), ((PyObject *)__pyx_n_s__peak_)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__score_column), ((PyObject *)__pyx_n_s__score)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.tobed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_19to_summits_bed(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_18to_summits_bed[] = "Print out peak summits in BED5 format.\n\n        Five columns are chromosome, summit start, summit end, peak name, and peak height.\n\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_19to_summits_bed = {__Pyx_NAMESTR("to_summits_bed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_19to_summits_bed, METH_O, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_18to_summits_bed)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_19to_summits_bed(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_summits_bed (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_18to_summits_bed(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":652
 *         return self._to_bed(name_prefix="peak_", score_column="score")
 * 
 *     def to_summits_bed (self):             # <<<<<<<<<<<<<<
 *         """Print out peak summits in BED5 format.
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_18to_summits_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("to_summits_bed", 0);
  __Pyx_TraceCall("to_summits_bed", __pyx_f[0], 652);

  /* "MACS2/IO/cPeakIO.pyx":658
 * 
 *         """
 *         return self._to_summits_bed(name_prefix="peak_", score_column="score")             # <<<<<<<<<<<<<<
 * 
 *     def write_to_bed (self, fhd, str name_prefix="peak_", str name="MACS",
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___to_summits_bed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__name_prefix), ((PyObject *)__pyx_n_s__peak_)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__score_column), ((PyObject *)__pyx_n_s__score)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.to_summits_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":660
 *         return self._to_summits_bed(name_prefix="peak_", score_column="score")
 * 
 *     def write_to_bed (self, fhd, str name_prefix="peak_", str name="MACS",             # <<<<<<<<<<<<<<
 *                       str description = "%s", str score_column="score", trackline=True):
 *         """Write peaks in BED5 format in a file handler. Score (5th
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_30__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_TraceCall("__defaults__", __pyx_f[0], 660);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults7, __pyx_self)->__pyx_arg_trackline);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __Pyx_CyFunction_Defaults(__pyx_defaults7, __pyx_self)->__pyx_arg_trackline);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults7, __pyx_self)->__pyx_arg_trackline);
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_21write_to_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_20write_to_bed[] = "Write peaks in BED5 format in a file handler. Score (5th\n        column) is decided by score_column setting. Check the\n        following list. Name column ( 4th column) is made by putting\n        name_prefix together with an ascending number.\n\n        Five columns are chromosome, peak start, peak end, peak name,\n        and peak score.\n\n        items in peak hash object:\n\n        start:start\n        end:end,\n        length:end-start,\n        summit:summit,\n        score:peak_score,\n        pileup:pileup,\n        pscore:pvalue,\n        fc:fold_change,\n        qscore:qvalue        \n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_21write_to_bed = {__Pyx_NAMESTR("write_to_bed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_21write_to_bed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_20write_to_bed)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_21write_to_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fhd = 0;
  PyObject *__pyx_v_name_prefix = 0;
  CYTHON_UNUSED PyObject *__pyx_v_name = 0;
  CYTHON_UNUSED PyObject *__pyx_v_description = 0;
  PyObject *__pyx_v_score_column = 0;
  CYTHON_UNUSED PyObject *__pyx_v_trackline = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fhd,&__pyx_n_s__name_prefix,&__pyx_n_s__name,&__pyx_n_s__description,&__pyx_n_s__score_column,&__pyx_n_s__trackline,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_to_bed (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[7] = {0,0,0,0,0,0,0};
    __pyx_defaults7 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults7, __pyx_self);
    values[2] = ((PyObject*)((PyObject*)__pyx_n_s__peak_));
    values[3] = ((PyObject*)((PyObject*)__pyx_n_s__MACS));
    values[4] = ((PyObject*)((PyObject*)__pyx_kp_s_2));
    values[5] = ((PyObject*)((PyObject*)__pyx_n_s__score));
    values[6] = __pyx_dynamic_args->__pyx_arg_trackline;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fhd);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_to_bed", 0, 2, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name_prefix);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__description);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__score_column);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trackline);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_to_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_fhd = values[1];
    __pyx_v_name_prefix = ((PyObject*)values[2]);
    __pyx_v_name = ((PyObject*)values[3]);
    __pyx_v_description = ((PyObject*)values[4]);
    __pyx_v_score_column = ((PyObject*)values[5]);
    __pyx_v_trackline = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_to_bed", 0, 2, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.write_to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name_prefix), (&PyString_Type), 1, "name_prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyString_Type), 1, "name", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_description), (&PyString_Type), 1, "description", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_score_column), (&PyString_Type), 1, "score_column", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_20write_to_bed(__pyx_self, __pyx_v_self, __pyx_v_fhd, __pyx_v_name_prefix, __pyx_v_name, __pyx_v_description, __pyx_v_score_column, __pyx_v_trackline);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_20write_to_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, CYTHON_UNUSED PyObject *__pyx_v_name, CYTHON_UNUSED PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, CYTHON_UNUSED PyObject *__pyx_v_trackline) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_to_bed", 0);
  __Pyx_TraceCall("write_to_bed", __pyx_f[0], 660);

  /* "MACS2/IO/cPeakIO.pyx":682
 *         qscore:qvalue
 *         """
 *         return self._to_bed(name_prefix=name_prefix, score_column=score_column,             # <<<<<<<<<<<<<<
 *                             print_func=fhd.write)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___to_bed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__name_prefix), ((PyObject *)__pyx_v_name_prefix)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__score_column), ((PyObject *)__pyx_v_score_column)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":683
 *         """
 *         return self._to_bed(name_prefix=name_prefix, score_column=score_column,
 *                             print_func=fhd.write)             # <<<<<<<<<<<<<<
 * 
 *     def write_to_summit_bed (self, fhd, name_prefix="peak_", name="MACS",
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_fhd, __pyx_n_s__write); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__print_func), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.write_to_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":685
 *                             print_func=fhd.write)
 * 
 *     def write_to_summit_bed (self, fhd, name_prefix="peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                              description = "%s", score_column="score", trackline=True):
 *         """Write peak summits in BED5 format in a file handler. Score
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_32__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_TraceCall("__defaults__", __pyx_f[0], 685);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_self)->__pyx_arg_trackline);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_self)->__pyx_arg_trackline);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_self)->__pyx_arg_trackline);
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_23write_to_summit_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_22write_to_summit_bed[] = "Write peak summits in BED5 format in a file handler. Score\n        (5th column) is decided by score_column setting. Check the\n        following list. Name column ( 4th column) is made by putting\n        name_prefix together with an ascending number.\n\n        Five columns are chromosome, summit start, summit end, peak name, and peak score.\n\n        items in peak object:\n\n        start:start\n        end:end,\n        length:end-start,\n        summit:summit,\n        score:peak_score,\n        pileup:pileup,\n        pscore:pvalue,\n        fc:fold_change,\n        qscore:qvalue\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_23write_to_summit_bed = {__Pyx_NAMESTR("write_to_summit_bed"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_23write_to_summit_bed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_22write_to_summit_bed)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_23write_to_summit_bed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fhd = 0;
  PyObject *__pyx_v_name_prefix = 0;
  CYTHON_UNUSED PyObject *__pyx_v_name = 0;
  CYTHON_UNUSED PyObject *__pyx_v_description = 0;
  PyObject *__pyx_v_score_column = 0;
  CYTHON_UNUSED PyObject *__pyx_v_trackline = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fhd,&__pyx_n_s__name_prefix,&__pyx_n_s__name,&__pyx_n_s__description,&__pyx_n_s__score_column,&__pyx_n_s__trackline,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_to_summit_bed (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[7] = {0,0,0,0,0,0,0};
    __pyx_defaults8 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_self);
    values[2] = ((PyObject *)((PyObject*)__pyx_n_s__peak_));
    values[3] = ((PyObject *)((PyObject*)__pyx_n_s__MACS));
    values[4] = ((PyObject *)((PyObject*)__pyx_kp_s_2));
    values[5] = ((PyObject *)((PyObject*)__pyx_n_s__score));
    values[6] = __pyx_dynamic_args->__pyx_arg_trackline;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fhd);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_to_summit_bed", 0, 2, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name_prefix);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__description);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__score_column);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trackline);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_to_summit_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_fhd = values[1];
    __pyx_v_name_prefix = values[2];
    __pyx_v_name = values[3];
    __pyx_v_description = values[4];
    __pyx_v_score_column = values[5];
    __pyx_v_trackline = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_to_summit_bed", 0, 2, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.write_to_summit_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_22write_to_summit_bed(__pyx_self, __pyx_v_self, __pyx_v_fhd, __pyx_v_name_prefix, __pyx_v_name, __pyx_v_description, __pyx_v_score_column, __pyx_v_trackline);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_22write_to_summit_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, CYTHON_UNUSED PyObject *__pyx_v_name, CYTHON_UNUSED PyObject *__pyx_v_description, PyObject *__pyx_v_score_column, CYTHON_UNUSED PyObject *__pyx_v_trackline) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_to_summit_bed", 0);
  __Pyx_TraceCall("write_to_summit_bed", __pyx_f[0], 685);

  /* "MACS2/IO/cPeakIO.pyx":706
 *         qscore:qvalue
 *         """
 *         return self._to_summits_bed(name_prefix=name_prefix, score_column=score_column,             # <<<<<<<<<<<<<<
 *                             print_func=fhd.write)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___to_summits_bed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__name_prefix), __pyx_v_name_prefix) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__score_column), __pyx_v_score_column) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":707
 *         """
 *         return self._to_summits_bed(name_prefix=name_prefix, score_column=score_column,
 *                             print_func=fhd.write)             # <<<<<<<<<<<<<<
 * 
 *     def write_to_narrowPeak (self, fhd, name_prefix="peak_", name="peak", score_column="score", trackline=True):
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_fhd, __pyx_n_s__write); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__print_func), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.write_to_summit_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":709
 *                             print_func=fhd.write)
 * 
 *     def write_to_narrowPeak (self, fhd, name_prefix="peak_", name="peak", score_column="score", trackline=True):             # <<<<<<<<<<<<<<
 *         """Print out peaks in narrowPeak format.
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_34__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_TraceCall("__defaults__", __pyx_f[0], 709);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__peak)));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)((PyObject*)__pyx_n_s__peak)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__peak)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__score)));
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_self)->__pyx_arg_trackline);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_self)->__pyx_arg_trackline);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_self)->__pyx_arg_trackline);
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_25write_to_narrowPeak(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_24write_to_narrowPeak[] = "Print out peaks in narrowPeak format.\n\n        This format is designed for ENCODE project, and basically a\n        BED6+4 format.\n\n        +-----------+------+----------------------------------------+\n        |field      |type  |description                             |\n        +-----------+------+----------------------------------------+\n        |chrom      |string|Name of the chromosome                  |\n        +-----------+------+----------------------------------------+\n        |chromStart |int   |The starting position of the feature in |\n        |           |      |the chromosome. The first base in a     |\n        |           |      |chromosome is numbered 0.               |\n        +-----------+------+----------------------------------------+\n        |chromEnd   |int   |The ending position of the feature in   |\n        |           |      |the chromosome or scaffold. The chromEnd|\n        |           |      |base is not included in the display of  |\n        |           |      |the feature.  For example, the first 100|\n        |           |      |bases of a chromosome are defined as    |\n        |           |      |chromStart=0, chromEnd=100, and span the|\n        |           |      |bases numbered 0-99.                    |\n        +-----------+------+----------------------------------------+\n        |name       |string|Name given to a region (preferably      |\n        |           |      |unique). Use '.' if no name is assigned.|\n        +-----------+------+----------------------------------------+\n        |score      |int   |Indicates how dark the peak will be     |\n        |(-logpvalue|      |displayed in the browser (1-1000). If   |\n        |in MACS2 * |      |'0', the DCC will assign this based on  |\n        |10)        |      |signal value. Ideally average           |\n        |           |      |signalValue per base spread between     |\n        |           |      |100-1000.                               |\n        +---------""--+------+----------------------------------------+\n        |strand     |char  |+/- to denote strand or orientation     |\n        |(always .) |      |(whenever applicable). Use '.' if no    |\n        |           |      |orientation is assigned.                |\n        +-----------+------+----------------------------------------+\n        |signalValue|float |Measurement of overall (usually,        |\n        |(fc)       |      |average) enrichment for the region.     |\n        +-----------+------+----------------------------------------+\n        |pValue     |float |Measurement of statistical signficance  |\n        |           |      |(-log10). Use -1 if no pValue is        |\n        |           |      |assigned.                               |\n        +-----------+------+----------------------------------------+\n        |qValue     |float |Measurement of statistical significance |\n        |           |      |using false discovery rate. Use -1 if no|\n        |           |      |qValue is assigned.                     |\n        +-----------+------+----------------------------------------+\n        |peak       |int   |Point-source called for this peak;      |\n        |           |      |0-based offset from chromStart. Use -1  |\n        |           |      |if no point-source called.              |\n        +-----------+------+----------------------------------------+\n        \n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_25write_to_narrowPeak = {__Pyx_NAMESTR("write_to_narrowPeak"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_25write_to_narrowPeak, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_10DiffPeakIO_24write_to_narrowPeak)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_10DiffPeakIO_25write_to_narrowPeak(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fhd = 0;
  PyObject *__pyx_v_name_prefix = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_score_column = 0;
  PyObject *__pyx_v_trackline = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fhd,&__pyx_n_s__name_prefix,&__pyx_n_s__name,&__pyx_n_s__score_column,&__pyx_n_s__trackline,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_to_narrowPeak (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[6] = {0,0,0,0,0,0};
    __pyx_defaults9 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_self);
    values[2] = ((PyObject *)((PyObject*)__pyx_n_s__peak_));
    values[3] = ((PyObject *)((PyObject*)__pyx_n_s__peak));
    values[4] = ((PyObject *)((PyObject*)__pyx_n_s__score));
    values[5] = __pyx_dynamic_args->__pyx_arg_trackline;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fhd);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_to_narrowPeak", 0, 2, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name_prefix);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__score_column);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trackline);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_to_narrowPeak") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_fhd = values[1];
    __pyx_v_name_prefix = values[2];
    __pyx_v_name = values[3];
    __pyx_v_score_column = values[4];
    __pyx_v_trackline = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_to_narrowPeak", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.write_to_narrowPeak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_24write_to_narrowPeak(__pyx_self, __pyx_v_self, __pyx_v_fhd, __pyx_v_name_prefix, __pyx_v_name, __pyx_v_score_column, __pyx_v_trackline);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_24write_to_narrowPeak(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_score_column, PyObject *__pyx_v_trackline) {
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_n_peak = NULL;
  PyObject *__pyx_v_peakprefix = NULL;
  PyObject *__pyx_v_chrom = NULL;
  PyObject *__pyx_v_peak = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_to_narrowPeak", 0);
  __Pyx_TraceCall("write_to_narrowPeak", __pyx_f[0], 709);

  /* "MACS2/IO/cPeakIO.pyx":763
 * 
 *         """
 *         chrs = self.peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         n_peak = 0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_chrs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":764
 *         """
 *         chrs = self.peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":765
 *         chrs = self.peaks.keys()
 *         chrs.sort()
 *         n_peak = 0             # <<<<<<<<<<<<<<
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_n_peak = __pyx_int_0;

  /* "MACS2/IO/cPeakIO.pyx":766
 *         chrs.sort()
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name             # <<<<<<<<<<<<<<
 *         except: peakprefix = name_prefix
 *         if trackline:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {
      __pyx_t_2 = PyNumber_Remainder(__pyx_v_name_prefix, __pyx_v_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_peakprefix = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "MACS2/IO/cPeakIO.pyx":767
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix             # <<<<<<<<<<<<<<
 *         if trackline:
 *             fhd.write("track type=narrowPeak name=\"%s\" description=\"%s\" nextItemButton=on\n" % (name, name))
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.write_to_narrowPeak", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_name_prefix);
      __Pyx_XDECREF(__pyx_v_peakprefix);
      __pyx_v_peakprefix = __pyx_v_name_prefix;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L10_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":768
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 *         if trackline:             # <<<<<<<<<<<<<<
 *             fhd.write("track type=narrowPeak name=\"%s\" description=\"%s\" nextItemButton=on\n" % (name, name))
 *         for chrom in chrs:
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_trackline); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_7) {

    /* "MACS2/IO/cPeakIO.pyx":769
 *         except: peakprefix = name_prefix
 *         if trackline:
 *             fhd.write("track type=narrowPeak name=\"%s\" description=\"%s\" nextItemButton=on\n" % (name, name))             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             for peak in self.peaks[chrom]:
 */
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_fhd, __pyx_n_s__write); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_name);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_name);
    __Pyx_GIVEREF(__pyx_v_name);
    __Pyx_INCREF(__pyx_v_name);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_name);
    __Pyx_GIVEREF(__pyx_v_name);
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "MACS2/IO/cPeakIO.pyx":770
 *         if trackline:
 *             fhd.write("track type=narrowPeak name=\"%s\" description=\"%s\" nextItemButton=on\n" % (name, name))
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             for peak in self.peaks[chrom]:
 *                 n_peak += 1
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_2 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++;
    } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++;
    } else {
      __pyx_t_1 = __pyx_t_9(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_chrom);
    __pyx_v_chrom = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "MACS2/IO/cPeakIO.pyx":771
 *             fhd.write("track type=narrowPeak name=\"%s\" description=\"%s\" nextItemButton=on\n" % (name, name))
 *         for chrom in chrs:
 *             for peak in self.peaks[chrom]:             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 # items in peak: (peak start,peak end, peak length,
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_v_chrom); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
      __pyx_t_1 = __pyx_t_6; __Pyx_INCREF(__pyx_t_1); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = Py_TYPE(__pyx_t_1)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    for (;;) {
      if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_1)) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++;
      } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_1)) {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++;
      } else {
        __pyx_t_6 = __pyx_t_11(__pyx_t_1);
        if (unlikely(!__pyx_t_6)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_XDECREF(__pyx_v_peak);
      __pyx_v_peak = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "MACS2/IO/cPeakIO.pyx":772
 *         for chrom in chrs:
 *             for peak in self.peaks[chrom]:
 *                 n_peak += 1             # <<<<<<<<<<<<<<
 *                 # items in peak: (peak start,peak end, peak length,
 *                 # peak summit, peak height, number of tags in peak
 */
      __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_n_peak, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_v_n_peak);
      __pyx_v_n_peak = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "MACS2/IO/cPeakIO.pyx":776
 *                 # peak summit, peak height, number of tags in peak
 *                 # region, peak pvalue, peak fold_enrichment, qvalue)
 *                 fhd.write( "%s\t%d\t%d\t%s%d\t%d\t.\t%.2f\t%.2f\t%.2f\t%d\n"             # <<<<<<<<<<<<<<
 *                            %
 *                            (chrom,peak["start"],peak["end"],peakprefix,n_peak,int(10*peak[score_column]),
 */
      __pyx_t_6 = PyObject_GetAttr(__pyx_v_fhd, __pyx_n_s__write); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);

      /* "MACS2/IO/cPeakIO.pyx":778
 *                 fhd.write( "%s\t%d\t%d\t%s%d\t%d\t.\t%.2f\t%.2f\t%.2f\t%d\n"
 *                            %
 *                            (chrom,peak["start"],peak["end"],peakprefix,n_peak,int(10*peak[score_column]),             # <<<<<<<<<<<<<<
 *                             peak["fc"],peak["pscore"],peak["qscore"],peak["summit"]-peak["start"]) )
 * 
 */
      __pyx_t_12 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__start)); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__end)); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = PyObject_GetItem(__pyx_v_peak, __pyx_v_score_column); if (!__pyx_t_14) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_15 = PyNumber_Multiply(__pyx_int_10, __pyx_t_14); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_15);
      __pyx_t_15 = 0;
      __pyx_t_15 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;

      /* "MACS2/IO/cPeakIO.pyx":779
 *                            %
 *                            (chrom,peak["start"],peak["end"],peakprefix,n_peak,int(10*peak[score_column]),
 *                             peak["fc"],peak["pscore"],peak["qscore"],peak["summit"]-peak["start"]) )             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_14 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__fc)); if (!__pyx_t_14) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_16 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__pscore)); if (!__pyx_t_16) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_17 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__qscore)); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__summit)); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_19 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__start)); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_19);
      __pyx_t_20 = PyNumber_Subtract(__pyx_t_18, __pyx_t_19); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_20);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __pyx_t_19 = PyTuple_New(10); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_19);
      __Pyx_INCREF(__pyx_v_chrom);
      PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_v_chrom);
      __Pyx_GIVEREF(__pyx_v_chrom);
      PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      __Pyx_INCREF(__pyx_v_peakprefix);
      PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_v_peakprefix);
      __Pyx_GIVEREF(__pyx_v_peakprefix);
      __Pyx_INCREF(__pyx_v_n_peak);
      PyTuple_SET_ITEM(__pyx_t_19, 4, __pyx_v_n_peak);
      __Pyx_GIVEREF(__pyx_v_n_peak);
      PyTuple_SET_ITEM(__pyx_t_19, 5, __pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_19, 6, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_19, 7, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_19, 8, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_19, 9, __pyx_t_20);
      __Pyx_GIVEREF(__pyx_t_20);
      __pyx_t_12 = 0;
      __pyx_t_13 = 0;
      __pyx_t_15 = 0;
      __pyx_t_14 = 0;
      __pyx_t_16 = 0;
      __pyx_t_17 = 0;
      __pyx_t_20 = 0;
      __pyx_t_20 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_19), ((PyObject *)__pyx_t_19)); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_20));
      __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
      __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_19);
      PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_20));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_20));
      __pyx_t_20 = 0;
      __pyx_t_20 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_20);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.DiffPeakIO.write_to_narrowPeak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_n_peak);
  __Pyx_XDECREF(__pyx_v_peakprefix);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_peak);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_11BroadPeakIO_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_11BroadPeakIO_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_11BroadPeakIO_1__init__, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_11BroadPeakIO_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO___init__(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":789
 *     """
 * 
 *     def __init__ (self):             # <<<<<<<<<<<<<<
 *         self.peaks = {}
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 789);

  /* "MACS2/IO/cPeakIO.pyx":790
 * 
 *     def __init__ (self):
 *         self.peaks = {}             # <<<<<<<<<<<<<<
 * 
 *     def add (self, char * chromosome, long start, long end, long score = 0,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__peaks, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.BroadPeakIO.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_11BroadPeakIO_3add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_11BroadPeakIO_2add[] = "items\n        chromosome : chromosome name,\n        start      : broad region start,\n        end        : broad region end,\n        score      : average score in all blocks,\n        thickStart : start of highly enriched region,\n        thickEnd   : end of highly enriched region,\n        blockNum   : number of blocks,\n        blockSizes : sizes of blocks,\n        blockStarts: starts of blocks\n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_11BroadPeakIO_3add = {__Pyx_NAMESTR("add"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_11BroadPeakIO_3add, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_11BroadPeakIO_2add)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_11BroadPeakIO_3add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  char *__pyx_v_chromosome;
  long __pyx_v_start;
  long __pyx_v_end;
  long __pyx_v_score;
  long __pyx_v_thickStart;
  long __pyx_v_thickEnd;
  long __pyx_v_blockNum;
  char *__pyx_v_blockSizes;
  char *__pyx_v_blockStarts;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__chromosome,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__score,&__pyx_n_s__thickStart,&__pyx_n_s__thickEnd,&__pyx_n_s__blockNum,&__pyx_n_s__blockSizes,&__pyx_n_s__blockStarts,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__chromosome);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 0, 4, 10, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 0, 4, 10, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
        if (likely(values[3])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 0, 4, 10, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__score);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__thickStart);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__thickEnd);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__blockNum);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__blockSizes);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__blockStarts);
          if (value) { values[9] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[4]) {
      } else {
        __pyx_v_score = ((long)((long)0));
      }
      if (values[5]) {
      } else {
        __pyx_v_thickStart = ((long)((long)0));
      }
      if (values[6]) {
      } else {
        __pyx_v_thickEnd = ((long)((long)0));
      }
      if (values[7]) {
      } else {
        __pyx_v_blockNum = ((long)((long)0));
      }
      if (values[8]) {
      } else {
        __pyx_v_blockSizes = ((char *)((char *)__pyx_k_45));
      }
      if (values[9]) {
      } else {
        __pyx_v_blockStarts = ((char *)((char *)__pyx_k_45));
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_chromosome = PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_chromosome) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_start = __Pyx_PyInt_AsLong(values[2]); if (unlikely((__pyx_v_start == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_end = __Pyx_PyInt_AsLong(values[3]); if (unlikely((__pyx_v_end == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[4]) {
      __pyx_v_score = __Pyx_PyInt_AsLong(values[4]); if (unlikely((__pyx_v_score == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_score = ((long)((long)0));
    }
    if (values[5]) {
      __pyx_v_thickStart = __Pyx_PyInt_AsLong(values[5]); if (unlikely((__pyx_v_thickStart == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_thickStart = ((long)((long)0));
    }
    if (values[6]) {
      __pyx_v_thickEnd = __Pyx_PyInt_AsLong(values[6]); if (unlikely((__pyx_v_thickEnd == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_thickEnd = ((long)((long)0));
    }
    if (values[7]) {
      __pyx_v_blockNum = __Pyx_PyInt_AsLong(values[7]); if (unlikely((__pyx_v_blockNum == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_blockNum = ((long)((long)0));
    }
    if (values[8]) {
      __pyx_v_blockSizes = PyBytes_AsString(values[8]); if (unlikely((!__pyx_v_blockSizes) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_blockSizes = ((char *)((char *)__pyx_k_45));
    }
    if (values[9]) {
      __pyx_v_blockStarts = PyBytes_AsString(values[9]); if (unlikely((!__pyx_v_blockStarts) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_blockStarts = ((char *)((char *)__pyx_k_45));
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 0, 4, 10, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.BroadPeakIO.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO_2add(__pyx_self, __pyx_v_self, __pyx_v_chromosome, __pyx_v_start, __pyx_v_end, __pyx_v_score, __pyx_v_thickStart, __pyx_v_thickEnd, __pyx_v_blockNum, __pyx_v_blockSizes, __pyx_v_blockStarts);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":792
 *         self.peaks = {}
 * 
 *     def add (self, char * chromosome, long start, long end, long score = 0,             # <<<<<<<<<<<<<<
 *              long thickStart=0, long thickEnd=0,
 *              long blockNum=0, char *blockSizes="",
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO_2add(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, char *__pyx_v_chromosome, long __pyx_v_start, long __pyx_v_end, long __pyx_v_score, long __pyx_v_thickStart, long __pyx_v_thickEnd, long __pyx_v_blockNum, char *__pyx_v_blockSizes, char *__pyx_v_blockStarts) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("add", 0);
  __Pyx_TraceCall("add", __pyx_f[0], 792);

  /* "MACS2/IO/cPeakIO.pyx":807
 *         blockStarts: starts of blocks
 *         """
 *         if not self.peaks.has_key(chromosome):             # <<<<<<<<<<<<<<
 *             self.peaks[chromosome]=[]
 *         self.peaks[chromosome].append({"start":start,
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__has_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyBytes_FromString(__pyx_v_chromosome); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = (!__pyx_t_4);
  if (__pyx_t_5) {

    /* "MACS2/IO/cPeakIO.pyx":808
 *         """
 *         if not self.peaks.has_key(chromosome):
 *             self.peaks[chromosome]=[]             # <<<<<<<<<<<<<<
 *         self.peaks[chromosome].append({"start":start,
 *                                        "end":end,
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyBytes_FromString(__pyx_v_chromosome); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    if (PyObject_SetItem(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "MACS2/IO/cPeakIO.pyx":809
 *         if not self.peaks.has_key(chromosome):
 *             self.peaks[chromosome]=[]
 *         self.peaks[chromosome].append({"start":start,             # <<<<<<<<<<<<<<
 *                                        "end":end,
 *                                        "score":score,
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyBytes_FromString(__pyx_v_chromosome); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyObject_GetItem(__pyx_t_1, ((PyObject *)__pyx_t_2)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_1 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__start), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":810
 *             self.peaks[chromosome]=[]
 *         self.peaks[chromosome].append({"start":start,
 *                                        "end":end,             # <<<<<<<<<<<<<<
 *                                        "score":score,
 *                                        "thickStart":thickStart,
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__end), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":811
 *         self.peaks[chromosome].append({"start":start,
 *                                        "end":end,
 *                                        "score":score,             # <<<<<<<<<<<<<<
 *                                        "thickStart":thickStart,
 *                                        "thickEnd":thickEnd,
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_score); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__score), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":812
 *                                        "end":end,
 *                                        "score":score,
 *                                        "thickStart":thickStart,             # <<<<<<<<<<<<<<
 *                                        "thickEnd":thickEnd,
 *                                        "blockNum":blockNum,
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_thickStart); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__thickStart), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":813
 *                                        "score":score,
 *                                        "thickStart":thickStart,
 *                                        "thickEnd":thickEnd,             # <<<<<<<<<<<<<<
 *                                        "blockNum":blockNum,
 *                                        "blockSizes":blockSizes,
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_thickEnd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__thickEnd), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":814
 *                                        "thickStart":thickStart,
 *                                        "thickEnd":thickEnd,
 *                                        "blockNum":blockNum,             # <<<<<<<<<<<<<<
 *                                        "blockSizes":blockSizes,
 *                                        "blockStarts":blockStarts,
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_blockNum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__blockNum), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":815
 *                                        "thickEnd":thickEnd,
 *                                        "blockNum":blockNum,
 *                                        "blockSizes":blockSizes,             # <<<<<<<<<<<<<<
 *                                        "blockStarts":blockStarts,
 *                                        }
 */
  __pyx_t_1 = PyBytes_FromString(__pyx_v_blockSizes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__blockSizes), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":816
 *                                        "blockNum":blockNum,
 *                                        "blockSizes":blockSizes,
 *                                        "blockStarts":blockStarts,             # <<<<<<<<<<<<<<
 *                                        }
 *                                       )
 */
  __pyx_t_1 = PyBytes_FromString(__pyx_v_blockStarts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__blockStarts), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Append(__pyx_t_3, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.BroadPeakIO.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_11BroadPeakIO_5total(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_11BroadPeakIO_5total = {__Pyx_NAMESTR("total"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_11BroadPeakIO_5total, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_11BroadPeakIO_5total(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("total (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO_4total(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":820
 *                                       )
 * 
 *     def total (self):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 *         cdef long x
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO_4total(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_chrom = 0;
  long __pyx_v_x;
  PyObject *__pyx_v_peaks = NULL;
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("total", 0);
  __Pyx_TraceCall("total", __pyx_f[0], 820);

  /* "MACS2/IO/cPeakIO.pyx":824
 *         cdef long x
 * 
 *         peaks = self.peaks             # <<<<<<<<<<<<<<
 *         chrs = peaks.keys()
 *         chrs.sort()
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_peaks = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":825
 * 
 *         peaks = self.peaks
 *         chrs = peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         x = 0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_peaks, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_chrs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":826
 *         peaks = self.peaks
 *         chrs = peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         x = 0
 *         for chrom in chrs:
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":827
 *         chrs = peaks.keys()
 *         chrs.sort()
 *         x = 0             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             x += len(peaks[chrom])
 */
  __pyx_v_x = 0;

  /* "MACS2/IO/cPeakIO.pyx":828
 *         chrs.sort()
 *         x = 0
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             x += len(peaks[chrom])
 *         return x
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_1 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_chrom));
    __pyx_v_chrom = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "MACS2/IO/cPeakIO.pyx":829
 *         x = 0
 *         for chrom in chrs:
 *             x += len(peaks[chrom])             # <<<<<<<<<<<<<<
 *         return x
 * 
 */
    __pyx_t_2 = PyObject_GetItem(__pyx_v_peaks, ((PyObject *)__pyx_v_chrom)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_x = (__pyx_v_x + __pyx_t_5);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":830
 *         for chrom in chrs:
 *             x += len(peaks[chrom])
 *         return x             # <<<<<<<<<<<<<<
 * 
 *     def write_to_gappedPeak (self, fhd, name_prefix="peak_", name='peak', description="%s", trackline=True):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_x); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.BroadPeakIO.total", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_peaks);
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "MACS2/IO/cPeakIO.pyx":832
 *         return x
 * 
 *     def write_to_gappedPeak (self, fhd, name_prefix="peak_", name='peak', description="%s", trackline=True):             # <<<<<<<<<<<<<<
 *         """Print out peaks in bed12 format.
 * 
 */

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO_8__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_TraceCall("__defaults__", __pyx_f[0], 832);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__peak_)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__peak)));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)((PyObject*)__pyx_n_s__peak)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__peak)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_2)));
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_self)->__pyx_arg_trackline);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_self)->__pyx_arg_trackline);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_self)->__pyx_arg_trackline);
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.BroadPeakIO.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_11BroadPeakIO_7write_to_gappedPeak(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_2IO_7cPeakIO_11BroadPeakIO_6write_to_gappedPeak[] = "Print out peaks in bed12 format.\n\n        This format is basically a BED12 format.\n\n        +--------------+------+----------------------------------------+\n        |field         |type  |description                             |\n        +--------------+------+----------------------------------------+\n        |chrom         |string|Name of the chromosome                  |\n        +--------------+------+----------------------------------------+\n        |chromStart    |int   |The starting position of the feature in |\n        |              |      |the chromosome. The first base in a     |\n        |              |      |chromosome is numbered 0.               |\n        +--------------+------+----------------------------------------+\n        |chromEnd      |int   |The ending position of the feature in   |\n        |              |      |the chromosome or scaffold. The chromEnd|\n        |              |      |base is not included in the display of  |\n        |              |      |the feature.  For example, the first 100|\n        |              |      |bases of a chromosome are defined as    |\n        |              |      |chromStart=0, chromEnd=100, and span the|\n        |              |      |bases numbered 0-99.                    |\n        +--------------+------+----------------------------------------+\n        |name          |string|Name given to a region (preferably      |\n        |              |      |unique). Use '.' if no name is assigned.|\n        +--------------+------+----------------------------------------+\n        |score         |int   |Indicates how dark the peak will be     |\n        |(always use   |      |displayed in the browser (1-1000). If   |\n        |1000 for      |      |'0', the DCC will assign this based on  |\n        |the           |      |signal value. Ideally average           |\n        |thickest      |      |signalValue per base spread between     |\n        |color)        |      |100-1000.                      ""         |\n        +--------------+------+----------------------------------------+\n        |strand        |char  |+/- to denote strand or orientation     |\n        |(always .)    |      |(whenever applicable). Use '.' if no    |\n        |              |      |orientation is assigned.                |\n        +--------------+------+----------------------------------------+\n        |thickStart    |int   | The starting position at which the     |\n        |              |      |feature is drawn thickly. Mark the start|\n        |              |      |of highly enriched regions.             |\n        |              |      |                                        |\n        +--------------+------+----------------------------------------+\n        |thickEnd      |int   | The ending position at which the       |\n        |              |      |feature is drawn thickly. Mark the end  |\n        |              |      |of highly enriched regions.             |\n        +--------------+------+----------------------------------------+\n        |itemRGB       |string| Not used. Set it as 0.                 |\n        +--------------+------+----------------------------------------+\n        |blockCounts   |int   | The number of blocks (exons) in the BED|\n        |              |      |line.                                   |\n        +--------------+------+----------------------------------------+\n        |blockSizes    |string| A comma-separated list of the block    |\n        |              |      |sizes.                                  |\n        +--------------+------+----------------------------------------+\n        |blockStarts   |string| A comma-separated list of block starts.|\n        +--------------+------+----------------------------------------+\n       \n        ";
static PyMethodDef __pyx_mdef_5MACS2_2IO_7cPeakIO_11BroadPeakIO_7write_to_gappedPeak = {__Pyx_NAMESTR("write_to_gappedPeak"), (PyCFunction)__pyx_pw_5MACS2_2IO_7cPeakIO_11BroadPeakIO_7write_to_gappedPeak, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5MACS2_2IO_7cPeakIO_11BroadPeakIO_6write_to_gappedPeak)};
static PyObject *__pyx_pw_5MACS2_2IO_7cPeakIO_11BroadPeakIO_7write_to_gappedPeak(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fhd = 0;
  PyObject *__pyx_v_name_prefix = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_description = 0;
  PyObject *__pyx_v_trackline = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fhd,&__pyx_n_s__name_prefix,&__pyx_n_s__name,&__pyx_n_s__description,&__pyx_n_s__trackline,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_to_gappedPeak (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[6] = {0,0,0,0,0,0};
    __pyx_defaults10 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_self);
    values[2] = ((PyObject *)((PyObject*)__pyx_n_s__peak_));
    values[3] = ((PyObject *)((PyObject*)__pyx_n_s__peak));
    values[4] = ((PyObject *)((PyObject*)__pyx_kp_s_2));
    values[5] = __pyx_dynamic_args->__pyx_arg_trackline;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fhd);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_to_gappedPeak", 0, 2, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name_prefix);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__description);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trackline);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_to_gappedPeak") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_fhd = values[1];
    __pyx_v_name_prefix = values[2];
    __pyx_v_name = values[3];
    __pyx_v_description = values[4];
    __pyx_v_trackline = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_to_gappedPeak", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.BroadPeakIO.write_to_gappedPeak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO_6write_to_gappedPeak(__pyx_self, __pyx_v_self, __pyx_v_fhd, __pyx_v_name_prefix, __pyx_v_name, __pyx_v_description, __pyx_v_trackline);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO_6write_to_gappedPeak(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fhd, PyObject *__pyx_v_name_prefix, PyObject *__pyx_v_name, PyObject *__pyx_v_description, PyObject *__pyx_v_trackline) {
  PyObject *__pyx_v_chrs = NULL;
  PyObject *__pyx_v_n_peak = NULL;
  PyObject *__pyx_v_peakprefix = NULL;
  PyObject *__pyx_v_desc = NULL;
  PyObject *__pyx_v_chrom = NULL;
  PyObject *__pyx_v_peak = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_to_gappedPeak", 0);
  __Pyx_TraceCall("write_to_gappedPeak", __pyx_f[0], 832);

  /* "MACS2/IO/cPeakIO.pyx":889
 * 
 *         """
 *         chrs = self.peaks.keys()             # <<<<<<<<<<<<<<
 *         chrs.sort()
 *         n_peak = 0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_chrs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":890
 *         """
 *         chrs = self.peaks.keys()
 *         chrs.sort()             # <<<<<<<<<<<<<<
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_chrs, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":891
 *         chrs = self.peaks.keys()
 *         chrs.sort()
 *         n_peak = 0             # <<<<<<<<<<<<<<
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_n_peak = __pyx_int_0;

  /* "MACS2/IO/cPeakIO.pyx":892
 *         chrs.sort()
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name             # <<<<<<<<<<<<<<
 *         except: peakprefix = name_prefix
 *         try: desc = description % name
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {
      __pyx_t_2 = PyNumber_Remainder(__pyx_v_name_prefix, __pyx_v_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_peakprefix = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "MACS2/IO/cPeakIO.pyx":893
 *         n_peak = 0
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix             # <<<<<<<<<<<<<<
 *         try: desc = description % name
 *         except: desc = description
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.BroadPeakIO.write_to_gappedPeak", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_name_prefix);
      __Pyx_XDECREF(__pyx_v_peakprefix);
      __pyx_v_peakprefix = __pyx_v_name_prefix;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L10_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":894
 *         try: peakprefix = name_prefix % name
 *         except: peakprefix = name_prefix
 *         try: desc = description % name             # <<<<<<<<<<<<<<
 *         except: desc = description
 *         if trackline:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {
      __pyx_t_6 = PyNumber_Remainder(__pyx_v_description, __pyx_v_name); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_v_desc = __pyx_t_6;
      __pyx_t_6 = 0;
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L20_try_end;
    __pyx_L13_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "MACS2/IO/cPeakIO.pyx":895
 *         except: peakprefix = name_prefix
 *         try: desc = description % name
 *         except: desc = description             # <<<<<<<<<<<<<<
 *         if trackline:
 *             fhd.write("track name=\"%s\" description=\"%s\" type=bed nextItemButton=on\n" % (name, desc) )
 */
    /*except:*/ {
      __Pyx_AddTraceback("MACS2.IO.cPeakIO.BroadPeakIO.write_to_gappedPeak", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_description);
      __Pyx_XDECREF(__pyx_v_desc);
      __pyx_v_desc = __pyx_v_description;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L14_exception_handled;
    }
    __pyx_L15_except_error:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L14_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    __pyx_L20_try_end:;
  }

  /* "MACS2/IO/cPeakIO.pyx":896
 *         try: desc = description % name
 *         except: desc = description
 *         if trackline:             # <<<<<<<<<<<<<<
 *             fhd.write("track name=\"%s\" description=\"%s\" type=bed nextItemButton=on\n" % (name, desc) )
 *         for chrom in chrs:
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_trackline); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_7) {

    /* "MACS2/IO/cPeakIO.pyx":897
 *         except: desc = description
 *         if trackline:
 *             fhd.write("track name=\"%s\" description=\"%s\" type=bed nextItemButton=on\n" % (name, desc) )             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             for peak in self.peaks[chrom]:
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_fhd, __pyx_n_s__write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_name);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_name);
    __Pyx_GIVEREF(__pyx_v_name);
    __Pyx_INCREF(__pyx_v_desc);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_desc);
    __Pyx_GIVEREF(__pyx_v_desc);
    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_6));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
    __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L23;
  }
  __pyx_L23:;

  /* "MACS2/IO/cPeakIO.pyx":898
 *         if trackline:
 *             fhd.write("track name=\"%s\" description=\"%s\" type=bed nextItemButton=on\n" % (name, desc) )
 *         for chrom in chrs:             # <<<<<<<<<<<<<<
 *             for peak in self.peaks[chrom]:
 *                 n_peak += 1
 */
  if (PyList_CheckExact(__pyx_v_chrs) || PyTuple_CheckExact(__pyx_v_chrs)) {
    __pyx_t_6 = __pyx_v_chrs; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_chrs); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_6)) {
      if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++;
    } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_6)) {
      if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++;
    } else {
      __pyx_t_1 = __pyx_t_9(__pyx_t_6);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_chrom);
    __pyx_v_chrom = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "MACS2/IO/cPeakIO.pyx":899
 *             fhd.write("track name=\"%s\" description=\"%s\" type=bed nextItemButton=on\n" % (name, desc) )
 *         for chrom in chrs:
 *             for peak in self.peaks[chrom]:             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 fhd.write( "%s\t%d\t%d\t%s%d\t%d\t.\t%d\t%d\t0\t%d\t%s\t%s\n"
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peaks); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_chrom); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = Py_TYPE(__pyx_t_1)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_1)) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++;
      } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_1)) {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++;
      } else {
        __pyx_t_2 = __pyx_t_11(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF(__pyx_v_peak);
      __pyx_v_peak = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "MACS2/IO/cPeakIO.pyx":900
 *         for chrom in chrs:
 *             for peak in self.peaks[chrom]:
 *                 n_peak += 1             # <<<<<<<<<<<<<<
 *                 fhd.write( "%s\t%d\t%d\t%s%d\t%d\t.\t%d\t%d\t0\t%d\t%s\t%s\n"
 *                            %
 */
      __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_n_peak, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_v_n_peak);
      __pyx_v_n_peak = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "MACS2/IO/cPeakIO.pyx":901
 *             for peak in self.peaks[chrom]:
 *                 n_peak += 1
 *                 fhd.write( "%s\t%d\t%d\t%s%d\t%d\t.\t%d\t%d\t0\t%d\t%s\t%s\n"             # <<<<<<<<<<<<<<
 *                            %
 *                            (chrom,peak["start"],peak["end"],peakprefix,n_peak,int(peak["score"]),
 */
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_fhd, __pyx_n_s__write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);

      /* "MACS2/IO/cPeakIO.pyx":903
 *                 fhd.write( "%s\t%d\t%d\t%s%d\t%d\t.\t%d\t%d\t0\t%d\t%s\t%s\n"
 *                            %
 *                            (chrom,peak["start"],peak["end"],peakprefix,n_peak,int(peak["score"]),             # <<<<<<<<<<<<<<
 *                             peak["thickStart"],peak["thickEnd"],
 *                             peak["blockNum"],peak["blockSizes"],peak["blockStarts"] ) )
 */
      __pyx_t_12 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__start)); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__end)); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__score)); if (!__pyx_t_14) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_14);
      __pyx_t_14 = 0;
      __pyx_t_14 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;

      /* "MACS2/IO/cPeakIO.pyx":904
 *                            %
 *                            (chrom,peak["start"],peak["end"],peakprefix,n_peak,int(peak["score"]),
 *                             peak["thickStart"],peak["thickEnd"],             # <<<<<<<<<<<<<<
 *                             peak["blockNum"],peak["blockSizes"],peak["blockStarts"] ) )
 * 
 */
      __pyx_t_15 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__thickStart)); if (!__pyx_t_15) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__thickEnd)); if (!__pyx_t_16) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);

      /* "MACS2/IO/cPeakIO.pyx":905
 *                            (chrom,peak["start"],peak["end"],peakprefix,n_peak,int(peak["score"]),
 *                             peak["thickStart"],peak["thickEnd"],
 *                             peak["blockNum"],peak["blockSizes"],peak["blockStarts"] ) )             # <<<<<<<<<<<<<<
 * 
 */
      __pyx_t_17 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__blockNum)); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_18 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__blockSizes)); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_19 = PyObject_GetItem(__pyx_v_peak, ((PyObject *)__pyx_n_s__blockStarts)); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_19);
      __pyx_t_20 = PyTuple_New(11); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_20);
      __Pyx_INCREF(__pyx_v_chrom);
      PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_chrom);
      __Pyx_GIVEREF(__pyx_v_chrom);
      PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_20, 2, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      __Pyx_INCREF(__pyx_v_peakprefix);
      PyTuple_SET_ITEM(__pyx_t_20, 3, __pyx_v_peakprefix);
      __Pyx_GIVEREF(__pyx_v_peakprefix);
      __Pyx_INCREF(__pyx_v_n_peak);
      PyTuple_SET_ITEM(__pyx_t_20, 4, __pyx_v_n_peak);
      __Pyx_GIVEREF(__pyx_v_n_peak);
      PyTuple_SET_ITEM(__pyx_t_20, 5, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_20, 6, __pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_20, 7, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_20, 8, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_20, 9, __pyx_t_18);
      __Pyx_GIVEREF(__pyx_t_18);
      PyTuple_SET_ITEM(__pyx_t_20, 10, __pyx_t_19);
      __Pyx_GIVEREF(__pyx_t_19);
      __pyx_t_12 = 0;
      __pyx_t_13 = 0;
      __pyx_t_14 = 0;
      __pyx_t_15 = 0;
      __pyx_t_16 = 0;
      __pyx_t_17 = 0;
      __pyx_t_18 = 0;
      __pyx_t_19 = 0;
      __pyx_t_19 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_47), ((PyObject *)__pyx_t_20)); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_19));
      __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
      __pyx_t_20 = PyTuple_New(1); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_20);
      PyTuple_SET_ITEM(__pyx_t_20, 0, ((PyObject *)__pyx_t_19));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_19));
      __pyx_t_19 = 0;
      __pyx_t_19 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_20), NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_19);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_AddTraceback("MACS2.IO.cPeakIO.BroadPeakIO.write_to_gappedPeak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrs);
  __Pyx_XDECREF(__pyx_v_n_peak);
  __Pyx_XDECREF(__pyx_v_peakprefix);
  __Pyx_XDECREF(__pyx_v_desc);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_peak);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

char* __pyx_import_star_type_names[] = {
  0
};

static int __pyx_import_star_set(PyObject *o, PyObject* py_name, char *name) {
  char** type_name = __pyx_import_star_type_names;
  while (*type_name) {
    if (__Pyx_StrEq(name, *type_name)) {
      PyErr_Format(PyExc_TypeError, "Cannot overwrite C type %s", name);
      goto bad;
    }
    type_name++;
  }
  if (0);
  else {
    if (PyObject_SetAttr(__pyx_m, py_name, o) < 0) goto bad;
  }
  return 0;
  bad:
  return -1;
}


/* import_all_from is an unexposed function from ceval.c */

static int
__Pyx_import_all_from(PyObject *locals, PyObject *v)
{
    PyObject *all = __Pyx_GetAttrString(v, "__all__");
    PyObject *dict, *name, *value;
    int skip_leading_underscores = 0;
    int pos, err;

    if (all == NULL) {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            return -1; /* Unexpected error */
        PyErr_Clear();
        dict = __Pyx_GetAttrString(v, "__dict__");
        if (dict == NULL) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError))
                return -1;
            PyErr_SetString(PyExc_ImportError,
            "from-import-* object has no __dict__ and no __all__");
            return -1;
        }
#if PY_MAJOR_VERSION < 3
        all = PyObject_CallMethod(dict, (char *)"keys", NULL);
#else
        all = PyMapping_Keys(dict);
#endif
        Py_DECREF(dict);
        if (all == NULL)
            return -1;
        skip_leading_underscores = 1;
    }

    for (pos = 0, err = 0; ; pos++) {
        name = PySequence_GetItem(all, pos);
        if (name == NULL) {
            if (!PyErr_ExceptionMatches(PyExc_IndexError))
                err = -1;
            else
                PyErr_Clear();
            break;
        }
        if (skip_leading_underscores &&
#if PY_MAJOR_VERSION < 3
            PyString_Check(name) &&
            PyString_AS_STRING(name)[0] == '_')
#else
            PyUnicode_Check(name) &&
            PyUnicode_AS_UNICODE(name)[0] == '_')
#endif
        {
            Py_DECREF(name);
            continue;
        }
        value = PyObject_GetAttr(v, name);
        if (value == NULL)
            err = -1;
        else if (PyDict_CheckExact(locals))
            err = PyDict_SetItem(locals, name, value);
        else
            err = PyObject_SetItem(locals, name, value);
        Py_DECREF(name);
        Py_XDECREF(value);
        if (err != 0)
            break;
    }
    Py_DECREF(all);
    return err;
}


static int __pyx_import_star(PyObject* m) {

    int i;
    int ret = -1;
    char* s;
    PyObject *locals = 0;
    PyObject *list = 0;
#if PY_MAJOR_VERSION >= 3
    PyObject *utf8_name = 0;
#endif
    PyObject *name;
    PyObject *item;

    locals = PyDict_New();              if (!locals) goto bad;
    if (__Pyx_import_all_from(locals, m) < 0) goto bad;
    list = PyDict_Items(locals);        if (!list) goto bad;

    for(i=0; i<PyList_GET_SIZE(list); i++) {
        name = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 0);
        item = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 1);
#if PY_MAJOR_VERSION >= 3
        utf8_name = PyUnicode_AsUTF8String(name);
        if (!utf8_name) goto bad;
        s = PyBytes_AS_STRING(utf8_name);
        if (__pyx_import_star_set(item, name, s) < 0) goto bad;
        Py_DECREF(utf8_name); utf8_name = 0;
#else
        s = PyString_AsString(name);
        if (!s) goto bad;
        if (__pyx_import_star_set(item, name, s) < 0) goto bad;
#endif
    }
    ret = 0;

bad:
    Py_XDECREF(locals);
    Py_XDECREF(list);
#if PY_MAJOR_VERSION >= 3
    Py_XDECREF(utf8_name);
#endif
    return ret;
}


#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("cPeakIO"),
    __Pyx_DOCSTR(__pyx_k_48), /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_100, __pyx_k_100, sizeof(__pyx_k_100), 0, 0, 1, 0},
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  {&__pyx_kp_s_128, __pyx_k_128, sizeof(__pyx_k_128), 0, 0, 1, 0},
  {&__pyx_kp_s_137, __pyx_k_137, sizeof(__pyx_k_137), 0, 0, 1, 0},
  {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
  {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
  {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
  {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
  {&__pyx_kp_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 0},
  {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
  {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
  {&__pyx_kp_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 0},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0},
  {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
  {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0},
  {&__pyx_n_s_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 1, 1},
  {&__pyx_kp_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0},
  {&__pyx_kp_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 0},
  {&__pyx_n_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 1},
  {&__pyx_n_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 1},
  {&__pyx_kp_s_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 0, 1, 0},
  {&__pyx_kp_s_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 0, 1, 0},
  {&__pyx_kp_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 0},
  {&__pyx_kp_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 0},
  {&__pyx_n_s_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 0, 1, 1},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
  {&__pyx_n_s_88, __pyx_k_88, sizeof(__pyx_k_88), 0, 0, 1, 1},
  {&__pyx_kp_s_89, __pyx_k_89, sizeof(__pyx_k_89), 0, 0, 1, 0},
  {&__pyx_n_s__BroadPeakIO, __pyx_k__BroadPeakIO, sizeof(__pyx_k__BroadPeakIO), 0, 0, 1, 1},
  {&__pyx_n_s__DiffPeakIO, __pyx_k__DiffPeakIO, sizeof(__pyx_k__DiffPeakIO), 0, 0, 1, 1},
  {&__pyx_n_s__MACS, __pyx_k__MACS, sizeof(__pyx_k__MACS), 0, 0, 1, 1},
  {&__pyx_n_s__PeakIO, __pyx_k__PeakIO, sizeof(__pyx_k__PeakIO), 0, 0, 1, 1},
  {&__pyx_n_s__Region, __pyx_k__Region, sizeof(__pyx_k__Region), 0, 0, 1, 1},
  {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
  {&__pyx_n_s____author__, __pyx_k____author__, sizeof(__pyx_k____author__), 0, 0, 1, 1},
  {&__pyx_n_s____doc__, __pyx_k____doc__, sizeof(__pyx_k____doc__), 0, 0, 1, 1},
  {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s____version__, __pyx_k____version__, sizeof(__pyx_k____version__), 0, 0, 1, 1},
  {&__pyx_n_s___to_bed, __pyx_k___to_bed, sizeof(__pyx_k___to_bed), 0, 0, 1, 1},
  {&__pyx_n_s___to_summits_bed, __pyx_k___to_summits_bed, sizeof(__pyx_k___to_summits_bed), 0, 0, 1, 1},
  {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1},
  {&__pyx_n_s__abs_summit, __pyx_k__abs_summit, sizeof(__pyx_k__abs_summit), 0, 0, 1, 1},
  {&__pyx_n_s__add, __pyx_k__add, sizeof(__pyx_k__add), 0, 0, 1, 1},
  {&__pyx_n_s__add_loc, __pyx_k__add_loc, sizeof(__pyx_k__add_loc), 0, 0, 1, 1},
  {&__pyx_n_s__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1},
  {&__pyx_n_s__blockNum, __pyx_k__blockNum, sizeof(__pyx_k__blockNum), 0, 0, 1, 1},
  {&__pyx_n_s__blockSizes, __pyx_k__blockSizes, sizeof(__pyx_k__blockSizes), 0, 0, 1, 1},
  {&__pyx_n_s__blockStarts, __pyx_k__blockStarts, sizeof(__pyx_k__blockStarts), 0, 0, 1, 1},
  {&__pyx_n_s__chr, __pyx_k__chr, sizeof(__pyx_k__chr), 0, 0, 1, 1},
  {&__pyx_n_s__chrom, __pyx_k__chrom, sizeof(__pyx_k__chrom), 0, 0, 1, 1},
  {&__pyx_n_s__chromosome, __pyx_k__chromosome, sizeof(__pyx_k__chromosome), 0, 0, 1, 1},
  {&__pyx_n_s__chrs, __pyx_k__chrs, sizeof(__pyx_k__chrs), 0, 0, 1, 1},
  {&__pyx_n_s__chrs1, __pyx_k__chrs1, sizeof(__pyx_k__chrs1), 0, 0, 1, 1},
  {&__pyx_n_s__chrs2, __pyx_k__chrs2, sizeof(__pyx_k__chrs2), 0, 0, 1, 1},
  {&__pyx_n_s__count, __pyx_k__count, sizeof(__pyx_k__count), 0, 0, 1, 1},
  {&__pyx_n_s__cover, __pyx_k__cover, sizeof(__pyx_k__cover), 0, 0, 1, 1},
  {&__pyx_n_s__desc, __pyx_k__desc, sizeof(__pyx_k__desc), 0, 0, 1, 1},
  {&__pyx_n_s__description, __pyx_k__description, sizeof(__pyx_k__description), 0, 0, 1, 1},
  {&__pyx_n_s__diff_score, __pyx_k__diff_score, sizeof(__pyx_k__diff_score), 0, 0, 1, 1},
  {&__pyx_n_s__e_new_region, __pyx_k__e_new_region, sizeof(__pyx_k__e_new_region), 0, 0, 1, 1},
  {&__pyx_n_s__end, __pyx_k__end, sizeof(__pyx_k__end), 0, 0, 1, 1},
  {&__pyx_n_s__enumerate, __pyx_k__enumerate, sizeof(__pyx_k__enumerate), 0, 0, 1, 1},
  {&__pyx_n_s__fc, __pyx_k__fc, sizeof(__pyx_k__fc), 0, 0, 1, 1},
  {&__pyx_n_s__fc_low, __pyx_k__fc_low, sizeof(__pyx_k__fc_low), 0, 0, 1, 1},
  {&__pyx_n_s__fc_up, __pyx_k__fc_up, sizeof(__pyx_k__fc_up), 0, 0, 1, 1},
  {&__pyx_n_s__fhd, __pyx_k__fhd, sizeof(__pyx_k__fhd), 0, 0, 1, 1},
  {&__pyx_n_s__filter_fc, __pyx_k__filter_fc, sizeof(__pyx_k__filter_fc), 0, 0, 1, 1},
  {&__pyx_n_s__filter_pscore, __pyx_k__filter_pscore, sizeof(__pyx_k__filter_pscore), 0, 0, 1, 1},
  {&__pyx_n_s__filter_qscore, __pyx_k__filter_qscore, sizeof(__pyx_k__filter_qscore), 0, 0, 1, 1},
  {&__pyx_n_s__fold_change, __pyx_k__fold_change, sizeof(__pyx_k__fold_change), 0, 0, 1, 1},
  {&__pyx_n_s__fold_enrichment, __pyx_k__fold_enrichment, sizeof(__pyx_k__fold_enrichment), 0, 0, 1, 1},
  {&__pyx_n_s__group, __pyx_k__group, sizeof(__pyx_k__group), 0, 0, 1, 1},
  {&__pyx_n_s__groupby, __pyx_k__groupby, sizeof(__pyx_k__groupby), 0, 0, 1, 1},
  {&__pyx_n_s__has_key, __pyx_k__has_key, sizeof(__pyx_k__has_key), 0, 0, 1, 1},
  {&__pyx_n_s__i, __pyx_k__i, sizeof(__pyx_k__i), 0, 0, 1, 1},
  {&__pyx_n_s__itemgetter, __pyx_k__itemgetter, sizeof(__pyx_k__itemgetter), 0, 0, 1, 1},
  {&__pyx_n_s__itertools, __pyx_k__itertools, sizeof(__pyx_k__itertools), 0, 0, 1, 1},
  {&__pyx_n_s__j, __pyx_k__j, sizeof(__pyx_k__j), 0, 0, 1, 1},
  {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
  {&__pyx_n_s__k, __pyx_k__k, sizeof(__pyx_k__k), 0, 0, 1, 1},
  {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1},
  {&__pyx_n_s__keys, __pyx_k__keys, sizeof(__pyx_k__keys), 0, 0, 1, 1},
  {&__pyx_n_s__length, __pyx_k__length, sizeof(__pyx_k__length), 0, 0, 1, 1},
  {&__pyx_n_s__merge_overlap, __pyx_k__merge_overlap, sizeof(__pyx_k__merge_overlap), 0, 0, 1, 1},
  {&__pyx_n_s__n_append, __pyx_k__n_append, sizeof(__pyx_k__n_append), 0, 0, 1, 1},
  {&__pyx_n_s__n_peak, __pyx_k__n_peak, sizeof(__pyx_k__n_peak), 0, 0, 1, 1},
  {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1},
  {&__pyx_n_s__name_prefix, __pyx_k__name_prefix, sizeof(__pyx_k__name_prefix), 0, 0, 1, 1},
  {&__pyx_n_s__new_peaks, __pyx_k__new_peaks, sizeof(__pyx_k__new_peaks), 0, 0, 1, 1},
  {&__pyx_n_s__new_regions, __pyx_k__new_regions, sizeof(__pyx_k__new_regions), 0, 0, 1, 1},
  {&__pyx_n_s__next, __pyx_k__next, sizeof(__pyx_k__next), 0, 0, 1, 1},
  {&__pyx_n_s__ofhd, __pyx_k__ofhd, sizeof(__pyx_k__ofhd), 0, 0, 1, 1},
  {&__pyx_n_s__operator, __pyx_k__operator, sizeof(__pyx_k__operator), 0, 0, 1, 1},
  {&__pyx_n_s__p, __pyx_k__p, sizeof(__pyx_k__p), 0, 0, 1, 1},
  {&__pyx_n_s__peak, __pyx_k__peak, sizeof(__pyx_k__peak), 0, 0, 1, 1},
  {&__pyx_n_s__peak_, __pyx_k__peak_, sizeof(__pyx_k__peak_), 0, 0, 1, 1},
  {&__pyx_n_s__peak_score, __pyx_k__peak_score, sizeof(__pyx_k__peak_score), 0, 0, 1, 1},
  {&__pyx_n_s__peakname, __pyx_k__peakname, sizeof(__pyx_k__peakname), 0, 0, 1, 1},
  {&__pyx_n_s__peakprefix, __pyx_k__peakprefix, sizeof(__pyx_k__peakprefix), 0, 0, 1, 1},
  {&__pyx_n_s__peaks, __pyx_k__peaks, sizeof(__pyx_k__peaks), 0, 0, 1, 1},
  {&__pyx_n_s__peaks1, __pyx_k__peaks1, sizeof(__pyx_k__peaks1), 0, 0, 1, 1},
  {&__pyx_n_s__peaks2, __pyx_k__peaks2, sizeof(__pyx_k__peaks2), 0, 0, 1, 1},
  {&__pyx_n_s__pileup, __pyx_k__pileup, sizeof(__pyx_k__pileup), 0, 0, 1, 1},
  {&__pyx_n_s__prev_region, __pyx_k__prev_region, sizeof(__pyx_k__prev_region), 0, 0, 1, 1},
  {&__pyx_n_s__print, __pyx_k__print, sizeof(__pyx_k__print), 0, 0, 1, 1},
  {&__pyx_n_s__print_func, __pyx_k__print_func, sizeof(__pyx_k__print_func), 0, 0, 1, 1},
  {&__pyx_n_s__pscore, __pyx_k__pscore, sizeof(__pyx_k__pscore), 0, 0, 1, 1},
  {&__pyx_n_s__pscore_cut, __pyx_k__pscore_cut, sizeof(__pyx_k__pscore_cut), 0, 0, 1, 1},
  {&__pyx_n_s__qscore, __pyx_k__qscore, sizeof(__pyx_k__qscore), 0, 0, 1, 1},
  {&__pyx_n_s__qscore_cut, __pyx_k__qscore_cut, sizeof(__pyx_k__qscore_cut), 0, 0, 1, 1},
  {&__pyx_n_s__r1, __pyx_k__r1, sizeof(__pyx_k__r1), 0, 0, 1, 1},
  {&__pyx_n_s__r2, __pyx_k__r2, sizeof(__pyx_k__r2), 0, 0, 1, 1},
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  {&__pyx_n_s__region, __pyx_k__region, sizeof(__pyx_k__region), 0, 0, 1, 1},
  {&__pyx_n_s__regions, __pyx_k__regions, sizeof(__pyx_k__regions), 0, 0, 1, 1},
  {&__pyx_n_s__regions_chr, __pyx_k__regions_chr, sizeof(__pyx_k__regions_chr), 0, 0, 1, 1},
  {&__pyx_n_s__replace, __pyx_k__replace, sizeof(__pyx_k__replace), 0, 0, 1, 1},
  {&__pyx_n_s__rl1_k, __pyx_k__rl1_k, sizeof(__pyx_k__rl1_k), 0, 0, 1, 1},
  {&__pyx_n_s__rl2_k, __pyx_k__rl2_k, sizeof(__pyx_k__rl2_k), 0, 0, 1, 1},
  {&__pyx_n_s__s_new_region, __pyx_k__s_new_region, sizeof(__pyx_k__s_new_region), 0, 0, 1, 1},
  {&__pyx_n_s__score, __pyx_k__score, sizeof(__pyx_k__score), 0, 0, 1, 1},
  {&__pyx_n_s__score_column, __pyx_k__score_column, sizeof(__pyx_k__score_column), 0, 0, 1, 1},
  {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
  {&__pyx_n_s__sort, __pyx_k__sort, sizeof(__pyx_k__sort), 0, 0, 1, 1},
  {&__pyx_n_s__sorted, __pyx_k__sorted, sizeof(__pyx_k__sorted), 0, 0, 1, 1},
  {&__pyx_n_s__start, __pyx_k__start, sizeof(__pyx_k__start), 0, 0, 1, 1},
  {&__pyx_n_s__summit, __pyx_k__summit, sizeof(__pyx_k__summit), 0, 0, 1, 1},
  {&__pyx_n_s__summit_p, __pyx_k__summit_p, sizeof(__pyx_k__summit_p), 0, 0, 1, 1},
  {&__pyx_n_s__these_peaks, __pyx_k__these_peaks, sizeof(__pyx_k__these_peaks), 0, 0, 1, 1},
  {&__pyx_n_s__thickEnd, __pyx_k__thickEnd, sizeof(__pyx_k__thickEnd), 0, 0, 1, 1},
  {&__pyx_n_s__thickStart, __pyx_k__thickStart, sizeof(__pyx_k__thickStart), 0, 0, 1, 1},
  {&__pyx_n_s__tmp_n, __pyx_k__tmp_n, sizeof(__pyx_k__tmp_n), 0, 0, 1, 1},
  {&__pyx_n_s__to_summits_bed, __pyx_k__to_summits_bed, sizeof(__pyx_k__to_summits_bed), 0, 0, 1, 1},
  {&__pyx_n_s__tobed, __pyx_k__tobed, sizeof(__pyx_k__tobed), 0, 0, 1, 1},
  {&__pyx_n_s__total, __pyx_k__total, sizeof(__pyx_k__total), 0, 0, 1, 1},
  {&__pyx_n_s__total_num, __pyx_k__total_num, sizeof(__pyx_k__total_num), 0, 0, 1, 1},
  {&__pyx_n_s__trackcontents, __pyx_k__trackcontents, sizeof(__pyx_k__trackcontents), 0, 0, 1, 1},
  {&__pyx_n_s__trackline, __pyx_k__trackline, sizeof(__pyx_k__trackline), 0, 0, 1, 1},
  {&__pyx_n_s__write, __pyx_k__write, sizeof(__pyx_k__write), 0, 0, 1, 1},
  {&__pyx_n_s__write_to_bed, __pyx_k__write_to_bed, sizeof(__pyx_k__write_to_bed), 0, 0, 1, 1},
  {&__pyx_n_s__write_to_gappedPeak, __pyx_k__write_to_gappedPeak, sizeof(__pyx_k__write_to_gappedPeak), 0, 0, 1, 1},
  {&__pyx_n_s__write_to_narrowPeak, __pyx_k__write_to_narrowPeak, sizeof(__pyx_k__write_to_narrowPeak), 0, 0, 1, 1},
  {&__pyx_n_s__write_to_summit_bed, __pyx_k__write_to_summit_bed, sizeof(__pyx_k__write_to_summit_bed), 0, 0, 1, 1},
  {&__pyx_n_s__write_to_xls, __pyx_k__write_to_xls, sizeof(__pyx_k__write_to_xls), 0, 0, 1, 1},
  {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_print = __Pyx_GetName(__pyx_b, __pyx_n_s__print); if (!__pyx_builtin_print) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_chr = __Pyx_GetName(__pyx_b, __pyx_n_s__chr); if (!__pyx_builtin_chr) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_sorted = __Pyx_GetName(__pyx_b, __pyx_n_s__sorted); if (!__pyx_builtin_sorted) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "MACS2/IO/cPeakIO.pyx":143
 *         try: desc = description % name
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))             # <<<<<<<<<<<<<<
 *         if trackline:
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)
 */
  __pyx_k_tuple_5 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_5);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
  PyTuple_SET_ITEM(__pyx_k_tuple_5, 1, ((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5));
  __pyx_k_tuple_6 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_6);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
  PyTuple_SET_ITEM(__pyx_k_tuple_6, 1, ((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6));

  /* "MACS2/IO/cPeakIO.pyx":146
 *         if trackline:
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 */
  __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_9);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
  PyTuple_SET_ITEM(__pyx_k_tuple_9, 0, ((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9));

  /* "MACS2/IO/cPeakIO.pyx":148
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 peaks = list(group)
 */
  __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_10);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10));

  /* "MACS2/IO/cPeakIO.pyx":171
 *         try: desc = description % name
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))             # <<<<<<<<<<<<<<
 *         if trackline:
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)
 */
  __pyx_k_tuple_13 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_13);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
  PyTuple_SET_ITEM(__pyx_k_tuple_13, 1, ((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13));
  __pyx_k_tuple_14 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_14);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
  PyTuple_SET_ITEM(__pyx_k_tuple_14, 1, ((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14));

  /* "MACS2/IO/cPeakIO.pyx":174
 *         if trackline:
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 */
  __pyx_k_tuple_16 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_16);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
  PyTuple_SET_ITEM(__pyx_k_tuple_16, 0, ((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_16));

  /* "MACS2/IO/cPeakIO.pyx":176
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 peaks = list(group)
 */
  __pyx_k_tuple_17 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_17);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17));

  /* "MACS2/IO/cPeakIO.pyx":346
 *         """
 *         write = ofhd.write
 *         write("\t".join(("chr","start", "end",  "length",  "abs_summit", "pileup", "-log10(pvalue)", "fold_enrichment", "-log10(qvalue)", "name"))+"\n")             # <<<<<<<<<<<<<<
 * 
 *         try: peakprefix = name_prefix % name
 */
  __pyx_k_tuple_23 = PyTuple_New(10); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_23);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chr));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 0, ((PyObject *)__pyx_n_s__chr));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chr));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__start));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 1, ((PyObject *)__pyx_n_s__start));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__start));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 2, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__length));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 3, ((PyObject *)__pyx_n_s__length));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__length));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__abs_summit));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 4, ((PyObject *)__pyx_n_s__abs_summit));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__abs_summit));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pileup));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 5, ((PyObject *)__pyx_n_s__pileup));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pileup));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_21));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 6, ((PyObject *)__pyx_kp_s_21));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_21));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fold_enrichment));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 7, ((PyObject *)__pyx_n_s__fold_enrichment));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fold_enrichment));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_22));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 8, ((PyObject *)__pyx_kp_s_22));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_22));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 9, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23));
  __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_24);
  __Pyx_INCREF(((PyObject *)__pyx_k_tuple_23));
  PyTuple_SET_ITEM(__pyx_k_tuple_24, 0, ((PyObject *)__pyx_k_tuple_23));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_24));

  /* "MACS2/IO/cPeakIO.pyx":356
 *         n_peak = 0
 *         for chrom in chrs:
 *             for end, group in groupby(peaks[chrom], key=itemgetter("end")):             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 these_peaks = list(group)
 */
  __pyx_k_tuple_26 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_26);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_26, 0, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26));

  /* "MACS2/IO/cPeakIO.pyx":370
 *                         write("\t%.2f" % (peak["qscore"])) # -log10qvalue at summit
 *                         write("\t%s" % peakname)
 *                         write("\n")             # <<<<<<<<<<<<<<
 *                 else:
 *                     peak = these_peaks[0]
 */
  __pyx_k_tuple_32 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_32);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_25));
  PyTuple_SET_ITEM(__pyx_k_tuple_32, 0, ((PyObject *)__pyx_kp_s_25));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_25));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_32));

  /* "MACS2/IO/cPeakIO.pyx":382
 *                     write("\t%.2f" % (peak["qscore"])) # -log10qvalue at summit
 *                     write("\t%s" % peakname)
 *                     write("\n")             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  __pyx_k_tuple_34 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_34);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_25));
  PyTuple_SET_ITEM(__pyx_k_tuple_34, 0, ((PyObject *)__pyx_kp_s_25));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_25));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_34));

  /* "MACS2/IO/cPeakIO.pyx":590
 *         try: desc = description % name
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))             # <<<<<<<<<<<<<<
 *         if trackline:
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)
 */
  __pyx_k_tuple_37 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_37);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_37, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
  PyTuple_SET_ITEM(__pyx_k_tuple_37, 1, ((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_37));
  __pyx_k_tuple_38 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_38);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_38, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
  PyTuple_SET_ITEM(__pyx_k_tuple_38, 1, ((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_38));

  /* "MACS2/IO/cPeakIO.pyx":593
 *         if trackline:
 *             try: print_func('track name="%s (peaks)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 */
  __pyx_k_tuple_39 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_39);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
  PyTuple_SET_ITEM(__pyx_k_tuple_39, 0, ((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_39));

  /* "MACS2/IO/cPeakIO.pyx":595
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 peaks = list(group)
 */
  __pyx_k_tuple_40 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_40);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_40, 0, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_40));

  /* "MACS2/IO/cPeakIO.pyx":618
 *         try: desc = description % name
 *         except: desc = description
 *         trackcontents = (name.replace("\"", "\\\""), desc.replace("\"", "\\\""))             # <<<<<<<<<<<<<<
 *         if trackline:
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)
 */
  __pyx_k_tuple_41 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_41);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_41, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
  PyTuple_SET_ITEM(__pyx_k_tuple_41, 1, ((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41));
  __pyx_k_tuple_42 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_42);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_42, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
  PyTuple_SET_ITEM(__pyx_k_tuple_42, 1, ((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_42));

  /* "MACS2/IO/cPeakIO.pyx":621
 *         if trackline:
 *             try: print_func('track name="%s (summits)" description="%s" visibility=1\n' % trackcontents)
 *             except: print_func('track name=MACS description=Unknown')             # <<<<<<<<<<<<<<
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):
 */
  __pyx_k_tuple_43 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_43);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
  PyTuple_SET_ITEM(__pyx_k_tuple_43, 0, ((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43));

  /* "MACS2/IO/cPeakIO.pyx":623
 *             except: print_func('track name=MACS description=Unknown')
 *         for chrom in chrs:
 *             for end, group in groupby(self.peaks[chrom], key=itemgetter("end")):             # <<<<<<<<<<<<<<
 *                 n_peak += 1
 *                 peaks = list(group)
 */
  __pyx_k_tuple_44 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_44);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_44, 0, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_44));

  /* "MACS2/IO/cPeakIO.pyx":52
 *     """
 * 
 *     def __init__ (self):             # <<<<<<<<<<<<<<
 *         self.peaks = {}
 * 
 */
  __pyx_k_tuple_54 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_54);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_54, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_54));
  __pyx_k_codeobj_55 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_54, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s____init__, 52, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":55
 *         self.peaks = {}
 * 
 *     def add (self, str chromosome, long start, long end, long summit = 0,             # <<<<<<<<<<<<<<
 *              double peak_score=0, int pileup=0,
 *              double pscore=0, double fold_change=0, double qscore=0):
 */
  __pyx_k_tuple_58 = PyTuple_New(10); if (unlikely(!__pyx_k_tuple_58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_58);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_58, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chromosome));
  PyTuple_SET_ITEM(__pyx_k_tuple_58, 1, ((PyObject *)__pyx_n_s__chromosome));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chromosome));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__start));
  PyTuple_SET_ITEM(__pyx_k_tuple_58, 2, ((PyObject *)__pyx_n_s__start));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__start));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_58, 3, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__summit));
  PyTuple_SET_ITEM(__pyx_k_tuple_58, 4, ((PyObject *)__pyx_n_s__summit));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__summit));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peak_score));
  PyTuple_SET_ITEM(__pyx_k_tuple_58, 5, ((PyObject *)__pyx_n_s__peak_score));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peak_score));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pileup));
  PyTuple_SET_ITEM(__pyx_k_tuple_58, 6, ((PyObject *)__pyx_n_s__pileup));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pileup));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pscore));
  PyTuple_SET_ITEM(__pyx_k_tuple_58, 7, ((PyObject *)__pyx_n_s__pscore));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pscore));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fold_change));
  PyTuple_SET_ITEM(__pyx_k_tuple_58, 8, ((PyObject *)__pyx_n_s__fold_change));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fold_change));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__qscore));
  PyTuple_SET_ITEM(__pyx_k_tuple_58, 9, ((PyObject *)__pyx_n_s__qscore));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qscore));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_58));
  __pyx_k_codeobj_59 = (PyObject*)__Pyx_PyCode_New(10, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_58, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__add, 55, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":81
 *                                        "qscore":qscore})
 * 
 *     def filter_pscore (self, double pscore_cut ):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 * 
 */
  __pyx_k_tuple_60 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_60);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pscore_cut));
  PyTuple_SET_ITEM(__pyx_k_tuple_60, 1, ((PyObject *)__pyx_n_s__pscore_cut));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pscore_cut));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_60, 2, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_60, 3, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__new_peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_60, 4, ((PyObject *)__pyx_n_s__new_peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__new_peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_60, 5, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__p));
  PyTuple_SET_ITEM(__pyx_k_tuple_60, 6, ((PyObject *)__pyx_n_s__p));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__p));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60));
  __pyx_k_codeobj_61 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__filter_pscore, 81, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":92
 *         self.peaks = new_peaks
 * 
 *     def filter_qscore (self, double qscore_cut ):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 * 
 */
  __pyx_k_tuple_62 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_62);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_62, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__qscore_cut));
  PyTuple_SET_ITEM(__pyx_k_tuple_62, 1, ((PyObject *)__pyx_n_s__qscore_cut));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qscore_cut));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_62, 2, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_62, 3, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__new_peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_62, 4, ((PyObject *)__pyx_n_s__new_peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__new_peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_62, 5, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__p));
  PyTuple_SET_ITEM(__pyx_k_tuple_62, 6, ((PyObject *)__pyx_n_s__p));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__p));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_62));
  __pyx_k_codeobj_63 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__filter_qscore, 92, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":103
 *         self.peaks = new_peaks
 * 
 *     def filter_fc (self, fc_low, fc_up=None ):             # <<<<<<<<<<<<<<
 *         """Filter peaks in a given fc range.
 * 
 */
  __pyx_k_tuple_64 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_64);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_64, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fc_low));
  PyTuple_SET_ITEM(__pyx_k_tuple_64, 1, ((PyObject *)__pyx_n_s__fc_low));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fc_low));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fc_up));
  PyTuple_SET_ITEM(__pyx_k_tuple_64, 2, ((PyObject *)__pyx_n_s__fc_up));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fc_up));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_64, 3, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__new_peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_64, 4, ((PyObject *)__pyx_n_s__new_peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__new_peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_64, 5, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_64, 6, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__p));
  PyTuple_SET_ITEM(__pyx_k_tuple_64, 7, ((PyObject *)__pyx_n_s__p));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__p));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_64));
  __pyx_k_codeobj_65 = (PyObject*)__Pyx_PyCode_New(3, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__filter_fc, 103, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_tuple_66 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_66);
  __Pyx_INCREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_k_tuple_66, 0, ((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_66));

  /* "MACS2/IO/cPeakIO.pyx":121
 *         self.peaks = new_peaks
 * 
 *     def total (self):             # <<<<<<<<<<<<<<
 *         peaks = self.peaks
 *         chrs = peaks.keys()
 */
  __pyx_k_tuple_67 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_67);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_67, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_67, 1, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_67, 2, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__x));
  PyTuple_SET_ITEM(__pyx_k_tuple_67, 3, ((PyObject *)__pyx_n_s__x));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__x));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_67, 4, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_67));
  __pyx_k_codeobj_68 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__total, 121, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":130
 *         return x
 * 
 *     def _to_bed(self, name_prefix="%s_peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                 description="%s", score_column="score",
 *                 print_func=print, trackline=False):
 */
  __pyx_k_tuple_69 = PyTuple_New(18); if (unlikely(!__pyx_k_tuple_69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_69);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name_prefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 1, ((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 2, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__description));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 3, ((PyObject *)__pyx_n_s__description));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__description));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__score_column));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 4, ((PyObject *)__pyx_n_s__score_column));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__score_column));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__print_func));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 5, ((PyObject *)__pyx_n_s__print_func));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__print_func));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackline));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 6, ((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackline));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 7, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__n_peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 8, ((PyObject *)__pyx_n_s__n_peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_peak));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peakprefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 9, ((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__desc));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 10, ((PyObject *)__pyx_n_s__desc));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__desc));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackcontents));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 11, ((PyObject *)__pyx_n_s__trackcontents));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackcontents));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 12, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 13, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__group));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 14, ((PyObject *)__pyx_n_s__group));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__group));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 15, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 16, ((PyObject *)__pyx_n_s__i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_69, 17, ((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_69));
  __pyx_k_codeobj_70 = (PyObject*)__Pyx_PyCode_New(7, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s___to_bed, 130, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":158
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,peak[score_column]))
 * 
 *     def _to_summits_bed(self, name_prefix="%s_peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                         description = "%s", score_column="score",
 *                         print_func=print, trackline=False):
 */
  __pyx_k_tuple_71 = PyTuple_New(19); if (unlikely(!__pyx_k_tuple_71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_71);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name_prefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 1, ((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 2, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__description));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 3, ((PyObject *)__pyx_n_s__description));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__description));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__score_column));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 4, ((PyObject *)__pyx_n_s__score_column));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__score_column));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__print_func));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 5, ((PyObject *)__pyx_n_s__print_func));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__print_func));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackline));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 6, ((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackline));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 7, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__n_peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 8, ((PyObject *)__pyx_n_s__n_peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_peak));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peakprefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 9, ((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__desc));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 10, ((PyObject *)__pyx_n_s__desc));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__desc));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackcontents));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 11, ((PyObject *)__pyx_n_s__trackcontents));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackcontents));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 12, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 13, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__group));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 14, ((PyObject *)__pyx_n_s__group));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__group));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 15, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 16, ((PyObject *)__pyx_n_s__i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 17, ((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peak));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__summit_p));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 18, ((PyObject *)__pyx_n_s__summit_p));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__summit_p));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_71));
  __pyx_k_codeobj_72 = (PyObject*)__Pyx_PyCode_New(7, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s___to_summits_bed, 158, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":188
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,summit_p,summit_p+1,peakprefix,n_peak,peak[score_column]))
 * 
 *     def tobed (self):             # <<<<<<<<<<<<<<
 *         """Print out peaks in BED5 format.
 * 
 */
  __pyx_k_tuple_73 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_73);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_73, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_73));
  __pyx_k_codeobj_74 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__tobed, 188, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_74)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":205
 *         return self._to_bed(name_prefix="peak_", score_column="score")
 * 
 *     def to_summits_bed (self):             # <<<<<<<<<<<<<<
 *         """Print out peak summits in BED5 format.
 * 
 */
  __pyx_k_tuple_75 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_75);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_75, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_75));
  __pyx_k_codeobj_76 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__to_summits_bed, 205, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":214
 * 
 *     # these methods are very fast, specifying types is unnecessary
 *     def write_to_bed (self, fhd, str name_prefix="peak_", str name="MACS",             # <<<<<<<<<<<<<<
 *                         str description = "%s", str score_column="score", trackline=True):
 *         """Write peaks in BED5 format in a file handler. Score (5th
 */
  __pyx_k_tuple_77 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_77);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_77, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fhd));
  PyTuple_SET_ITEM(__pyx_k_tuple_77, 1, ((PyObject *)__pyx_n_s__fhd));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fhd));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name_prefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_77, 2, ((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_77, 3, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__description));
  PyTuple_SET_ITEM(__pyx_k_tuple_77, 4, ((PyObject *)__pyx_n_s__description));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__description));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__score_column));
  PyTuple_SET_ITEM(__pyx_k_tuple_77, 5, ((PyObject *)__pyx_n_s__score_column));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__score_column));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackline));
  PyTuple_SET_ITEM(__pyx_k_tuple_77, 6, ((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_77));
  __pyx_k_codeobj_78 = (PyObject*)__Pyx_PyCode_New(7, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__write_to_bed, 214, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":240
 *                             print_func=fhd.write, trackline=trackline)
 * 
 *     def write_to_summit_bed (self, fhd, name_prefix="peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                              description = "%s", score_column="score", trackline=True):
 *         """Write peak summits in BED5 format in a file handler. Score
 */
  __pyx_k_tuple_79 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_79);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_79, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fhd));
  PyTuple_SET_ITEM(__pyx_k_tuple_79, 1, ((PyObject *)__pyx_n_s__fhd));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fhd));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name_prefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_79, 2, ((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_79, 3, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__description));
  PyTuple_SET_ITEM(__pyx_k_tuple_79, 4, ((PyObject *)__pyx_n_s__description));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__description));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__score_column));
  PyTuple_SET_ITEM(__pyx_k_tuple_79, 5, ((PyObject *)__pyx_n_s__score_column));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__score_column));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackline));
  PyTuple_SET_ITEM(__pyx_k_tuple_79, 6, ((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_79));
  __pyx_k_codeobj_80 = (PyObject*)__Pyx_PyCode_New(7, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__write_to_summit_bed, 240, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":265
 *                                     print_func=fhd.write, trackline=trackline)
 * 
 *     def write_to_narrowPeak (self, fhd, name_prefix="peak_", name="peak", score_column="score", trackline=True):             # <<<<<<<<<<<<<<
 *         """Print out peaks in narrowPeak format.
 * 
 */
  __pyx_k_tuple_81 = PyTuple_New(11); if (unlikely(!__pyx_k_tuple_81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_81);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_81, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fhd));
  PyTuple_SET_ITEM(__pyx_k_tuple_81, 1, ((PyObject *)__pyx_n_s__fhd));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fhd));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name_prefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_81, 2, ((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_81, 3, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__score_column));
  PyTuple_SET_ITEM(__pyx_k_tuple_81, 4, ((PyObject *)__pyx_n_s__score_column));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__score_column));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackline));
  PyTuple_SET_ITEM(__pyx_k_tuple_81, 5, ((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackline));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__n_peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_81, 6, ((PyObject *)__pyx_n_s__n_peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_peak));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_81, 7, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_81, 8, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peakprefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_81, 9, ((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_81, 10, ((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_81));
  __pyx_k_codeobj_82 = (PyObject*)__Pyx_PyCode_New(6, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__write_to_narrowPeak, 265, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":340
 *                             peak["fc"],peak["pscore"],peak["qscore"],peak["summit"]-peak["start"]) )
 * 
 *     def write_to_xls (self, ofhd, name_prefix="%s_peak_", name="MACS"):             # <<<<<<<<<<<<<<
 *         """Save the peak results in a tab-delimited plain text file
 *         with suffix .xls.
 */
  __pyx_k_tuple_83 = PyTuple_New(16); if (unlikely(!__pyx_k_tuple_83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_83);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__ofhd));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 1, ((PyObject *)__pyx_n_s__ofhd));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ofhd));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name_prefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 2, ((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 3, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__write));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 4, ((PyObject *)__pyx_n_s__write));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__write));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peakprefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 5, ((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 6, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 7, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__n_peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 8, ((PyObject *)__pyx_n_s__n_peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_peak));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 9, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 10, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__group));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 11, ((PyObject *)__pyx_n_s__group));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__group));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__these_peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 12, ((PyObject *)__pyx_n_s__these_peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__these_peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 13, ((PyObject *)__pyx_n_s__i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 14, ((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peak));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peakname));
  PyTuple_SET_ITEM(__pyx_k_tuple_83, 15, ((PyObject *)__pyx_n_s__peakname));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peakname));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_83));
  __pyx_k_codeobj_84 = (PyObject*)__Pyx_PyCode_New(4, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_83, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__write_to_xls, 340, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_tuple_85 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_85);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_kp_s_1)));
  PyTuple_SET_ITEM(__pyx_k_tuple_85, 0, ((PyObject *)((PyObject*)__pyx_kp_s_1)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_kp_s_1)));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  PyTuple_SET_ITEM(__pyx_k_tuple_85, 1, ((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_n_s__MACS)));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_85));

  /* "MACS2/IO/cPeakIO.pyx":386
 * 
 * 
 *     def overlap_with_other_peaks (self, peaks2, double cover=0):             # <<<<<<<<<<<<<<
 *         """Peaks2 is a PeakIO object or dictionary with can be
 *         initialzed as a PeakIO. check __init__ for PeakIO for detail.
 */
  __pyx_k_tuple_86 = PyTuple_New(14); if (unlikely(!__pyx_k_tuple_86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_86);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks2));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 1, ((PyObject *)__pyx_n_s__peaks2));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__cover));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 2, ((PyObject *)__pyx_n_s__cover));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__cover));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__total_num));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 3, ((PyObject *)__pyx_n_s__total_num));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__total_num));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs1));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 4, ((PyObject *)__pyx_n_s__chrs1));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs2));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 5, ((PyObject *)__pyx_n_s__chrs2));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__a));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 6, ((PyObject *)__pyx_n_s__a));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__a));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__k));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 7, ((PyObject *)__pyx_n_s__k));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__k));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks1));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 8, ((PyObject *)__pyx_n_s__peaks1));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__rl1_k));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 9, ((PyObject *)__pyx_n_s__rl1_k));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rl1_k));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__rl2_k));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 10, ((PyObject *)__pyx_n_s__rl2_k));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rl2_k));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__tmp_n));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 11, ((PyObject *)__pyx_n_s__tmp_n));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tmp_n));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__r1));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 12, ((PyObject *)__pyx_n_s__r1));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__r2));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 13, ((PyObject *)__pyx_n_s__r2));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r2));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_86));
  __pyx_k_codeobj_87 = (PyObject*)__Pyx_PyCode_New(3, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_86, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s_88, 386, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":431
 *     """For plain region of chrom, start and end
 *     """
 *     def __init__ (self):             # <<<<<<<<<<<<<<
 *         self.regions= {}
 *         self.__flag_sorted = False
 */
  __pyx_k_tuple_90 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_90);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_90, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_90));
  __pyx_k_codeobj_91 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_90, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s____init__, 431, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":435
 *         self.__flag_sorted = False
 * 
 *     def add_loc ( self, str chrom, int start, int end ):             # <<<<<<<<<<<<<<
 *         if self.regions.has_key(chrom):
 *             self.regions[chrom].append( (start,end) )
 */
  __pyx_k_tuple_92 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_92)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_92);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_92, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_92, 1, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__start));
  PyTuple_SET_ITEM(__pyx_k_tuple_92, 2, ((PyObject *)__pyx_n_s__start));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__start));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_92, 3, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_92));
  __pyx_k_codeobj_93 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_92, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__add_loc, 435, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_93)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":443
 *         return
 * 
 *     def sort (self):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 * 
 */
  __pyx_k_tuple_94 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_94)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_94);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_94, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_94, 1, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_94));
  __pyx_k_codeobj_95 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_94, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__sort, 443, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":450
 *         self.__flag_sorted = True
 * 
 *     def merge_overlap ( self ):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 *         cdef int s_new_region, e_new_region, i, j
 */
  __pyx_k_tuple_96 = PyTuple_New(12); if (unlikely(!__pyx_k_tuple_96)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_96);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 1, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__s_new_region));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 2, ((PyObject *)__pyx_n_s__s_new_region));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__s_new_region));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__e_new_region));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 3, ((PyObject *)__pyx_n_s__e_new_region));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__e_new_region));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 4, ((PyObject *)__pyx_n_s__i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__j));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 5, ((PyObject *)__pyx_n_s__j));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__j));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__regions));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 6, ((PyObject *)__pyx_n_s__regions));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__regions));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__new_regions));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 7, ((PyObject *)__pyx_n_s__new_regions));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__new_regions));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 8, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__n_append));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 9, ((PyObject *)__pyx_n_s__n_append));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_append));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__prev_region));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 10, ((PyObject *)__pyx_n_s__prev_region));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__prev_region));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__regions_chr));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 11, ((PyObject *)__pyx_n_s__regions_chr));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__regions_chr));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_96));
  __pyx_k_codeobj_97 = (PyObject*)__Pyx_PyCode_New(1, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_96, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__merge_overlap, 450, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_97)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":485
 *         return True
 * 
 *     def write_to_bed (self, fhd ):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef str chrom
 */
  __pyx_k_tuple_98 = PyTuple_New(6); if (unlikely(!__pyx_k_tuple_98)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_98);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_98, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fhd));
  PyTuple_SET_ITEM(__pyx_k_tuple_98, 1, ((PyObject *)__pyx_n_s__fhd));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fhd));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
  PyTuple_SET_ITEM(__pyx_k_tuple_98, 2, ((PyObject *)__pyx_n_s__i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_98, 3, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_98, 4, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__region));
  PyTuple_SET_ITEM(__pyx_k_tuple_98, 5, ((PyObject *)__pyx_n_s__region));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__region));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_98));
  __pyx_k_codeobj_99 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_98, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__write_to_bed, 485, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_99)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":503
 *     """
 * 
 *     def __init__ (self):             # <<<<<<<<<<<<<<
 *         self.peaks = {}
 * 
 */
  __pyx_k_tuple_101 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_101)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_101);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_101, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_101));
  __pyx_k_codeobj_102 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_101, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s____init__, 503, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_102)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":506
 *         self.peaks = {}
 * 
 *     def add (self, str chromosome, long start, long end, long summit = 0,             # <<<<<<<<<<<<<<
 *              double diff_score=0, int pileup=0,
 *              double pscore=0, double fold_change=0, double qscore=0):
 */
  __pyx_k_tuple_103 = PyTuple_New(10); if (unlikely(!__pyx_k_tuple_103)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_103);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_103, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chromosome));
  PyTuple_SET_ITEM(__pyx_k_tuple_103, 1, ((PyObject *)__pyx_n_s__chromosome));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chromosome));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__start));
  PyTuple_SET_ITEM(__pyx_k_tuple_103, 2, ((PyObject *)__pyx_n_s__start));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__start));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_103, 3, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__summit));
  PyTuple_SET_ITEM(__pyx_k_tuple_103, 4, ((PyObject *)__pyx_n_s__summit));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__summit));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__diff_score));
  PyTuple_SET_ITEM(__pyx_k_tuple_103, 5, ((PyObject *)__pyx_n_s__diff_score));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__diff_score));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pileup));
  PyTuple_SET_ITEM(__pyx_k_tuple_103, 6, ((PyObject *)__pyx_n_s__pileup));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pileup));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pscore));
  PyTuple_SET_ITEM(__pyx_k_tuple_103, 7, ((PyObject *)__pyx_n_s__pscore));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pscore));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fold_change));
  PyTuple_SET_ITEM(__pyx_k_tuple_103, 8, ((PyObject *)__pyx_n_s__fold_change));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fold_change));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__qscore));
  PyTuple_SET_ITEM(__pyx_k_tuple_103, 9, ((PyObject *)__pyx_n_s__qscore));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qscore));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_103));
  __pyx_k_codeobj_104 = (PyObject*)__Pyx_PyCode_New(10, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_103, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__add, 506, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_104)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":532
 *                                        "qscore":qscore})
 * 
 *     def filter_pscore (self, double pscore_cut ):             # <<<<<<<<<<<<<<
 *         peaks = self.peaks
 *         new_peaks = {}
 */
  __pyx_k_tuple_105 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_105)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_105);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_105, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pscore_cut));
  PyTuple_SET_ITEM(__pyx_k_tuple_105, 1, ((PyObject *)__pyx_n_s__pscore_cut));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pscore_cut));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_105, 2, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__new_peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_105, 3, ((PyObject *)__pyx_n_s__new_peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__new_peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_105, 4, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_105, 5, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__p));
  PyTuple_SET_ITEM(__pyx_k_tuple_105, 6, ((PyObject *)__pyx_n_s__p));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__p));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_105));
  __pyx_k_codeobj_106 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_105, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__filter_pscore, 532, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_106)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":541
 *         self.peaks = new_peaks
 * 
 *     def filter_qscore (self, double qscore_cut ):             # <<<<<<<<<<<<<<
 *         peaks = self.peaks
 *         new_peaks = {}
 */
  __pyx_k_tuple_107 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_107)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_107);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_107, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__qscore_cut));
  PyTuple_SET_ITEM(__pyx_k_tuple_107, 1, ((PyObject *)__pyx_n_s__qscore_cut));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qscore_cut));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_107, 2, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__new_peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_107, 3, ((PyObject *)__pyx_n_s__new_peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__new_peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_107, 4, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_107, 5, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__p));
  PyTuple_SET_ITEM(__pyx_k_tuple_107, 6, ((PyObject *)__pyx_n_s__p));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__p));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_107));
  __pyx_k_codeobj_108 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_107, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__filter_qscore, 541, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_108)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":550
 *         self.peaks = new_peaks
 * 
 *     def filter_fc (self, fc_low, fc_up=None ):             # <<<<<<<<<<<<<<
 *         """Filter peaks in a given fc range.
 * 
 */
  __pyx_k_tuple_109 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_109)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_109);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_109, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fc_low));
  PyTuple_SET_ITEM(__pyx_k_tuple_109, 1, ((PyObject *)__pyx_n_s__fc_low));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fc_low));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fc_up));
  PyTuple_SET_ITEM(__pyx_k_tuple_109, 2, ((PyObject *)__pyx_n_s__fc_up));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fc_up));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_109, 3, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__new_peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_109, 4, ((PyObject *)__pyx_n_s__new_peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__new_peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_109, 5, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_109, 6, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__p));
  PyTuple_SET_ITEM(__pyx_k_tuple_109, 7, ((PyObject *)__pyx_n_s__p));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__p));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_109));
  __pyx_k_codeobj_110 = (PyObject*)__Pyx_PyCode_New(3, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_109, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__filter_fc, 550, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_110)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_tuple_111 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_111)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_111);
  __Pyx_INCREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_k_tuple_111, 0, ((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_111));

  /* "MACS2/IO/cPeakIO.pyx":568
 *         self.peaks = new_peaks
 * 
 *     def total (self):             # <<<<<<<<<<<<<<
 *         peaks = self.peaks
 *         chrs = peaks.keys()
 */
  __pyx_k_tuple_112 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_112)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_112);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_112, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_112, 1, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_112, 2, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__x));
  PyTuple_SET_ITEM(__pyx_k_tuple_112, 3, ((PyObject *)__pyx_n_s__x));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__x));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_112, 4, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_112));
  __pyx_k_codeobj_113 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_112, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__total, 568, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_113)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":577
 *         return x
 * 
 *     def _to_bed(self, name_prefix="%s_peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                 description="%s", score_column="score",
 *                 print_func=print, trackline=False):
 */
  __pyx_k_tuple_114 = PyTuple_New(18); if (unlikely(!__pyx_k_tuple_114)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_114);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name_prefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 1, ((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 2, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__description));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 3, ((PyObject *)__pyx_n_s__description));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__description));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__score_column));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 4, ((PyObject *)__pyx_n_s__score_column));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__score_column));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__print_func));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 5, ((PyObject *)__pyx_n_s__print_func));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__print_func));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackline));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 6, ((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackline));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 7, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__n_peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 8, ((PyObject *)__pyx_n_s__n_peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_peak));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peakprefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 9, ((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__desc));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 10, ((PyObject *)__pyx_n_s__desc));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__desc));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackcontents));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 11, ((PyObject *)__pyx_n_s__trackcontents));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackcontents));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 12, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 13, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__group));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 14, ((PyObject *)__pyx_n_s__group));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__group));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 15, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 16, ((PyObject *)__pyx_n_s__i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 17, ((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_114));
  __pyx_k_codeobj_115 = (PyObject*)__Pyx_PyCode_New(7, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_114, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s___to_bed, 577, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_115)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":605
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,peak[score_column]))
 * 
 *     def _to_summits_bed(self, name_prefix="%s_peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                         description = "%s", score_column="score",
 *                         print_func=print, trackline=False):
 */
  __pyx_k_tuple_116 = PyTuple_New(19); if (unlikely(!__pyx_k_tuple_116)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_116);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name_prefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 1, ((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 2, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__description));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 3, ((PyObject *)__pyx_n_s__description));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__description));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__score_column));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 4, ((PyObject *)__pyx_n_s__score_column));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__score_column));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__print_func));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 5, ((PyObject *)__pyx_n_s__print_func));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__print_func));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackline));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 6, ((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackline));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 7, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__n_peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 8, ((PyObject *)__pyx_n_s__n_peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_peak));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peakprefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 9, ((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__desc));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 10, ((PyObject *)__pyx_n_s__desc));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__desc));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackcontents));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 11, ((PyObject *)__pyx_n_s__trackcontents));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackcontents));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 12, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 13, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__group));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 14, ((PyObject *)__pyx_n_s__group));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__group));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 15, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 16, ((PyObject *)__pyx_n_s__i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 17, ((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peak));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__summit_p));
  PyTuple_SET_ITEM(__pyx_k_tuple_116, 18, ((PyObject *)__pyx_n_s__summit_p));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__summit_p));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_116));
  __pyx_k_codeobj_117 = (PyObject*)__Pyx_PyCode_New(7, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_116, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s___to_summits_bed, 605, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_117)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":635
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,summit_p,summit_p+1,name_prefix,n_peak,peak[score_column]))
 * 
 *     def tobed (self):             # <<<<<<<<<<<<<<
 *         """Print out peaks in BED5 format.
 * 
 */
  __pyx_k_tuple_118 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_118)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_118);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_118, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_118));
  __pyx_k_codeobj_119 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_118, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__tobed, 635, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_119)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":652
 *         return self._to_bed(name_prefix="peak_", score_column="score")
 * 
 *     def to_summits_bed (self):             # <<<<<<<<<<<<<<
 *         """Print out peak summits in BED5 format.
 * 
 */
  __pyx_k_tuple_120 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_120)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_120);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_120, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_120));
  __pyx_k_codeobj_121 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_120, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__to_summits_bed, 652, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_121)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":660
 *         return self._to_summits_bed(name_prefix="peak_", score_column="score")
 * 
 *     def write_to_bed (self, fhd, str name_prefix="peak_", str name="MACS",             # <<<<<<<<<<<<<<
 *                       str description = "%s", str score_column="score", trackline=True):
 *         """Write peaks in BED5 format in a file handler. Score (5th
 */
  __pyx_k_tuple_122 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_122)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_122);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_122, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fhd));
  PyTuple_SET_ITEM(__pyx_k_tuple_122, 1, ((PyObject *)__pyx_n_s__fhd));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fhd));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name_prefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_122, 2, ((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_122, 3, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__description));
  PyTuple_SET_ITEM(__pyx_k_tuple_122, 4, ((PyObject *)__pyx_n_s__description));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__description));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__score_column));
  PyTuple_SET_ITEM(__pyx_k_tuple_122, 5, ((PyObject *)__pyx_n_s__score_column));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__score_column));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackline));
  PyTuple_SET_ITEM(__pyx_k_tuple_122, 6, ((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_122));
  __pyx_k_codeobj_123 = (PyObject*)__Pyx_PyCode_New(7, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_122, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__write_to_bed, 660, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_123)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":685
 *                             print_func=fhd.write)
 * 
 *     def write_to_summit_bed (self, fhd, name_prefix="peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                              description = "%s", score_column="score", trackline=True):
 *         """Write peak summits in BED5 format in a file handler. Score
 */
  __pyx_k_tuple_124 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_124)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_124);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_124, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fhd));
  PyTuple_SET_ITEM(__pyx_k_tuple_124, 1, ((PyObject *)__pyx_n_s__fhd));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fhd));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name_prefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_124, 2, ((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_124, 3, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__description));
  PyTuple_SET_ITEM(__pyx_k_tuple_124, 4, ((PyObject *)__pyx_n_s__description));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__description));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__score_column));
  PyTuple_SET_ITEM(__pyx_k_tuple_124, 5, ((PyObject *)__pyx_n_s__score_column));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__score_column));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackline));
  PyTuple_SET_ITEM(__pyx_k_tuple_124, 6, ((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_124));
  __pyx_k_codeobj_125 = (PyObject*)__Pyx_PyCode_New(7, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_124, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__write_to_summit_bed, 685, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_125)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":709
 *                             print_func=fhd.write)
 * 
 *     def write_to_narrowPeak (self, fhd, name_prefix="peak_", name="peak", score_column="score", trackline=True):             # <<<<<<<<<<<<<<
 *         """Print out peaks in narrowPeak format.
 * 
 */
  __pyx_k_tuple_126 = PyTuple_New(11); if (unlikely(!__pyx_k_tuple_126)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_126);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fhd));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 1, ((PyObject *)__pyx_n_s__fhd));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fhd));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name_prefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 2, ((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 3, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__score_column));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 4, ((PyObject *)__pyx_n_s__score_column));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__score_column));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackline));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 5, ((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackline));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 6, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__n_peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 7, ((PyObject *)__pyx_n_s__n_peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_peak));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peakprefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 8, ((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 9, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 10, ((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_126));
  __pyx_k_codeobj_127 = (PyObject*)__Pyx_PyCode_New(6, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_126, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__write_to_narrowPeak, 709, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_127)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":789
 *     """
 * 
 *     def __init__ (self):             # <<<<<<<<<<<<<<
 *         self.peaks = {}
 * 
 */
  __pyx_k_tuple_129 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_129)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_129);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_129, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_129));
  __pyx_k_codeobj_130 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_129, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s____init__, 789, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_130)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":792
 *         self.peaks = {}
 * 
 *     def add (self, char * chromosome, long start, long end, long score = 0,             # <<<<<<<<<<<<<<
 *              long thickStart=0, long thickEnd=0,
 *              long blockNum=0, char *blockSizes="",
 */
  __pyx_k_tuple_131 = PyTuple_New(10); if (unlikely(!__pyx_k_tuple_131)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_131);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_131, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chromosome));
  PyTuple_SET_ITEM(__pyx_k_tuple_131, 1, ((PyObject *)__pyx_n_s__chromosome));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chromosome));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__start));
  PyTuple_SET_ITEM(__pyx_k_tuple_131, 2, ((PyObject *)__pyx_n_s__start));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__start));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__end));
  PyTuple_SET_ITEM(__pyx_k_tuple_131, 3, ((PyObject *)__pyx_n_s__end));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__score));
  PyTuple_SET_ITEM(__pyx_k_tuple_131, 4, ((PyObject *)__pyx_n_s__score));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__score));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__thickStart));
  PyTuple_SET_ITEM(__pyx_k_tuple_131, 5, ((PyObject *)__pyx_n_s__thickStart));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__thickStart));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__thickEnd));
  PyTuple_SET_ITEM(__pyx_k_tuple_131, 6, ((PyObject *)__pyx_n_s__thickEnd));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__thickEnd));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__blockNum));
  PyTuple_SET_ITEM(__pyx_k_tuple_131, 7, ((PyObject *)__pyx_n_s__blockNum));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__blockNum));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__blockSizes));
  PyTuple_SET_ITEM(__pyx_k_tuple_131, 8, ((PyObject *)__pyx_n_s__blockSizes));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__blockSizes));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__blockStarts));
  PyTuple_SET_ITEM(__pyx_k_tuple_131, 9, ((PyObject *)__pyx_n_s__blockStarts));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__blockStarts));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_131));
  __pyx_k_codeobj_132 = (PyObject*)__Pyx_PyCode_New(10, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_131, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__add, 792, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_132)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":820
 *                                       )
 * 
 *     def total (self):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 *         cdef long x
 */
  __pyx_k_tuple_133 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_133)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_133);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_133, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_133, 1, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__x));
  PyTuple_SET_ITEM(__pyx_k_tuple_133, 2, ((PyObject *)__pyx_n_s__x));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__x));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peaks));
  PyTuple_SET_ITEM(__pyx_k_tuple_133, 3, ((PyObject *)__pyx_n_s__peaks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peaks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_133, 4, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_133));
  __pyx_k_codeobj_134 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_133, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__total, 820, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_134)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":832
 *         return x
 * 
 *     def write_to_gappedPeak (self, fhd, name_prefix="peak_", name='peak', description="%s", trackline=True):             # <<<<<<<<<<<<<<
 *         """Print out peaks in bed12 format.
 * 
 */
  __pyx_k_tuple_135 = PyTuple_New(12); if (unlikely(!__pyx_k_tuple_135)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_135);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_135, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fhd));
  PyTuple_SET_ITEM(__pyx_k_tuple_135, 1, ((PyObject *)__pyx_n_s__fhd));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fhd));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name_prefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_135, 2, ((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name_prefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_135, 3, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__description));
  PyTuple_SET_ITEM(__pyx_k_tuple_135, 4, ((PyObject *)__pyx_n_s__description));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__description));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__trackline));
  PyTuple_SET_ITEM(__pyx_k_tuple_135, 5, ((PyObject *)__pyx_n_s__trackline));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__trackline));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrs));
  PyTuple_SET_ITEM(__pyx_k_tuple_135, 6, ((PyObject *)__pyx_n_s__chrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__n_peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_135, 7, ((PyObject *)__pyx_n_s__n_peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_peak));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peakprefix));
  PyTuple_SET_ITEM(__pyx_k_tuple_135, 8, ((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peakprefix));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__desc));
  PyTuple_SET_ITEM(__pyx_k_tuple_135, 9, ((PyObject *)__pyx_n_s__desc));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__desc));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
  PyTuple_SET_ITEM(__pyx_k_tuple_135, 10, ((PyObject *)__pyx_n_s__chrom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__peak));
  PyTuple_SET_ITEM(__pyx_k_tuple_135, 11, ((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__peak));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_135));
  __pyx_k_codeobj_136 = (PyObject*)__Pyx_PyCode_New(6, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_135, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s__write_to_gappedPeak, 832, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_136)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initcPeakIO(void); /*proto*/
PyMODINIT_FUNC initcPeakIO(void)
#else
PyMODINIT_FUNC PyInit_cPeakIO(void); /*proto*/
PyMODINIT_FUNC PyInit_cPeakIO(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_cPeakIO(void)", 0);
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("cPeakIO"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_48), 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_MACS2__IO__cPeakIO) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  /*--- Type import code ---*/
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "MACS2/IO/cPeakIO.pyx":24
 * # python modules
 * # ------------------------------------
 * from MACS2.Constants import *             # <<<<<<<<<<<<<<
 * from itertools import groupby
 * from operator import itemgetter
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s_50));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s_50));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_50));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_49), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (__pyx_import_star(__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":25
 * # ------------------------------------
 * from MACS2.Constants import *
 * from itertools import groupby             # <<<<<<<<<<<<<<
 * from operator import itemgetter
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__groupby));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__groupby));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__groupby));
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__itertools), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__groupby);
  if (__pyx_t_2 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__groupby);
    if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__groupby, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":26
 * from MACS2.Constants import *
 * from itertools import groupby
 * from operator import itemgetter             # <<<<<<<<<<<<<<
 * 
 * # ------------------------------------
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__itemgetter));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__itemgetter));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__itemgetter));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__operator), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__itemgetter);
  if (__pyx_t_1 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__itemgetter);
    if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__itemgetter, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":31
 * # constants
 * # ------------------------------------
 * __version__ = "PeakIO $Revision$"             # <<<<<<<<<<<<<<
 * __author__ = "Tao Liu <taoliu@jimmy.harvard.edu>"
 * __doc__ = "PeakIO class"
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____version__, ((PyObject *)__pyx_kp_s_51)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":32
 * # ------------------------------------
 * __version__ = "PeakIO $Revision$"
 * __author__ = "Tao Liu <taoliu@jimmy.harvard.edu>"             # <<<<<<<<<<<<<<
 * __doc__ = "PeakIO class"
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____author__, ((PyObject *)__pyx_kp_s_52)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":33
 * __version__ = "PeakIO $Revision$"
 * __author__ = "Tao Liu <taoliu@jimmy.harvard.edu>"
 * __doc__ = "PeakIO class"             # <<<<<<<<<<<<<<
 * 
 * # ------------------------------------
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____doc__, ((PyObject *)__pyx_kp_s_53)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":47
 * # Classes
 * # ------------------------------------
 * class PeakIO:             # <<<<<<<<<<<<<<
 *     """IO for peak information.
 * 
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));

  /* "MACS2/IO/cPeakIO.pyx":52
 *     """
 * 
 *     def __init__ (self):             # <<<<<<<<<<<<<<
 *         self.peaks = {}
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_1__init__, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_55)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s____init__, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "MACS2/IO/cPeakIO.pyx":55
 *         self.peaks = {}
 * 
 *     def add (self, str chromosome, long start, long end, long summit = 0,             # <<<<<<<<<<<<<<
 *              double peak_score=0, int pileup=0,
 *              double pscore=0, double fold_change=0, double qscore=0):
 */
  __pyx_t_1 = PyInt_FromLong(((long)0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "MACS2/IO/cPeakIO.pyx":56
 * 
 *     def add (self, str chromosome, long start, long end, long summit = 0,
 *              double peak_score=0, int pileup=0,             # <<<<<<<<<<<<<<
 *              double pscore=0, double fold_change=0, double qscore=0):
 *         """items:
 */
  __pyx_t_3 = PyFloat_FromDouble(((double)0.0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyInt_FromLong(((int)0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "MACS2/IO/cPeakIO.pyx":57
 *     def add (self, str chromosome, long start, long end, long summit = 0,
 *              double peak_score=0, int pileup=0,
 *              double pscore=0, double fold_change=0, double qscore=0):             # <<<<<<<<<<<<<<
 *         """items:
 *         start:start
 */
  __pyx_t_5 = PyFloat_FromDouble(((double)0.0)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyFloat_FromDouble(((double)0.0)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyFloat_FromDouble(((double)0.0)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyTuple_New(6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_3add, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_59)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, ((PyObject *)__pyx_t_8));
  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__add, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":81
 *                                        "qscore":qscore})
 * 
 *     def filter_pscore (self, double pscore_cut ):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 * 
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_5filter_pscore, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_61)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__filter_pscore, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":92
 *         self.peaks = new_peaks
 * 
 *     def filter_qscore (self, double qscore_cut ):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 * 
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_7filter_qscore, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_63)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__filter_qscore, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":103
 *         self.peaks = new_peaks
 * 
 *     def filter_fc (self, fc_low, fc_up=None ):             # <<<<<<<<<<<<<<
 *         """Filter peaks in a given fc range.
 * 
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_9filter_fc, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_65)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, ((PyObject *)__pyx_k_tuple_66));
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__filter_fc, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":121
 *         self.peaks = new_peaks
 * 
 *     def total (self):             # <<<<<<<<<<<<<<
 *         peaks = self.peaks
 *         chrs = peaks.keys()
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_11total, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_68)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__total, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":130
 *         return x
 * 
 *     def _to_bed(self, name_prefix="%s_peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                 description="%s", score_column="score",
 *                 print_func=print, trackline=False):
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_13_to_bed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_70)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_7, sizeof(__pyx_defaults), 2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":132
 *     def _to_bed(self, name_prefix="%s_peak_", name="MACS",
 *                 description="%s", score_column="score",
 *                 print_func=print, trackline=False):             # <<<<<<<<<<<<<<
 *         """
 *         generalization of tobed and write_to_bed
 */
  __Pyx_INCREF(__pyx_builtin_print);
  __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_t_7)->__pyx_arg_print_func = __pyx_builtin_print;
  __Pyx_GIVEREF(__pyx_builtin_print);
  __pyx_t_8 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_t_7)->__pyx_arg_trackline = __pyx_t_8;
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_7, __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_30__defaults__);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s___to_bed, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":158
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,peak[score_column]))
 * 
 *     def _to_summits_bed(self, name_prefix="%s_peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                         description = "%s", score_column="score",
 *                         print_func=print, trackline=False):
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_15_to_summits_bed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_72)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_7, sizeof(__pyx_defaults1), 2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":160
 *     def _to_summits_bed(self, name_prefix="%s_peak_", name="MACS",
 *                         description = "%s", score_column="score",
 *                         print_func=print, trackline=False):             # <<<<<<<<<<<<<<
 *         """
 *         generalization of to_summits_bed and write_to_summit_bed
 */
  __Pyx_INCREF(__pyx_builtin_print);
  __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_t_7)->__pyx_arg_print_func = __pyx_builtin_print;
  __Pyx_GIVEREF(__pyx_builtin_print);
  __pyx_t_8 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_t_7)->__pyx_arg_trackline = __pyx_t_8;
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_7, __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_32__defaults__);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s___to_summits_bed, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":188
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,summit_p,summit_p+1,peakprefix,n_peak,peak[score_column]))
 * 
 *     def tobed (self):             # <<<<<<<<<<<<<<
 *         """Print out peaks in BED5 format.
 * 
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_17tobed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_74)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__tobed, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":205
 *         return self._to_bed(name_prefix="peak_", score_column="score")
 * 
 *     def to_summits_bed (self):             # <<<<<<<<<<<<<<
 *         """Print out peak summits in BED5 format.
 * 
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_19to_summits_bed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_76)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__to_summits_bed, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":214
 * 
 *     # these methods are very fast, specifying types is unnecessary
 *     def write_to_bed (self, fhd, str name_prefix="peak_", str name="MACS",             # <<<<<<<<<<<<<<
 *                         str description = "%s", str score_column="score", trackline=True):
 *         """Write peaks in BED5 format in a file handler. Score (5th
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_21write_to_bed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_78)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_7, sizeof(__pyx_defaults2), 1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":215
 *     # these methods are very fast, specifying types is unnecessary
 *     def write_to_bed (self, fhd, str name_prefix="peak_", str name="MACS",
 *                         str description = "%s", str score_column="score", trackline=True):             # <<<<<<<<<<<<<<
 *         """Write peaks in BED5 format in a file handler. Score (5th
 *         column) is decided by score_column setting. Check the
 */
  __pyx_t_8 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_t_7)->__pyx_arg_trackline = __pyx_t_8;
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_7, __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_34__defaults__);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__write_to_bed, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":240
 *                             print_func=fhd.write, trackline=trackline)
 * 
 *     def write_to_summit_bed (self, fhd, name_prefix="peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                              description = "%s", score_column="score", trackline=True):
 *         """Write peak summits in BED5 format in a file handler. Score
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_23write_to_summit_bed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_80)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_7, sizeof(__pyx_defaults3), 1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":241
 * 
 *     def write_to_summit_bed (self, fhd, name_prefix="peak_", name="MACS",
 *                              description = "%s", score_column="score", trackline=True):             # <<<<<<<<<<<<<<
 *         """Write peak summits in BED5 format in a file handler. Score
 *         (5th column) is decided by score_column setting. Check the
 */
  __pyx_t_8 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_t_7)->__pyx_arg_trackline = __pyx_t_8;
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_7, __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_36__defaults__);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__write_to_summit_bed, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":265
 *                                     print_func=fhd.write, trackline=trackline)
 * 
 *     def write_to_narrowPeak (self, fhd, name_prefix="peak_", name="peak", score_column="score", trackline=True):             # <<<<<<<<<<<<<<
 *         """Print out peaks in narrowPeak format.
 * 
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_25write_to_narrowPeak, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_82)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_7, sizeof(__pyx_defaults4), 1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_t_7)->__pyx_arg_trackline = __pyx_t_8;
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_7, __pyx_pf_5MACS2_2IO_7cPeakIO_6PeakIO_38__defaults__);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__write_to_narrowPeak, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":340
 *                             peak["fc"],peak["pscore"],peak["qscore"],peak["summit"]-peak["start"]) )
 * 
 *     def write_to_xls (self, ofhd, name_prefix="%s_peak_", name="MACS"):             # <<<<<<<<<<<<<<
 *         """Save the peak results in a tab-delimited plain text file
 *         with suffix .xls.
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_27write_to_xls, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_84)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, ((PyObject *)__pyx_k_tuple_85));
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__write_to_xls, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":386
 * 
 * 
 *     def overlap_with_other_peaks (self, peaks2, double cover=0):             # <<<<<<<<<<<<<<
 *         """Peaks2 is a PeakIO object or dictionary with can be
 *         initialzed as a PeakIO. check __init__ for PeakIO for detail.
 */
  __pyx_t_7 = PyFloat_FromDouble(((double)0.0)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6PeakIO_29overlap_with_other_peaks, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_87)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, ((PyObject *)__pyx_t_8));
  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s_88, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":47
 * # Classes
 * # ------------------------------------
 * class PeakIO:             # <<<<<<<<<<<<<<
 *     """IO for peak information.
 * 
 */
  if (PyDict_SetItemString(((PyObject *)__pyx_t_2), "__doc__", ((PyObject *)__pyx_kp_s_89)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2), __pyx_n_s__PeakIO, __pyx_n_s_57); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PeakIO, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":428
 *         return total_num
 * 
 * class Region:             # <<<<<<<<<<<<<<
 *     """For plain region of chrom, start and end
 *     """
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));

  /* "MACS2/IO/cPeakIO.pyx":431
 *     """For plain region of chrom, start and end
 *     """
 *     def __init__ (self):             # <<<<<<<<<<<<<<
 *         self.regions= {}
 *         self.__flag_sorted = False
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6Region_1__init__, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_91)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s____init__, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":435
 *         self.__flag_sorted = False
 * 
 *     def add_loc ( self, str chrom, int start, int end ):             # <<<<<<<<<<<<<<
 *         if self.regions.has_key(chrom):
 *             self.regions[chrom].append( (start,end) )
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6Region_3add_loc, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_93)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__add_loc, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":443
 *         return
 * 
 *     def sort (self):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 * 
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6Region_5sort, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_95)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__sort, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":450
 *         self.__flag_sorted = True
 * 
 *     def merge_overlap ( self ):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 *         cdef int s_new_region, e_new_region, i, j
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6Region_7merge_overlap, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_97)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__merge_overlap, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":485
 *         return True
 * 
 *     def write_to_bed (self, fhd ):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef str chrom
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_6Region_9write_to_bed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_99)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__write_to_bed, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":428
 *         return total_num
 * 
 * class Region:             # <<<<<<<<<<<<<<
 *     """For plain region of chrom, start and end
 *     """
 */
  if (PyDict_SetItemString(((PyObject *)__pyx_t_2), "__doc__", ((PyObject *)__pyx_kp_s_100)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2), __pyx_n_s__Region, __pyx_n_s_57); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Region, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":498
 * 
 * ###
 * class DiffPeakIO:             # <<<<<<<<<<<<<<
 *     """IO for differential peak information.
 * 
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));

  /* "MACS2/IO/cPeakIO.pyx":503
 *     """
 * 
 *     def __init__ (self):             # <<<<<<<<<<<<<<
 *         self.peaks = {}
 * 
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_1__init__, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_102)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s____init__, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "MACS2/IO/cPeakIO.pyx":506
 *         self.peaks = {}
 * 
 *     def add (self, str chromosome, long start, long end, long summit = 0,             # <<<<<<<<<<<<<<
 *              double diff_score=0, int pileup=0,
 *              double pscore=0, double fold_change=0, double qscore=0):
 */
  __pyx_t_7 = PyInt_FromLong(((long)0)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "MACS2/IO/cPeakIO.pyx":507
 * 
 *     def add (self, str chromosome, long start, long end, long summit = 0,
 *              double diff_score=0, int pileup=0,             # <<<<<<<<<<<<<<
 *              double pscore=0, double fold_change=0, double qscore=0):
 *         """items:
 */
  __pyx_t_8 = PyFloat_FromDouble(((double)0.0)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = PyInt_FromLong(((int)0)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);

  /* "MACS2/IO/cPeakIO.pyx":508
 *     def add (self, str chromosome, long start, long end, long summit = 0,
 *              double diff_score=0, int pileup=0,
 *              double pscore=0, double fold_change=0, double qscore=0):             # <<<<<<<<<<<<<<
 *         """items:
 *         start:start
 */
  __pyx_t_5 = PyFloat_FromDouble(((double)0.0)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyFloat_FromDouble(((double)0.0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyFloat_FromDouble(((double)0.0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_6 = 0;
  __pyx_t_5 = 0;
  __pyx_t_4 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_3add, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_104)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, ((PyObject *)__pyx_t_1));
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__add, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":532
 *                                        "qscore":qscore})
 * 
 *     def filter_pscore (self, double pscore_cut ):             # <<<<<<<<<<<<<<
 *         peaks = self.peaks
 *         new_peaks = {}
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_5filter_pscore, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_106)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__filter_pscore, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":541
 *         self.peaks = new_peaks
 * 
 *     def filter_qscore (self, double qscore_cut ):             # <<<<<<<<<<<<<<
 *         peaks = self.peaks
 *         new_peaks = {}
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_7filter_qscore, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_108)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__filter_qscore, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":550
 *         self.peaks = new_peaks
 * 
 *     def filter_fc (self, fc_low, fc_up=None ):             # <<<<<<<<<<<<<<
 *         """Filter peaks in a given fc range.
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_9filter_fc, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_110)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, ((PyObject *)__pyx_k_tuple_111));
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__filter_fc, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":568
 *         self.peaks = new_peaks
 * 
 *     def total (self):             # <<<<<<<<<<<<<<
 *         peaks = self.peaks
 *         chrs = peaks.keys()
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_11total, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_113)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__total, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":577
 *         return x
 * 
 *     def _to_bed(self, name_prefix="%s_peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                 description="%s", score_column="score",
 *                 print_func=print, trackline=False):
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_13_to_bed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_115)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults5), 2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":579
 *     def _to_bed(self, name_prefix="%s_peak_", name="MACS",
 *                 description="%s", score_column="score",
 *                 print_func=print, trackline=False):             # <<<<<<<<<<<<<<
 *         """
 *         generalization of tobed and write_to_bed
 */
  __Pyx_INCREF(__pyx_builtin_print);
  __Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_t_3)->__pyx_arg_print_func = __pyx_builtin_print;
  __Pyx_GIVEREF(__pyx_builtin_print);
  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_t_3)->__pyx_arg_trackline = __pyx_t_1;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_26__defaults__);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s___to_bed, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":605
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,peak["start"],peak["end"],peakprefix,n_peak,peak[score_column]))
 * 
 *     def _to_summits_bed(self, name_prefix="%s_peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                         description = "%s", score_column="score",
 *                         print_func=print, trackline=False):
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_15_to_summits_bed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_117)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults6), 2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":607
 *     def _to_summits_bed(self, name_prefix="%s_peak_", name="MACS",
 *                         description = "%s", score_column="score",
 *                         print_func=print, trackline=False):             # <<<<<<<<<<<<<<
 *         """
 *         generalization of to_summits_bed and write_to_summit_bed
 */
  __Pyx_INCREF(__pyx_builtin_print);
  __Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_t_3)->__pyx_arg_print_func = __pyx_builtin_print;
  __Pyx_GIVEREF(__pyx_builtin_print);
  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_t_3)->__pyx_arg_trackline = __pyx_t_1;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_28__defaults__);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s___to_summits_bed, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":635
 *                     print_func("%s\t%d\t%d\t%s%d\t%.2f\n" % (chrom,summit_p,summit_p+1,name_prefix,n_peak,peak[score_column]))
 * 
 *     def tobed (self):             # <<<<<<<<<<<<<<
 *         """Print out peaks in BED5 format.
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_17tobed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_119)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__tobed, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":652
 *         return self._to_bed(name_prefix="peak_", score_column="score")
 * 
 *     def to_summits_bed (self):             # <<<<<<<<<<<<<<
 *         """Print out peak summits in BED5 format.
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_19to_summits_bed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_121)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__to_summits_bed, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":660
 *         return self._to_summits_bed(name_prefix="peak_", score_column="score")
 * 
 *     def write_to_bed (self, fhd, str name_prefix="peak_", str name="MACS",             # <<<<<<<<<<<<<<
 *                       str description = "%s", str score_column="score", trackline=True):
 *         """Write peaks in BED5 format in a file handler. Score (5th
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_21write_to_bed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_123)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults7), 1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":661
 * 
 *     def write_to_bed (self, fhd, str name_prefix="peak_", str name="MACS",
 *                       str description = "%s", str score_column="score", trackline=True):             # <<<<<<<<<<<<<<
 *         """Write peaks in BED5 format in a file handler. Score (5th
 *         column) is decided by score_column setting. Check the
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_CyFunction_Defaults(__pyx_defaults7, __pyx_t_3)->__pyx_arg_trackline = __pyx_t_1;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_30__defaults__);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__write_to_bed, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":685
 *                             print_func=fhd.write)
 * 
 *     def write_to_summit_bed (self, fhd, name_prefix="peak_", name="MACS",             # <<<<<<<<<<<<<<
 *                              description = "%s", score_column="score", trackline=True):
 *         """Write peak summits in BED5 format in a file handler. Score
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_23write_to_summit_bed, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_125)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults8), 1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "MACS2/IO/cPeakIO.pyx":686
 * 
 *     def write_to_summit_bed (self, fhd, name_prefix="peak_", name="MACS",
 *                              description = "%s", score_column="score", trackline=True):             # <<<<<<<<<<<<<<
 *         """Write peak summits in BED5 format in a file handler. Score
 *         (5th column) is decided by score_column setting. Check the
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_t_3)->__pyx_arg_trackline = __pyx_t_1;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_32__defaults__);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__write_to_summit_bed, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":709
 *                             print_func=fhd.write)
 * 
 *     def write_to_narrowPeak (self, fhd, name_prefix="peak_", name="peak", score_column="score", trackline=True):             # <<<<<<<<<<<<<<
 *         """Print out peaks in narrowPeak format.
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_10DiffPeakIO_25write_to_narrowPeak, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_127)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults9), 1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_t_3)->__pyx_arg_trackline = __pyx_t_1;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_5MACS2_2IO_7cPeakIO_10DiffPeakIO_34__defaults__);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__write_to_narrowPeak, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":498
 * 
 * ###
 * class DiffPeakIO:             # <<<<<<<<<<<<<<
 *     """IO for differential peak information.
 * 
 */
  if (PyDict_SetItemString(((PyObject *)__pyx_t_2), "__doc__", ((PyObject *)__pyx_kp_s_128)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2), __pyx_n_s__DiffPeakIO, __pyx_n_s_57); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DiffPeakIO, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":784
 * #
 * 
 * class BroadPeakIO:             # <<<<<<<<<<<<<<
 *     """IO for broad peak information.
 * 
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));

  /* "MACS2/IO/cPeakIO.pyx":789
 *     """
 * 
 *     def __init__ (self):             # <<<<<<<<<<<<<<
 *         self.peaks = {}
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_11BroadPeakIO_1__init__, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_130)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s____init__, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "MACS2/IO/cPeakIO.pyx":792
 *         self.peaks = {}
 * 
 *     def add (self, char * chromosome, long start, long end, long score = 0,             # <<<<<<<<<<<<<<
 *              long thickStart=0, long thickEnd=0,
 *              long blockNum=0, char *blockSizes="",
 */
  __pyx_t_3 = PyInt_FromLong(((long)0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "MACS2/IO/cPeakIO.pyx":793
 * 
 *     def add (self, char * chromosome, long start, long end, long score = 0,
 *              long thickStart=0, long thickEnd=0,             # <<<<<<<<<<<<<<
 *              long blockNum=0, char *blockSizes="",
 *              char * blockStarts="" ):
 */
  __pyx_t_1 = PyInt_FromLong(((long)0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyInt_FromLong(((long)0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "MACS2/IO/cPeakIO.pyx":794
 *     def add (self, char * chromosome, long start, long end, long score = 0,
 *              long thickStart=0, long thickEnd=0,
 *              long blockNum=0, char *blockSizes="",             # <<<<<<<<<<<<<<
 *              char * blockStarts="" ):
 *         """items
 */
  __pyx_t_5 = PyInt_FromLong(((long)0)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyBytes_FromString(((char *)__pyx_k_45)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));

  /* "MACS2/IO/cPeakIO.pyx":795
 *              long thickStart=0, long thickEnd=0,
 *              long blockNum=0, char *blockSizes="",
 *              char * blockStarts="" ):             # <<<<<<<<<<<<<<
 *         """items
 *         chromosome : chromosome name,
 */
  __pyx_t_8 = PyBytes_FromString(((char *)__pyx_k_45)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_8));
  __pyx_t_7 = PyTuple_New(6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 4, ((PyObject *)__pyx_t_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
  PyTuple_SET_ITEM(__pyx_t_7, 5, ((PyObject *)__pyx_t_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
  __pyx_t_3 = 0;
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_11BroadPeakIO_3add, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_132)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, ((PyObject *)__pyx_t_7));
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__add, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "MACS2/IO/cPeakIO.pyx":820
 *                                       )
 * 
 *     def total (self):             # <<<<<<<<<<<<<<
 *         cdef str chrom
 *         cdef long x
 */
  __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_11BroadPeakIO_5total, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_134)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__total, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "MACS2/IO/cPeakIO.pyx":832
 *         return x
 * 
 *     def write_to_gappedPeak (self, fhd, name_prefix="peak_", name='peak', description="%s", trackline=True):             # <<<<<<<<<<<<<<
 *         """Print out peaks in bed12 format.
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5MACS2_2IO_7cPeakIO_11BroadPeakIO_7write_to_gappedPeak, 0, NULL, __pyx_n_s_57, ((PyObject *)__pyx_k_codeobj_136)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_8, sizeof(__pyx_defaults10), 1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_t_8)->__pyx_arg_trackline = __pyx_t_7;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_8, __pyx_pf_5MACS2_2IO_7cPeakIO_11BroadPeakIO_8__defaults__);
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__write_to_gappedPeak, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "MACS2/IO/cPeakIO.pyx":784
 * #
 * 
 * class BroadPeakIO:             # <<<<<<<<<<<<<<
 *     """IO for broad peak information.
 * 
 */
  if (PyDict_SetItemString(((PyObject *)__pyx_t_2), "__doc__", ((PyObject *)__pyx_kp_s_137)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2), __pyx_n_s__BroadPeakIO, __pyx_n_s_57); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BroadPeakIO, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "MACS2/IO/cPeakIO.pyx":1
 * # cython: profile=True             # <<<<<<<<<<<<<<
 * # Time-stamp: <2012-06-05 20:46:06 Tao Liu>
 * 
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  if (__pyx_m) {
    __Pyx_AddTraceback("init MACS2.IO.cPeakIO", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init MACS2.IO.cPeakIO");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif /* CYTHON_REFNANNY */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result) {
        if (dict != __pyx_b) {
            PyErr_Clear();
            result = PyObject_GetAttr(__pyx_b, name);
        }
        if (!result) {
            PyErr_SetObject(PyExc_NameError, name);
        }
    }
    return result;
}

#if CYTHON_PROFILE
static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
                                   PyFrameObject** frame,
                                   const char *funcname,
                                   const char *srcfile,
                                   int firstlineno) {
    if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) {
        if (*code == NULL) {
            *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno);
            if (*code == NULL) return 0;
        }
        *frame = PyFrame_New(
            PyThreadState_GET(),            /*PyThreadState *tstate*/
            *code,                          /*PyCodeObject *code*/
            PyModule_GetDict(__pyx_m),      /*PyObject *globals*/
            0                               /*PyObject *locals*/
        );
        if (*frame == NULL) return 0;
    }
    else {
        (*frame)->f_tstate = PyThreadState_GET();
    }
    return PyThreadState_GET()->c_profilefunc(PyThreadState_GET()->c_profileobj, *frame, PyTrace_CALL, NULL) == 0;
}
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,                /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,                /*int kwonlyargcount,*/
        #endif
        0,                /*int nlocals,*/
        0,                /*int stacksize,*/
        0,                /*int flags,*/
        __pyx_empty_bytes,  /*PyObject *code,*/
        __pyx_empty_tuple,  /*PyObject *consts,*/
        __pyx_empty_tuple,  /*PyObject *names,*/
        __pyx_empty_tuple,  /*PyObject *varnames,*/
        __pyx_empty_tuple,  /*PyObject *freevars,*/
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,       /*PyObject *filename,*/
        py_funcname,      /*PyObject *name,*/
        firstlineno,      /*int firstlineno,*/
        __pyx_empty_bytes   /*PyObject *lnotab*/
    );
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return py_code;
}
#endif /* CYTHON_PROFILE */

static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
    long q = a / b;
    long r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

static CYTHON_INLINE long __Pyx_mod_long(long a, long b) {
    long r = a % b;
    r += ((r != 0) & ((r ^ b) < 0)) * b;
    return r;
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
    if (unlikely(tstate->curexc_type))
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    /* Make sure tstate is in a consistent state when we XDECREF
       these objects (XDECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %"PY_FORMAT_SIZE_T"d value%s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %"PY_FORMAT_SIZE_T"d)", expected);
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else if (PyErr_Occurred()) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
}



static double __Pyx__PyObject_AsDouble(PyObject* obj) {
    PyObject* float_value;
    if (Py_TYPE(obj)->tp_as_number && Py_TYPE(obj)->tp_as_number->nb_float) {
        return PyFloat_AsDouble(obj);
    } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
#if PY_MAJOR_VERSION >= 3
        float_value = PyFloat_FromString(obj);
#else
        float_value = PyFloat_FromString(obj, 0);
#endif
    } else {
        PyObject* args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        PyTuple_SET_ITEM(args, 0, obj);
        float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
        PyTuple_SET_ITEM(args, 0, 0);
        Py_DECREF(args);
    }
    if (likely(float_value)) {
        double value = PyFloat_AS_DOUBLE(float_value);
        Py_DECREF(float_value);
        return value;
    }
bad:
    return (double)-1;
}

static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable");
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
    PyObject *py_import = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
    if (!py_import)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    #if PY_VERSION_HEX >= 0x02050000
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                /* try package relative import first */
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0; /* try absolute import on failure */
        }
        #endif
        if (!module) {
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
        }
    }
    #else
    if (level>0) {
        PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
        goto bad;
    }
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
    #endif
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(py_import);
    Py_XDECREF(empty_dict);
    return module;
}

static CYTHON_INLINE void __Pyx_RaiseImportError(PyObject *name) {
#if PY_MAJOR_VERSION < 3
    PyErr_Format(PyExc_ImportError, "cannot import name %.230s",
                 PyString_AsString(name));
#else
    PyErr_Format(PyExc_ImportError, "cannot import name %S", name);
#endif
}

static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
    PyObject *metaclass;
    /* Default metaclass */
#if PY_MAJOR_VERSION < 3
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = PyObject_GetAttrString(base, (char *)"__class__");
        if (!metaclass) {
            PyErr_Clear();
            metaclass = (PyObject*) Py_TYPE(base);
        }
    } else {
        metaclass = (PyObject *) &PyClass_Type;
    }
#else
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = (PyObject*) Py_TYPE(base);
    } else {
        metaclass = (PyObject *) &PyType_Type;
    }
#endif
    Py_INCREF(metaclass);
    return metaclass;
}

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname) {
    PyObject *result;
    PyObject *metaclass;
    if (PyDict_SetItemString(dict, "__module__", modname) < 0)
        return NULL;
    /* Python2 __metaclass__ */
    metaclass = PyDict_GetItemString(dict, "__metaclass__");
    if (metaclass) {
        Py_INCREF(metaclass);
    } else {
        metaclass = __Pyx_FindPy2Metaclass(bases);
    }
    result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
    Py_DECREF(metaclass);
    return result;
}

static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (op->func_doc == NULL && op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
        op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
        op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
    }
    if (op->func_doc == 0) {
        Py_INCREF(Py_None);
        return Py_None;
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL)
        op->func_doc = Py_None; /* Mark as deleted */
    else
        op->func_doc = value;
    Py_INCREF(op->func_doc);
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
    if (op->func_name == NULL) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (value == NULL || !PyUnicode_Check(value)) {
#else
    if (value == NULL || !PyString_Check(value)) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
{
    if (op->func_dict == NULL) {
        op->func_dict = PyDict_New();
        if (op->func_dict == NULL)
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
    if (value == NULL) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    PyObject* dict = PyModule_GetDict(__pyx_m);
    Py_XINCREF(dict);
    return dict;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op)
{
    if (op->defaults_tuple) {
        Py_INCREF(op->defaults_tuple);
        return op->defaults_tuple;
    }
    if (op->defaults_getter) {
        PyObject *res = op->defaults_getter((PyObject *) op);
        if (res) {
            Py_INCREF(res);
            op->defaults_tuple = res;
        }
        return res;
    }
    Py_INCREF(Py_None);
    return Py_None;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, 0, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, 0, 0, 0},
    {0, 0, 0, 0, 0}
};
#ifndef PY_WRITE_RESTRICTED /* < Py2.5 */
#define PY_WRITE_RESTRICTED WRITE_RESTRICTED
#endif
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags,
                                      PyObject *closure, PyObject *module, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    op->func_weakreflist = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_getter = NULL;
    PyObject_GC_Track(op);
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyMem_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    if (m->func_weakreflist != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return PyMethod_New(func,
                            type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
    PyObject *func_name = __Pyx_CyFunction_get_name(op);
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                func_name, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(func_name), (void *)op);
#endif
}
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    __Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/
    sizeof(__pyx_CyFunctionObject),   /*tp_basicsize*/
    0,                                  /*tp_itemsize*/
    (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/
    0,                                  /*tp_print*/
    0,                                  /*tp_getattr*/
    0,                                  /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
    0,                                  /*tp_compare*/
#else
    0,                                  /*reserved*/
#endif
    (reprfunc) __Pyx_CyFunction_repr,   /*tp_repr*/
    0,                                  /*tp_as_number*/
    0,                                  /*tp_as_sequence*/
    0,                                  /*tp_as_mapping*/
    0,                                  /*tp_hash*/
    __Pyx_PyCFunction_Call,             /*tp_call*/
    0,                                  /*tp_str*/
    0,                                  /*tp_getattro*/
    0,                                  /*tp_setattro*/
    0,                                  /*tp_as_buffer*/
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/
    0,                                  /*tp_doc*/
    (traverseproc) __Pyx_CyFunction_traverse,   /*tp_traverse*/
    (inquiry) __Pyx_CyFunction_clear,   /*tp_clear*/
    0,                                  /*tp_richcompare*/
    offsetof(__pyx_CyFunctionObject, func_weakreflist), /* tp_weaklistoffse */
    0,                                  /*tp_iter*/
    0,                                  /*tp_iternext*/
    __pyx_CyFunction_methods,           /*tp_methods*/
    __pyx_CyFunction_members,           /*tp_members*/
    __pyx_CyFunction_getsets,           /*tp_getset*/
    0,                                  /*tp_base*/
    0,                                  /*tp_dict*/
    __Pyx_CyFunction_descr_get,         /*tp_descr_get*/
    0,                                  /*tp_descr_set*/
    offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/
    0,                                  /*tp_init*/
    0,                                  /*tp_alloc*/
    0,                                  /*tp_new*/
    0,                                  /*tp_free*/
    0,                                  /*tp_is_gc*/
    0,                                  /*tp_bases*/
    0,                                  /*tp_mro*/
    0,                                  /*tp_cache*/
    0,                                  /*tp_subclasses*/
    0,                                  /*tp_weaklist*/
    0,                                  /*tp_del*/
#if PY_VERSION_HEX >= 0x02060000
    0,                                  /*tp_version_tag*/
#endif
};
static int __Pyx_CyFunction_init(void)
{
    if (PyType_Ready(&__pyx_CyFunctionType_type) < 0)
        return -1;
    __pyx_CyFunctionType = &__pyx_CyFunctionType_type;
    return 0;
}
void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyMem_Malloc(size);
    if (!m->defaults)
        return PyErr_NoMemory();
    memset(m->defaults, 0, sizeof(size));
    m->defaults_pyobjects = pyobjects;
    return m->defaults;
}
static void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return (unsigned long)PyLong_AsUnsignedLong(x);
        } else {
            return (unsigned long)PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return (long)PyLong_AsUnsignedLong(x);
        } else {
            return (long)PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return (signed long)PyLong_AsUnsignedLong(x);
        } else {
            return (signed long)PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE int __Pyx_StrEq(const char *s1, const char *s2) {
     while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
     return *s1 == *s2;
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        #if PY_VERSION_HEX < 0x02050000
        return PyErr_Warn(NULL, message);
        #else
        return PyErr_WarnEx(NULL, message, 1);
        #endif
    }
    return 0;
}

static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = (start + end) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,            /*int argcount,*/
        0,            /*int kwonlyargcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,      /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_globals = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}


/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_VERSION_HEX < 0x03000000
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
