/* Generated by Cython 0.16 on Wed Apr 25 13:44:32 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__obitools__align___dynamic
#define __PYX_HAVE_API__obitools__align___dynamic
#include "stdlib.h"
#include "string.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


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

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

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


/* Type Conversion Predeclarations */

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

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

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

#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[] = {
  "_dynamic.pyx",
};

/*--- Type declarations ---*/
struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming;
struct __pyx_t_8obitools_5align_8_dynamic_AlignCell;
struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix;
struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateMatrix;
struct __pyx_t_8obitools_5align_8_dynamic_alignSequence;
struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence;
struct __pyx_t_8obitools_5align_8_dynamic_alignPath;
struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath;

/* "obitools/align/_dynamic.pxd":11
 *     void memcpy(void* s1, void* s2, int n)
 * 
 * cdef struct AlignCell :             # <<<<<<<<<<<<<<
 *     double score
 *     int   path
 */
struct __pyx_t_8obitools_5align_8_dynamic_AlignCell {
  double score;
  int path;
};

/* "obitools/align/_dynamic.pxd":15
 *     int   path
 * 
 * cdef struct AlignMatrix :             # <<<<<<<<<<<<<<
 *     AlignCell*  matrix
 *     int*        bestVJump
 */
struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix {
  struct __pyx_t_8obitools_5align_8_dynamic_AlignCell *matrix;
  int *bestVJump;
  int *bestHJump;
  int msize;
  int vsize;
  int hsize;
};

/* "obitools/align/_dynamic.pxd":25
 * 
 * 
 * cdef AlignMatrix* allocateMatrix(int hsize, int vsize,AlignMatrix *matrix=?)             # <<<<<<<<<<<<<<
 * 
 * cdef void freeMatrix(AlignMatrix* matrix)
 */
struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateMatrix {
  int __pyx_n;
  struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *matrix;
};

/* "obitools/align/_dynamic.pxd":32
 * 
 * 
 * cdef struct alignSequence:             # <<<<<<<<<<<<<<
 *     long    length
 *     long    buffsize
 */
struct __pyx_t_8obitools_5align_8_dynamic_alignSequence {
  long length;
  long buffsize;
  int hasQuality;
  char *sequence;
  double *quality;
};

/* "obitools/align/_dynamic.pxd":39
 *     double* quality
 * 
 * cdef alignSequence* allocateSequence(object bioseq, alignSequence* seq=?) except *             # <<<<<<<<<<<<<<
 * 
 * cdef void freeSequence(alignSequence* seq)
 */
struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence {
  int __pyx_n;
  struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *seq;
};

/* "obitools/align/_dynamic.pxd":43
 * cdef void freeSequence(alignSequence* seq)
 * 
 * cdef struct alignPath:             # <<<<<<<<<<<<<<
 *     long length
 *     long buffsize
 */
struct __pyx_t_8obitools_5align_8_dynamic_alignPath {
  long length;
  long buffsize;
  long vStart;
  long hStart;
  long *path;
};

/* "obitools/align/_dynamic.pxd":50
 *     long *path
 * 
 * cdef alignPath* allocatePath(long l1,long l2,alignPath* path=?)             # <<<<<<<<<<<<<<
 * 
 * cdef void reversePath(alignPath* path)
 */
struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath {
  int __pyx_n;
  struct __pyx_t_8obitools_5align_8_dynamic_alignPath *path;
};

/* "obitools/align/_dynamic.pxd":63
 * cpdef unsigned char encodeBase(unsigned char lettre)
 * 
 * cdef class DynamicProgramming:             # <<<<<<<<<<<<<<
 *     cdef AlignMatrix* matrix
 * 
 */
struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming {
  PyObject_HEAD
  struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_vtab;
  struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *matrix;
  PyObject *horizontalSeq;
  PyObject *verticalSeq;
  struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *hSeq;
  struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *vSeq;
  struct __pyx_t_8obitools_5align_8_dynamic_alignPath *path;
  double _opengap;
  double _extgap;
  PyObject *alignment;
  int sequenceChanged;
  int scoreChanged;
};



/* "obitools/align/_dynamic.pyx":189
 * 
 * 
 * cdef class DynamicProgramming:             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self,opengap,extgap):
 */

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

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

static CYTHON_INLINE int __Pyx_NegateNonNeg(int b) {
    return unlikely(b < 0) ? b : !b;
}
static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
    return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
}

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 CYTHON_INLINE long __Pyx_div_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 CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*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 PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseImportError(PyObject *name);

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 void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

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

static int __Pyx_check_binary_version(void);

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

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

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

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

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


/* Module declarations from 'obitools.align._dynamic' */
static PyTypeObject *__pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming = 0;
static int __pyx_v_8obitools_5align_8_dynamic_aascii;
static int __pyx_v_8obitools_5align_8_dynamic__basecode[26];
static struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *__pyx_f_8obitools_5align_8_dynamic_allocateMatrix(int, int, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateMatrix *__pyx_optional_args); /*proto*/
static void __pyx_f_8obitools_5align_8_dynamic_freeMatrix(struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *); /*proto*/
static void __pyx_f_8obitools_5align_8_dynamic_resetMatrix(struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *); /*proto*/
static struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *__pyx_f_8obitools_5align_8_dynamic_allocateSequence(PyObject *, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence *__pyx_optional_args); /*proto*/
static void __pyx_f_8obitools_5align_8_dynamic_freeSequence(struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *); /*proto*/
static void __pyx_f_8obitools_5align_8_dynamic_freePath(struct __pyx_t_8obitools_5align_8_dynamic_alignPath *); /*proto*/
static int __pyx_f_8obitools_5align_8_dynamic_bitCount(int); /*proto*/
static int __pyx_f_8obitools_5align_8_dynamic_iupacMatch(unsigned char, unsigned char, int __pyx_skip_dispatch); /*proto*/
static double __pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch(unsigned char, unsigned char, int __pyx_skip_dispatch); /*proto*/
static unsigned char __pyx_f_8obitools_5align_8_dynamic_encodeBase(unsigned char, int __pyx_skip_dispatch); /*proto*/
#define __Pyx_MODULE_NAME "obitools.align._dynamic"
int __pyx_module_is_main_obitools__align___dynamic = 0;

/* Implementation of 'obitools.align._dynamic' */
static PyObject *__pyx_builtin_ord;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_pf_8obitools_5align_8_dynamic_iupacMatch(CYTHON_UNUSED PyObject *__pyx_self, unsigned char __pyx_v_a, unsigned char __pyx_v_b); /* proto */
static PyObject *__pyx_pf_8obitools_5align_8_dynamic_2encodeBase(CYTHON_UNUSED PyObject *__pyx_self, unsigned char __pyx_v_lettre); /* proto */
static PyObject *__pyx_pf_8obitools_5align_8_dynamic_4iupacPartialMatch(CYTHON_UNUSED PyObject *__pyx_self, unsigned char __pyx_v_a, unsigned char __pyx_v_b); /* proto */
static int __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming___init__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self, PyObject *__pyx_v_opengap, PyObject *__pyx_v_extgap); /* proto */
static PyObject *__pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4seqA___get__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self); /* proto */
static int __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4seqA_2__set__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self, PyObject *__pyx_v_seq); /* proto */
static PyObject *__pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4seqB___get__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self); /* proto */
static int __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4seqB_2__set__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self, PyObject *__pyx_v_seq); /* proto */
static PyObject *__pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_7opengap___get__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self); /* proto */
static int __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_7opengap_2__set__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self, PyObject *__pyx_v_opengap); /* proto */
static PyObject *__pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_6extgap___get__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self); /* proto */
static int __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_6extgap_2__set__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self, PyObject *__pyx_v_extgap); /* proto */
static PyObject *__pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_13needToCompute___get__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_5score___get__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self); /* proto */
static void __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_2__dealloc__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4__call__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self); /* proto */
static char __pyx_k_1[] = "Sequence A must be set";
static char __pyx_k_2[] = "Sequence B must be set";
static char __pyx_k_3[] = "\nCreated on 14 sept. 2009\n\n@author: coissac\n";
static char __pyx_k_4[] = "obitools.alignment";
static char __pyx_k__a[] = "a";
static char __pyx_k__b[] = "b";
static char __pyx_k__i[] = "i";
static char __pyx_k__ord[] = "ord";
static char __pyx_k__gaps[] = "gaps";
static char __pyx_k__clone[] = "clone";
static char __pyx_k__lower[] = "lower";
static char __pyx_k__range[] = "range";
static char __pyx_k__score[] = "score";
static char __pyx_k__extgap[] = "extgap";
static char __pyx_k__opengap[] = "opengap";
static char __pyx_k__quality[] = "quality";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__obitools[] = "obitools";
static char __pyx_k__Alignment[] = "Alignment";
static char __pyx_k____basecode[] = "__basecode";
static char __pyx_k__BioSequence[] = "BioSequence";
static char __pyx_k__AlignedSequence[] = "AlignedSequence";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_n_s_4;
static PyObject *__pyx_n_s__AlignedSequence;
static PyObject *__pyx_n_s__Alignment;
static PyObject *__pyx_n_s__BioSequence;
static PyObject *__pyx_n_s____basecode;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_b__a;
static PyObject *__pyx_n_s__a;
static PyObject *__pyx_n_s__b;
static PyObject *__pyx_n_s__clone;
static PyObject *__pyx_n_s__extgap;
static PyObject *__pyx_n_s__gaps;
static PyObject *__pyx_n_s__i;
static PyObject *__pyx_n_s__lower;
static PyObject *__pyx_n_s__obitools;
static PyObject *__pyx_n_s__opengap;
static PyObject *__pyx_n_s__ord;
static PyObject *__pyx_n_s__quality;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__score;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_5;
static PyObject *__pyx_int_6;
static PyObject *__pyx_int_7;
static PyObject *__pyx_int_8;
static PyObject *__pyx_int_9;
static PyObject *__pyx_int_10;
static PyObject *__pyx_int_11;
static PyObject *__pyx_int_12;
static PyObject *__pyx_int_13;
static PyObject *__pyx_int_14;
static PyObject *__pyx_int_15;
static PyObject *__pyx_int_26;
static PyObject *__pyx_k_tuple_5;
static PyObject *__pyx_k_tuple_6;

/* "obitools/align/_dynamic.pyx":22
 * from _dynamic cimport *
 * 
 * cdef AlignMatrix* allocateMatrix(int hsize, int vsize,AlignMatrix *matrix=NULL):             # <<<<<<<<<<<<<<
 * 
 *     vsize+=1
 */

static struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *__pyx_f_8obitools_5align_8_dynamic_allocateMatrix(int __pyx_v_hsize, int __pyx_v_vsize, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateMatrix *__pyx_optional_args) {
  struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *__pyx_v_matrix = ((struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *)NULL);
  struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  void *__pyx_t_2;
  void *__pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("allocateMatrix", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_matrix = __pyx_optional_args->matrix;
    }
  }

  /* "obitools/align/_dynamic.pyx":24
 * cdef AlignMatrix* allocateMatrix(int hsize, int vsize,AlignMatrix *matrix=NULL):
 * 
 *     vsize+=1             # <<<<<<<<<<<<<<
 *     hsize+=1
 * 
 */
  __pyx_v_vsize = (__pyx_v_vsize + 1);

  /* "obitools/align/_dynamic.pyx":25
 * 
 *     vsize+=1
 *     hsize+=1             # <<<<<<<<<<<<<<
 * 
 *     if matrix is NULL:
 */
  __pyx_v_hsize = (__pyx_v_hsize + 1);

  /* "obitools/align/_dynamic.pyx":27
 *     hsize+=1
 * 
 *     if matrix is NULL:             # <<<<<<<<<<<<<<
 *         matrix = <AlignMatrix*>malloc(sizeof(AlignMatrix))
 *         matrix.vsize=0
 */
  __pyx_t_1 = (__pyx_v_matrix == NULL);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":28
 * 
 *     if matrix is NULL:
 *         matrix = <AlignMatrix*>malloc(sizeof(AlignMatrix))             # <<<<<<<<<<<<<<
 *         matrix.vsize=0
 *         matrix.hsize=0
 */
    __pyx_t_2 = malloc((sizeof(struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix))); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_matrix = ((struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *)__pyx_t_2);

    /* "obitools/align/_dynamic.pyx":29
 *     if matrix is NULL:
 *         matrix = <AlignMatrix*>malloc(sizeof(AlignMatrix))
 *         matrix.vsize=0             # <<<<<<<<<<<<<<
 *         matrix.hsize=0
 *         matrix.msize=0
 */
    __pyx_v_matrix->vsize = 0;

    /* "obitools/align/_dynamic.pyx":30
 *         matrix = <AlignMatrix*>malloc(sizeof(AlignMatrix))
 *         matrix.vsize=0
 *         matrix.hsize=0             # <<<<<<<<<<<<<<
 *         matrix.msize=0
 *         matrix.matrix=NULL
 */
    __pyx_v_matrix->hsize = 0;

    /* "obitools/align/_dynamic.pyx":31
 *         matrix.vsize=0
 *         matrix.hsize=0
 *         matrix.msize=0             # <<<<<<<<<<<<<<
 *         matrix.matrix=NULL
 *         matrix.bestVJump=NULL
 */
    __pyx_v_matrix->msize = 0;

    /* "obitools/align/_dynamic.pyx":32
 *         matrix.hsize=0
 *         matrix.msize=0
 *         matrix.matrix=NULL             # <<<<<<<<<<<<<<
 *         matrix.bestVJump=NULL
 *         matrix.bestHJump=NULL
 */
    __pyx_v_matrix->matrix = NULL;

    /* "obitools/align/_dynamic.pyx":33
 *         matrix.msize=0
 *         matrix.matrix=NULL
 *         matrix.bestVJump=NULL             # <<<<<<<<<<<<<<
 *         matrix.bestHJump=NULL
 * 
 */
    __pyx_v_matrix->bestVJump = NULL;

    /* "obitools/align/_dynamic.pyx":34
 *         matrix.matrix=NULL
 *         matrix.bestVJump=NULL
 *         matrix.bestHJump=NULL             # <<<<<<<<<<<<<<
 * 
 *     if hsize > matrix.hsize:
 */
    __pyx_v_matrix->bestHJump = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "obitools/align/_dynamic.pyx":36
 *         matrix.bestHJump=NULL
 * 
 *     if hsize > matrix.hsize:             # <<<<<<<<<<<<<<
 *         matrix.bestVJump = <int*>realloc(matrix.bestVJump,hsize * sizeof(int))
 *         matrix.hsize=hsize
 */
  __pyx_t_1 = (__pyx_v_hsize > __pyx_v_matrix->hsize);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":37
 * 
 *     if hsize > matrix.hsize:
 *         matrix.bestVJump = <int*>realloc(matrix.bestVJump,hsize * sizeof(int))             # <<<<<<<<<<<<<<
 *         matrix.hsize=hsize
 * 
 */
    __pyx_t_3 = realloc(__pyx_v_matrix->bestVJump, (__pyx_v_hsize * (sizeof(int)))); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_matrix->bestVJump = ((int *)__pyx_t_3);

    /* "obitools/align/_dynamic.pyx":38
 *     if hsize > matrix.hsize:
 *         matrix.bestVJump = <int*>realloc(matrix.bestVJump,hsize * sizeof(int))
 *         matrix.hsize=hsize             # <<<<<<<<<<<<<<
 * 
 *     if vsize > matrix.vsize:
 */
    __pyx_v_matrix->hsize = __pyx_v_hsize;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "obitools/align/_dynamic.pyx":40
 *         matrix.hsize=hsize
 * 
 *     if vsize > matrix.vsize:             # <<<<<<<<<<<<<<
 *         matrix.bestHJump = <int*>realloc(matrix.bestHJump,vsize * sizeof(int))
 *         matrix.vsize=vsize
 */
  __pyx_t_1 = (__pyx_v_vsize > __pyx_v_matrix->vsize);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":41
 * 
 *     if vsize > matrix.vsize:
 *         matrix.bestHJump = <int*>realloc(matrix.bestHJump,vsize * sizeof(int))             # <<<<<<<<<<<<<<
 *         matrix.vsize=vsize
 * 
 */
    __pyx_t_3 = realloc(__pyx_v_matrix->bestHJump, (__pyx_v_vsize * (sizeof(int)))); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_matrix->bestHJump = ((int *)__pyx_t_3);

    /* "obitools/align/_dynamic.pyx":42
 *     if vsize > matrix.vsize:
 *         matrix.bestHJump = <int*>realloc(matrix.bestHJump,vsize * sizeof(int))
 *         matrix.vsize=vsize             # <<<<<<<<<<<<<<
 * 
 *     if (hsize * vsize) > matrix.msize:
 */
    __pyx_v_matrix->vsize = __pyx_v_vsize;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "obitools/align/_dynamic.pyx":44
 *         matrix.vsize=vsize
 * 
 *     if (hsize * vsize) > matrix.msize:             # <<<<<<<<<<<<<<
 *         matrix.msize = hsize * vsize
 *         matrix.matrix = <AlignCell*>realloc(matrix.matrix, matrix.msize * sizeof(AlignCell))
 */
  __pyx_t_1 = ((__pyx_v_hsize * __pyx_v_vsize) > __pyx_v_matrix->msize);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":45
 * 
 *     if (hsize * vsize) > matrix.msize:
 *         matrix.msize = hsize * vsize             # <<<<<<<<<<<<<<
 *         matrix.matrix = <AlignCell*>realloc(matrix.matrix, matrix.msize * sizeof(AlignCell))
 * 
 */
    __pyx_v_matrix->msize = (__pyx_v_hsize * __pyx_v_vsize);

    /* "obitools/align/_dynamic.pyx":46
 *     if (hsize * vsize) > matrix.msize:
 *         matrix.msize = hsize * vsize
 *         matrix.matrix = <AlignCell*>realloc(matrix.matrix, matrix.msize * sizeof(AlignCell))             # <<<<<<<<<<<<<<
 * 
 *     return matrix
 */
    __pyx_t_3 = realloc(__pyx_v_matrix->matrix, (__pyx_v_matrix->msize * (sizeof(struct __pyx_t_8obitools_5align_8_dynamic_AlignCell)))); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_matrix->matrix = ((struct __pyx_t_8obitools_5align_8_dynamic_AlignCell *)__pyx_t_3);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "obitools/align/_dynamic.pyx":48
 *         matrix.matrix = <AlignCell*>realloc(matrix.matrix, matrix.msize * sizeof(AlignCell))
 * 
 *     return matrix             # <<<<<<<<<<<<<<
 * 
 * cdef void freeMatrix(AlignMatrix* matrix):
 */
  __pyx_r = __pyx_v_matrix;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("obitools.align._dynamic.allocateMatrix", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":50
 *     return matrix
 * 
 * cdef void freeMatrix(AlignMatrix* matrix):             # <<<<<<<<<<<<<<
 *     if matrix is not NULL:
 *         if matrix.matrix is not NULL:
 */

static void __pyx_f_8obitools_5align_8_dynamic_freeMatrix(struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *__pyx_v_matrix) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("freeMatrix", 0);

  /* "obitools/align/_dynamic.pyx":51
 * 
 * cdef void freeMatrix(AlignMatrix* matrix):
 *     if matrix is not NULL:             # <<<<<<<<<<<<<<
 *         if matrix.matrix is not NULL:
 *             free(matrix.matrix)
 */
  __pyx_t_1 = (__pyx_v_matrix != NULL);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":52
 * cdef void freeMatrix(AlignMatrix* matrix):
 *     if matrix is not NULL:
 *         if matrix.matrix is not NULL:             # <<<<<<<<<<<<<<
 *             free(matrix.matrix)
 *         if matrix.bestVJump is not NULL:
 */
    __pyx_t_1 = (__pyx_v_matrix->matrix != NULL);
    if (__pyx_t_1) {

      /* "obitools/align/_dynamic.pyx":53
 *     if matrix is not NULL:
 *         if matrix.matrix is not NULL:
 *             free(matrix.matrix)             # <<<<<<<<<<<<<<
 *         if matrix.bestVJump is not NULL:
 *             free(matrix.bestVJump)
 */
      free(__pyx_v_matrix->matrix);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "obitools/align/_dynamic.pyx":54
 *         if matrix.matrix is not NULL:
 *             free(matrix.matrix)
 *         if matrix.bestVJump is not NULL:             # <<<<<<<<<<<<<<
 *             free(matrix.bestVJump)
 *         if matrix.bestHJump is not NULL:
 */
    __pyx_t_1 = (__pyx_v_matrix->bestVJump != NULL);
    if (__pyx_t_1) {

      /* "obitools/align/_dynamic.pyx":55
 *             free(matrix.matrix)
 *         if matrix.bestVJump is not NULL:
 *             free(matrix.bestVJump)             # <<<<<<<<<<<<<<
 *         if matrix.bestHJump is not NULL:
 *             free(matrix.bestHJump)
 */
      free(__pyx_v_matrix->bestVJump);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "obitools/align/_dynamic.pyx":56
 *         if matrix.bestVJump is not NULL:
 *             free(matrix.bestVJump)
 *         if matrix.bestHJump is not NULL:             # <<<<<<<<<<<<<<
 *             free(matrix.bestHJump)
 *         free(matrix)
 */
    __pyx_t_1 = (__pyx_v_matrix->bestHJump != NULL);
    if (__pyx_t_1) {

      /* "obitools/align/_dynamic.pyx":57
 *             free(matrix.bestVJump)
 *         if matrix.bestHJump is not NULL:
 *             free(matrix.bestHJump)             # <<<<<<<<<<<<<<
 *         free(matrix)
 * 
 */
      free(__pyx_v_matrix->bestHJump);
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "obitools/align/_dynamic.pyx":58
 *         if matrix.bestHJump is not NULL:
 *             free(matrix.bestHJump)
 *         free(matrix)             # <<<<<<<<<<<<<<
 * 
 * cdef void resetMatrix(AlignMatrix* matrix):
 */
    free(__pyx_v_matrix);
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* "obitools/align/_dynamic.pyx":60
 *         free(matrix)
 * 
 * cdef void resetMatrix(AlignMatrix* matrix):             # <<<<<<<<<<<<<<
 *     if matrix is not NULL:
 *         if matrix.matrix is not NULL:
 */

static void __pyx_f_8obitools_5align_8_dynamic_resetMatrix(struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *__pyx_v_matrix) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("resetMatrix", 0);

  /* "obitools/align/_dynamic.pyx":61
 * 
 * cdef void resetMatrix(AlignMatrix* matrix):
 *     if matrix is not NULL:             # <<<<<<<<<<<<<<
 *         if matrix.matrix is not NULL:
 *             bzero(<void*>matrix.matrix, matrix.msize * sizeof(AlignCell))
 */
  __pyx_t_1 = (__pyx_v_matrix != NULL);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":62
 * cdef void resetMatrix(AlignMatrix* matrix):
 *     if matrix is not NULL:
 *         if matrix.matrix is not NULL:             # <<<<<<<<<<<<<<
 *             bzero(<void*>matrix.matrix, matrix.msize * sizeof(AlignCell))
 *         if matrix.bestHJump is not NULL:
 */
    __pyx_t_1 = (__pyx_v_matrix->matrix != NULL);
    if (__pyx_t_1) {

      /* "obitools/align/_dynamic.pyx":63
 *     if matrix is not NULL:
 *         if matrix.matrix is not NULL:
 *             bzero(<void*>matrix.matrix, matrix.msize * sizeof(AlignCell))             # <<<<<<<<<<<<<<
 *         if matrix.bestHJump is not NULL:
 *             memset(<void*>matrix.bestHJump,255,matrix.vsize * sizeof(int))
 */
      bzero(((void *)__pyx_v_matrix->matrix), (__pyx_v_matrix->msize * (sizeof(struct __pyx_t_8obitools_5align_8_dynamic_AlignCell))));
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "obitools/align/_dynamic.pyx":64
 *         if matrix.matrix is not NULL:
 *             bzero(<void*>matrix.matrix, matrix.msize * sizeof(AlignCell))
 *         if matrix.bestHJump is not NULL:             # <<<<<<<<<<<<<<
 *             memset(<void*>matrix.bestHJump,255,matrix.vsize * sizeof(int))
 *         if matrix.bestVJump is not NULL:
 */
    __pyx_t_1 = (__pyx_v_matrix->bestHJump != NULL);
    if (__pyx_t_1) {

      /* "obitools/align/_dynamic.pyx":65
 *             bzero(<void*>matrix.matrix, matrix.msize * sizeof(AlignCell))
 *         if matrix.bestHJump is not NULL:
 *             memset(<void*>matrix.bestHJump,255,matrix.vsize * sizeof(int))             # <<<<<<<<<<<<<<
 *         if matrix.bestVJump is not NULL:
 *             memset(<void*>matrix.bestVJump,255,matrix.hsize * sizeof(int))
 */
      memset(((void *)__pyx_v_matrix->bestHJump), 255, (__pyx_v_matrix->vsize * (sizeof(int))));
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "obitools/align/_dynamic.pyx":66
 *         if matrix.bestHJump is not NULL:
 *             memset(<void*>matrix.bestHJump,255,matrix.vsize * sizeof(int))
 *         if matrix.bestVJump is not NULL:             # <<<<<<<<<<<<<<
 *             memset(<void*>matrix.bestVJump,255,matrix.hsize * sizeof(int))
 * 
 */
    __pyx_t_1 = (__pyx_v_matrix->bestVJump != NULL);
    if (__pyx_t_1) {

      /* "obitools/align/_dynamic.pyx":67
 *             memset(<void*>matrix.bestHJump,255,matrix.vsize * sizeof(int))
 *         if matrix.bestVJump is not NULL:
 *             memset(<void*>matrix.bestVJump,255,matrix.hsize * sizeof(int))             # <<<<<<<<<<<<<<
 * 
 * 
 */
      memset(((void *)__pyx_v_matrix->bestVJump), 255, (__pyx_v_matrix->hsize * (sizeof(int))));
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* "obitools/align/_dynamic.pyx":70
 * 
 * 
 * cdef alignSequence* allocateSequence(object bioseq, alignSequence* seq=NULL) except *:             # <<<<<<<<<<<<<<
 *     cdef bytes strseq
 *     cdef int i
 */

static struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *__pyx_f_8obitools_5align_8_dynamic_allocateSequence(PyObject *__pyx_v_bioseq, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence *__pyx_optional_args) {
  struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *__pyx_v_seq = ((struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *)NULL);
  PyObject *__pyx_v_strseq = 0;
  int __pyx_v_i;
  PyObject *__pyx_v_quality = NULL;
  struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  void *__pyx_t_2;
  Py_ssize_t __pyx_t_3;
  void *__pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  char *__pyx_t_7;
  long __pyx_t_8;
  int __pyx_t_9;
  double __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("allocateSequence", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_seq = __pyx_optional_args->seq;
    }
  }

  /* "obitools/align/_dynamic.pyx":74
 *     cdef int i
 * 
 *     if seq is NULL:             # <<<<<<<<<<<<<<
 *         seq = <alignSequence*>malloc(sizeof(alignSequence))
 *         seq.length=0
 */
  __pyx_t_1 = (__pyx_v_seq == NULL);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":75
 * 
 *     if seq is NULL:
 *         seq = <alignSequence*>malloc(sizeof(alignSequence))             # <<<<<<<<<<<<<<
 *         seq.length=0
 *         seq.buffsize=0
 */
    __pyx_t_2 = malloc((sizeof(struct __pyx_t_8obitools_5align_8_dynamic_alignSequence))); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_seq = ((struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *)__pyx_t_2);

    /* "obitools/align/_dynamic.pyx":76
 *     if seq is NULL:
 *         seq = <alignSequence*>malloc(sizeof(alignSequence))
 *         seq.length=0             # <<<<<<<<<<<<<<
 *         seq.buffsize=0
 *         seq.sequence=NULL
 */
    __pyx_v_seq->length = 0;

    /* "obitools/align/_dynamic.pyx":77
 *         seq = <alignSequence*>malloc(sizeof(alignSequence))
 *         seq.length=0
 *         seq.buffsize=0             # <<<<<<<<<<<<<<
 *         seq.sequence=NULL
 *         seq.quality=NULL
 */
    __pyx_v_seq->buffsize = 0;

    /* "obitools/align/_dynamic.pyx":78
 *         seq.length=0
 *         seq.buffsize=0
 *         seq.sequence=NULL             # <<<<<<<<<<<<<<
 *         seq.quality=NULL
 *         seq.hasQuality=False
 */
    __pyx_v_seq->sequence = NULL;

    /* "obitools/align/_dynamic.pyx":79
 *         seq.buffsize=0
 *         seq.sequence=NULL
 *         seq.quality=NULL             # <<<<<<<<<<<<<<
 *         seq.hasQuality=False
 * 
 */
    __pyx_v_seq->quality = NULL;

    /* "obitools/align/_dynamic.pyx":80
 *         seq.sequence=NULL
 *         seq.quality=NULL
 *         seq.hasQuality=False             # <<<<<<<<<<<<<<
 * 
 *     seq.length=len(bioseq)
 */
    __pyx_v_seq->hasQuality = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "obitools/align/_dynamic.pyx":82
 *         seq.hasQuality=False
 * 
 *     seq.length=len(bioseq)             # <<<<<<<<<<<<<<
 *     if seq.length > seq.buffsize:
 *         seq.sequence = <char*>realloc(seq.sequence,sizeof(char)*seq.length)
 */
  __pyx_t_3 = PyObject_Length(__pyx_v_bioseq); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_seq->length = __pyx_t_3;

  /* "obitools/align/_dynamic.pyx":83
 * 
 *     seq.length=len(bioseq)
 *     if seq.length > seq.buffsize:             # <<<<<<<<<<<<<<
 *         seq.sequence = <char*>realloc(seq.sequence,sizeof(char)*seq.length)
 *         seq.quality  = <double*>realloc(seq.quality,sizeof(double)*seq.length)
 */
  __pyx_t_1 = (__pyx_v_seq->length > __pyx_v_seq->buffsize);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":84
 *     seq.length=len(bioseq)
 *     if seq.length > seq.buffsize:
 *         seq.sequence = <char*>realloc(seq.sequence,sizeof(char)*seq.length)             # <<<<<<<<<<<<<<
 *         seq.quality  = <double*>realloc(seq.quality,sizeof(double)*seq.length)
 *         seq.buffsize = seq.length
 */
    __pyx_t_4 = realloc(__pyx_v_seq->sequence, ((sizeof(char)) * __pyx_v_seq->length)); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_seq->sequence = ((char *)__pyx_t_4);

    /* "obitools/align/_dynamic.pyx":85
 *     if seq.length > seq.buffsize:
 *         seq.sequence = <char*>realloc(seq.sequence,sizeof(char)*seq.length)
 *         seq.quality  = <double*>realloc(seq.quality,sizeof(double)*seq.length)             # <<<<<<<<<<<<<<
 *         seq.buffsize = seq.length
 * 
 */
    __pyx_t_4 = realloc(__pyx_v_seq->quality, ((sizeof(double)) * __pyx_v_seq->length)); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_seq->quality = ((double *)__pyx_t_4);

    /* "obitools/align/_dynamic.pyx":86
 *         seq.sequence = <char*>realloc(seq.sequence,sizeof(char)*seq.length)
 *         seq.quality  = <double*>realloc(seq.quality,sizeof(double)*seq.length)
 *         seq.buffsize = seq.length             # <<<<<<<<<<<<<<
 * 
 *     strseq = str(bioseq).lower()
 */
    __pyx_v_seq->buffsize = __pyx_v_seq->length;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "obitools/align/_dynamic.pyx":88
 *         seq.buffsize = seq.length
 * 
 *     strseq = str(bioseq).lower()             # <<<<<<<<<<<<<<
 *     memcpy(seq.sequence,<char*>strseq,seq.length)
 * 
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_bioseq);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_bioseq);
  __Pyx_GIVEREF(__pyx_v_bioseq);
  __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__lower); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __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 = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(PyBytes_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_strseq = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "obitools/align/_dynamic.pyx":89
 * 
 *     strseq = str(bioseq).lower()
 *     memcpy(seq.sequence,<char*>strseq,seq.length)             # <<<<<<<<<<<<<<
 * 
 *     if 'quality' in bioseq:
 */
  __pyx_t_7 = PyBytes_AsString(((PyObject *)__pyx_v_strseq)); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  memcpy(__pyx_v_seq->sequence, ((char *)__pyx_t_7), __pyx_v_seq->length);

  /* "obitools/align/_dynamic.pyx":91
 *     memcpy(seq.sequence,<char*>strseq,seq.length)
 * 
 *     if 'quality' in bioseq:             # <<<<<<<<<<<<<<
 *         seq.hasQuality=True
 *         quality=bioseq['quality']
 */
  __pyx_t_1 = ((PySequence_Contains(__pyx_v_bioseq, ((PyObject *)__pyx_n_s__quality)))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":92
 * 
 *     if 'quality' in bioseq:
 *         seq.hasQuality=True             # <<<<<<<<<<<<<<
 *         quality=bioseq['quality']
 *         for i in range(0,seq.length):
 */
    __pyx_v_seq->hasQuality = 1;

    /* "obitools/align/_dynamic.pyx":93
 *     if 'quality' in bioseq:
 *         seq.hasQuality=True
 *         quality=bioseq['quality']             # <<<<<<<<<<<<<<
 *         for i in range(0,seq.length):
 *             seq.quality[i]=<double>quality[i]
 */
    __pyx_t_6 = PyObject_GetItem(__pyx_v_bioseq, ((PyObject *)__pyx_n_s__quality)); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_quality = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "obitools/align/_dynamic.pyx":94
 *         seq.hasQuality=True
 *         quality=bioseq['quality']
 *         for i in range(0,seq.length):             # <<<<<<<<<<<<<<
 *             seq.quality[i]=<double>quality[i]
 * 
 */
    __pyx_t_8 = __pyx_v_seq->length;
    for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
      __pyx_v_i = __pyx_t_9;

      /* "obitools/align/_dynamic.pyx":95
 *         quality=bioseq['quality']
 *         for i in range(0,seq.length):
 *             seq.quality[i]=<double>quality[i]             # <<<<<<<<<<<<<<
 * 
 *     return seq
 */
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_quality, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      (__pyx_v_seq->quality[__pyx_v_i]) = ((double)__pyx_t_10);
    }
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "obitools/align/_dynamic.pyx":97
 *             seq.quality[i]=<double>quality[i]
 * 
 *     return seq             # <<<<<<<<<<<<<<
 * 
 * cdef void freeSequence(alignSequence* seq):
 */
  __pyx_r = __pyx_v_seq;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("obitools.align._dynamic.allocateSequence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_strseq);
  __Pyx_XDECREF(__pyx_v_quality);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":99
 *     return seq
 * 
 * cdef void freeSequence(alignSequence* seq):             # <<<<<<<<<<<<<<
 *     if seq is not NULL:
 *         if seq.sequence is not NULL:
 */

static void __pyx_f_8obitools_5align_8_dynamic_freeSequence(struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *__pyx_v_seq) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("freeSequence", 0);

  /* "obitools/align/_dynamic.pyx":100
 * 
 * cdef void freeSequence(alignSequence* seq):
 *     if seq is not NULL:             # <<<<<<<<<<<<<<
 *         if seq.sequence is not NULL:
 *             free(<void*>seq.sequence)
 */
  __pyx_t_1 = (__pyx_v_seq != NULL);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":101
 * cdef void freeSequence(alignSequence* seq):
 *     if seq is not NULL:
 *         if seq.sequence is not NULL:             # <<<<<<<<<<<<<<
 *             free(<void*>seq.sequence)
 *         if seq.quality is not NULL:
 */
    __pyx_t_1 = (__pyx_v_seq->sequence != NULL);
    if (__pyx_t_1) {

      /* "obitools/align/_dynamic.pyx":102
 *     if seq is not NULL:
 *         if seq.sequence is not NULL:
 *             free(<void*>seq.sequence)             # <<<<<<<<<<<<<<
 *         if seq.quality is not NULL:
 *             free(<void*>seq.quality)
 */
      free(((void *)__pyx_v_seq->sequence));
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "obitools/align/_dynamic.pyx":103
 *         if seq.sequence is not NULL:
 *             free(<void*>seq.sequence)
 *         if seq.quality is not NULL:             # <<<<<<<<<<<<<<
 *             free(<void*>seq.quality)
 *         free(seq)
 */
    __pyx_t_1 = (__pyx_v_seq->quality != NULL);
    if (__pyx_t_1) {

      /* "obitools/align/_dynamic.pyx":104
 *             free(<void*>seq.sequence)
 *         if seq.quality is not NULL:
 *             free(<void*>seq.quality)             # <<<<<<<<<<<<<<
 *         free(seq)
 * 
 */
      free(((void *)__pyx_v_seq->quality));
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "obitools/align/_dynamic.pyx":105
 *         if seq.quality is not NULL:
 *             free(<void*>seq.quality)
 *         free(seq)             # <<<<<<<<<<<<<<
 * 
 * cdef alignPath* allocatePath(long l1,long l2,alignPath* path=NULL):
 */
    free(__pyx_v_seq);
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* "obitools/align/_dynamic.pyx":107
 *         free(seq)
 * 
 * cdef alignPath* allocatePath(long l1,long l2,alignPath* path=NULL):             # <<<<<<<<<<<<<<
 *     cdef long length=l1+l2
 * 
 */

static struct __pyx_t_8obitools_5align_8_dynamic_alignPath *__pyx_f_8obitools_5align_8_dynamic_allocatePath(long __pyx_v_l1, long __pyx_v_l2, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath *__pyx_optional_args) {
  struct __pyx_t_8obitools_5align_8_dynamic_alignPath *__pyx_v_path = ((struct __pyx_t_8obitools_5align_8_dynamic_alignPath *)NULL);
  long __pyx_v_length;
  struct __pyx_t_8obitools_5align_8_dynamic_alignPath *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  void *__pyx_t_2;
  void *__pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("allocatePath", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_path = __pyx_optional_args->path;
    }
  }

  /* "obitools/align/_dynamic.pyx":108
 * 
 * cdef alignPath* allocatePath(long l1,long l2,alignPath* path=NULL):
 *     cdef long length=l1+l2             # <<<<<<<<<<<<<<
 * 
 *     if path is NULL:
 */
  __pyx_v_length = (__pyx_v_l1 + __pyx_v_l2);

  /* "obitools/align/_dynamic.pyx":110
 *     cdef long length=l1+l2
 * 
 *     if path is NULL:             # <<<<<<<<<<<<<<
 *         path = <alignPath*>malloc(sizeof(alignPath))
 *         path.length=0
 */
  __pyx_t_1 = (__pyx_v_path == NULL);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":111
 * 
 *     if path is NULL:
 *         path = <alignPath*>malloc(sizeof(alignPath))             # <<<<<<<<<<<<<<
 *         path.length=0
 *         path.buffsize=0
 */
    __pyx_t_2 = malloc((sizeof(struct __pyx_t_8obitools_5align_8_dynamic_alignPath))); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_path = ((struct __pyx_t_8obitools_5align_8_dynamic_alignPath *)__pyx_t_2);

    /* "obitools/align/_dynamic.pyx":112
 *     if path is NULL:
 *         path = <alignPath*>malloc(sizeof(alignPath))
 *         path.length=0             # <<<<<<<<<<<<<<
 *         path.buffsize=0
 *         path.path=NULL
 */
    __pyx_v_path->length = 0;

    /* "obitools/align/_dynamic.pyx":113
 *         path = <alignPath*>malloc(sizeof(alignPath))
 *         path.length=0
 *         path.buffsize=0             # <<<<<<<<<<<<<<
 *         path.path=NULL
 * 
 */
    __pyx_v_path->buffsize = 0;

    /* "obitools/align/_dynamic.pyx":114
 *         path.length=0
 *         path.buffsize=0
 *         path.path=NULL             # <<<<<<<<<<<<<<
 * 
 *     if length > path.buffsize:
 */
    __pyx_v_path->path = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "obitools/align/_dynamic.pyx":116
 *         path.path=NULL
 * 
 *     if length > path.buffsize:             # <<<<<<<<<<<<<<
 *         path.buffsize=length
 *         path.path=<long*>realloc(path.path,sizeof(long)*length)
 */
  __pyx_t_1 = (__pyx_v_length > __pyx_v_path->buffsize);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":117
 * 
 *     if length > path.buffsize:
 *         path.buffsize=length             # <<<<<<<<<<<<<<
 *         path.path=<long*>realloc(path.path,sizeof(long)*length)
 * 
 */
    __pyx_v_path->buffsize = __pyx_v_length;

    /* "obitools/align/_dynamic.pyx":118
 *     if length > path.buffsize:
 *         path.buffsize=length
 *         path.path=<long*>realloc(path.path,sizeof(long)*length)             # <<<<<<<<<<<<<<
 * 
 *     path.length=0
 */
    __pyx_t_3 = realloc(__pyx_v_path->path, ((sizeof(long)) * __pyx_v_length)); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_path->path = ((long *)__pyx_t_3);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "obitools/align/_dynamic.pyx":120
 *         path.path=<long*>realloc(path.path,sizeof(long)*length)
 * 
 *     path.length=0             # <<<<<<<<<<<<<<
 *     path.vStart=0
 *     path.hStart=0
 */
  __pyx_v_path->length = 0;

  /* "obitools/align/_dynamic.pyx":121
 * 
 *     path.length=0
 *     path.vStart=0             # <<<<<<<<<<<<<<
 *     path.hStart=0
 * 
 */
  __pyx_v_path->vStart = 0;

  /* "obitools/align/_dynamic.pyx":122
 *     path.length=0
 *     path.vStart=0
 *     path.hStart=0             # <<<<<<<<<<<<<<
 * 
 *     return path
 */
  __pyx_v_path->hStart = 0;

  /* "obitools/align/_dynamic.pyx":124
 *     path.hStart=0
 * 
 *     return path             # <<<<<<<<<<<<<<
 * 
 * cdef void reversePath(alignPath* path):
 */
  __pyx_r = __pyx_v_path;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("obitools.align._dynamic.allocatePath", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":126
 *     return path
 * 
 * cdef void reversePath(alignPath* path):             # <<<<<<<<<<<<<<
 *         cdef long i
 *         cdef long j
 */

static void __pyx_f_8obitools_5align_8_dynamic_reversePath(struct __pyx_t_8obitools_5align_8_dynamic_alignPath *__pyx_v_path) {
  long __pyx_v_i;
  long __pyx_v_j;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  long __pyx_t_2;
  long __pyx_t_3;
  long __pyx_t_4;
  __Pyx_RefNannySetupContext("reversePath", 0);

  /* "obitools/align/_dynamic.pyx":130
 *         cdef long j
 * 
 *         j=path.length             # <<<<<<<<<<<<<<
 *         for i in range(path.length/2):
 *             j-=1
 */
  __pyx_v_j = __pyx_v_path->length;

  /* "obitools/align/_dynamic.pyx":131
 * 
 *         j=path.length
 *         for i in range(path.length/2):             # <<<<<<<<<<<<<<
 *             j-=1
 *             path.path[i],path.path[j]=path.path[j],path.path[i]
 */
  __pyx_t_1 = __Pyx_div_long(__pyx_v_path->length, 2);
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "obitools/align/_dynamic.pyx":132
 *         j=path.length
 *         for i in range(path.length/2):
 *             j-=1             # <<<<<<<<<<<<<<
 *             path.path[i],path.path[j]=path.path[j],path.path[i]
 * 
 */
    __pyx_v_j = (__pyx_v_j - 1);

    /* "obitools/align/_dynamic.pyx":133
 *         for i in range(path.length/2):
 *             j-=1
 *             path.path[i],path.path[j]=path.path[j],path.path[i]             # <<<<<<<<<<<<<<
 * 
 * cdef void freePath(alignPath* path):
 */
    __pyx_t_3 = (__pyx_v_path->path[__pyx_v_j]);
    __pyx_t_4 = (__pyx_v_path->path[__pyx_v_i]);
    (__pyx_v_path->path[__pyx_v_i]) = __pyx_t_3;
    (__pyx_v_path->path[__pyx_v_j]) = __pyx_t_4;
  }

  __Pyx_RefNannyFinishContext();
}

/* "obitools/align/_dynamic.pyx":135
 *             path.path[i],path.path[j]=path.path[j],path.path[i]
 * 
 * cdef void freePath(alignPath* path):             # <<<<<<<<<<<<<<
 *     if path is not NULL:
 *         if path.path is not NULL:
 */

static void __pyx_f_8obitools_5align_8_dynamic_freePath(struct __pyx_t_8obitools_5align_8_dynamic_alignPath *__pyx_v_path) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("freePath", 0);

  /* "obitools/align/_dynamic.pyx":136
 * 
 * cdef void freePath(alignPath* path):
 *     if path is not NULL:             # <<<<<<<<<<<<<<
 *         if path.path is not NULL:
 *             free(<void*>path.path)
 */
  __pyx_t_1 = (__pyx_v_path != NULL);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":137
 * cdef void freePath(alignPath* path):
 *     if path is not NULL:
 *         if path.path is not NULL:             # <<<<<<<<<<<<<<
 *             free(<void*>path.path)
 *         free(<void*>path)
 */
    __pyx_t_1 = (__pyx_v_path->path != NULL);
    if (__pyx_t_1) {

      /* "obitools/align/_dynamic.pyx":138
 *     if path is not NULL:
 *         if path.path is not NULL:
 *             free(<void*>path.path)             # <<<<<<<<<<<<<<
 *         free(<void*>path)
 * 
 */
      free(((void *)__pyx_v_path->path));
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "obitools/align/_dynamic.pyx":139
 *         if path.path is not NULL:
 *             free(<void*>path.path)
 *         free(<void*>path)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    free(((void *)__pyx_v_path));
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* "obitools/align/_dynamic.pyx":145
 * cdef int _basecode[26]
 * 
 * cdef int bitCount(int x):             # <<<<<<<<<<<<<<
 *     cdef int i=0
 *     while(x):
 */

static int __pyx_f_8obitools_5align_8_dynamic_bitCount(int __pyx_v_x) {
  int __pyx_v_i;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bitCount", 0);

  /* "obitools/align/_dynamic.pyx":146
 * 
 * cdef int bitCount(int x):
 *     cdef int i=0             # <<<<<<<<<<<<<<
 *     while(x):
 *         i+=1
 */
  __pyx_v_i = 0;

  /* "obitools/align/_dynamic.pyx":147
 * cdef int bitCount(int x):
 *     cdef int i=0
 *     while(x):             # <<<<<<<<<<<<<<
 *         i+=1
 *         x&=x-1
 */
  while (1) {
    if (!__pyx_v_x) break;

    /* "obitools/align/_dynamic.pyx":148
 *     cdef int i=0
 *     while(x):
 *         i+=1             # <<<<<<<<<<<<<<
 *         x&=x-1
 *     return i
 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "obitools/align/_dynamic.pyx":149
 *     while(x):
 *         i+=1
 *         x&=x-1             # <<<<<<<<<<<<<<
 *     return i
 * 
 */
    __pyx_v_x = (__pyx_v_x & (__pyx_v_x - 1));
  }

  /* "obitools/align/_dynamic.pyx":150
 *         i+=1
 *         x&=x-1
 *     return i             # <<<<<<<<<<<<<<
 * 
 * cpdef bint iupacMatch(unsigned char a, unsigned char b):
 */
  __pyx_r = __pyx_v_i;
  goto __pyx_L0;

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

/* "obitools/align/_dynamic.pyx":152
 *     return i
 * 
 * cpdef bint iupacMatch(unsigned char a, unsigned char b):             # <<<<<<<<<<<<<<
 *     cdef bint m
 * 
 */

static PyObject *__pyx_pw_8obitools_5align_8_dynamic_1iupacMatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_8obitools_5align_8_dynamic_iupacMatch(unsigned char __pyx_v_a, unsigned char __pyx_v_b, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_m;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("iupacMatch", 0);

  /* "obitools/align/_dynamic.pyx":155
 *     cdef bint m
 * 
 *     if a==42:    # * ascii code             # <<<<<<<<<<<<<<
 *         a=110    # n ascii code
 * 
 */
  __pyx_t_1 = (__pyx_v_a == 42);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":156
 * 
 *     if a==42:    # * ascii code
 *         a=110    # n ascii code             # <<<<<<<<<<<<<<
 * 
 *     if b==42:    # * ascii code
 */
    __pyx_v_a = 110;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "obitools/align/_dynamic.pyx":158
 *         a=110    # n ascii code
 * 
 *     if b==42:    # * ascii code             # <<<<<<<<<<<<<<
 *         b=110    # n ascii code
 * 
 */
  __pyx_t_1 = (__pyx_v_b == 42);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":159
 * 
 *     if b==42:    # * ascii code
 *         b=110    # n ascii code             # <<<<<<<<<<<<<<
 * 
 *     m = _basecode[a - aascii] & _basecode[b - aascii]
 */
    __pyx_v_b = 110;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "obitools/align/_dynamic.pyx":161
 *         b=110    # n ascii code
 * 
 *     m = _basecode[a - aascii] & _basecode[b - aascii]             # <<<<<<<<<<<<<<
 *     return m
 * 
 */
  __pyx_v_m = ((__pyx_v_8obitools_5align_8_dynamic__basecode[(__pyx_v_a - __pyx_v_8obitools_5align_8_dynamic_aascii)]) & (__pyx_v_8obitools_5align_8_dynamic__basecode[(__pyx_v_b - __pyx_v_8obitools_5align_8_dynamic_aascii)]));

  /* "obitools/align/_dynamic.pyx":162
 * 
 *     m = _basecode[a - aascii] & _basecode[b - aascii]
 *     return m             # <<<<<<<<<<<<<<
 * 
 * cpdef unsigned char encodeBase(unsigned char lettre):
 */
  __pyx_r = __pyx_v_m;
  goto __pyx_L0;

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

/* Python wrapper */
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_1iupacMatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_1iupacMatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  unsigned char __pyx_v_a;
  unsigned char __pyx_v_b;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__a,&__pyx_n_s__b,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iupacMatch (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__a);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__b);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iupacMatch", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "iupacMatch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = __Pyx_PyInt_AsUnsignedChar(values[0]); if (unlikely((__pyx_v_a == (unsigned char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_b = __Pyx_PyInt_AsUnsignedChar(values[1]); if (unlikely((__pyx_v_b == (unsigned char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iupacMatch", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("obitools.align._dynamic.iupacMatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_iupacMatch(__pyx_self, __pyx_v_a, __pyx_v_b);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":152
 *     return i
 * 
 * cpdef bint iupacMatch(unsigned char a, unsigned char b):             # <<<<<<<<<<<<<<
 *     cdef bint m
 * 
 */

static PyObject *__pyx_pf_8obitools_5align_8_dynamic_iupacMatch(CYTHON_UNUSED PyObject *__pyx_self, unsigned char __pyx_v_a, unsigned char __pyx_v_b) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iupacMatch", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_8obitools_5align_8_dynamic_iupacMatch(__pyx_v_a, __pyx_v_b, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("obitools.align._dynamic.iupacMatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":164
 *     return m
 * 
 * cpdef unsigned char encodeBase(unsigned char lettre):             # <<<<<<<<<<<<<<
 *     return _basecode[lettre - aascii]
 * 
 */

static PyObject *__pyx_pw_8obitools_5align_8_dynamic_3encodeBase(PyObject *__pyx_self, PyObject *__pyx_arg_lettre); /*proto*/
static unsigned char __pyx_f_8obitools_5align_8_dynamic_encodeBase(unsigned char __pyx_v_lettre, CYTHON_UNUSED int __pyx_skip_dispatch) {
  unsigned char __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("encodeBase", 0);

  /* "obitools/align/_dynamic.pyx":165
 * 
 * cpdef unsigned char encodeBase(unsigned char lettre):
 *     return _basecode[lettre - aascii]             # <<<<<<<<<<<<<<
 * 
 * cpdef double iupacPartialMatch(unsigned char a, unsigned char b):
 */
  __pyx_r = (__pyx_v_8obitools_5align_8_dynamic__basecode[(__pyx_v_lettre - __pyx_v_8obitools_5align_8_dynamic_aascii)]);
  goto __pyx_L0;

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

/* Python wrapper */
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_3encodeBase(PyObject *__pyx_self, PyObject *__pyx_arg_lettre); /*proto*/
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_3encodeBase(PyObject *__pyx_self, PyObject *__pyx_arg_lettre) {
  unsigned char __pyx_v_lettre;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("encodeBase (wrapper)", 0);
  __pyx_self = __pyx_self;
  assert(__pyx_arg_lettre); {
    __pyx_v_lettre = __Pyx_PyInt_AsUnsignedChar(__pyx_arg_lettre); if (unlikely((__pyx_v_lettre == (unsigned char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("obitools.align._dynamic.encodeBase", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_2encodeBase(__pyx_self, ((unsigned char)__pyx_v_lettre));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":164
 *     return m
 * 
 * cpdef unsigned char encodeBase(unsigned char lettre):             # <<<<<<<<<<<<<<
 *     return _basecode[lettre - aascii]
 * 
 */

static PyObject *__pyx_pf_8obitools_5align_8_dynamic_2encodeBase(CYTHON_UNUSED PyObject *__pyx_self, unsigned char __pyx_v_lettre) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encodeBase", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_f_8obitools_5align_8_dynamic_encodeBase(__pyx_v_lettre, 0)); 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_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("obitools.align._dynamic.encodeBase", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":167
 *     return _basecode[lettre - aascii]
 * 
 * cpdef double iupacPartialMatch(unsigned char a, unsigned char b):             # <<<<<<<<<<<<<<
 *     cdef int codeA
 *     cdef int codeB
 */

static PyObject *__pyx_pw_8obitools_5align_8_dynamic_5iupacPartialMatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static double __pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch(unsigned char __pyx_v_a, unsigned char __pyx_v_b, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_codeA;
  int __pyx_v_codeB;
  int __pyx_v_good;
  int __pyx_v_all;
  double __pyx_v_partial;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iupacPartialMatch", 0);

  /* "obitools/align/_dynamic.pyx":174
 *     cdef double partial
 * 
 *     if a==42:    # * ascii code             # <<<<<<<<<<<<<<
 *         a=110    # n ascii code
 * 
 */
  __pyx_t_1 = (__pyx_v_a == 42);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":175
 * 
 *     if a==42:    # * ascii code
 *         a=110    # n ascii code             # <<<<<<<<<<<<<<
 * 
 *     if b==42:    # * ascii code
 */
    __pyx_v_a = 110;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "obitools/align/_dynamic.pyx":177
 *         a=110    # n ascii code
 * 
 *     if b==42:    # * ascii code             # <<<<<<<<<<<<<<
 *         b=110    # n ascii code
 * 
 */
  __pyx_t_1 = (__pyx_v_b == 42);
  if (__pyx_t_1) {

    /* "obitools/align/_dynamic.pyx":178
 * 
 *     if b==42:    # * ascii code
 *         b=110    # n ascii code             # <<<<<<<<<<<<<<
 * 
 *     codeA =  _basecode[a - aascii]
 */
    __pyx_v_b = 110;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "obitools/align/_dynamic.pyx":180
 *         b=110    # n ascii code
 * 
 *     codeA =  _basecode[a - aascii]             # <<<<<<<<<<<<<<
 *     codeB =  _basecode[b - aascii]
 *     good  =  bitCount(codeA & codeB)
 */
  __pyx_v_codeA = (__pyx_v_8obitools_5align_8_dynamic__basecode[(__pyx_v_a - __pyx_v_8obitools_5align_8_dynamic_aascii)]);

  /* "obitools/align/_dynamic.pyx":181
 * 
 *     codeA =  _basecode[a - aascii]
 *     codeB =  _basecode[b - aascii]             # <<<<<<<<<<<<<<
 *     good  =  bitCount(codeA & codeB)
 *     all   =  bitCount(codeA)  * bitCount(codeB)
 */
  __pyx_v_codeB = (__pyx_v_8obitools_5align_8_dynamic__basecode[(__pyx_v_b - __pyx_v_8obitools_5align_8_dynamic_aascii)]);

  /* "obitools/align/_dynamic.pyx":182
 *     codeA =  _basecode[a - aascii]
 *     codeB =  _basecode[b - aascii]
 *     good  =  bitCount(codeA & codeB)             # <<<<<<<<<<<<<<
 *     all   =  bitCount(codeA)  * bitCount(codeB)
 *     partial= <double>good / all
 */
  __pyx_v_good = __pyx_f_8obitools_5align_8_dynamic_bitCount((__pyx_v_codeA & __pyx_v_codeB));

  /* "obitools/align/_dynamic.pyx":183
 *     codeB =  _basecode[b - aascii]
 *     good  =  bitCount(codeA & codeB)
 *     all   =  bitCount(codeA)  * bitCount(codeB)             # <<<<<<<<<<<<<<
 *     partial= <double>good / all
 * 
 */
  __pyx_v_all = (__pyx_f_8obitools_5align_8_dynamic_bitCount(__pyx_v_codeA) * __pyx_f_8obitools_5align_8_dynamic_bitCount(__pyx_v_codeB));

  /* "obitools/align/_dynamic.pyx":184
 *     good  =  bitCount(codeA & codeB)
 *     all   =  bitCount(codeA)  * bitCount(codeB)
 *     partial= <double>good / all             # <<<<<<<<<<<<<<
 * 
 *     return partial
 */
  if (unlikely(__pyx_v_all == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_partial = (((double)__pyx_v_good) / __pyx_v_all);

  /* "obitools/align/_dynamic.pyx":186
 *     partial= <double>good / all
 * 
 *     return partial             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_partial;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("obitools.align._dynamic.iupacPartialMatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_5iupacPartialMatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_5iupacPartialMatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  unsigned char __pyx_v_a;
  unsigned char __pyx_v_b;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__a,&__pyx_n_s__b,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iupacPartialMatch (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__a);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__b);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iupacPartialMatch", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "iupacPartialMatch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = __Pyx_PyInt_AsUnsignedChar(values[0]); if (unlikely((__pyx_v_a == (unsigned char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_b = __Pyx_PyInt_AsUnsignedChar(values[1]); if (unlikely((__pyx_v_b == (unsigned char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iupacPartialMatch", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("obitools.align._dynamic.iupacPartialMatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_4iupacPartialMatch(__pyx_self, __pyx_v_a, __pyx_v_b);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":167
 *     return _basecode[lettre - aascii]
 * 
 * cpdef double iupacPartialMatch(unsigned char a, unsigned char b):             # <<<<<<<<<<<<<<
 *     cdef int codeA
 *     cdef int codeB
 */

static PyObject *__pyx_pf_8obitools_5align_8_dynamic_4iupacPartialMatch(CYTHON_UNUSED PyObject *__pyx_self, unsigned char __pyx_v_a, unsigned char __pyx_v_b) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iupacPartialMatch", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch(__pyx_v_a, __pyx_v_b, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("obitools.align._dynamic.iupacPartialMatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_opengap = 0;
  PyObject *__pyx_v_extgap = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__opengap,&__pyx_n_s__extgap,0};
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__opengap);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__extgap);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __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_opengap = values[0];
    __pyx_v_extgap = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("obitools.align._dynamic.DynamicProgramming.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming___init__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_opengap, __pyx_v_extgap);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":191
 * cdef class DynamicProgramming:
 * 
 *     def __init__(self,opengap,extgap):             # <<<<<<<<<<<<<<
 *         self.sequenceChanged=True
 *         self.scoreChanged=True
 */

static int __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming___init__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self, PyObject *__pyx_v_opengap, PyObject *__pyx_v_extgap) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "obitools/align/_dynamic.pyx":192
 * 
 *     def __init__(self,opengap,extgap):
 *         self.sequenceChanged=True             # <<<<<<<<<<<<<<
 *         self.scoreChanged=True
 * 
 */
  __pyx_v_self->sequenceChanged = 1;

  /* "obitools/align/_dynamic.pyx":193
 *     def __init__(self,opengap,extgap):
 *         self.sequenceChanged=True
 *         self.scoreChanged=True             # <<<<<<<<<<<<<<
 * 
 *         self.matrix=NULL
 */
  __pyx_v_self->scoreChanged = 1;

  /* "obitools/align/_dynamic.pyx":195
 *         self.scoreChanged=True
 * 
 *         self.matrix=NULL             # <<<<<<<<<<<<<<
 *         self.hSeq=NULL
 *         self.vSeq=NULL
 */
  __pyx_v_self->matrix = NULL;

  /* "obitools/align/_dynamic.pyx":196
 * 
 *         self.matrix=NULL
 *         self.hSeq=NULL             # <<<<<<<<<<<<<<
 *         self.vSeq=NULL
 *         self.path=NULL
 */
  __pyx_v_self->hSeq = NULL;

  /* "obitools/align/_dynamic.pyx":197
 *         self.matrix=NULL
 *         self.hSeq=NULL
 *         self.vSeq=NULL             # <<<<<<<<<<<<<<
 *         self.path=NULL
 * 
 */
  __pyx_v_self->vSeq = NULL;

  /* "obitools/align/_dynamic.pyx":198
 *         self.hSeq=NULL
 *         self.vSeq=NULL
 *         self.path=NULL             # <<<<<<<<<<<<<<
 * 
 *         self.horizontalSeq=None
 */
  __pyx_v_self->path = NULL;

  /* "obitools/align/_dynamic.pyx":200
 *         self.path=NULL
 * 
 *         self.horizontalSeq=None             # <<<<<<<<<<<<<<
 *         self.verticalSeq=None
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->horizontalSeq);
  __Pyx_DECREF(__pyx_v_self->horizontalSeq);
  __pyx_v_self->horizontalSeq = Py_None;

  /* "obitools/align/_dynamic.pyx":201
 * 
 *         self.horizontalSeq=None
 *         self.verticalSeq=None             # <<<<<<<<<<<<<<
 * 
 *         self._opengap=opengap
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->verticalSeq);
  __Pyx_DECREF(__pyx_v_self->verticalSeq);
  __pyx_v_self->verticalSeq = Py_None;

  /* "obitools/align/_dynamic.pyx":203
 *         self.verticalSeq=None
 * 
 *         self._opengap=opengap             # <<<<<<<<<<<<<<
 *         self._extgap=extgap
 * 
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_opengap); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_opengap = __pyx_t_1;

  /* "obitools/align/_dynamic.pyx":204
 * 
 *         self._opengap=opengap
 *         self._extgap=extgap             # <<<<<<<<<<<<<<
 * 
 *     cdef int _vlen(self):
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_extgap); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_extgap = __pyx_t_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("obitools.align._dynamic.DynamicProgramming.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":206
 *         self._extgap=extgap
 * 
 *     cdef int _vlen(self):             # <<<<<<<<<<<<<<
 *         return self.vSeq.length
 * 
 */

static int __pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming__vlen(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_vlen", 0);

  /* "obitools/align/_dynamic.pyx":207
 * 
 *     cdef int _vlen(self):
 *         return self.vSeq.length             # <<<<<<<<<<<<<<
 * 
 *     cdef int _hlen(self):
 */
  __pyx_r = __pyx_v_self->vSeq->length;
  goto __pyx_L0;

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

/* "obitools/align/_dynamic.pyx":209
 *         return self.vSeq.length
 * 
 *     cdef int _hlen(self):             # <<<<<<<<<<<<<<
 *         return self.hSeq.length
 * 
 */

static int __pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming__hlen(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_hlen", 0);

  /* "obitools/align/_dynamic.pyx":210
 * 
 *     cdef int _hlen(self):
 *         return self.hSeq.length             # <<<<<<<<<<<<<<
 * 
 *     cdef int allocate(self) except -1:
 */
  __pyx_r = __pyx_v_self->hSeq->length;
  goto __pyx_L0;

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

/* "obitools/align/_dynamic.pyx":212
 *         return self.hSeq.length
 * 
 *     cdef int allocate(self) except -1:             # <<<<<<<<<<<<<<
 * 
 *         assert self.horizontalSeq is not None,'Sequence A must be set'
 */

static int __pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming_allocate(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  long __pyx_v_lenH;
  long __pyx_v_lenV;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *__pyx_t_2;
  struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateMatrix __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("allocate", 0);

  /* "obitools/align/_dynamic.pyx":214
 *     cdef int allocate(self) except -1:
 * 
 *         assert self.horizontalSeq is not None,'Sequence A must be set'             # <<<<<<<<<<<<<<
 *         assert self.verticalSeq is not None,'Sequence B must be set'
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = (__pyx_v_self->horizontalSeq != Py_None);
  if (unlikely(!__pyx_t_1)) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_1));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "obitools/align/_dynamic.pyx":215
 * 
 *         assert self.horizontalSeq is not None,'Sequence A must be set'
 *         assert self.verticalSeq is not None,'Sequence B must be set'             # <<<<<<<<<<<<<<
 * 
 *         cdef long lenH=self._hlen()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = (__pyx_v_self->verticalSeq != Py_None);
  if (unlikely(!__pyx_t_1)) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_2));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "obitools/align/_dynamic.pyx":217
 *         assert self.verticalSeq is not None,'Sequence B must be set'
 * 
 *         cdef long lenH=self._hlen()             # <<<<<<<<<<<<<<
 *         cdef long lenV=self._vlen()
 * 
 */
  __pyx_v_lenH = ((struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self->__pyx_vtab)->_hlen(__pyx_v_self);

  /* "obitools/align/_dynamic.pyx":218
 * 
 *         cdef long lenH=self._hlen()
 *         cdef long lenV=self._vlen()             # <<<<<<<<<<<<<<
 * 
 *         self.matrix=allocateMatrix(lenH,lenV,self.matrix)
 */
  __pyx_v_lenV = ((struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self->__pyx_vtab)->_vlen(__pyx_v_self);

  /* "obitools/align/_dynamic.pyx":220
 *         cdef long lenV=self._vlen()
 * 
 *         self.matrix=allocateMatrix(lenH,lenV,self.matrix)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  __pyx_t_3.__pyx_n = 1;
  __pyx_t_3.matrix = __pyx_v_self->matrix;
  __pyx_t_2 = __pyx_f_8obitools_5align_8_dynamic_allocateMatrix(__pyx_v_lenH, __pyx_v_lenV, &__pyx_t_3); 
  __pyx_v_self->matrix = __pyx_t_2;

  /* "obitools/align/_dynamic.pyx":221
 * 
 *         self.matrix=allocateMatrix(lenH,lenV,self.matrix)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("obitools.align._dynamic.DynamicProgramming.allocate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":224
 * 
 * 
 *     cdef double doAlignment(self) except? 0:             # <<<<<<<<<<<<<<
 *         pass
 * 
 */

static double __pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming_doAlignment(CYTHON_UNUSED struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("doAlignment", 0);

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

/* "obitools/align/_dynamic.pyx":227
 *         pass
 * 
 *     cdef bint _needToCompute(self):             # <<<<<<<<<<<<<<
 *         return self.scoreChanged or self.sequenceChanged
 * 
 */

static int __pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming__needToCompute(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_needToCompute", 0);

  /* "obitools/align/_dynamic.pyx":228
 * 
 *     cdef bint _needToCompute(self):
 *         return self.scoreChanged or self.sequenceChanged             # <<<<<<<<<<<<<<
 * 
 *     cdef void backtrack(self):
 */
  if (!__pyx_v_self->scoreChanged) {
    __pyx_t_1 = __pyx_v_self->sequenceChanged;
  } else {
    __pyx_t_1 = __pyx_v_self->scoreChanged;
  }
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

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

/* "obitools/align/_dynamic.pyx":230
 *         return self.scoreChanged or self.sequenceChanged
 * 
 *     cdef void backtrack(self):             # <<<<<<<<<<<<<<
 *         pass
 * 
 */

static void __pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming_backtrack(CYTHON_UNUSED struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("backtrack", 0);

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_4seqA_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_4seqA_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4seqA___get__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":234
 * 
 *     property seqA:
 *             def __get__(self):             # <<<<<<<<<<<<<<
 *                 return self.horizontalSeq
 * 
 */

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

  /* "obitools/align/_dynamic.pyx":235
 *     property seqA:
 *             def __get__(self):
 *                 return self.horizontalSeq             # <<<<<<<<<<<<<<
 * 
 *             def __set__(self, seq):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->horizontalSeq);
  __pyx_r = __pyx_v_self->horizontalSeq;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_4seqA_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_seq); /*proto*/
static int __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_4seqA_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_seq) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4seqA_2__set__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), ((PyObject *)__pyx_v_seq));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":237
 *                 return self.horizontalSeq
 * 
 *             def __set__(self, seq):             # <<<<<<<<<<<<<<
 *                 self.sequenceChanged=True
 *                 self.horizontalSeq=seq
 */

static int __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4seqA_2__set__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self, PyObject *__pyx_v_seq) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *__pyx_t_2;
  struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "obitools/align/_dynamic.pyx":238
 * 
 *             def __set__(self, seq):
 *                 self.sequenceChanged=True             # <<<<<<<<<<<<<<
 *                 self.horizontalSeq=seq
 *                 self.hSeq=allocateSequence(self.horizontalSeq,self.hSeq)
 */
  __pyx_v_self->sequenceChanged = 1;

  /* "obitools/align/_dynamic.pyx":239
 *             def __set__(self, seq):
 *                 self.sequenceChanged=True
 *                 self.horizontalSeq=seq             # <<<<<<<<<<<<<<
 *                 self.hSeq=allocateSequence(self.horizontalSeq,self.hSeq)
 * 
 */
  __Pyx_INCREF(__pyx_v_seq);
  __Pyx_GIVEREF(__pyx_v_seq);
  __Pyx_GOTREF(__pyx_v_self->horizontalSeq);
  __Pyx_DECREF(__pyx_v_self->horizontalSeq);
  __pyx_v_self->horizontalSeq = __pyx_v_seq;

  /* "obitools/align/_dynamic.pyx":240
 *                 self.sequenceChanged=True
 *                 self.horizontalSeq=seq
 *                 self.hSeq=allocateSequence(self.horizontalSeq,self.hSeq)             # <<<<<<<<<<<<<<
 * 
 *     property seqB:
 */
  __pyx_t_1 = __pyx_v_self->horizontalSeq;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3.__pyx_n = 1;
  __pyx_t_3.seq = __pyx_v_self->hSeq;
  __pyx_t_2 = __pyx_f_8obitools_5align_8_dynamic_allocateSequence(__pyx_t_1, &__pyx_t_3); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->hSeq = __pyx_t_2;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("obitools.align._dynamic.DynamicProgramming.seqA.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_4seqB_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_4seqB_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4seqB___get__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":243
 * 
 *     property seqB:
 *             def __get__(self):             # <<<<<<<<<<<<<<
 *                 return self.verticalSeq
 * 
 */

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

  /* "obitools/align/_dynamic.pyx":244
 *     property seqB:
 *             def __get__(self):
 *                 return self.verticalSeq             # <<<<<<<<<<<<<<
 * 
 *             def __set__(self, seq):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->verticalSeq);
  __pyx_r = __pyx_v_self->verticalSeq;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_4seqB_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_seq); /*proto*/
static int __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_4seqB_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_seq) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4seqB_2__set__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), ((PyObject *)__pyx_v_seq));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":246
 *                 return self.verticalSeq
 * 
 *             def __set__(self, seq):             # <<<<<<<<<<<<<<
 *                 self.sequenceChanged=True
 *                 self.verticalSeq=seq
 */

static int __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4seqB_2__set__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self, PyObject *__pyx_v_seq) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *__pyx_t_2;
  struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "obitools/align/_dynamic.pyx":247
 * 
 *             def __set__(self, seq):
 *                 self.sequenceChanged=True             # <<<<<<<<<<<<<<
 *                 self.verticalSeq=seq
 *                 self.vSeq=allocateSequence(self.verticalSeq,self.vSeq)
 */
  __pyx_v_self->sequenceChanged = 1;

  /* "obitools/align/_dynamic.pyx":248
 *             def __set__(self, seq):
 *                 self.sequenceChanged=True
 *                 self.verticalSeq=seq             # <<<<<<<<<<<<<<
 *                 self.vSeq=allocateSequence(self.verticalSeq,self.vSeq)
 * 
 */
  __Pyx_INCREF(__pyx_v_seq);
  __Pyx_GIVEREF(__pyx_v_seq);
  __Pyx_GOTREF(__pyx_v_self->verticalSeq);
  __Pyx_DECREF(__pyx_v_self->verticalSeq);
  __pyx_v_self->verticalSeq = __pyx_v_seq;

  /* "obitools/align/_dynamic.pyx":249
 *                 self.sequenceChanged=True
 *                 self.verticalSeq=seq
 *                 self.vSeq=allocateSequence(self.verticalSeq,self.vSeq)             # <<<<<<<<<<<<<<
 * 
 *     property opengap:
 */
  __pyx_t_1 = __pyx_v_self->verticalSeq;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3.__pyx_n = 1;
  __pyx_t_3.seq = __pyx_v_self->vSeq;
  __pyx_t_2 = __pyx_f_8obitools_5align_8_dynamic_allocateSequence(__pyx_t_1, &__pyx_t_3); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->vSeq = __pyx_t_2;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("obitools.align._dynamic.DynamicProgramming.seqB.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_7opengap_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_7opengap_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_7opengap___get__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":252
 * 
 *     property opengap:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._opengap
 * 
 */

static PyObject *__pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_7opengap___get__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "obitools/align/_dynamic.pyx":253
 *     property opengap:
 *         def __get__(self):
 *             return self._opengap             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self,opengap):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->_opengap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("obitools.align._dynamic.DynamicProgramming.opengap.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_7opengap_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_opengap); /*proto*/
static int __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_7opengap_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_opengap) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_7opengap_2__set__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), ((PyObject *)__pyx_v_opengap));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":255
 *             return self._opengap
 * 
 *         def __set__(self,opengap):             # <<<<<<<<<<<<<<
 *             self._opengap=opengap
 *             self.scoreChanged=True
 */

static int __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_7opengap_2__set__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self, PyObject *__pyx_v_opengap) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "obitools/align/_dynamic.pyx":256
 * 
 *         def __set__(self,opengap):
 *             self._opengap=opengap             # <<<<<<<<<<<<<<
 *             self.scoreChanged=True
 * 
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_opengap); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_opengap = __pyx_t_1;

  /* "obitools/align/_dynamic.pyx":257
 *         def __set__(self,opengap):
 *             self._opengap=opengap
 *             self.scoreChanged=True             # <<<<<<<<<<<<<<
 * 
 *     property extgap:
 */
  __pyx_v_self->scoreChanged = 1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("obitools.align._dynamic.DynamicProgramming.opengap.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_6extgap_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_6extgap_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_6extgap___get__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":260
 * 
 *     property extgap:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._extgap
 * 
 */

static PyObject *__pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_6extgap___get__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "obitools/align/_dynamic.pyx":261
 *     property extgap:
 *         def __get__(self):
 *             return self._extgap             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self,extgap):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->_extgap); 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_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("obitools.align._dynamic.DynamicProgramming.extgap.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_6extgap_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_extgap); /*proto*/
static int __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_6extgap_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_extgap) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_6extgap_2__set__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), ((PyObject *)__pyx_v_extgap));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":263
 *             return self._extgap
 * 
 *         def __set__(self,extgap):             # <<<<<<<<<<<<<<
 *             self._extgap=extgap
 *             self.scoreChanged=True
 */

static int __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_6extgap_2__set__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self, PyObject *__pyx_v_extgap) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "obitools/align/_dynamic.pyx":264
 * 
 *         def __set__(self,extgap):
 *             self._extgap=extgap             # <<<<<<<<<<<<<<
 *             self.scoreChanged=True
 * 
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_extgap); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_extgap = __pyx_t_1;

  /* "obitools/align/_dynamic.pyx":265
 *         def __set__(self,extgap):
 *             self._extgap=extgap
 *             self.scoreChanged=True             # <<<<<<<<<<<<<<
 * 
 *     property needToCompute:
 */
  __pyx_v_self->scoreChanged = 1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("obitools.align._dynamic.DynamicProgramming.extgap.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_13needToCompute_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_13needToCompute_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_13needToCompute___get__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":268
 * 
 *     property needToCompute:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.scoreChanged or self.sequenceChanged
 * 
 */

static PyObject *__pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_13needToCompute___get__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "obitools/align/_dynamic.pyx":269
 *     property needToCompute:
 *         def __get__(self):
 *             return self.scoreChanged or self.sequenceChanged             # <<<<<<<<<<<<<<
 * 
 *     property score:
 */
  __Pyx_XDECREF(__pyx_r);
  if (!__pyx_v_self->scoreChanged) {
    __pyx_t_1 = __pyx_v_self->sequenceChanged;
  } else {
    __pyx_t_1 = __pyx_v_self->scoreChanged;
  }
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("obitools.align._dynamic.DynamicProgramming.needToCompute.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_5score_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_5score_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_5score___get__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":272
 * 
 *     property score:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.doAlignment()
 * 
 */

static PyObject *__pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_5score___get__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "obitools/align/_dynamic.pyx":273
 *     property score:
 *         def __get__(self):
 *             return self.doAlignment()             # <<<<<<<<<<<<<<
 * 
 *     cdef void reset(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self->__pyx_vtab)->doAlignment(__pyx_v_self); if (unlikely(__pyx_t_1 == 0.0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("obitools.align._dynamic.DynamicProgramming.score.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":275
 *             return self.doAlignment()
 * 
 *     cdef void reset(self):             # <<<<<<<<<<<<<<
 *         self.scoreChanged=True
 *         resetMatrix(self.matrix)
 */

static void __pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming_reset(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset", 0);

  /* "obitools/align/_dynamic.pyx":276
 * 
 *     cdef void reset(self):
 *         self.scoreChanged=True             # <<<<<<<<<<<<<<
 *         resetMatrix(self.matrix)
 * 
 */
  __pyx_v_self->scoreChanged = 1;

  /* "obitools/align/_dynamic.pyx":277
 *     cdef void reset(self):
 *         self.scoreChanged=True
 *         resetMatrix(self.matrix)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int index(self, int x, int y):
 */
  __pyx_f_8obitools_5align_8_dynamic_resetMatrix(__pyx_v_self->matrix);

  __Pyx_RefNannyFinishContext();
}

/* "obitools/align/_dynamic.pyx":279
 *         resetMatrix(self.matrix)
 * 
 *     cdef inline int index(self, int x, int y):             # <<<<<<<<<<<<<<
 *         return (self._hlen()+1) * y + x
 * 
 */

static CYTHON_INLINE int __pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming_index(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self, int __pyx_v_x, int __pyx_v_y) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("index", 0);

  /* "obitools/align/_dynamic.pyx":280
 * 
 *     cdef inline int index(self, int x, int y):
 *         return (self._hlen()+1) * y + x             # <<<<<<<<<<<<<<
 * 
 *     cdef void clean(self):
 */
  __pyx_r = (((((struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self->__pyx_vtab)->_hlen(__pyx_v_self) + 1) * __pyx_v_y) + __pyx_v_x);
  goto __pyx_L0;

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

/* "obitools/align/_dynamic.pyx":282
 *         return (self._hlen()+1) * y + x
 * 
 *     cdef void clean(self):             # <<<<<<<<<<<<<<
 *         freeMatrix(self.matrix)
 *         freeSequence(self.hSeq)
 */

static void __pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming_clean(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clean", 0);

  /* "obitools/align/_dynamic.pyx":283
 * 
 *     cdef void clean(self):
 *         freeMatrix(self.matrix)             # <<<<<<<<<<<<<<
 *         freeSequence(self.hSeq)
 *         freeSequence(self.vSeq)
 */
  __pyx_f_8obitools_5align_8_dynamic_freeMatrix(__pyx_v_self->matrix);

  /* "obitools/align/_dynamic.pyx":284
 *     cdef void clean(self):
 *         freeMatrix(self.matrix)
 *         freeSequence(self.hSeq)             # <<<<<<<<<<<<<<
 *         freeSequence(self.vSeq)
 *         freePath(self.path)
 */
  __pyx_f_8obitools_5align_8_dynamic_freeSequence(__pyx_v_self->hSeq);

  /* "obitools/align/_dynamic.pyx":285
 *         freeMatrix(self.matrix)
 *         freeSequence(self.hSeq)
 *         freeSequence(self.vSeq)             # <<<<<<<<<<<<<<
 *         freePath(self.path)
 * 
 */
  __pyx_f_8obitools_5align_8_dynamic_freeSequence(__pyx_v_self->vSeq);

  /* "obitools/align/_dynamic.pyx":286
 *         freeSequence(self.hSeq)
 *         freeSequence(self.vSeq)
 *         freePath(self.path)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_f_8obitools_5align_8_dynamic_freePath(__pyx_v_self->path);

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static void __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_2__dealloc__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "obitools/align/_dynamic.pyx":288
 *         freePath(self.path)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         self.clean()
 * 
 */

static void __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_2__dealloc__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "obitools/align/_dynamic.pyx":289
 * 
 *     def __dealloc__(self):
 *         self.clean()             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self):
 */
  ((struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self->__pyx_vtab)->clean(__pyx_v_self);

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_5__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_5__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__call__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return NULL;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__call__", 0))) return NULL;
  __pyx_r = __pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4__call__(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_dynamic.pyx":291
 *         self.clean()
 * 
 *     def __call__(self):             # <<<<<<<<<<<<<<
 *         cdef list hgaps=[]
 *         cdef list vgaps=[]
 */

static PyObject *__pyx_pf_8obitools_5align_8_dynamic_18DynamicProgramming_4__call__(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_v_self) {
  PyObject *__pyx_v_hgaps = 0;
  PyObject *__pyx_v_vgaps = 0;
  int __pyx_v_hp;
  int __pyx_v_vp;
  int __pyx_v_lenh;
  int __pyx_v_lenv;
  int __pyx_v_p;
  int __pyx_v_i;
  PyObject *__pyx_v_ali = 0;
  double __pyx_v_score;
  PyObject *__pyx_v_hseq = NULL;
  PyObject *__pyx_v_vseq = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  double __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "obitools/align/_dynamic.pyx":292
 * 
 *     def __call__(self):
 *         cdef list hgaps=[]             # <<<<<<<<<<<<<<
 *         cdef list vgaps=[]
 *         cdef list b
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_hgaps = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "obitools/align/_dynamic.pyx":293
 *     def __call__(self):
 *         cdef list hgaps=[]
 *         cdef list vgaps=[]             # <<<<<<<<<<<<<<
 *         cdef list b
 *         cdef int  hp=0
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_vgaps = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "obitools/align/_dynamic.pyx":295
 *         cdef list vgaps=[]
 *         cdef list b
 *         cdef int  hp=0             # <<<<<<<<<<<<<<
 *         cdef int  vp=0
 *         cdef int  lenh=0
 */
  __pyx_v_hp = 0;

  /* "obitools/align/_dynamic.pyx":296
 *         cdef list b
 *         cdef int  hp=0
 *         cdef int  vp=0             # <<<<<<<<<<<<<<
 *         cdef int  lenh=0
 *         cdef int  lenv=0
 */
  __pyx_v_vp = 0;

  /* "obitools/align/_dynamic.pyx":297
 *         cdef int  hp=0
 *         cdef int  vp=0
 *         cdef int  lenh=0             # <<<<<<<<<<<<<<
 *         cdef int  lenv=0
 *         cdef int  h,v,p
 */
  __pyx_v_lenh = 0;

  /* "obitools/align/_dynamic.pyx":298
 *         cdef int  vp=0
 *         cdef int  lenh=0
 *         cdef int  lenv=0             # <<<<<<<<<<<<<<
 *         cdef int  h,v,p
 *         cdef int  i
 */
  __pyx_v_lenv = 0;

  /* "obitools/align/_dynamic.pyx":304
 *         cdef double score
 * 
 *         if self._needToCompute():             # <<<<<<<<<<<<<<
 *             score = self.doAlignment()
 *             self.backtrack()
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self->__pyx_vtab)->_needToCompute(__pyx_v_self);
  if (__pyx_t_2) {

    /* "obitools/align/_dynamic.pyx":305
 * 
 *         if self._needToCompute():
 *             score = self.doAlignment()             # <<<<<<<<<<<<<<
 *             self.backtrack()
 *             for i in range(self.path.length-1,-1,-1):
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self->__pyx_vtab)->doAlignment(__pyx_v_self); if (unlikely(__pyx_t_3 == 0.0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_score = __pyx_t_3;

    /* "obitools/align/_dynamic.pyx":306
 *         if self._needToCompute():
 *             score = self.doAlignment()
 *             self.backtrack()             # <<<<<<<<<<<<<<
 *             for i in range(self.path.length-1,-1,-1):
 *                 p=self.path.path[i]
 */
    ((struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self->__pyx_vtab)->backtrack(__pyx_v_self);

    /* "obitools/align/_dynamic.pyx":307
 *             score = self.doAlignment()
 *             self.backtrack()
 *             for i in range(self.path.length-1,-1,-1):             # <<<<<<<<<<<<<<
 *                 p=self.path.path[i]
 *                 if p==0:
 */
    for (__pyx_t_4 = (__pyx_v_self->path->length - 1); __pyx_t_4 > -1; __pyx_t_4-=1) {
      __pyx_v_i = __pyx_t_4;

      /* "obitools/align/_dynamic.pyx":308
 *             self.backtrack()
 *             for i in range(self.path.length-1,-1,-1):
 *                 p=self.path.path[i]             # <<<<<<<<<<<<<<
 *                 if p==0:
 *                     hp+=1
 */
      __pyx_v_p = (__pyx_v_self->path->path[__pyx_v_i]);

      /* "obitools/align/_dynamic.pyx":309
 *             for i in range(self.path.length-1,-1,-1):
 *                 p=self.path.path[i]
 *                 if p==0:             # <<<<<<<<<<<<<<
 *                     hp+=1
 *                     vp+=1
 */
      __pyx_t_2 = (__pyx_v_p == 0);
      if (__pyx_t_2) {

        /* "obitools/align/_dynamic.pyx":310
 *                 p=self.path.path[i]
 *                 if p==0:
 *                     hp+=1             # <<<<<<<<<<<<<<
 *                     vp+=1
 *                     lenh+=1
 */
        __pyx_v_hp = (__pyx_v_hp + 1);

        /* "obitools/align/_dynamic.pyx":311
 *                 if p==0:
 *                     hp+=1
 *                     vp+=1             # <<<<<<<<<<<<<<
 *                     lenh+=1
 *                     lenv+=1
 */
        __pyx_v_vp = (__pyx_v_vp + 1);

        /* "obitools/align/_dynamic.pyx":312
 *                     hp+=1
 *                     vp+=1
 *                     lenh+=1             # <<<<<<<<<<<<<<
 *                     lenv+=1
 *                 elif p>0:
 */
        __pyx_v_lenh = (__pyx_v_lenh + 1);

        /* "obitools/align/_dynamic.pyx":313
 *                     vp+=1
 *                     lenh+=1
 *                     lenv+=1             # <<<<<<<<<<<<<<
 *                 elif p>0:
 *                     hp+=p
 */
        __pyx_v_lenv = (__pyx_v_lenv + 1);
        goto __pyx_L6;
      }

      /* "obitools/align/_dynamic.pyx":314
 *                     lenh+=1
 *                     lenv+=1
 *                 elif p>0:             # <<<<<<<<<<<<<<
 *                     hp+=p
 *                     lenh+=p
 */
      __pyx_t_2 = (__pyx_v_p > 0);
      if (__pyx_t_2) {

        /* "obitools/align/_dynamic.pyx":315
 *                     lenv+=1
 *                 elif p>0:
 *                     hp+=p             # <<<<<<<<<<<<<<
 *                     lenh+=p
 *                     vgaps.append([vp,p])
 */
        __pyx_v_hp = (__pyx_v_hp + __pyx_v_p);

        /* "obitools/align/_dynamic.pyx":316
 *                 elif p>0:
 *                     hp+=p
 *                     lenh+=p             # <<<<<<<<<<<<<<
 *                     vgaps.append([vp,p])
 *                     vp=0
 */
        __pyx_v_lenh = (__pyx_v_lenh + __pyx_v_p);

        /* "obitools/align/_dynamic.pyx":317
 *                     hp+=p
 *                     lenh+=p
 *                     vgaps.append([vp,p])             # <<<<<<<<<<<<<<
 *                     vp=0
 *                 else:
 */
        __pyx_t_1 = PyInt_FromLong(__pyx_v_vp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = PyInt_FromLong(__pyx_v_p); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        PyList_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_1 = 0;
        __pyx_t_5 = 0;
        __pyx_t_7 = PyList_Append(__pyx_v_vgaps, ((PyObject *)__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

        /* "obitools/align/_dynamic.pyx":318
 *                     lenh+=p
 *                     vgaps.append([vp,p])
 *                     vp=0             # <<<<<<<<<<<<<<
 *                 else:
 *                     vp-=p
 */
        __pyx_v_vp = 0;
        goto __pyx_L6;
      }
      /*else*/ {

        /* "obitools/align/_dynamic.pyx":320
 *                     vp=0
 *                 else:
 *                     vp-=p             # <<<<<<<<<<<<<<
 *                     lenv-=p
 *                     hgaps.append([hp,-p])
 */
        __pyx_v_vp = (__pyx_v_vp - __pyx_v_p);

        /* "obitools/align/_dynamic.pyx":321
 *                 else:
 *                     vp-=p
 *                     lenv-=p             # <<<<<<<<<<<<<<
 *                     hgaps.append([hp,-p])
 *                     hp=0
 */
        __pyx_v_lenv = (__pyx_v_lenv - __pyx_v_p);

        /* "obitools/align/_dynamic.pyx":322
 *                     vp-=p
 *                     lenv-=p
 *                     hgaps.append([hp,-p])             # <<<<<<<<<<<<<<
 *                     hp=0
 * 
 */
        __pyx_t_6 = PyInt_FromLong(__pyx_v_hp); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_5 = PyInt_FromLong((-__pyx_v_p)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = PyList_New(2); 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);
        PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_6 = 0;
        __pyx_t_5 = 0;
        __pyx_t_7 = PyList_Append(__pyx_v_hgaps, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

        /* "obitools/align/_dynamic.pyx":323
 *                     lenv-=p
 *                     hgaps.append([hp,-p])
 *                     hp=0             # <<<<<<<<<<<<<<
 * 
 *             if hp:
 */
        __pyx_v_hp = 0;
      }
      __pyx_L6:;
    }

    /* "obitools/align/_dynamic.pyx":325
 *                     hp=0
 * 
 *             if hp:             # <<<<<<<<<<<<<<
 *                 hgaps.append([hp,0])
 *             if vp:
 */
    if (__pyx_v_hp) {

      /* "obitools/align/_dynamic.pyx":326
 * 
 *             if hp:
 *                 hgaps.append([hp,0])             # <<<<<<<<<<<<<<
 *             if vp:
 *                 vgaps.append([vp,0])
 */
      __pyx_t_1 = PyInt_FromLong(__pyx_v_hp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_int_0);
      PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      __pyx_t_1 = 0;
      __pyx_t_7 = PyList_Append(__pyx_v_hgaps, ((PyObject *)__pyx_t_5)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "obitools/align/_dynamic.pyx":327
 *             if hp:
 *                 hgaps.append([hp,0])
 *             if vp:             # <<<<<<<<<<<<<<
 *                 vgaps.append([vp,0])
 * 
 */
    if (__pyx_v_vp) {

      /* "obitools/align/_dynamic.pyx":328
 *                 hgaps.append([hp,0])
 *             if vp:
 *                 vgaps.append([vp,0])             # <<<<<<<<<<<<<<
 * 
 *             if lenh < self._hlen():
 */
      __pyx_t_5 = PyInt_FromLong(__pyx_v_vp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyList_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);
      PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_int_0);
      PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      __pyx_t_5 = 0;
      __pyx_t_7 = PyList_Append(__pyx_v_vgaps, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "obitools/align/_dynamic.pyx":330
 *                 vgaps.append([vp,0])
 * 
 *             if lenh < self._hlen():             # <<<<<<<<<<<<<<
 *                 hseq=self.horizontalSeq[self.path.hStart:self.path.hStart+lenh]
 *             else:
 */
    __pyx_t_2 = (__pyx_v_lenh < ((struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self->__pyx_vtab)->_hlen(__pyx_v_self));
    if (__pyx_t_2) {

      /* "obitools/align/_dynamic.pyx":331
 * 
 *             if lenh < self._hlen():
 *                 hseq=self.horizontalSeq[self.path.hStart:self.path.hStart+lenh]             # <<<<<<<<<<<<<<
 *             else:
 *                 hseq=self.horizontalSeq
 */
      __pyx_t_1 = __Pyx_PySequence_GetSlice(__pyx_v_self->horizontalSeq, __pyx_v_self->path->hStart, (__pyx_v_self->path->hStart + __pyx_v_lenh)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_hseq = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L9;
    }
    /*else*/ {

      /* "obitools/align/_dynamic.pyx":333
 *                 hseq=self.horizontalSeq[self.path.hStart:self.path.hStart+lenh]
 *             else:
 *                 hseq=self.horizontalSeq             # <<<<<<<<<<<<<<
 * 
 *             hseq=AlignedSequence(hseq)
 */
      __Pyx_INCREF(__pyx_v_self->horizontalSeq);
      __pyx_v_hseq = __pyx_v_self->horizontalSeq;
    }
    __pyx_L9:;

    /* "obitools/align/_dynamic.pyx":335
 *                 hseq=self.horizontalSeq
 * 
 *             hseq=AlignedSequence(hseq)             # <<<<<<<<<<<<<<
 *             hseq.gaps=hgaps
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__AlignedSequence); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_hseq);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_hseq);
    __Pyx_GIVEREF(__pyx_v_hseq);
    __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); 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);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_v_hseq);
    __pyx_v_hseq = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "obitools/align/_dynamic.pyx":336
 * 
 *             hseq=AlignedSequence(hseq)
 *             hseq.gaps=hgaps             # <<<<<<<<<<<<<<
 * 
 *             if lenv < self._vlen():
 */
    if (PyObject_SetAttr(__pyx_v_hseq, __pyx_n_s__gaps, ((PyObject *)__pyx_v_hgaps)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "obitools/align/_dynamic.pyx":338
 *             hseq.gaps=hgaps
 * 
 *             if lenv < self._vlen():             # <<<<<<<<<<<<<<
 *                 vseq=self.verticalSeq[self.path.vStart:self.path.vStart+lenv]
 *             else:
 */
    __pyx_t_2 = (__pyx_v_lenv < ((struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self->__pyx_vtab)->_vlen(__pyx_v_self));
    if (__pyx_t_2) {

      /* "obitools/align/_dynamic.pyx":339
 * 
 *             if lenv < self._vlen():
 *                 vseq=self.verticalSeq[self.path.vStart:self.path.vStart+lenv]             # <<<<<<<<<<<<<<
 *             else:
 *                 vseq=self.verticalSeq
 */
      __pyx_t_6 = __Pyx_PySequence_GetSlice(__pyx_v_self->verticalSeq, __pyx_v_self->path->vStart, (__pyx_v_self->path->vStart + __pyx_v_lenv)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_v_vseq = __pyx_t_6;
      __pyx_t_6 = 0;
      goto __pyx_L10;
    }
    /*else*/ {

      /* "obitools/align/_dynamic.pyx":341
 *                 vseq=self.verticalSeq[self.path.vStart:self.path.vStart+lenv]
 *             else:
 *                 vseq=self.verticalSeq             # <<<<<<<<<<<<<<
 * 
 *             vseq=AlignedSequence(vseq)
 */
      __Pyx_INCREF(__pyx_v_self->verticalSeq);
      __pyx_v_vseq = __pyx_v_self->verticalSeq;
    }
    __pyx_L10:;

    /* "obitools/align/_dynamic.pyx":343
 *                 vseq=self.verticalSeq
 * 
 *             vseq=AlignedSequence(vseq)             # <<<<<<<<<<<<<<
 *             vseq.gaps=vgaps
 * 
 */
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__AlignedSequence); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_vseq);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_vseq);
    __Pyx_GIVEREF(__pyx_v_vseq);
    __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_v_vseq);
    __pyx_v_vseq = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "obitools/align/_dynamic.pyx":344
 * 
 *             vseq=AlignedSequence(vseq)
 *             vseq.gaps=vgaps             # <<<<<<<<<<<<<<
 * 
 *             ali=Alignment()
 */
    if (PyObject_SetAttr(__pyx_v_vseq, __pyx_n_s__gaps, ((PyObject *)__pyx_v_vgaps)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "obitools/align/_dynamic.pyx":346
 *             vseq.gaps=vgaps
 * 
 *             ali=Alignment()             # <<<<<<<<<<<<<<
 *             ali.append(hseq)
 *             ali.append(vseq)
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__Alignment); 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_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_ali = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "obitools/align/_dynamic.pyx":347
 * 
 *             ali=Alignment()
 *             ali.append(hseq)             # <<<<<<<<<<<<<<
 *             ali.append(vseq)
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_ali, __pyx_v_hseq); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "obitools/align/_dynamic.pyx":348
 *             ali=Alignment()
 *             ali.append(hseq)
 *             ali.append(vseq)             # <<<<<<<<<<<<<<
 * 
 *             ali.score=score
 */
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_ali, __pyx_v_vseq); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "obitools/align/_dynamic.pyx":350
 *             ali.append(vseq)
 * 
 *             ali.score=score             # <<<<<<<<<<<<<<
 *             self.alignment=ali
 *         ali=self.alignment.clone()
 */
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_score); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyObject_SetAttr(__pyx_v_ali, __pyx_n_s__score, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "obitools/align/_dynamic.pyx":351
 * 
 *             ali.score=score
 *             self.alignment=ali             # <<<<<<<<<<<<<<
 *         ali=self.alignment.clone()
 *         ali.score=self.alignment.score
 */
    __Pyx_INCREF(__pyx_v_ali);
    __Pyx_GIVEREF(__pyx_v_ali);
    __Pyx_GOTREF(__pyx_v_self->alignment);
    __Pyx_DECREF(__pyx_v_self->alignment);
    __pyx_v_self->alignment = __pyx_v_ali;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "obitools/align/_dynamic.pyx":352
 *             ali.score=score
 *             self.alignment=ali
 *         ali=self.alignment.clone()             # <<<<<<<<<<<<<<
 *         ali.score=self.alignment.score
 *         return ali
 */
  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self->alignment, __pyx_n_s__clone); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_XDECREF(__pyx_v_ali);
  __pyx_v_ali = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "obitools/align/_dynamic.pyx":353
 *             self.alignment=ali
 *         ali=self.alignment.clone()
 *         ali.score=self.alignment.score             # <<<<<<<<<<<<<<
 *         return ali
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->alignment, __pyx_n_s__score); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_v_ali, __pyx_n_s__score, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "obitools/align/_dynamic.pyx":354
 *         ali=self.alignment.clone()
 *         ali.score=self.alignment.score
 *         return ali             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ali);
  __pyx_r = __pyx_v_ali;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("obitools.align._dynamic.DynamicProgramming.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_hgaps);
  __Pyx_XDECREF(__pyx_v_vgaps);
  __Pyx_XDECREF(__pyx_v_ali);
  __Pyx_XDECREF(__pyx_v_hseq);
  __Pyx_XDECREF(__pyx_v_vseq);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming __pyx_vtable_8obitools_5align_8_dynamic_DynamicProgramming;

static PyObject *__pyx_tp_new_8obitools_5align_8_dynamic_DynamicProgramming(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)o);
  p->__pyx_vtab = __pyx_vtabptr_8obitools_5align_8_dynamic_DynamicProgramming;
  p->horizontalSeq = Py_None; Py_INCREF(Py_None);
  p->verticalSeq = Py_None; Py_INCREF(Py_None);
  p->alignment = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_8obitools_5align_8_dynamic_DynamicProgramming(PyObject *o) {
  struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *p = (struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_3__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->horizontalSeq);
  Py_XDECREF(p->verticalSeq);
  Py_XDECREF(p->alignment);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_8obitools_5align_8_dynamic_DynamicProgramming(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *p = (struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)o;
  if (p->horizontalSeq) {
    e = (*v)(p->horizontalSeq, a); if (e) return e;
  }
  if (p->verticalSeq) {
    e = (*v)(p->verticalSeq, a); if (e) return e;
  }
  if (p->alignment) {
    e = (*v)(p->alignment, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_8obitools_5align_8_dynamic_DynamicProgramming(PyObject *o) {
  struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *p = (struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->horizontalSeq);
  p->horizontalSeq = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->verticalSeq);
  p->verticalSeq = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->alignment);
  p->alignment = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_8obitools_5align_8_dynamic_18DynamicProgramming_seqA(PyObject *o, void *x) {
  return __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_4seqA_1__get__(o);
}

static int __pyx_setprop_8obitools_5align_8_dynamic_18DynamicProgramming_seqA(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_4seqA_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_8obitools_5align_8_dynamic_18DynamicProgramming_seqB(PyObject *o, void *x) {
  return __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_4seqB_1__get__(o);
}

static int __pyx_setprop_8obitools_5align_8_dynamic_18DynamicProgramming_seqB(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_4seqB_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_8obitools_5align_8_dynamic_18DynamicProgramming_opengap(PyObject *o, void *x) {
  return __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_7opengap_1__get__(o);
}

static int __pyx_setprop_8obitools_5align_8_dynamic_18DynamicProgramming_opengap(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_7opengap_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_8obitools_5align_8_dynamic_18DynamicProgramming_extgap(PyObject *o, void *x) {
  return __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_6extgap_1__get__(o);
}

static int __pyx_setprop_8obitools_5align_8_dynamic_18DynamicProgramming_extgap(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_6extgap_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_8obitools_5align_8_dynamic_18DynamicProgramming_needToCompute(PyObject *o, void *x) {
  return __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_13needToCompute_1__get__(o);
}

static PyObject *__pyx_getprop_8obitools_5align_8_dynamic_18DynamicProgramming_score(PyObject *o, void *x) {
  return __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_5score_1__get__(o);
}

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

static struct PyGetSetDef __pyx_getsets_8obitools_5align_8_dynamic_DynamicProgramming[] = {
  {(char *)"seqA", __pyx_getprop_8obitools_5align_8_dynamic_18DynamicProgramming_seqA, __pyx_setprop_8obitools_5align_8_dynamic_18DynamicProgramming_seqA, 0, 0},
  {(char *)"seqB", __pyx_getprop_8obitools_5align_8_dynamic_18DynamicProgramming_seqB, __pyx_setprop_8obitools_5align_8_dynamic_18DynamicProgramming_seqB, 0, 0},
  {(char *)"opengap", __pyx_getprop_8obitools_5align_8_dynamic_18DynamicProgramming_opengap, __pyx_setprop_8obitools_5align_8_dynamic_18DynamicProgramming_opengap, 0, 0},
  {(char *)"extgap", __pyx_getprop_8obitools_5align_8_dynamic_18DynamicProgramming_extgap, __pyx_setprop_8obitools_5align_8_dynamic_18DynamicProgramming_extgap, 0, 0},
  {(char *)"needToCompute", __pyx_getprop_8obitools_5align_8_dynamic_18DynamicProgramming_needToCompute, 0, 0, 0},
  {(char *)"score", __pyx_getprop_8obitools_5align_8_dynamic_18DynamicProgramming_score, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_DynamicProgramming = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_DynamicProgramming = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_DynamicProgramming = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_DynamicProgramming = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_8obitools_5align_8_dynamic_DynamicProgramming = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("obitools.align._dynamic.DynamicProgramming"), /*tp_name*/
  sizeof(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8obitools_5align_8_dynamic_DynamicProgramming, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_DynamicProgramming, /*tp_as_number*/
  &__pyx_tp_as_sequence_DynamicProgramming, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_DynamicProgramming, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_5__call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_DynamicProgramming, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_8obitools_5align_8_dynamic_DynamicProgramming, /*tp_traverse*/
  __pyx_tp_clear_8obitools_5align_8_dynamic_DynamicProgramming, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_8obitools_5align_8_dynamic_DynamicProgramming, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_8obitools_5align_8_dynamic_DynamicProgramming, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_8obitools_5align_8_dynamic_18DynamicProgramming_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8obitools_5align_8_dynamic_DynamicProgramming, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {__Pyx_NAMESTR("iupacMatch"), (PyCFunction)__pyx_pw_8obitools_5align_8_dynamic_1iupacMatch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("encodeBase"), (PyCFunction)__pyx_pw_8obitools_5align_8_dynamic_3encodeBase, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("iupacPartialMatch"), (PyCFunction)__pyx_pw_8obitools_5align_8_dynamic_5iupacPartialMatch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("_dynamic"),
    __Pyx_DOCSTR(__pyx_k_3), /* 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_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_n_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 1},
  {&__pyx_n_s__AlignedSequence, __pyx_k__AlignedSequence, sizeof(__pyx_k__AlignedSequence), 0, 0, 1, 1},
  {&__pyx_n_s__Alignment, __pyx_k__Alignment, sizeof(__pyx_k__Alignment), 0, 0, 1, 1},
  {&__pyx_n_s__BioSequence, __pyx_k__BioSequence, sizeof(__pyx_k__BioSequence), 0, 0, 1, 1},
  {&__pyx_n_s____basecode, __pyx_k____basecode, sizeof(__pyx_k____basecode), 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_b__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 0, 1},
  {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1},
  {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1},
  {&__pyx_n_s__clone, __pyx_k__clone, sizeof(__pyx_k__clone), 0, 0, 1, 1},
  {&__pyx_n_s__extgap, __pyx_k__extgap, sizeof(__pyx_k__extgap), 0, 0, 1, 1},
  {&__pyx_n_s__gaps, __pyx_k__gaps, sizeof(__pyx_k__gaps), 0, 0, 1, 1},
  {&__pyx_n_s__i, __pyx_k__i, sizeof(__pyx_k__i), 0, 0, 1, 1},
  {&__pyx_n_s__lower, __pyx_k__lower, sizeof(__pyx_k__lower), 0, 0, 1, 1},
  {&__pyx_n_s__obitools, __pyx_k__obitools, sizeof(__pyx_k__obitools), 0, 0, 1, 1},
  {&__pyx_n_s__opengap, __pyx_k__opengap, sizeof(__pyx_k__opengap), 0, 0, 1, 1},
  {&__pyx_n_s__ord, __pyx_k__ord, sizeof(__pyx_k__ord), 0, 0, 1, 1},
  {&__pyx_n_s__quality, __pyx_k__quality, sizeof(__pyx_k__quality), 0, 0, 1, 1},
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  {&__pyx_n_s__score, __pyx_k__score, sizeof(__pyx_k__score), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ord = __Pyx_GetName(__pyx_b, __pyx_n_s__ord); if (!__pyx_builtin_ord) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __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 = 362; __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);

  /* "obitools/align/_dynamic.pyx":142
 * 
 * 
 * cdef int aascii = ord(b'a')             # <<<<<<<<<<<<<<
 * cdef int _basecode[26]
 * 
 */
  __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_5);
  __Pyx_INCREF(((PyObject *)__pyx_n_b__a));
  PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_n_b__a));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_b__a));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5));

  /* "obitools/align/_dynamic.pyx":362
 * 
 * __basecode=[1,14,2,13,0,0,4,11,0,0,12,0,3,15,0,0,0,5,6,8,8,7,9,0,10,0]
 * for i in range(26):             # <<<<<<<<<<<<<<
 *     _basecode[i]=__basecode[i]
 * 
 */
  __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_6);
  __Pyx_INCREF(__pyx_int_26);
  PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, __pyx_int_26);
  __Pyx_GIVEREF(__pyx_int_26);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6));
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_7 = PyInt_FromLong(7); if (unlikely(!__pyx_int_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_9 = PyInt_FromLong(9); if (unlikely(!__pyx_int_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_11 = PyInt_FromLong(11); if (unlikely(!__pyx_int_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_12 = PyInt_FromLong(12); if (unlikely(!__pyx_int_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_13 = PyInt_FromLong(13); if (unlikely(!__pyx_int_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_14 = PyInt_FromLong(14); if (unlikely(!__pyx_int_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_26 = PyInt_FromLong(26); if (unlikely(!__pyx_int_26)) {__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 init_dynamic(void); /*proto*/
PyMODINIT_FUNC init_dynamic(void)
#else
PyMODINIT_FUNC PyInit__dynamic(void); /*proto*/
PyMODINIT_FUNC PyInit__dynamic(void)
#endif
{
  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;
  __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__dynamic(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("_dynamic"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_3), 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_obitools__align___dynamic) {
    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 ---*/
  if (__Pyx_ExportFunction("allocateMatrix", (void (*)(void))__pyx_f_8obitools_5align_8_dynamic_allocateMatrix, "struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *(int, int, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateMatrix *__pyx_optional_args)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("freeMatrix", (void (*)(void))__pyx_f_8obitools_5align_8_dynamic_freeMatrix, "void (struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("resetMatrix", (void (*)(void))__pyx_f_8obitools_5align_8_dynamic_resetMatrix, "void (struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("allocateSequence", (void (*)(void))__pyx_f_8obitools_5align_8_dynamic_allocateSequence, "struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *(PyObject *, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence *__pyx_optional_args)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("freeSequence", (void (*)(void))__pyx_f_8obitools_5align_8_dynamic_freeSequence, "void (struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("allocatePath", (void (*)(void))__pyx_f_8obitools_5align_8_dynamic_allocatePath, "struct __pyx_t_8obitools_5align_8_dynamic_alignPath *(long, long, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath *__pyx_optional_args)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("reversePath", (void (*)(void))__pyx_f_8obitools_5align_8_dynamic_reversePath, "void (struct __pyx_t_8obitools_5align_8_dynamic_alignPath *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("freePath", (void (*)(void))__pyx_f_8obitools_5align_8_dynamic_freePath, "void (struct __pyx_t_8obitools_5align_8_dynamic_alignPath *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("bitCount", (void (*)(void))__pyx_f_8obitools_5align_8_dynamic_bitCount, "int (int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("iupacMatch", (void (*)(void))__pyx_f_8obitools_5align_8_dynamic_iupacMatch, "int (unsigned char, unsigned char, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("iupacPartialMatch", (void (*)(void))__pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch, "double (unsigned char, unsigned char, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("encodeBase", (void (*)(void))__pyx_f_8obitools_5align_8_dynamic_encodeBase, "unsigned char (unsigned char, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Type init code ---*/
  __pyx_vtabptr_8obitools_5align_8_dynamic_DynamicProgramming = &__pyx_vtable_8obitools_5align_8_dynamic_DynamicProgramming;
  __pyx_vtable_8obitools_5align_8_dynamic_DynamicProgramming._vlen = (int (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming__vlen;
  __pyx_vtable_8obitools_5align_8_dynamic_DynamicProgramming._hlen = (int (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming__hlen;
  __pyx_vtable_8obitools_5align_8_dynamic_DynamicProgramming.allocate = (int (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming_allocate;
  __pyx_vtable_8obitools_5align_8_dynamic_DynamicProgramming.doAlignment = (double (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming_doAlignment;
  __pyx_vtable_8obitools_5align_8_dynamic_DynamicProgramming.reset = (void (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming_reset;
  __pyx_vtable_8obitools_5align_8_dynamic_DynamicProgramming.index = (int (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *, int, int))__pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming_index;
  __pyx_vtable_8obitools_5align_8_dynamic_DynamicProgramming._needToCompute = (int (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming__needToCompute;
  __pyx_vtable_8obitools_5align_8_dynamic_DynamicProgramming.backtrack = (void (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming_backtrack;
  __pyx_vtable_8obitools_5align_8_dynamic_DynamicProgramming.clean = (void (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_8_dynamic_18DynamicProgramming_clean;
  if (PyType_Ready(&__pyx_type_8obitools_5align_8_dynamic_DynamicProgramming) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_8obitools_5align_8_dynamic_DynamicProgramming.tp_dict, __pyx_vtabptr_8obitools_5align_8_dynamic_DynamicProgramming) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "DynamicProgramming", (PyObject *)&__pyx_type_8obitools_5align_8_dynamic_DynamicProgramming) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming = &__pyx_type_8obitools_5align_8_dynamic_DynamicProgramming;
  /*--- Type import code ---*/
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "obitools/align/_dynamic.pyx":8
 * '''
 * 
 * from obitools import BioSequence             # <<<<<<<<<<<<<<
 * from obitools.alignment import AlignedSequence
 * from obitools.alignment import Alignment
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__BioSequence));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__BioSequence));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__BioSequence));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__obitools), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __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__BioSequence);
  if (__pyx_t_1 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__BioSequence);
    if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BioSequence, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "obitools/align/_dynamic.pyx":9
 * 
 * from obitools import BioSequence
 * from obitools.alignment import AlignedSequence             # <<<<<<<<<<<<<<
 * from obitools.alignment import Alignment
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__AlignedSequence));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__AlignedSequence));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__AlignedSequence));
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s_4), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __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__AlignedSequence);
  if (__pyx_t_2 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__AlignedSequence);
    if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__AlignedSequence, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __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;

  /* "obitools/align/_dynamic.pyx":10
 * from obitools import BioSequence
 * from obitools.alignment import AlignedSequence
 * from obitools.alignment import Alignment             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Alignment));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__Alignment));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Alignment));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_4), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __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__Alignment);
  if (__pyx_t_1 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__Alignment);
    if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Alignment, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __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;

  /* "obitools/align/_dynamic.pyx":142
 * 
 * 
 * cdef int aascii = ord(b'a')             # <<<<<<<<<<<<<<
 * cdef int _basecode[26]
 * 
 */
  __pyx_t_2 = PyObject_Call(__pyx_builtin_ord, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_8obitools_5align_8_dynamic_aascii = __pyx_t_3;

  /* "obitools/align/_dynamic.pyx":361
 * # initialize iupac carray
 * 
 * __basecode=[1,14,2,13,0,0,4,11,0,0,12,0,3,15,0,0,0,5,6,8,8,7,9,0,10,0]             # <<<<<<<<<<<<<<
 * for i in range(26):
 *     _basecode[i]=__basecode[i]
 */
  __pyx_t_2 = PyList_New(26); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  __Pyx_INCREF(__pyx_int_14);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_int_14);
  __Pyx_GIVEREF(__pyx_int_14);
  __Pyx_INCREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  __Pyx_INCREF(__pyx_int_13);
  PyList_SET_ITEM(__pyx_t_2, 3, __pyx_int_13);
  __Pyx_GIVEREF(__pyx_int_13);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_2, 4, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_2, 5, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_4);
  PyList_SET_ITEM(__pyx_t_2, 6, __pyx_int_4);
  __Pyx_GIVEREF(__pyx_int_4);
  __Pyx_INCREF(__pyx_int_11);
  PyList_SET_ITEM(__pyx_t_2, 7, __pyx_int_11);
  __Pyx_GIVEREF(__pyx_int_11);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_2, 8, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_2, 9, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_12);
  PyList_SET_ITEM(__pyx_t_2, 10, __pyx_int_12);
  __Pyx_GIVEREF(__pyx_int_12);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_2, 11, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_2, 12, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __Pyx_INCREF(__pyx_int_15);
  PyList_SET_ITEM(__pyx_t_2, 13, __pyx_int_15);
  __Pyx_GIVEREF(__pyx_int_15);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_2, 14, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_2, 15, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_2, 16, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_5);
  PyList_SET_ITEM(__pyx_t_2, 17, __pyx_int_5);
  __Pyx_GIVEREF(__pyx_int_5);
  __Pyx_INCREF(__pyx_int_6);
  PyList_SET_ITEM(__pyx_t_2, 18, __pyx_int_6);
  __Pyx_GIVEREF(__pyx_int_6);
  __Pyx_INCREF(__pyx_int_8);
  PyList_SET_ITEM(__pyx_t_2, 19, __pyx_int_8);
  __Pyx_GIVEREF(__pyx_int_8);
  __Pyx_INCREF(__pyx_int_8);
  PyList_SET_ITEM(__pyx_t_2, 20, __pyx_int_8);
  __Pyx_GIVEREF(__pyx_int_8);
  __Pyx_INCREF(__pyx_int_7);
  PyList_SET_ITEM(__pyx_t_2, 21, __pyx_int_7);
  __Pyx_GIVEREF(__pyx_int_7);
  __Pyx_INCREF(__pyx_int_9);
  PyList_SET_ITEM(__pyx_t_2, 22, __pyx_int_9);
  __Pyx_GIVEREF(__pyx_int_9);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_2, 23, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_10);
  PyList_SET_ITEM(__pyx_t_2, 24, __pyx_int_10);
  __Pyx_GIVEREF(__pyx_int_10);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_2, 25, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____basecode, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "obitools/align/_dynamic.pyx":362
 * 
 * __basecode=[1,14,2,13,0,0,4,11,0,0,12,0,3,15,0,0,0,5,6,8,8,7,9,0,10,0]
 * for i in range(26):             # <<<<<<<<<<<<<<
 *     _basecode[i]=__basecode[i]
 * 
 */
  __pyx_t_2 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  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 = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__i, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "obitools/align/_dynamic.pyx":363
 * __basecode=[1,14,2,13,0,0,4,11,0,0,12,0,3,15,0,0,0,5,6,8,8,7,9,0,10,0]
 * for i in range(26):
 *     _basecode[i]=__basecode[i]             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s____basecode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyObject_GetItem(__pyx_t_2, __pyx_t_6); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__i); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    (__pyx_v_8obitools_5align_8_dynamic__basecode[__pyx_t_8]) = __pyx_t_3;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "obitools/align/_dynamic.pyx":1
 * #@PydevCodeAnalysisIgnore             # <<<<<<<<<<<<<<
 * '''
 * Created on 14 sept. 2009
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  if (__pyx_m) {
    __Pyx_AddTraceback("init obitools.align._dynamic", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init obitools.align._dynamic");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

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

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



static 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 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 CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #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;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

static 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 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 void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static 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_ExportFunction(const char *name, void (*f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
            goto bad;
    }
    tmp.fp = f;
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    cobj = PyCapsule_New(tmp.p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItemString(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

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