/* Generated by Cython 0.16 on Wed Apr 25 13:44:33 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___lcs
#define __PYX_HAVE_API__obitools__align___lcs
#include "_lcs.h"
#include "stdlib.h"
#include "arrayarray.h"
#include "_upperbond.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[] = {
  "_lcs.pyx",
  "array.pxd",
};
#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
  const char* name; /* for error messages only */
  struct __Pyx_StructField_* fields;
  size_t size;     /* sizeof(type) */
  size_t arraysize[8]; /* length of array in each dimension */
  int ndim;
  char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject */
  char is_unsigned;
  int flags;
} __Pyx_TypeInfo;
typedef struct __Pyx_StructField_ {
  __Pyx_TypeInfo* type;
  const char* name;
  size_t offset;
} __Pyx_StructField;
typedef struct {
  __Pyx_StructField* field;
  size_t parent_offset;
} __Pyx_BufFmt_StackElem;
typedef struct {
  __Pyx_StructField root;
  __Pyx_BufFmt_StackElem* head;
  size_t fmt_offset;
  size_t new_count, enc_count;
  size_t struct_alignment;
  int is_complex;
  char enc_type;
  char new_packmode;
  char enc_packmode;
  char is_valid_array;
} __Pyx_BufFmt_Context;


/*--- Type declarations ---*/
struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming;
struct __pyx_obj_8obitools_5align_4_lcs_LCS;
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;

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

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

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

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

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

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

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

/* "_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/_lcs.pyx":15
 * from _upperbond import *
 * 
 * cdef class LCS(DynamicProgramming):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self):
 */
struct __pyx_obj_8obitools_5align_4_lcs_LCS {
  struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming __pyx_base;
};



/* "_dynamic.pxd":63
 * cpdef unsigned char encodeBase(unsigned char lettre)
 * 
 * cdef class DynamicProgramming:             # <<<<<<<<<<<<<<
 *     cdef AlignMatrix* matrix
 * 
 */

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;


/* "obitools/align/_lcs.pyx":15
 * from _upperbond import *
 * 
 * cdef class LCS(DynamicProgramming):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self):
 */

struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS {
  struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming __pyx_base;
  double (*matchScore)(struct __pyx_obj_8obitools_5align_4_lcs_LCS *, int, int);
};
static struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *__pyx_vtabptr_8obitools_5align_4_lcs_LCS;
#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 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 CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*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_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

static CYTHON_INLINE int  __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
    __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);

static void __Pyx_RaiseBufferFallbackError(void); /*proto*/

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

typedef struct {
  Py_ssize_t shape, strides, suboffsets;
} __Pyx_Buf_DimInfo;
typedef struct {
  size_t refcount;
  Py_buffer pybuffer;
} __Pyx_Buffer;
typedef struct {
  __Pyx_Buffer *rcbuffer;
  char *data;
  __Pyx_Buf_DimInfo diminfo[8];
} __Pyx_LocalBuf_ND;

#if PY_MAJOR_VERSION < 3
    static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
    static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
    #define __Pyx_GetBuffer PyObject_GetBuffer
    #define __Pyx_ReleaseBuffer PyBuffer_Release
#endif

static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0};
static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1};

static 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 void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename); /*proto*/

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

static int __Pyx_check_binary_version(void);

#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

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

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

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

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

static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*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 'libc.stdlib' */

/* Module declarations from 'stdlib' */

/* Module declarations from 'array' */

/* Module declarations from 'obitools.align.array' */
static PyTypeObject *__pyx_ptype_8obitools_5align_5array_array = 0;
static CYTHON_INLINE int __pyx_f_8obitools_5align_5array_extend_buffer(arrayobject *, char *, Py_ssize_t); /*proto*/

/* Module declarations from 'obitools.align._upperbond' */
static arrayobject *(*__pyx_f_8obitools_5align_10_upperbond_newtable)(void); /*proto*/

/* Module declarations from 'obitools.align._dynamic' */
static PyTypeObject *__pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming = 0;
static struct __pyx_t_8obitools_5align_8_dynamic_alignPath *(*__pyx_f_8obitools_5align_8_dynamic_allocatePath)(long, long, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath *__pyx_optional_args); /*proto*/
static double (*__pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch)(unsigned char, unsigned char, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'obitools.align._lcs' */
static PyTypeObject *__pyx_ptype_8obitools_5align_4_lcs_LCS = 0;
static __Pyx_TypeInfo __Pyx_TypeInfo_unsigned_char = { "unsigned char", NULL, sizeof(unsigned char), { 0 }, 0, 'U', IS_UNSIGNED(unsigned char), 0 };
#define __Pyx_MODULE_NAME "obitools.align._lcs"
int __pyx_module_is_main_obitools__align___lcs = 0;

/* Implementation of 'obitools.align._lcs' */
static PyObject *__pyx_builtin_range;
static int __pyx_pf_8obitools_5align_4_lcs_3LCS___init__(struct __pyx_obj_8obitools_5align_4_lcs_LCS *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_7opengap___get__(struct __pyx_obj_8obitools_5align_4_lcs_LCS *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_6extgap___get__(struct __pyx_obj_8obitools_5align_4_lcs_LCS *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8obitools_5align_4_lcs_lenlcs(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_seq1, PyObject *__pyx_v_seq2, double __pyx_v_minimum, int __pyx_v_normalized, int __pyx_v_reference); /* proto */
static int __pyx_pf_8obitools_5align_5array_5array___getbuffer__(arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info, CYTHON_UNUSED int __pyx_v_flags); /* proto */
static void __pyx_pf_8obitools_5align_5array_5array_2__releasebuffer__(CYTHON_UNUSED arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
static char __pyx_k_2[] = "\nCreated on 6 Nov. 2009\n\n@author: coissac\n";
static char __pyx_k_3[] = "*";
static char __pyx_k_6[] = "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx";
static char __pyx_k_7[] = "obitools.align._lcs";
static char __pyx_k__l1[] = "l1";
static char __pyx_k__l2[] = "l2";
static char __pyx_k__o1[] = "o1";
static char __pyx_k__o2[] = "o2";
static char __pyx_k__op[] = "op";
static char __pyx_k__s1[] = "s1";
static char __pyx_k__s2[] = "s2";
static char __pyx_k__w1[] = "w1";
static char __pyx_k__w2[] = "w2";
static char __pyx_k__lcs[] = "lcs";
static char __pyx_k__se1[] = "se1";
static char __pyx_k__se2[] = "se2";
static char __pyx_k__seq1[] = "seq1";
static char __pyx_k__seq2[] = "seq2";
static char __pyx_k__seqA[] = "seqA";
static char __pyx_k__seqB[] = "seqB";
static char __pyx_k__large[] = "large";
static char __pyx_k__range[] = "range";
static char __pyx_k__ALILEN[] = "ALILEN";
static char __pyx_k__MAXLEN[] = "MAXLEN";
static char __pyx_k__MINLEN[] = "MINLEN";
static char __pyx_k__extgap[] = "extgap";
static char __pyx_k__lcsali[] = "lcsali";
static char __pyx_k__lenlcs[] = "lenlcs";
static char __pyx_k__minimum[] = "minimum";
static char __pyx_k__ob_size[] = "ob_size";
static char __pyx_k__opengap[] = "opengap";
static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__obitools[] = "obitools";
static char __pyx_k__possible[] = "possible";
static char __pyx_k__alilength[] = "alilength";
static char __pyx_k__reference[] = "reference";
static char __pyx_k__word4over[] = "word4over";
static char __pyx_k__wordcount[] = "wordcount";
static char __pyx_k___upperbond[] = "_upperbond";
static char __pyx_k__normalized[] = "normalized";
static char __pyx_k__word4table[] = "word4table";
static char __pyx_k__BioSequence[] = "BioSequence";
static char __pyx_k__needToCompute[] = "needToCompute";
static PyObject *__pyx_n_s_3;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_n_s_7;
static PyObject *__pyx_n_s__ALILEN;
static PyObject *__pyx_n_s__BioSequence;
static PyObject *__pyx_n_s__MAXLEN;
static PyObject *__pyx_n_s__MINLEN;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___upperbond;
static PyObject *__pyx_n_s__alilength;
static PyObject *__pyx_n_s__extgap;
static PyObject *__pyx_n_s__l1;
static PyObject *__pyx_n_s__l2;
static PyObject *__pyx_n_s__large;
static PyObject *__pyx_n_s__lcs;
static PyObject *__pyx_n_s__lcsali;
static PyObject *__pyx_n_s__lenlcs;
static PyObject *__pyx_n_s__minimum;
static PyObject *__pyx_n_s__needToCompute;
static PyObject *__pyx_n_s__normalized;
static PyObject *__pyx_n_s__o1;
static PyObject *__pyx_n_s__o2;
static PyObject *__pyx_n_s__ob_size;
static PyObject *__pyx_n_s__obitools;
static PyObject *__pyx_n_s__op;
static PyObject *__pyx_n_s__opengap;
static PyObject *__pyx_n_s__possible;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__reference;
static PyObject *__pyx_n_s__s1;
static PyObject *__pyx_n_s__s2;
static PyObject *__pyx_n_s__se1;
static PyObject *__pyx_n_s__se2;
static PyObject *__pyx_n_s__seq1;
static PyObject *__pyx_n_s__seq2;
static PyObject *__pyx_n_s__seqA;
static PyObject *__pyx_n_s__seqB;
static PyObject *__pyx_n_s__w1;
static PyObject *__pyx_n_s__w2;
static PyObject *__pyx_n_s__word4over;
static PyObject *__pyx_n_s__word4table;
static PyObject *__pyx_n_s__wordcount;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static int __pyx_k_1;
static PyObject *__pyx_k_tuple_4;
static PyObject *__pyx_k_codeobj_5;

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

/* "obitools/align/_lcs.pyx":17
 * cdef class LCS(DynamicProgramming):
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         DynamicProgramming.__init__(self,opengap=0,extgap=0)
 * 
 */

static int __pyx_pf_8obitools_5align_4_lcs_3LCS___init__(struct __pyx_obj_8obitools_5align_4_lcs_LCS *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "obitools/align/_lcs.pyx":18
 * 
 *     def __init__(self):
 *         DynamicProgramming.__init__(self,opengap=0,extgap=0)             # <<<<<<<<<<<<<<
 * 
 *     property opengap:
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming)), __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__opengap), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__extgap), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("obitools.align._lcs.LCS.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

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

static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_7opengap___get__(struct __pyx_obj_8obitools_5align_4_lcs_LCS *__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/_lcs.pyx":22
 *     property opengap:
 *         def __get__(self):
 *             return self._opengap             # <<<<<<<<<<<<<<
 * 
 *     property extgap:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base._opengap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __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._lcs.LCS.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 PyObject *__pyx_pw_8obitools_5align_4_lcs_3LCS_6extgap_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8obitools_5align_4_lcs_3LCS_6extgap_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_4_lcs_3LCS_6extgap___get__(((struct __pyx_obj_8obitools_5align_4_lcs_LCS *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_6extgap___get__(struct __pyx_obj_8obitools_5align_4_lcs_LCS *__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/_lcs.pyx":26
 *     property extgap:
 *         def __get__(self):
 *             return self._extgap             # <<<<<<<<<<<<<<
 * 
 *     cdef double matchScore(self,int h, int v):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base._extgap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_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._lcs.LCS.extgap.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_lcs.pyx":28
 *             return self._extgap
 * 
 *     cdef double matchScore(self,int h, int v):             # <<<<<<<<<<<<<<
 *         return iupacPartialMatch(self.hSeq.sequence[h-1],self.vSeq.sequence[v-1])
 * 
 */

static double __pyx_f_8obitools_5align_4_lcs_3LCS_matchScore(struct __pyx_obj_8obitools_5align_4_lcs_LCS *__pyx_v_self, int __pyx_v_h, int __pyx_v_v) {
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("matchScore", 0);

  /* "obitools/align/_lcs.pyx":29
 * 
 *     cdef double matchScore(self,int h, int v):
 *         return iupacPartialMatch(self.hSeq.sequence[h-1],self.vSeq.sequence[v-1])             # <<<<<<<<<<<<<<
 * 
 *     cdef double doAlignment(self) except? 0:
 */
  __pyx_r = __pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch((__pyx_v_self->__pyx_base.hSeq->sequence[(__pyx_v_h - 1)]), (__pyx_v_self->__pyx_base.vSeq->sequence[(__pyx_v_v - 1)]), 0);
  goto __pyx_L0;

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

/* "obitools/align/_lcs.pyx":31
 *         return iupacPartialMatch(self.hSeq.sequence[h-1],self.vSeq.sequence[v-1])
 * 
 *     cdef double doAlignment(self) except? 0:             # <<<<<<<<<<<<<<
 *         cdef int i  # vertical index
 *         cdef int j  # horizontal index
 */

static double __pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment(struct __pyx_obj_8obitools_5align_4_lcs_LCS *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_idx;
  double __pyx_v_score;
  double __pyx_v_scoremax;
  int __pyx_v_path;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  long __pyx_t_4;
  long __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("doAlignment", 0);

  /* "obitools/align/_lcs.pyx":42
 * 
 * 
 *         if self.needToCompute:             # <<<<<<<<<<<<<<
 *             self.allocate()
 *             self.reset()
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__needToCompute); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "obitools/align/_lcs.pyx":43
 * 
 *         if self.needToCompute:
 *             self.allocate()             # <<<<<<<<<<<<<<
 *             self.reset()
 * 
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.allocate(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "obitools/align/_lcs.pyx":44
 *         if self.needToCompute:
 *             self.allocate()
 *             self.reset()             # <<<<<<<<<<<<<<
 * 
 *             for j in range(1,self.hSeq.length+1):
 */
    ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.reset(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self));

    /* "obitools/align/_lcs.pyx":46
 *             self.reset()
 * 
 *             for j in range(1,self.hSeq.length+1):             # <<<<<<<<<<<<<<
 *                 idx = self.index(j,0)
 *                 self.matrix.matrix[idx].score = 0
 */
    __pyx_t_4 = (__pyx_v_self->__pyx_base.hSeq->length + 1);
    for (__pyx_t_3 = 1; __pyx_t_3 < __pyx_t_4; __pyx_t_3+=1) {
      __pyx_v_j = __pyx_t_3;

      /* "obitools/align/_lcs.pyx":47
 * 
 *             for j in range(1,self.hSeq.length+1):
 *                 idx = self.index(j,0)             # <<<<<<<<<<<<<<
 *                 self.matrix.matrix[idx].score = 0
 *                 self.matrix.matrix[idx].path  = j
 */
      __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, 0);

      /* "obitools/align/_lcs.pyx":48
 *             for j in range(1,self.hSeq.length+1):
 *                 idx = self.index(j,0)
 *                 self.matrix.matrix[idx].score = 0             # <<<<<<<<<<<<<<
 *                 self.matrix.matrix[idx].path  = j
 * 
 */
      (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).score = 0.0;

      /* "obitools/align/_lcs.pyx":49
 *                 idx = self.index(j,0)
 *                 self.matrix.matrix[idx].score = 0
 *                 self.matrix.matrix[idx].path  = j             # <<<<<<<<<<<<<<
 * 
 *             for i in range(1,self.vSeq.length+1):
 */
      (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).path = __pyx_v_j;
    }

    /* "obitools/align/_lcs.pyx":51
 *                 self.matrix.matrix[idx].path  = j
 * 
 *             for i in range(1,self.vSeq.length+1):             # <<<<<<<<<<<<<<
 *                 idx = self.index(0,i)
 *                 self.matrix.matrix[idx].score = 0
 */
    __pyx_t_4 = (__pyx_v_self->__pyx_base.vSeq->length + 1);
    for (__pyx_t_3 = 1; __pyx_t_3 < __pyx_t_4; __pyx_t_3+=1) {
      __pyx_v_i = __pyx_t_3;

      /* "obitools/align/_lcs.pyx":52
 * 
 *             for i in range(1,self.vSeq.length+1):
 *                 idx = self.index(0,i)             # <<<<<<<<<<<<<<
 *                 self.matrix.matrix[idx].score = 0
 *                 self.matrix.matrix[idx].path  = -i
 */
      __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), 0, __pyx_v_i);

      /* "obitools/align/_lcs.pyx":53
 *             for i in range(1,self.vSeq.length+1):
 *                 idx = self.index(0,i)
 *                 self.matrix.matrix[idx].score = 0             # <<<<<<<<<<<<<<
 *                 self.matrix.matrix[idx].path  = -i
 * 
 */
      (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).score = 0.0;

      /* "obitools/align/_lcs.pyx":54
 *                 idx = self.index(0,i)
 *                 self.matrix.matrix[idx].score = 0
 *                 self.matrix.matrix[idx].path  = -i             # <<<<<<<<<<<<<<
 * 
 *             for i in range(1,self.vSeq.length+1):
 */
      (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).path = (-__pyx_v_i);
    }

    /* "obitools/align/_lcs.pyx":56
 *                 self.matrix.matrix[idx].path  = -i
 * 
 *             for i in range(1,self.vSeq.length+1):             # <<<<<<<<<<<<<<
 *                 for j in range(1,self.hSeq.length+1):
 * 
 */
    __pyx_t_4 = (__pyx_v_self->__pyx_base.vSeq->length + 1);
    for (__pyx_t_3 = 1; __pyx_t_3 < __pyx_t_4; __pyx_t_3+=1) {
      __pyx_v_i = __pyx_t_3;

      /* "obitools/align/_lcs.pyx":57
 * 
 *             for i in range(1,self.vSeq.length+1):
 *                 for j in range(1,self.hSeq.length+1):             # <<<<<<<<<<<<<<
 * 
 *                     # 1 - came from diagonal
 */
      __pyx_t_5 = (__pyx_v_self->__pyx_base.hSeq->length + 1);
      for (__pyx_t_6 = 1; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
        __pyx_v_j = __pyx_t_6;

        /* "obitools/align/_lcs.pyx":60
 * 
 *                     # 1 - came from diagonal
 *                     idx = self.index(j-1,i-1)             # <<<<<<<<<<<<<<
 *                     # print "computing cell : %d,%d --> %d/%d" % (j,i,self.index(j,i),self.matrix.msize),
 *                     scoremax = self.matrix.matrix[idx].score + \
 */
        __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), (__pyx_v_j - 1), (__pyx_v_i - 1));

        /* "obitools/align/_lcs.pyx":63
 *                     # print "computing cell : %d,%d --> %d/%d" % (j,i,self.index(j,i),self.matrix.msize),
 *                     scoremax = self.matrix.matrix[idx].score + \
 *                                self.matchScore(j,i)             # <<<<<<<<<<<<<<
 *                     path = 0
 * 
 */
        __pyx_v_scoremax = ((__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).score + ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->matchScore(__pyx_v_self, __pyx_v_j, __pyx_v_i));

        /* "obitools/align/_lcs.pyx":64
 *                     scoremax = self.matrix.matrix[idx].score + \
 *                                self.matchScore(j,i)
 *                     path = 0             # <<<<<<<<<<<<<<
 * 
 *                     # print "so=%f sd=%f sm=%f" % (self.matrix.matrix[idx].score,self.matchScore(j,i),scoremax),
 */
        __pyx_v_path = 0;

        /* "obitools/align/_lcs.pyx":69
 * 
 *                     # 2 - open horizontal gap
 *                     idx = self.index(j-1,i)             # <<<<<<<<<<<<<<
 *                     score = self.matrix.matrix[idx].score
 *                     if score > scoremax :
 */
        __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), (__pyx_v_j - 1), __pyx_v_i);

        /* "obitools/align/_lcs.pyx":70
 *                     # 2 - open horizontal gap
 *                     idx = self.index(j-1,i)
 *                     score = self.matrix.matrix[idx].score             # <<<<<<<<<<<<<<
 *                     if score > scoremax :
 *                         scoremax = score
 */
        __pyx_v_score = (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).score;

        /* "obitools/align/_lcs.pyx":71
 *                     idx = self.index(j-1,i)
 *                     score = self.matrix.matrix[idx].score
 *                     if score > scoremax :             # <<<<<<<<<<<<<<
 *                         scoremax = score
 *                         path = self.matrix.matrix[idx].path
 */
        __pyx_t_2 = (__pyx_v_score > __pyx_v_scoremax);
        if (__pyx_t_2) {

          /* "obitools/align/_lcs.pyx":72
 *                     score = self.matrix.matrix[idx].score
 *                     if score > scoremax :
 *                         scoremax = score             # <<<<<<<<<<<<<<
 *                         path = self.matrix.matrix[idx].path
 *                         if path >=0:
 */
          __pyx_v_scoremax = __pyx_v_score;

          /* "obitools/align/_lcs.pyx":73
 *                     if score > scoremax :
 *                         scoremax = score
 *                         path = self.matrix.matrix[idx].path             # <<<<<<<<<<<<<<
 *                         if path >=0:
 *                             path+=1
 */
          __pyx_v_path = (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).path;

          /* "obitools/align/_lcs.pyx":74
 *                         scoremax = score
 *                         path = self.matrix.matrix[idx].path
 *                         if path >=0:             # <<<<<<<<<<<<<<
 *                             path+=1
 *                         else:
 */
          __pyx_t_2 = (__pyx_v_path >= 0);
          if (__pyx_t_2) {

            /* "obitools/align/_lcs.pyx":75
 *                         path = self.matrix.matrix[idx].path
 *                         if path >=0:
 *                             path+=1             # <<<<<<<<<<<<<<
 *                         else:
 *                             path=+1
 */
            __pyx_v_path = (__pyx_v_path + 1);
            goto __pyx_L13;
          }
          /*else*/ {

            /* "obitools/align/_lcs.pyx":77
 *                             path+=1
 *                         else:
 *                             path=+1             # <<<<<<<<<<<<<<
 * 
 *                     # 3 - open vertical gap
 */
            __pyx_v_path = 1;
          }
          __pyx_L13:;
          goto __pyx_L12;
        }
        __pyx_L12:;

        /* "obitools/align/_lcs.pyx":80
 * 
 *                     # 3 - open vertical gap
 *                     idx = self.index(j,i-1)             # <<<<<<<<<<<<<<
 *                     score = self.matrix.matrix[idx].score
 *                     if score > scoremax :
 */
        __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, (__pyx_v_i - 1));

        /* "obitools/align/_lcs.pyx":81
 *                     # 3 - open vertical gap
 *                     idx = self.index(j,i-1)
 *                     score = self.matrix.matrix[idx].score             # <<<<<<<<<<<<<<
 *                     if score > scoremax :
 *                         scoremax = score
 */
        __pyx_v_score = (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).score;

        /* "obitools/align/_lcs.pyx":82
 *                     idx = self.index(j,i-1)
 *                     score = self.matrix.matrix[idx].score
 *                     if score > scoremax :             # <<<<<<<<<<<<<<
 *                         scoremax = score
 *                         path = self.matrix.matrix[idx].path
 */
        __pyx_t_2 = (__pyx_v_score > __pyx_v_scoremax);
        if (__pyx_t_2) {

          /* "obitools/align/_lcs.pyx":83
 *                     score = self.matrix.matrix[idx].score
 *                     if score > scoremax :
 *                         scoremax = score             # <<<<<<<<<<<<<<
 *                         path = self.matrix.matrix[idx].path
 *                         if path <=0:
 */
          __pyx_v_scoremax = __pyx_v_score;

          /* "obitools/align/_lcs.pyx":84
 *                     if score > scoremax :
 *                         scoremax = score
 *                         path = self.matrix.matrix[idx].path             # <<<<<<<<<<<<<<
 *                         if path <=0:
 *                             path-=1
 */
          __pyx_v_path = (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).path;

          /* "obitools/align/_lcs.pyx":85
 *                         scoremax = score
 *                         path = self.matrix.matrix[idx].path
 *                         if path <=0:             # <<<<<<<<<<<<<<
 *                             path-=1
 *                         else:
 */
          __pyx_t_2 = (__pyx_v_path <= 0);
          if (__pyx_t_2) {

            /* "obitools/align/_lcs.pyx":86
 *                         path = self.matrix.matrix[idx].path
 *                         if path <=0:
 *                             path-=1             # <<<<<<<<<<<<<<
 *                         else:
 *                             path=-1
 */
            __pyx_v_path = (__pyx_v_path - 1);
            goto __pyx_L15;
          }
          /*else*/ {

            /* "obitools/align/_lcs.pyx":88
 *                             path-=1
 *                         else:
 *                             path=-1             # <<<<<<<<<<<<<<
 * 
 *                     idx = self.index(j,i)
 */
            __pyx_v_path = -1;
          }
          __pyx_L15:;
          goto __pyx_L14;
        }
        __pyx_L14:;

        /* "obitools/align/_lcs.pyx":90
 *                             path=-1
 * 
 *                     idx = self.index(j,i)             # <<<<<<<<<<<<<<
 *                     self.matrix.matrix[idx].score = scoremax
 *                     self.matrix.matrix[idx].path  = path
 */
        __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, __pyx_v_i);

        /* "obitools/align/_lcs.pyx":91
 * 
 *                     idx = self.index(j,i)
 *                     self.matrix.matrix[idx].score = scoremax             # <<<<<<<<<<<<<<
 *                     self.matrix.matrix[idx].path  = path
 * 
 */
        (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).score = __pyx_v_scoremax;

        /* "obitools/align/_lcs.pyx":92
 *                     idx = self.index(j,i)
 *                     self.matrix.matrix[idx].score = scoremax
 *                     self.matrix.matrix[idx].path  = path             # <<<<<<<<<<<<<<
 * 
 *         self.sequenceChanged=False
 */
        (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).path = __pyx_v_path;
      }
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "obitools/align/_lcs.pyx":94
 *                     self.matrix.matrix[idx].path  = path
 * 
 *         self.sequenceChanged=False             # <<<<<<<<<<<<<<
 *         self.scoreChanged=False
 * 
 */
  __pyx_v_self->__pyx_base.sequenceChanged = 0;

  /* "obitools/align/_lcs.pyx":95
 * 
 *         self.sequenceChanged=False
 *         self.scoreChanged=False             # <<<<<<<<<<<<<<
 * 
 *         idx = self.index(self.hSeq.length,self.vSeq.length)
 */
  __pyx_v_self->__pyx_base.scoreChanged = 0;

  /* "obitools/align/_lcs.pyx":97
 *         self.scoreChanged=False
 * 
 *         idx = self.index(self.hSeq.length,self.vSeq.length)             # <<<<<<<<<<<<<<
 *         return self.matrix.matrix[idx].score
 * 
 */
  __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_self->__pyx_base.hSeq->length, __pyx_v_self->__pyx_base.vSeq->length);

  /* "obitools/align/_lcs.pyx":98
 * 
 *         idx = self.index(self.hSeq.length,self.vSeq.length)
 *         return self.matrix.matrix[idx].score             # <<<<<<<<<<<<<<
 * 
 *     cdef void backtrack(self):
 */
  __pyx_r = (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).score;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("obitools.align._lcs.LCS.doAlignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0.0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_lcs.pyx":100
 *         return self.matrix.matrix[idx].score
 * 
 *     cdef void backtrack(self):             # <<<<<<<<<<<<<<
 *         #cdef list path=[]
 *         cdef int i
 */

static void __pyx_f_8obitools_5align_4_lcs_3LCS_backtrack(struct __pyx_obj_8obitools_5align_4_lcs_LCS *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_p;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  struct __pyx_t_8obitools_5align_8_dynamic_alignPath *__pyx_t_2;
  struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("backtrack", 0);

  /* "obitools/align/_lcs.pyx":106
 *         cdef int p
 * 
 *         self.doAlignment()             # <<<<<<<<<<<<<<
 *         i=self.vSeq.length
 *         j=self.hSeq.length
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.doAlignment(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self)); if (unlikely(__pyx_t_1 == 0.0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "obitools/align/_lcs.pyx":107
 * 
 *         self.doAlignment()
 *         i=self.vSeq.length             # <<<<<<<<<<<<<<
 *         j=self.hSeq.length
 *         self.path=allocatePath(i,j,self.path)
 */
  __pyx_v_i = __pyx_v_self->__pyx_base.vSeq->length;

  /* "obitools/align/_lcs.pyx":108
 *         self.doAlignment()
 *         i=self.vSeq.length
 *         j=self.hSeq.length             # <<<<<<<<<<<<<<
 *         self.path=allocatePath(i,j,self.path)
 * 
 */
  __pyx_v_j = __pyx_v_self->__pyx_base.hSeq->length;

  /* "obitools/align/_lcs.pyx":109
 *         i=self.vSeq.length
 *         j=self.hSeq.length
 *         self.path=allocatePath(i,j,self.path)             # <<<<<<<<<<<<<<
 * 
 *         while (i or j):
 */
  __pyx_t_3.__pyx_n = 1;
  __pyx_t_3.path = __pyx_v_self->__pyx_base.path;
  __pyx_t_2 = __pyx_f_8obitools_5align_8_dynamic_allocatePath(__pyx_v_i, __pyx_v_j, &__pyx_t_3); 
  __pyx_v_self->__pyx_base.path = __pyx_t_2;

  /* "obitools/align/_lcs.pyx":111
 *         self.path=allocatePath(i,j,self.path)
 * 
 *         while (i or j):             # <<<<<<<<<<<<<<
 *             p=self.matrix.matrix[self.index(j,i)].path
 *             self.path.path[self.path.length]=p
 */
  while (1) {
    if (!__pyx_v_i) {
      __pyx_t_4 = __pyx_v_j;
    } else {
      __pyx_t_4 = __pyx_v_i;
    }
    if (!__pyx_t_4) break;

    /* "obitools/align/_lcs.pyx":112
 * 
 *         while (i or j):
 *             p=self.matrix.matrix[self.index(j,i)].path             # <<<<<<<<<<<<<<
 *             self.path.path[self.path.length]=p
 *             self.path.length+=1
 */
    __pyx_v_p = (__pyx_v_self->__pyx_base.matrix->matrix[((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, __pyx_v_i)]).path;

    /* "obitools/align/_lcs.pyx":113
 *         while (i or j):
 *             p=self.matrix.matrix[self.index(j,i)].path
 *             self.path.path[self.path.length]=p             # <<<<<<<<<<<<<<
 *             self.path.length+=1
 * #            path.append(p)
 */
    (__pyx_v_self->__pyx_base.path->path[__pyx_v_self->__pyx_base.path->length]) = __pyx_v_p;

    /* "obitools/align/_lcs.pyx":114
 *             p=self.matrix.matrix[self.index(j,i)].path
 *             self.path.path[self.path.length]=p
 *             self.path.length+=1             # <<<<<<<<<<<<<<
 * #            path.append(p)
 *             if p==0:
 */
    __pyx_v_self->__pyx_base.path->length = (__pyx_v_self->__pyx_base.path->length + 1);

    /* "obitools/align/_lcs.pyx":116
 *             self.path.length+=1
 * #            path.append(p)
 *             if p==0:             # <<<<<<<<<<<<<<
 *                 i-=1
 *                 j-=1
 */
    __pyx_t_4 = (__pyx_v_p == 0);
    if (__pyx_t_4) {

      /* "obitools/align/_lcs.pyx":117
 * #            path.append(p)
 *             if p==0:
 *                 i-=1             # <<<<<<<<<<<<<<
 *                 j-=1
 *             elif p < 0:
 */
      __pyx_v_i = (__pyx_v_i - 1);

      /* "obitools/align/_lcs.pyx":118
 *             if p==0:
 *                 i-=1
 *                 j-=1             # <<<<<<<<<<<<<<
 *             elif p < 0:
 *                 i+=p
 */
      __pyx_v_j = (__pyx_v_j - 1);
      goto __pyx_L5;
    }

    /* "obitools/align/_lcs.pyx":119
 *                 i-=1
 *                 j-=1
 *             elif p < 0:             # <<<<<<<<<<<<<<
 *                 i+=p
 *             else:
 */
    __pyx_t_4 = (__pyx_v_p < 0);
    if (__pyx_t_4) {

      /* "obitools/align/_lcs.pyx":120
 *                 j-=1
 *             elif p < 0:
 *                 i+=p             # <<<<<<<<<<<<<<
 *             else:
 *                 j-=p
 */
      __pyx_v_i = (__pyx_v_i + __pyx_v_p);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "obitools/align/_lcs.pyx":122
 *                 i+=p
 *             else:
 *                 j-=p             # <<<<<<<<<<<<<<
 * 
 *         #path.reverse()
 */
      __pyx_v_j = (__pyx_v_j - __pyx_v_p);
    }
    __pyx_L5:;
  }

  /* "obitools/align/_lcs.pyx":126
 *         #path.reverse()
 *         #reversePath(self.path)
 *         self.path.hStart=0             # <<<<<<<<<<<<<<
 *         self.path.vStart=0
 *         #return 0,0,path
 */
  __pyx_v_self->__pyx_base.path->hStart = 0;

  /* "obitools/align/_lcs.pyx":127
 *         #reversePath(self.path)
 *         self.path.hStart=0
 *         self.path.vStart=0             # <<<<<<<<<<<<<<
 *         #return 0,0,path
 * 
 */
  __pyx_v_self->__pyx_base.path->vStart = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("obitools.align._lcs.LCS.backtrack", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_8obitools_5align_4_lcs_1lenlcs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_8obitools_5align_4_lcs_1lenlcs = {__Pyx_NAMESTR("lenlcs"), (PyCFunction)__pyx_pw_8obitools_5align_4_lcs_1lenlcs, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_8obitools_5align_4_lcs_1lenlcs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_seq1 = 0;
  PyObject *__pyx_v_seq2 = 0;
  double __pyx_v_minimum;
  int __pyx_v_normalized;
  int __pyx_v_reference;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__seq1,&__pyx_n_s__seq2,&__pyx_n_s__minimum,&__pyx_n_s__normalized,&__pyx_n_s__reference,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lenlcs (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seq1);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seq2);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lenlcs", 0, 2, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__minimum);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__normalized);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lenlcs") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[2]) {
      } else {

        /* "obitools/align/_lcs.pyx":134
 * MINLEN=2
 * 
 * def lenlcs(seq1,seq2,double minimum=0.,bint normalized=False, int reference=ALILEN):             # <<<<<<<<<<<<<<
 *     cdef double lcs
 *     cdef bytes se1=bytes(str(seq1))
 */
        __pyx_v_minimum = ((double)0.);
      }
      if (values[3]) {
      } else {
        __pyx_v_normalized = ((int)0);
      }
      if (values[4]) {
      } else {
        __pyx_v_reference = __pyx_k_1;
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_seq1 = values[0];
    __pyx_v_seq2 = values[1];
    if (values[2]) {
      __pyx_v_minimum = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_minimum == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_minimum = ((double)0.);
    }
    if (values[3]) {
      __pyx_v_normalized = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_normalized == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_normalized = ((int)0);
    }
    if (values[4]) {
      __pyx_v_reference = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_reference == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_reference = __pyx_k_1;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("lenlcs", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("obitools.align._lcs.lenlcs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8obitools_5align_4_lcs_lenlcs(__pyx_self, __pyx_v_seq1, __pyx_v_seq2, __pyx_v_minimum, __pyx_v_normalized, __pyx_v_reference);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8obitools_5align_4_lcs_lenlcs(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_seq1, PyObject *__pyx_v_seq2, double __pyx_v_minimum, int __pyx_v_normalized, int __pyx_v_reference) {
  double __pyx_v_lcs;
  PyObject *__pyx_v_se1 = 0;
  PyObject *__pyx_v_se2 = 0;
  int __pyx_v_l1;
  int __pyx_v_l2;
  arrayobject *__pyx_v_w1 = 0;
  arrayobject *__pyx_v_w2 = 0;
  int __pyx_v_o1;
  int __pyx_v_o2;
  int __pyx_v_wordcount;
  int __pyx_v_alilength;
  int __pyx_v_possible;
  int __pyx_v_large;
  char *__pyx_v_s1;
  char *__pyx_v_s2;
  struct __pyx_obj_8obitools_5align_4_lcs_LCS *__pyx_v_lcsali = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_w1;
  __Pyx_Buffer __pyx_pybuffer_w1;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_w2;
  __Pyx_Buffer __pyx_pybuffer_w2;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  char *__pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  double __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  arrayobject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  arrayobject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lenlcs", 0);
  __pyx_pybuffer_w1.pybuffer.buf = NULL;
  __pyx_pybuffer_w1.refcount = 0;
  __pyx_pybuffernd_w1.data = NULL;
  __pyx_pybuffernd_w1.rcbuffer = &__pyx_pybuffer_w1;
  __pyx_pybuffer_w2.pybuffer.buf = NULL;
  __pyx_pybuffer_w2.refcount = 0;
  __pyx_pybuffernd_w2.data = NULL;
  __pyx_pybuffernd_w2.rcbuffer = &__pyx_pybuffer_w2;

  /* "obitools/align/_lcs.pyx":136
 * def lenlcs(seq1,seq2,double minimum=0.,bint normalized=False, int reference=ALILEN):
 *     cdef double lcs
 *     cdef bytes se1=bytes(str(seq1))             # <<<<<<<<<<<<<<
 *     cdef bytes se2=bytes(str(seq2))
 *     cdef int l1 = len(seq1)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_seq1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_seq1);
  __Pyx_GIVEREF(__pyx_v_seq1);
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_se1 = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "obitools/align/_lcs.pyx":137
 *     cdef double lcs
 *     cdef bytes se1=bytes(str(seq1))
 *     cdef bytes se2=bytes(str(seq2))             # <<<<<<<<<<<<<<
 *     cdef int l1 = len(seq1)
 *     cdef int l2 = len(seq2)
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_seq2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_seq2);
  __Pyx_GIVEREF(__pyx_v_seq2);
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_se2 = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "obitools/align/_lcs.pyx":138
 *     cdef bytes se1=bytes(str(seq1))
 *     cdef bytes se2=bytes(str(seq2))
 *     cdef int l1 = len(seq1)             # <<<<<<<<<<<<<<
 *     cdef int l2 = len(seq2)
 *     cdef array.array[unsigned char] w1
 */
  __pyx_t_3 = PyObject_Length(__pyx_v_seq1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_l1 = __pyx_t_3;

  /* "obitools/align/_lcs.pyx":139
 *     cdef bytes se2=bytes(str(seq2))
 *     cdef int l1 = len(seq1)
 *     cdef int l2 = len(seq2)             # <<<<<<<<<<<<<<
 *     cdef array.array[unsigned char] w1
 *     cdef array.array[unsigned char] w2
 */
  __pyx_t_3 = PyObject_Length(__pyx_v_seq2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_l2 = __pyx_t_3;

  /* "obitools/align/_lcs.pyx":151
 *     cdef char *s1
 *     cdef char *s2
 *     s1=se1             # <<<<<<<<<<<<<<
 *     s2=se2
 * 
 */
  __pyx_t_4 = PyBytes_AsString(((PyObject *)__pyx_v_se1)); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_s1 = __pyx_t_4;

  /* "obitools/align/_lcs.pyx":152
 *     cdef char *s2
 *     s1=se1
 *     s2=se2             # <<<<<<<<<<<<<<
 * 
 *     if min(l1,l2) < 8:
 */
  __pyx_t_4 = PyBytes_AsString(((PyObject *)__pyx_v_se2)); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_s2 = __pyx_t_4;

  /* "obitools/align/_lcs.pyx":154
 *     s2=se2
 * 
 *     if min(l1,l2) < 8:             # <<<<<<<<<<<<<<
 *         lcsali = LCS()
 *         lcsali.seqA = seq1
 */
  __pyx_t_5 = __pyx_v_l2;
  __pyx_t_6 = __pyx_v_l1;
  if ((__pyx_t_5 < __pyx_t_6)) {
    __pyx_t_7 = __pyx_t_5;
  } else {
    __pyx_t_7 = __pyx_t_6;
  }
  __pyx_t_8 = (__pyx_t_7 < 8);
  if (__pyx_t_8) {

    /* "obitools/align/_lcs.pyx":155
 * 
 *     if min(l1,l2) < 8:
 *         lcsali = LCS()             # <<<<<<<<<<<<<<
 *         lcsali.seqA = seq1
 *         lcsali.seqB = seq2
 */
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8obitools_5align_4_lcs_LCS)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_lcsali = ((struct __pyx_obj_8obitools_5align_4_lcs_LCS *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "obitools/align/_lcs.pyx":156
 *     if min(l1,l2) < 8:
 *         lcsali = LCS()
 *         lcsali.seqA = seq1             # <<<<<<<<<<<<<<
 *         lcsali.seqB = seq2
 *         lcs = lcsali.doAlignment()
 */
    if (PyObject_SetAttr(((PyObject *)__pyx_v_lcsali), __pyx_n_s__seqA, __pyx_v_seq1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "obitools/align/_lcs.pyx":157
 *         lcsali = LCS()
 *         lcsali.seqA = seq1
 *         lcsali.seqB = seq2             # <<<<<<<<<<<<<<
 *         lcs = lcsali.doAlignment()
 *     else:
 */
    if (PyObject_SetAttr(((PyObject *)__pyx_v_lcsali), __pyx_n_s__seqB, __pyx_v_seq2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "obitools/align/_lcs.pyx":158
 *         lcsali.seqA = seq1
 *         lcsali.seqB = seq2
 *         lcs = lcsali.doAlignment()             # <<<<<<<<<<<<<<
 *     else:
 *         if minimum > 0.:
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_lcsali->__pyx_base.__pyx_vtab)->__pyx_base.doAlignment(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_lcsali)); if (unlikely(__pyx_t_9 == 0.0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_lcs = __pyx_t_9;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "obitools/align/_lcs.pyx":160
 *         lcs = lcsali.doAlignment()
 *     else:
 *         if minimum > 0.:             # <<<<<<<<<<<<<<
 *             if isinstance(seq1, BioSequence) and hasattr(seq1, "word4table"):
 *                 w1 = seq1.word4table
 */
    __pyx_t_8 = (__pyx_v_minimum > 0.);
    if (__pyx_t_8) {

      /* "obitools/align/_lcs.pyx":161
 *     else:
 *         if minimum > 0.:
 *             if isinstance(seq1, BioSequence) and hasattr(seq1, "word4table"):             # <<<<<<<<<<<<<<
 *                 w1 = seq1.word4table
 *                 o1 = seq1.word4over
 */
      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__BioSequence); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = PyObject_IsInstance(__pyx_v_seq1, __pyx_t_1); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_8) {
        __pyx_t_1 = ((PyObject *)__pyx_n_s__word4table);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_10 = PyObject_HasAttr(__pyx_v_seq1, __pyx_t_1); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_11 = __pyx_t_10;
      } else {
        __pyx_t_11 = __pyx_t_8;
      }
      if (__pyx_t_11) {

        /* "obitools/align/_lcs.pyx":162
 *         if minimum > 0.:
 *             if isinstance(seq1, BioSequence) and hasattr(seq1, "word4table"):
 *                 w1 = seq1.word4table             # <<<<<<<<<<<<<<
 *                 o1 = seq1.word4over
 *             else:
 */
        __pyx_t_1 = PyObject_GetAttr(__pyx_v_seq1, __pyx_n_s__word4table); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8obitools_5align_5array_array))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_12 = ((arrayobject *)__pyx_t_1);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w1.rcbuffer->pybuffer);
          __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_w1.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_unsigned_char, PyBUF_FORMAT| PyBUF_INDIRECT, 1, 0, __pyx_stack);
          if (unlikely(__pyx_t_7 < 0)) {
            PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_w1.rcbuffer->pybuffer, (PyObject*)__pyx_v_w1, &__Pyx_TypeInfo_unsigned_char, PyBUF_FORMAT| PyBUF_INDIRECT, 1, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
            }
          }
          __pyx_pybuffernd_w1.diminfo[0].strides = __pyx_pybuffernd_w1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_w1.diminfo[0].shape = __pyx_pybuffernd_w1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_w1.diminfo[0].suboffsets = __pyx_pybuffernd_w1.rcbuffer->pybuffer.suboffsets[0];
          if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_12 = 0;
        __pyx_v_w1 = ((arrayobject *)__pyx_t_1);
        __pyx_t_1 = 0;

        /* "obitools/align/_lcs.pyx":163
 *             if isinstance(seq1, BioSequence) and hasattr(seq1, "word4table"):
 *                 w1 = seq1.word4table
 *                 o1 = seq1.word4over             # <<<<<<<<<<<<<<
 *             else:
 *                 w1 = newtable()
 */
        __pyx_t_1 = PyObject_GetAttr(__pyx_v_seq1, __pyx_n_s__word4over); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_o1 = __pyx_t_7;
        goto __pyx_L5;
      }
      /*else*/ {

        /* "obitools/align/_lcs.pyx":165
 *                 o1 = seq1.word4over
 *             else:
 *                 w1 = newtable()             # <<<<<<<<<<<<<<
 *                 o1 = buildTable(s1,w1._B,&wordcount)
 *                 if isinstance(seq1, BioSequence):
 */
        __pyx_t_1 = ((PyObject *)__pyx_f_8obitools_5align_10_upperbond_newtable()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w1.rcbuffer->pybuffer);
          __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_w1.rcbuffer->pybuffer, (PyObject*)((arrayobject *)__pyx_t_1), &__Pyx_TypeInfo_unsigned_char, PyBUF_FORMAT| PyBUF_INDIRECT, 1, 0, __pyx_stack);
          if (unlikely(__pyx_t_7 < 0)) {
            PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_w1.rcbuffer->pybuffer, (PyObject*)__pyx_v_w1, &__Pyx_TypeInfo_unsigned_char, PyBUF_FORMAT| PyBUF_INDIRECT, 1, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
            }
          }
          __pyx_pybuffernd_w1.diminfo[0].strides = __pyx_pybuffernd_w1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_w1.diminfo[0].shape = __pyx_pybuffernd_w1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_w1.diminfo[0].suboffsets = __pyx_pybuffernd_w1.rcbuffer->pybuffer.suboffsets[0];
          if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_w1 = ((arrayobject *)__pyx_t_1);
        __pyx_t_1 = 0;

        /* "obitools/align/_lcs.pyx":166
 *             else:
 *                 w1 = newtable()
 *                 o1 = buildTable(s1,w1._B,&wordcount)             # <<<<<<<<<<<<<<
 *                 if isinstance(seq1, BioSequence):
 *                     seq1.word4table=w1
 */
        __pyx_v_o1 = buildTable(__pyx_v_s1, __pyx_v_w1->_B, (&__pyx_v_wordcount));

        /* "obitools/align/_lcs.pyx":167
 *                 w1 = newtable()
 *                 o1 = buildTable(s1,w1._B,&wordcount)
 *                 if isinstance(seq1, BioSequence):             # <<<<<<<<<<<<<<
 *                     seq1.word4table=w1
 *                     seq1.word4over=o1
 */
        __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__BioSequence); 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_t_11 = PyObject_IsInstance(__pyx_v_seq1, __pyx_t_1); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_11) {

          /* "obitools/align/_lcs.pyx":168
 *                 o1 = buildTable(s1,w1._B,&wordcount)
 *                 if isinstance(seq1, BioSequence):
 *                     seq1.word4table=w1             # <<<<<<<<<<<<<<
 *                     seq1.word4over=o1
 *             if isinstance(seq2, BioSequence) and hasattr(seq2, "word4table"):
 */
          if (PyObject_SetAttr(__pyx_v_seq1, __pyx_n_s__word4table, ((PyObject *)__pyx_v_w1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

          /* "obitools/align/_lcs.pyx":169
 *                 if isinstance(seq1, BioSequence):
 *                     seq1.word4table=w1
 *                     seq1.word4over=o1             # <<<<<<<<<<<<<<
 *             if isinstance(seq2, BioSequence) and hasattr(seq2, "word4table"):
 *                 w2 = seq2.word4table
 */
          __pyx_t_1 = PyInt_FromLong(__pyx_v_o1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          if (PyObject_SetAttr(__pyx_v_seq1, __pyx_n_s__word4over, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L6;
        }
        __pyx_L6:;
      }
      __pyx_L5:;

      /* "obitools/align/_lcs.pyx":170
 *                     seq1.word4table=w1
 *                     seq1.word4over=o1
 *             if isinstance(seq2, BioSequence) and hasattr(seq2, "word4table"):             # <<<<<<<<<<<<<<
 *                 w2 = seq2.word4table
 *                 o2 = seq2.word4over
 */
      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__BioSequence); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = PyObject_IsInstance(__pyx_v_seq2, __pyx_t_1); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_11) {
        __pyx_t_1 = ((PyObject *)__pyx_n_s__word4table);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_8 = PyObject_HasAttr(__pyx_v_seq2, __pyx_t_1); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_10 = __pyx_t_8;
      } else {
        __pyx_t_10 = __pyx_t_11;
      }
      if (__pyx_t_10) {

        /* "obitools/align/_lcs.pyx":171
 *                     seq1.word4over=o1
 *             if isinstance(seq2, BioSequence) and hasattr(seq2, "word4table"):
 *                 w2 = seq2.word4table             # <<<<<<<<<<<<<<
 *                 o2 = seq2.word4over
 *             else:
 */
        __pyx_t_1 = PyObject_GetAttr(__pyx_v_seq2, __pyx_n_s__word4table); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8obitools_5align_5array_array))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_16 = ((arrayobject *)__pyx_t_1);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w2.rcbuffer->pybuffer);
          __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_w2.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_unsigned_char, PyBUF_FORMAT| PyBUF_INDIRECT, 1, 0, __pyx_stack);
          if (unlikely(__pyx_t_7 < 0)) {
            PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_w2.rcbuffer->pybuffer, (PyObject*)__pyx_v_w2, &__Pyx_TypeInfo_unsigned_char, PyBUF_FORMAT| PyBUF_INDIRECT, 1, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
            }
          }
          __pyx_pybuffernd_w2.diminfo[0].strides = __pyx_pybuffernd_w2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_w2.diminfo[0].shape = __pyx_pybuffernd_w2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_w2.diminfo[0].suboffsets = __pyx_pybuffernd_w2.rcbuffer->pybuffer.suboffsets[0];
          if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_16 = 0;
        __pyx_v_w2 = ((arrayobject *)__pyx_t_1);
        __pyx_t_1 = 0;

        /* "obitools/align/_lcs.pyx":172
 *             if isinstance(seq2, BioSequence) and hasattr(seq2, "word4table"):
 *                 w2 = seq2.word4table
 *                 o2 = seq2.word4over             # <<<<<<<<<<<<<<
 *             else:
 *                 w2 = newtable()
 */
        __pyx_t_1 = PyObject_GetAttr(__pyx_v_seq2, __pyx_n_s__word4over); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_o2 = __pyx_t_7;
        goto __pyx_L7;
      }
      /*else*/ {

        /* "obitools/align/_lcs.pyx":174
 *                 o2 = seq2.word4over
 *             else:
 *                 w2 = newtable()             # <<<<<<<<<<<<<<
 *                 o2 = buildTable(s2,w2._B,&wordcount)
 *                 if isinstance(seq2, BioSequence) :
 */
        __pyx_t_1 = ((PyObject *)__pyx_f_8obitools_5align_10_upperbond_newtable()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w2.rcbuffer->pybuffer);
          __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_w2.rcbuffer->pybuffer, (PyObject*)((arrayobject *)__pyx_t_1), &__Pyx_TypeInfo_unsigned_char, PyBUF_FORMAT| PyBUF_INDIRECT, 1, 0, __pyx_stack);
          if (unlikely(__pyx_t_7 < 0)) {
            PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_w2.rcbuffer->pybuffer, (PyObject*)__pyx_v_w2, &__Pyx_TypeInfo_unsigned_char, PyBUF_FORMAT| PyBUF_INDIRECT, 1, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
            }
          }
          __pyx_pybuffernd_w2.diminfo[0].strides = __pyx_pybuffernd_w2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_w2.diminfo[0].shape = __pyx_pybuffernd_w2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_w2.diminfo[0].suboffsets = __pyx_pybuffernd_w2.rcbuffer->pybuffer.suboffsets[0];
          if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_w2 = ((arrayobject *)__pyx_t_1);
        __pyx_t_1 = 0;

        /* "obitools/align/_lcs.pyx":175
 *             else:
 *                 w2 = newtable()
 *                 o2 = buildTable(s2,w2._B,&wordcount)             # <<<<<<<<<<<<<<
 *                 if isinstance(seq2, BioSequence) :
 *                     seq2.word4table=w2
 */
        __pyx_v_o2 = buildTable(__pyx_v_s2, __pyx_v_w2->_B, (&__pyx_v_wordcount));

        /* "obitools/align/_lcs.pyx":176
 *                 w2 = newtable()
 *                 o2 = buildTable(s2,w2._B,&wordcount)
 *                 if isinstance(seq2, BioSequence) :             # <<<<<<<<<<<<<<
 *                     seq2.word4table=w2
 *                     seq2.word4over=o2
 */
        __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__BioSequence); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_10 = PyObject_IsInstance(__pyx_v_seq2, __pyx_t_1); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_10) {

          /* "obitools/align/_lcs.pyx":177
 *                 o2 = buildTable(s2,w2._B,&wordcount)
 *                 if isinstance(seq2, BioSequence) :
 *                     seq2.word4table=w2             # <<<<<<<<<<<<<<
 *                     seq2.word4over=o2
 *             large = reference==ALILEN or reference==MAXLEN
 */
          if (PyObject_SetAttr(__pyx_v_seq2, __pyx_n_s__word4table, ((PyObject *)__pyx_v_w2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

          /* "obitools/align/_lcs.pyx":178
 *                 if isinstance(seq2, BioSequence) :
 *                     seq2.word4table=w2
 *                     seq2.word4over=o2             # <<<<<<<<<<<<<<
 *             large = reference==ALILEN or reference==MAXLEN
 *             possible = ispossible(l1, w1._B, o1,
 */
          __pyx_t_1 = PyInt_FromLong(__pyx_v_o2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          if (PyObject_SetAttr(__pyx_v_seq2, __pyx_n_s__word4over, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L8;
        }
        __pyx_L8:;
      }
      __pyx_L7:;

      /* "obitools/align/_lcs.pyx":179
 *                     seq2.word4table=w2
 *                     seq2.word4over=o2
 *             large = reference==ALILEN or reference==MAXLEN             # <<<<<<<<<<<<<<
 *             possible = ispossible(l1, w1._B, o1,
 *                                   l2, w2._B, o2,
 */
      __pyx_t_1 = PyInt_FromLong(__pyx_v_reference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ALILEN); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_17 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_17); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!__pyx_t_10) {
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_2 = PyInt_FromLong(__pyx_v_reference); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__MAXLEN); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_18 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __pyx_t_18;
        __pyx_t_18 = 0;
      } else {
        __pyx_t_1 = __pyx_t_17;
        __pyx_t_17 = 0;
      }
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_large = __pyx_t_10;

      /* "obitools/align/_lcs.pyx":182
 *             possible = ispossible(l1, w1._B, o1,
 *                                   l2, w2._B, o2,
 *                                   minimum,normalized,large)             # <<<<<<<<<<<<<<
 *             if possible:
 *                 lcs = fastLCSScore(s1,s2,NULL,&alilength)
 */
      __pyx_v_possible = ispossible(__pyx_v_l1, __pyx_v_w1->_B, __pyx_v_o1, __pyx_v_l2, __pyx_v_w2->_B, __pyx_v_o2, __pyx_v_minimum, __pyx_v_normalized, __pyx_v_large);

      /* "obitools/align/_lcs.pyx":183
 *                                   l2, w2._B, o2,
 *                                   minimum,normalized,large)
 *             if possible:             # <<<<<<<<<<<<<<
 *                 lcs = fastLCSScore(s1,s2,NULL,&alilength)
 *             else:
 */
      if (__pyx_v_possible) {

        /* "obitools/align/_lcs.pyx":184
 *                                   minimum,normalized,large)
 *             if possible:
 *                 lcs = fastLCSScore(s1,s2,NULL,&alilength)             # <<<<<<<<<<<<<<
 *             else:
 *                 lcs = -1.0
 */
        __pyx_v_lcs = fastLCSScore(__pyx_v_s1, __pyx_v_s2, NULL, (&__pyx_v_alilength));
        goto __pyx_L9;
      }
      /*else*/ {

        /* "obitools/align/_lcs.pyx":186
 *                 lcs = fastLCSScore(s1,s2,NULL,&alilength)
 *             else:
 *                 lcs = -1.0             # <<<<<<<<<<<<<<
 *         else:
 *             lcs = fastLCSScore(s1,s2,NULL,&alilength)
 */
        __pyx_v_lcs = -1.0;
      }
      __pyx_L9:;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "obitools/align/_lcs.pyx":188
 *                 lcs = -1.0
 *         else:
 *             lcs = fastLCSScore(s1,s2,NULL,&alilength)             # <<<<<<<<<<<<<<
 * 
 *     if lcs >= 0 and normalized:
 */
      __pyx_v_lcs = fastLCSScore(__pyx_v_s1, __pyx_v_s2, NULL, (&__pyx_v_alilength));
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  /* "obitools/align/_lcs.pyx":190
 *             lcs = fastLCSScore(s1,s2,NULL,&alilength)
 * 
 *     if lcs >= 0 and normalized:             # <<<<<<<<<<<<<<
 *         if reference==ALILEN:
 *             if alilength > 0:
 */
  __pyx_t_10 = (__pyx_v_lcs >= 0.0);
  if (__pyx_t_10) {
    __pyx_t_11 = __pyx_v_normalized;
  } else {
    __pyx_t_11 = __pyx_t_10;
  }
  if (__pyx_t_11) {

    /* "obitools/align/_lcs.pyx":191
 * 
 *     if lcs >= 0 and normalized:
 *         if reference==ALILEN:             # <<<<<<<<<<<<<<
 *             if alilength > 0:
 *                 lcs /=alilength
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_reference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_17 = __Pyx_GetName(__pyx_m, __pyx_n_s__ALILEN); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_17);
    __pyx_t_18 = PyObject_RichCompare(__pyx_t_1, __pyx_t_17, Py_EQ); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_18);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    if (__pyx_t_11) {

      /* "obitools/align/_lcs.pyx":192
 *     if lcs >= 0 and normalized:
 *         if reference==ALILEN:
 *             if alilength > 0:             # <<<<<<<<<<<<<<
 *                 lcs /=alilength
 *             else:
 */
      __pyx_t_11 = (__pyx_v_alilength > 0);
      if (__pyx_t_11) {

        /* "obitools/align/_lcs.pyx":193
 *         if reference==ALILEN:
 *             if alilength > 0:
 *                 lcs /=alilength             # <<<<<<<<<<<<<<
 *             else:
 *                 lcs = 0
 */
        if (unlikely(__pyx_v_alilength == 0)) {
          PyErr_Format(PyExc_ZeroDivisionError, "float division");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_lcs = (__pyx_v_lcs / __pyx_v_alilength);
        goto __pyx_L12;
      }
      /*else*/ {

        /* "obitools/align/_lcs.pyx":195
 *                 lcs /=alilength
 *             else:
 *                 lcs = 0             # <<<<<<<<<<<<<<
 *         elif reference==MAXLEN:
 *             lcs /=max(l1,l2)
 */
        __pyx_v_lcs = 0.0;
      }
      __pyx_L12:;
      goto __pyx_L11;
    }

    /* "obitools/align/_lcs.pyx":196
 *             else:
 *                 lcs = 0
 *         elif reference==MAXLEN:             # <<<<<<<<<<<<<<
 *             lcs /=max(l1,l2)
 *         elif reference==MINLEN:
 */
    __pyx_t_18 = PyInt_FromLong(__pyx_v_reference); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_18);
    __pyx_t_17 = __Pyx_GetName(__pyx_m, __pyx_n_s__MAXLEN); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_17);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_18, __pyx_t_17, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_11) {

      /* "obitools/align/_lcs.pyx":197
 *                 lcs = 0
 *         elif reference==MAXLEN:
 *             lcs /=max(l1,l2)             # <<<<<<<<<<<<<<
 *         elif reference==MINLEN:
 *             lcs /=min(l1,l2)
 */
      __pyx_t_7 = __pyx_v_l2;
      __pyx_t_5 = __pyx_v_l1;
      if ((__pyx_t_7 > __pyx_t_5)) {
        __pyx_t_6 = __pyx_t_7;
      } else {
        __pyx_t_6 = __pyx_t_5;
      }
      __pyx_t_7 = __pyx_t_6;
      if (unlikely(__pyx_t_7 == 0)) {
        PyErr_Format(PyExc_ZeroDivisionError, "float division");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_lcs = (__pyx_v_lcs / __pyx_t_7);
      goto __pyx_L11;
    }

    /* "obitools/align/_lcs.pyx":198
 *         elif reference==MAXLEN:
 *             lcs /=max(l1,l2)
 *         elif reference==MINLEN:             # <<<<<<<<<<<<<<
 *             lcs /=min(l1,l2)
 * 
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_reference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_17 = __Pyx_GetName(__pyx_m, __pyx_n_s__MINLEN); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_17);
    __pyx_t_18 = PyObject_RichCompare(__pyx_t_1, __pyx_t_17, Py_EQ); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_18);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    if (__pyx_t_11) {

      /* "obitools/align/_lcs.pyx":199
 *             lcs /=max(l1,l2)
 *         elif reference==MINLEN:
 *             lcs /=min(l1,l2)             # <<<<<<<<<<<<<<
 * 
 *     return lcs,alilength
 */
      __pyx_t_7 = __pyx_v_l2;
      __pyx_t_6 = __pyx_v_l1;
      if ((__pyx_t_7 < __pyx_t_6)) {
        __pyx_t_5 = __pyx_t_7;
      } else {
        __pyx_t_5 = __pyx_t_6;
      }
      __pyx_t_7 = __pyx_t_5;
      if (unlikely(__pyx_t_7 == 0)) {
        PyErr_Format(PyExc_ZeroDivisionError, "float division");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_lcs = (__pyx_v_lcs / __pyx_t_7);
      goto __pyx_L11;
    }
    __pyx_L11:;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "obitools/align/_lcs.pyx":201
 *             lcs /=min(l1,l2)
 * 
 *     return lcs,alilength             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_18 = PyFloat_FromDouble(__pyx_v_lcs); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_17 = PyInt_FromLong(__pyx_v_alilength); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_18);
  __Pyx_GIVEREF(__pyx_t_18);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_17);
  __pyx_t_18 = 0;
  __pyx_t_17 = 0;
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w1.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w2.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("obitools.align._lcs.lenlcs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w1.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w2.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_se1);
  __Pyx_XDECREF(__pyx_v_se2);
  __Pyx_XDECREF((PyObject *)__pyx_v_w1);
  __Pyx_XDECREF((PyObject *)__pyx_v_w2);
  __Pyx_XDECREF((PyObject *)__pyx_v_lcsali);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8obitools_5align_5array_5array_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static int __pyx_pw_8obitools_5align_5array_5array_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_5array_5array___getbuffer__(((arrayobject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":107
 *             void* _v
 * 
 *         def __getbuffer__(array self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

static int __pyx_pf_8obitools_5align_5array_5array___getbuffer__(arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info, CYTHON_UNUSED int __pyx_v_flags) {
  CYTHON_UNUSED unsigned int __pyx_v_itemsize;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  if (__pyx_v_info != NULL) {
    __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(__pyx_v_info->obj);
  }

  /* "array.pxd":114
 *             cdef unsigned rows, columns, itemsize
 * 
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *             info.buf = self.ob_item
 *             info.readonly = 0
 */
  __pyx_v_info->suboffsets = NULL;

  /* "array.pxd":115
 * 
 *             info.suboffsets = NULL
 *             info.buf = self.ob_item             # <<<<<<<<<<<<<<
 *             info.readonly = 0
 *             info.ndim = 1
 */
  __pyx_v_info->buf = __pyx_v_self->ob_item;

  /* "array.pxd":116
 *             info.suboffsets = NULL
 *             info.buf = self.ob_item
 *             info.readonly = 0             # <<<<<<<<<<<<<<
 *             info.ndim = 1
 *             info.itemsize = itemsize = self.ob_descr.itemsize   # e.g. sizeof(float)
 */
  __pyx_v_info->readonly = 0;

  /* "array.pxd":117
 *             info.buf = self.ob_item
 *             info.readonly = 0
 *             info.ndim = 1             # <<<<<<<<<<<<<<
 *             info.itemsize = itemsize = self.ob_descr.itemsize   # e.g. sizeof(float)
 * 
 */
  __pyx_v_info->ndim = 1;

  /* "array.pxd":118
 *             info.readonly = 0
 *             info.ndim = 1
 *             info.itemsize = itemsize = self.ob_descr.itemsize   # e.g. sizeof(float)             # <<<<<<<<<<<<<<
 * 
 *             info.strides = <Py_ssize_t*> \
 */
  __pyx_v_info->itemsize = __pyx_v_self->ob_descr->itemsize;
  __pyx_v_itemsize = __pyx_v_self->ob_descr->itemsize;

  /* "array.pxd":120
 *             info.itemsize = itemsize = self.ob_descr.itemsize   # e.g. sizeof(float)
 * 
 *             info.strides = <Py_ssize_t*> \             # <<<<<<<<<<<<<<
 *                            stdlib.malloc(sizeof(Py_ssize_t) * info.ndim * 2 + 2)
 *             info.shape = info.strides + 1
 */
  __pyx_v_info->strides = ((Py_ssize_t *)malloc(((((sizeof(Py_ssize_t)) * __pyx_v_info->ndim) * 2) + 2)));

  /* "array.pxd":122
 *             info.strides = <Py_ssize_t*> \
 *                            stdlib.malloc(sizeof(Py_ssize_t) * info.ndim * 2 + 2)
 *             info.shape = info.strides + 1             # <<<<<<<<<<<<<<
 *             info.shape[0] = self.ob_size            # number of items
 *             info.strides[0] = info.itemsize
 */
  __pyx_v_info->shape = (__pyx_v_info->strides + 1);

  /* "array.pxd":123
 *                            stdlib.malloc(sizeof(Py_ssize_t) * info.ndim * 2 + 2)
 *             info.shape = info.strides + 1
 *             info.shape[0] = self.ob_size            # number of items             # <<<<<<<<<<<<<<
 *             info.strides[0] = info.itemsize
 * 
 */
  (__pyx_v_info->shape[0]) = __pyx_v_self->ob_size;

  /* "array.pxd":124
 *             info.shape = info.strides + 1
 *             info.shape[0] = self.ob_size            # number of items
 *             info.strides[0] = info.itemsize             # <<<<<<<<<<<<<<
 * 
 *             info.format = <char*>(info.strides + 2 * info.ndim)
 */
  (__pyx_v_info->strides[0]) = __pyx_v_info->itemsize;

  /* "array.pxd":126
 *             info.strides[0] = info.itemsize
 * 
 *             info.format = <char*>(info.strides + 2 * info.ndim)             # <<<<<<<<<<<<<<
 *             info.format[0] = self.ob_descr.typecode
 *             info.format[1] = 0
 */
  __pyx_v_info->format = ((char *)(__pyx_v_info->strides + (2 * __pyx_v_info->ndim)));

  /* "array.pxd":127
 * 
 *             info.format = <char*>(info.strides + 2 * info.ndim)
 *             info.format[0] = self.ob_descr.typecode             # <<<<<<<<<<<<<<
 *             info.format[1] = 0
 *             info.obj = self
 */
  (__pyx_v_info->format[0]) = __pyx_v_self->ob_descr->typecode;

  /* "array.pxd":128
 *             info.format = <char*>(info.strides + 2 * info.ndim)
 *             info.format[0] = self.ob_descr.typecode
 *             info.format[1] = 0             # <<<<<<<<<<<<<<
 *             info.obj = self
 * 
 */
  (__pyx_v_info->format[1]) = 0;

  /* "array.pxd":129
 *             info.format[0] = self.ob_descr.typecode
 *             info.format[1] = 0
 *             info.obj = self             # <<<<<<<<<<<<<<
 * 
 *         def __releasebuffer__(array self, Py_buffer* info):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_GOTREF(__pyx_v_info->obj);
  __Pyx_DECREF(__pyx_v_info->obj);
  __pyx_v_info->obj = ((PyObject *)__pyx_v_self);

  __pyx_r = 0;
  if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_8obitools_5align_5array_5array_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
static void __pyx_pw_8obitools_5align_5array_5array_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
  __pyx_pf_8obitools_5align_5array_5array_2__releasebuffer__(((arrayobject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));
  __Pyx_RefNannyFinishContext();
}

/* "array.pxd":131
 *             info.obj = self
 * 
 *         def __releasebuffer__(array self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             #if PyArray_HASFIELDS(self):
 *             #    stdlib.free(info.format)
 */

static void __pyx_pf_8obitools_5align_5array_5array_2__releasebuffer__(CYTHON_UNUSED arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__", 0);

  /* "array.pxd":135
 *             #    stdlib.free(info.format)
 *             #if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *             stdlib.free(info.strides)             # <<<<<<<<<<<<<<
 * 
 *     array newarrayobject(PyTypeObject* type, Py_ssize_t size,
 */
  free(__pyx_v_info->strides);

  __Pyx_RefNannyFinishContext();
}

/* "array.pxd":149
 * #  fast creation of a new array - init with zeros
 * #  yet you need a (any) template array of the same item type (but not same size)
 * cdef inline array zeros_like(array sametype):             # <<<<<<<<<<<<<<
 *     cdef array op = newarrayobject(<PyTypeObject*>sametype.ob_type, sametype.ob_size, sametype.ob_descr)
 *     if op:
 */

static CYTHON_INLINE arrayobject *__pyx_f_8obitools_5align_5array_zeros_like(arrayobject *__pyx_v_sametype) {
  arrayobject *__pyx_v_op = 0;
  arrayobject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("zeros_like", 0);

  /* "array.pxd":150
 * #  yet you need a (any) template array of the same item type (but not same size)
 * cdef inline array zeros_like(array sametype):
 *     cdef array op = newarrayobject(<PyTypeObject*>sametype.ob_type, sametype.ob_size, sametype.ob_descr)             # <<<<<<<<<<<<<<
 *     if op:
 *         memset(op.ob_item, 0, op.ob_size * op.ob_descr.itemsize)
 */
  __pyx_t_1 = ((PyObject *)newarrayobject(((PyTypeObject *)__pyx_v_sametype->ob_type), __pyx_v_sametype->ob_size, __pyx_v_sametype->ob_descr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((arrayobject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "array.pxd":151
 * cdef inline array zeros_like(array sametype):
 *     cdef array op = newarrayobject(<PyTypeObject*>sametype.ob_type, sametype.ob_size, sametype.ob_descr)
 *     if op:             # <<<<<<<<<<<<<<
 *         memset(op.ob_item, 0, op.ob_size * op.ob_descr.itemsize)
 *         return op
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_op)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {

    /* "array.pxd":152
 *     cdef array op = newarrayobject(<PyTypeObject*>sametype.ob_type, sametype.ob_size, sametype.ob_descr)
 *     if op:
 *         memset(op.ob_item, 0, op.ob_size * op.ob_descr.itemsize)             # <<<<<<<<<<<<<<
 *         return op
 * 
 */
    memset(__pyx_v_op->ob_item, 0, (__pyx_v_op->ob_size * __pyx_v_op->ob_descr->itemsize));

    /* "array.pxd":153
 *     if op:
 *         memset(op.ob_item, 0, op.ob_size * op.ob_descr.itemsize)
 *         return op             # <<<<<<<<<<<<<<
 * 
 * #  fast creation of a new array - no init with zeros
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_op));
    __pyx_r = __pyx_v_op;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = ((arrayobject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("obitools.align.array.zeros_like", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_op);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":156
 * 
 * #  fast creation of a new array - no init with zeros
 * cdef inline array empty_like(array sametype):             # <<<<<<<<<<<<<<
 *     return newarrayobject(<PyTypeObject*>sametype.ob_type, sametype.op.ob_size,
 *                            sametype.ob_descr)
 */

static CYTHON_INLINE arrayobject *__pyx_f_8obitools_5align_5array_empty_like(arrayobject *__pyx_v_sametype) {
  arrayobject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("empty_like", 0);

  /* "array.pxd":157
 * #  fast creation of a new array - no init with zeros
 * cdef inline array empty_like(array sametype):
 *     return newarrayobject(<PyTypeObject*>sametype.ob_type, sametype.op.ob_size,             # <<<<<<<<<<<<<<
 *                            sametype.ob_descr)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_sametype), __pyx_n_s__op); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__ob_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "array.pxd":158
 * cdef inline array empty_like(array sametype):
 *     return newarrayobject(<PyTypeObject*>sametype.ob_type, sametype.op.ob_size,
 *                            sametype.ob_descr)             # <<<<<<<<<<<<<<
 * 
 * cdef inline array copy(array self):
 */
  __pyx_t_2 = ((PyObject *)newarrayobject(((PyTypeObject *)__pyx_v_sametype->ob_type), __pyx_t_3, __pyx_v_sametype->ob_descr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = ((arrayobject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = ((arrayobject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("obitools.align.array.empty_like", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":160
 *                            sametype.ob_descr)
 * 
 * cdef inline array copy(array self):             # <<<<<<<<<<<<<<
 *     cdef array op = newarrayobject(<PyTypeObject*>self.ob_type, self.ob_size,
 *                                    self.ob_descr)
 */

static CYTHON_INLINE arrayobject *__pyx_f_8obitools_5align_5array_copy(arrayobject *__pyx_v_self) {
  arrayobject *__pyx_v_op = 0;
  arrayobject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("copy", 0);

  /* "array.pxd":162
 * cdef inline array copy(array self):
 *     cdef array op = newarrayobject(<PyTypeObject*>self.ob_type, self.ob_size,
 *                                    self.ob_descr)             # <<<<<<<<<<<<<<
 *     memcpy(op.ob_item, self.ob_item, op.ob_size * op.ob_descr.itemsize)
 *     return op
 */
  __pyx_t_1 = ((PyObject *)newarrayobject(((PyTypeObject *)__pyx_v_self->ob_type), __pyx_v_self->ob_size, __pyx_v_self->ob_descr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((arrayobject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "array.pxd":163
 *     cdef array op = newarrayobject(<PyTypeObject*>self.ob_type, self.ob_size,
 *                                    self.ob_descr)
 *     memcpy(op.ob_item, self.ob_item, op.ob_size * op.ob_descr.itemsize)             # <<<<<<<<<<<<<<
 *     return op
 * 
 */
  memcpy(__pyx_v_op->ob_item, __pyx_v_self->ob_item, (__pyx_v_op->ob_size * __pyx_v_op->ob_descr->itemsize));

  /* "array.pxd":164
 *                                    self.ob_descr)
 *     memcpy(op.ob_item, self.ob_item, op.ob_size * op.ob_descr.itemsize)
 *     return op             # <<<<<<<<<<<<<<
 * 
 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_op));
  __pyx_r = __pyx_v_op;
  goto __pyx_L0;

  __pyx_r = ((arrayobject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("obitools.align.array.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_op);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":166
 *     return op
 * 
 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n):             # <<<<<<<<<<<<<<
 *     """ efficent appending of new stuff of same type (e.g. of same array type)
 *         n: number of elements (not number of bytes!)
 */

static CYTHON_INLINE int __pyx_f_8obitools_5align_5array_extend_buffer(arrayobject *__pyx_v_self, char *__pyx_v_stuff, Py_ssize_t __pyx_v_n) {
  Py_ssize_t __pyx_v_itemsize;
  Py_ssize_t __pyx_v_orgsize;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("extend_buffer", 0);

  /* "array.pxd":170
 *         n: number of elements (not number of bytes!)
 *     """
 *     cdef Py_ssize_t itemsize = self.ob_descr.itemsize, orgsize = self.ob_size             # <<<<<<<<<<<<<<
 *     if -1 == resize_smart(self, orgsize + n):
 *         return -1
 */
  __pyx_v_itemsize = __pyx_v_self->ob_descr->itemsize;
  __pyx_v_orgsize = __pyx_v_self->ob_size;

  /* "array.pxd":171
 *     """
 *     cdef Py_ssize_t itemsize = self.ob_descr.itemsize, orgsize = self.ob_size
 *     if -1 == resize_smart(self, orgsize + n):             # <<<<<<<<<<<<<<
 *         return -1
 *     memcpy( self.ob_item + orgsize * itemsize, stuff, n * itemsize )
 */
  __pyx_t_1 = (-1 == resize_smart(__pyx_v_self, (__pyx_v_orgsize + __pyx_v_n)));
  if (__pyx_t_1) {

    /* "array.pxd":172
 *     cdef Py_ssize_t itemsize = self.ob_descr.itemsize, orgsize = self.ob_size
 *     if -1 == resize_smart(self, orgsize + n):
 *         return -1             # <<<<<<<<<<<<<<
 *     memcpy( self.ob_item + orgsize * itemsize, stuff, n * itemsize )
 * 
 */
    __pyx_r = -1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "array.pxd":173
 *     if -1 == resize_smart(self, orgsize + n):
 *         return -1
 *     memcpy( self.ob_item + orgsize * itemsize, stuff, n * itemsize )             # <<<<<<<<<<<<<<
 * 
 * cdef inline int extend(array self, array other):
 */
  memcpy((__pyx_v_self->ob_item + (__pyx_v_orgsize * __pyx_v_itemsize)), __pyx_v_stuff, (__pyx_v_n * __pyx_v_itemsize));

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

/* "array.pxd":175
 *     memcpy( self.ob_item + orgsize * itemsize, stuff, n * itemsize )
 * 
 * cdef inline int extend(array self, array other):             # <<<<<<<<<<<<<<
 *     if self.ob_descr.typecode != self.ob_descr.typecode:
 *         PyErr_BadArgument()
 */

static CYTHON_INLINE int __pyx_f_8obitools_5align_5array_extend(arrayobject *__pyx_v_self, arrayobject *__pyx_v_other) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "array.pxd":176
 * 
 * cdef inline int extend(array self, array other):
 *     if self.ob_descr.typecode != self.ob_descr.typecode:             # <<<<<<<<<<<<<<
 *         PyErr_BadArgument()
 *         return -1
 */
  __pyx_t_1 = (__pyx_v_self->ob_descr->typecode != __pyx_v_self->ob_descr->typecode);
  if (__pyx_t_1) {

    /* "array.pxd":177
 * cdef inline int extend(array self, array other):
 *     if self.ob_descr.typecode != self.ob_descr.typecode:
 *         PyErr_BadArgument()             # <<<<<<<<<<<<<<
 *         return -1
 *     return extend_buffer(self, other.ob_item, other.ob_size)
 */
    PyErr_BadArgument();

    /* "array.pxd":178
 *     if self.ob_descr.typecode != self.ob_descr.typecode:
 *         PyErr_BadArgument()
 *         return -1             # <<<<<<<<<<<<<<
 *     return extend_buffer(self, other.ob_item, other.ob_size)
 * 
 */
    __pyx_r = -1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "array.pxd":179
 *         PyErr_BadArgument()
 *         return -1
 *     return extend_buffer(self, other.ob_item, other.ob_size)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_f_8obitools_5align_5array_extend_buffer(__pyx_v_self, __pyx_v_other->ob_item, __pyx_v_other->ob_size);
  goto __pyx_L0;

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

/* "array.pxd":182
 * 
 * 
 * cdef inline void zero(array op):             # <<<<<<<<<<<<<<
 *     memset(op.ob_item, 0, op.ob_size * op.ob_descr.itemsize)
 */

static CYTHON_INLINE void __pyx_f_8obitools_5align_5array_zero(arrayobject *__pyx_v_op) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("zero", 0);

  /* "array.pxd":183
 * 
 * cdef inline void zero(array op):
 *     memset(op.ob_item, 0, op.ob_size * op.ob_descr.itemsize)             # <<<<<<<<<<<<<<
 */
  memset(__pyx_v_op->ob_item, 0, (__pyx_v_op->ob_size * __pyx_v_op->ob_descr->itemsize));

  __Pyx_RefNannyFinishContext();
}
static struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS __pyx_vtable_8obitools_5align_4_lcs_LCS;

static PyObject *__pyx_tp_new_8obitools_5align_4_lcs_LCS(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_8obitools_5align_4_lcs_LCS *p;
  PyObject *o = __pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_8obitools_5align_4_lcs_LCS *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming*)__pyx_vtabptr_8obitools_5align_4_lcs_LCS;
  return o;
}

static void __pyx_tp_dealloc_8obitools_5align_4_lcs_LCS(PyObject *o) {
  __pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming->tp_dealloc(o);
}

static int __pyx_tp_traverse_8obitools_5align_4_lcs_LCS(PyObject *o, visitproc v, void *a) {
  int e;
  if (__pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming->tp_traverse) {
    e = __pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming->tp_traverse(o, v, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_8obitools_5align_4_lcs_LCS(PyObject *o) {
  if (__pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming->tp_clear) {
    __pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming->tp_clear(o);
  }
  return 0;
}

static PyObject *__pyx_getprop_8obitools_5align_4_lcs_3LCS_opengap(PyObject *o, void *x) {
  return __pyx_pw_8obitools_5align_4_lcs_3LCS_7opengap_1__get__(o);
}

static PyObject *__pyx_getprop_8obitools_5align_4_lcs_3LCS_extgap(PyObject *o, void *x) {
  return __pyx_pw_8obitools_5align_4_lcs_3LCS_6extgap_1__get__(o);
}

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

static struct PyGetSetDef __pyx_getsets_8obitools_5align_4_lcs_LCS[] = {
  {(char *)"opengap", __pyx_getprop_8obitools_5align_4_lcs_3LCS_opengap, 0, 0, 0},
  {(char *)"extgap", __pyx_getprop_8obitools_5align_4_lcs_3LCS_extgap, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_LCS = {
  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_LCS = {
  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_LCS = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_LCS = {
  #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_4_lcs_LCS = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("obitools.align._lcs.LCS"), /*tp_name*/
  sizeof(struct __pyx_obj_8obitools_5align_4_lcs_LCS), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8obitools_5align_4_lcs_LCS, /*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_LCS, /*tp_as_number*/
  &__pyx_tp_as_sequence_LCS, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_LCS, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_LCS, /*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_4_lcs_LCS, /*tp_traverse*/
  __pyx_tp_clear_8obitools_5align_4_lcs_LCS, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_8obitools_5align_4_lcs_LCS, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_8obitools_5align_4_lcs_LCS, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_8obitools_5align_4_lcs_3LCS_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8obitools_5align_4_lcs_LCS, /*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[] = {
  {0, 0, 0, 0}
};

char* __pyx_import_star_type_names[] = {
  "__pyx_opt_args_8obitools_5align_8_dynamic_allocateMatrix",
  "column_t",
  "alignSequence",
  "__pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence",
  "int32_ptr",
  "__pyx_opt_args_8obitools_5align_8_dynamic_allocatePath",
  "LCS",
  "alignPath",
  "DynamicProgramming",
  "const_char_ptr",
  "AlignCell",
  "AlignMatrix",
  0
};

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


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

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

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

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


static int __pyx_import_star(PyObject* m) {

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

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

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

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


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

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 1},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_n_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 1},
  {&__pyx_n_s__ALILEN, __pyx_k__ALILEN, sizeof(__pyx_k__ALILEN), 0, 0, 1, 1},
  {&__pyx_n_s__BioSequence, __pyx_k__BioSequence, sizeof(__pyx_k__BioSequence), 0, 0, 1, 1},
  {&__pyx_n_s__MAXLEN, __pyx_k__MAXLEN, sizeof(__pyx_k__MAXLEN), 0, 0, 1, 1},
  {&__pyx_n_s__MINLEN, __pyx_k__MINLEN, sizeof(__pyx_k__MINLEN), 0, 0, 1, 1},
  {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___upperbond, __pyx_k___upperbond, sizeof(__pyx_k___upperbond), 0, 0, 1, 1},
  {&__pyx_n_s__alilength, __pyx_k__alilength, sizeof(__pyx_k__alilength), 0, 0, 1, 1},
  {&__pyx_n_s__extgap, __pyx_k__extgap, sizeof(__pyx_k__extgap), 0, 0, 1, 1},
  {&__pyx_n_s__l1, __pyx_k__l1, sizeof(__pyx_k__l1), 0, 0, 1, 1},
  {&__pyx_n_s__l2, __pyx_k__l2, sizeof(__pyx_k__l2), 0, 0, 1, 1},
  {&__pyx_n_s__large, __pyx_k__large, sizeof(__pyx_k__large), 0, 0, 1, 1},
  {&__pyx_n_s__lcs, __pyx_k__lcs, sizeof(__pyx_k__lcs), 0, 0, 1, 1},
  {&__pyx_n_s__lcsali, __pyx_k__lcsali, sizeof(__pyx_k__lcsali), 0, 0, 1, 1},
  {&__pyx_n_s__lenlcs, __pyx_k__lenlcs, sizeof(__pyx_k__lenlcs), 0, 0, 1, 1},
  {&__pyx_n_s__minimum, __pyx_k__minimum, sizeof(__pyx_k__minimum), 0, 0, 1, 1},
  {&__pyx_n_s__needToCompute, __pyx_k__needToCompute, sizeof(__pyx_k__needToCompute), 0, 0, 1, 1},
  {&__pyx_n_s__normalized, __pyx_k__normalized, sizeof(__pyx_k__normalized), 0, 0, 1, 1},
  {&__pyx_n_s__o1, __pyx_k__o1, sizeof(__pyx_k__o1), 0, 0, 1, 1},
  {&__pyx_n_s__o2, __pyx_k__o2, sizeof(__pyx_k__o2), 0, 0, 1, 1},
  {&__pyx_n_s__ob_size, __pyx_k__ob_size, sizeof(__pyx_k__ob_size), 0, 0, 1, 1},
  {&__pyx_n_s__obitools, __pyx_k__obitools, sizeof(__pyx_k__obitools), 0, 0, 1, 1},
  {&__pyx_n_s__op, __pyx_k__op, sizeof(__pyx_k__op), 0, 0, 1, 1},
  {&__pyx_n_s__opengap, __pyx_k__opengap, sizeof(__pyx_k__opengap), 0, 0, 1, 1},
  {&__pyx_n_s__possible, __pyx_k__possible, sizeof(__pyx_k__possible), 0, 0, 1, 1},
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  {&__pyx_n_s__reference, __pyx_k__reference, sizeof(__pyx_k__reference), 0, 0, 1, 1},
  {&__pyx_n_s__s1, __pyx_k__s1, sizeof(__pyx_k__s1), 0, 0, 1, 1},
  {&__pyx_n_s__s2, __pyx_k__s2, sizeof(__pyx_k__s2), 0, 0, 1, 1},
  {&__pyx_n_s__se1, __pyx_k__se1, sizeof(__pyx_k__se1), 0, 0, 1, 1},
  {&__pyx_n_s__se2, __pyx_k__se2, sizeof(__pyx_k__se2), 0, 0, 1, 1},
  {&__pyx_n_s__seq1, __pyx_k__seq1, sizeof(__pyx_k__seq1), 0, 0, 1, 1},
  {&__pyx_n_s__seq2, __pyx_k__seq2, sizeof(__pyx_k__seq2), 0, 0, 1, 1},
  {&__pyx_n_s__seqA, __pyx_k__seqA, sizeof(__pyx_k__seqA), 0, 0, 1, 1},
  {&__pyx_n_s__seqB, __pyx_k__seqB, sizeof(__pyx_k__seqB), 0, 0, 1, 1},
  {&__pyx_n_s__w1, __pyx_k__w1, sizeof(__pyx_k__w1), 0, 0, 1, 1},
  {&__pyx_n_s__w2, __pyx_k__w2, sizeof(__pyx_k__w2), 0, 0, 1, 1},
  {&__pyx_n_s__word4over, __pyx_k__word4over, sizeof(__pyx_k__word4over), 0, 0, 1, 1},
  {&__pyx_n_s__word4table, __pyx_k__word4table, sizeof(__pyx_k__word4table), 0, 0, 1, 1},
  {&__pyx_n_s__wordcount, __pyx_k__wordcount, sizeof(__pyx_k__wordcount), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __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/_lcs.pyx":134
 * MINLEN=2
 * 
 * def lenlcs(seq1,seq2,double minimum=0.,bint normalized=False, int reference=ALILEN):             # <<<<<<<<<<<<<<
 *     cdef double lcs
 *     cdef bytes se1=bytes(str(seq1))
 */
  __pyx_k_tuple_4 = PyTuple_New(21); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_4);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__seq1));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_n_s__seq1));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__seq1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__seq2));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 1, ((PyObject *)__pyx_n_s__seq2));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__seq2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__minimum));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 2, ((PyObject *)__pyx_n_s__minimum));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__minimum));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__normalized));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 3, ((PyObject *)__pyx_n_s__normalized));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__normalized));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__reference));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 4, ((PyObject *)__pyx_n_s__reference));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__reference));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__lcs));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 5, ((PyObject *)__pyx_n_s__lcs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__lcs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__se1));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 6, ((PyObject *)__pyx_n_s__se1));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__se1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__se2));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 7, ((PyObject *)__pyx_n_s__se2));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__se2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__l1));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 8, ((PyObject *)__pyx_n_s__l1));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__l2));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 9, ((PyObject *)__pyx_n_s__l2));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__w1));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 10, ((PyObject *)__pyx_n_s__w1));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__w1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__w2));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 11, ((PyObject *)__pyx_n_s__w2));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__w2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__o1));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 12, ((PyObject *)__pyx_n_s__o1));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__o1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__o2));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 13, ((PyObject *)__pyx_n_s__o2));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__o2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__wordcount));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 14, ((PyObject *)__pyx_n_s__wordcount));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__wordcount));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__alilength));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 15, ((PyObject *)__pyx_n_s__alilength));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__alilength));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__possible));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 16, ((PyObject *)__pyx_n_s__possible));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__possible));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__large));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 17, ((PyObject *)__pyx_n_s__large));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__large));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__s1));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 18, ((PyObject *)__pyx_n_s__s1));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__s1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__s2));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 19, ((PyObject *)__pyx_n_s__s2));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__s2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__lcsali));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 20, ((PyObject *)__pyx_n_s__lcsali));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__lcsali));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4));
  __pyx_k_codeobj_5 = (PyObject*)__Pyx_PyCode_New(5, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_6, __pyx_n_s__lenlcs, 134, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__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_lcs(void); /*proto*/
PyMODINIT_FUNC init_lcs(void)
#else
PyMODINIT_FUNC PyInit__lcs(void); /*proto*/
PyMODINIT_FUNC PyInit__lcs(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  __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__lcs(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("_lcs"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_2), 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___lcs) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming = __Pyx_ImportType("obitools.align._dynamic", "DynamicProgramming", sizeof(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming), 1); if (unlikely(!__pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_8obitools_5align_8_dynamic_DynamicProgramming = (struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming*)__Pyx_GetVtable(__pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming->tp_dict); if (unlikely(!__pyx_vtabptr_8obitools_5align_8_dynamic_DynamicProgramming)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_8obitools_5align_4_lcs_LCS = &__pyx_vtable_8obitools_5align_4_lcs_LCS;
  __pyx_vtable_8obitools_5align_4_lcs_LCS.__pyx_base = *__pyx_vtabptr_8obitools_5align_8_dynamic_DynamicProgramming;
  __pyx_vtable_8obitools_5align_4_lcs_LCS.__pyx_base.doAlignment = (double (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment;
  __pyx_vtable_8obitools_5align_4_lcs_LCS.__pyx_base.backtrack = (void (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_4_lcs_3LCS_backtrack;
  __pyx_vtable_8obitools_5align_4_lcs_LCS.matchScore = (double (*)(struct __pyx_obj_8obitools_5align_4_lcs_LCS *, int, int))__pyx_f_8obitools_5align_4_lcs_3LCS_matchScore;
  __pyx_type_8obitools_5align_4_lcs_LCS.tp_base = __pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming;
  if (PyType_Ready(&__pyx_type_8obitools_5align_4_lcs_LCS) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_8obitools_5align_4_lcs_LCS.tp_dict, __pyx_vtabptr_8obitools_5align_4_lcs_LCS) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "LCS", (PyObject *)&__pyx_type_8obitools_5align_4_lcs_LCS) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_8obitools_5align_4_lcs_LCS = &__pyx_type_8obitools_5align_4_lcs_LCS;
  /*--- Type import code ---*/
  __pyx_ptype_8obitools_5align_5array_array = __Pyx_ImportType("array", "array", sizeof(arrayobject), 0); if (unlikely(!__pyx_ptype_8obitools_5align_5array_array)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("obitools.align._upperbond"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_1, "newtable", (void (**)(void))&__pyx_f_8obitools_5align_10_upperbond_newtable, "arrayobject *(void)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = __Pyx_ImportModule("obitools.align._dynamic"); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "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_ImportFunction(__pyx_t_2, "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;}
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  /*--- Execution code ---*/

  /* "obitools/align/_lcs.pyx":8
 * #@PydevCodeAnalysisIgnore
 * 
 * from obitools import BioSequence             # <<<<<<<<<<<<<<
 * from _lcs cimport *
 * from _upperbond cimport *
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__BioSequence));
  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__BioSequence));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__BioSequence));
  __pyx_t_4 = __Pyx_Import(((PyObject *)__pyx_n_s__obitools), ((PyObject *)__pyx_t_3), -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__BioSequence);
  if (__pyx_t_3 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__BioSequence);
    if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BioSequence, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "obitools/align/_lcs.pyx":13
 * from _dynamic cimport *
 * 
 * from _upperbond import *             # <<<<<<<<<<<<<<
 * 
 * cdef class LCS(DynamicProgramming):
 */
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_n_s_3));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_3));
  __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s___upperbond), ((PyObject *)__pyx_t_4), -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  if (__pyx_import_star(__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "obitools/align/_lcs.pyx":130
 *         #return 0,0,path
 * 
 * ALILEN=0             # <<<<<<<<<<<<<<
 * MAXLEN=1
 * MINLEN=2
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ALILEN, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "obitools/align/_lcs.pyx":131
 * 
 * ALILEN=0
 * MAXLEN=1             # <<<<<<<<<<<<<<
 * MINLEN=2
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__MAXLEN, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "obitools/align/_lcs.pyx":132
 * ALILEN=0
 * MAXLEN=1
 * MINLEN=2             # <<<<<<<<<<<<<<
 * 
 * def lenlcs(seq1,seq2,double minimum=0.,bint normalized=False, int reference=ALILEN):
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__MINLEN, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "obitools/align/_lcs.pyx":134
 * MINLEN=2
 * 
 * def lenlcs(seq1,seq2,double minimum=0.,bint normalized=False, int reference=ALILEN):             # <<<<<<<<<<<<<<
 *     cdef double lcs
 *     cdef bytes se1=bytes(str(seq1))
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ALILEN); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_k_1 = __pyx_t_5;
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_8obitools_5align_4_lcs_1lenlcs, NULL, __pyx_n_s_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__lenlcs, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "obitools/align/_lcs.pyx":1
 * '''             # <<<<<<<<<<<<<<
 * Created on 6 Nov. 2009
 * 
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;

  /* "array.pxd":182
 * 
 * 
 * cdef inline void zero(array op):             # <<<<<<<<<<<<<<
 *     memset(op.ob_item, 0, op.ob_size * op.ob_descr.itemsize)
 */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__pyx_m) {
    __Pyx_AddTraceback("init obitools.align._lcs", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init obitools.align._lcs");
  }
  __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 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 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 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_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static CYTHON_INLINE int __Pyx_IsLittleEndian(void) {
  unsigned int n = 1;
  return *(unsigned char*)(&n) != 0;
}
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type) {
  stack[0].field = &ctx->root;
  stack[0].parent_offset = 0;
  ctx->root.type = type;
  ctx->root.name = "buffer dtype";
  ctx->root.offset = 0;
  ctx->head = stack;
  ctx->head->field = &ctx->root;
  ctx->fmt_offset = 0;
  ctx->head->parent_offset = 0;
  ctx->new_packmode = '@';
  ctx->enc_packmode = '@';
  ctx->new_count = 1;
  ctx->enc_count = 0;
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  ctx->is_valid_array = 0;
  ctx->struct_alignment = 0;
  while (type->typegroup == 'S') {
    ++ctx->head;
    ctx->head->field = type->fields;
    ctx->head->parent_offset = 0;
    type = type->fields->type;
  }
}
static int __Pyx_BufFmt_ParseNumber(const char** ts) {
    int count;
    const char* t = *ts;
    if (*t < '0' || *t > '9') {
      return -1;
    } else {
        count = *t++ - '0';
        while (*t >= '0' && *t < '9') {
            count *= 10;
            count += *t++ - '0';
        }
    }
    *ts = t;
    return count;
}
static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
    int number = __Pyx_BufFmt_ParseNumber(ts);
    if (number == -1) /* First char was not a digit */
        PyErr_Format(PyExc_ValueError,\
                     "Does not understand character buffer dtype format string ('%c')", **ts);
    return number;
}
static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
  PyErr_Format(PyExc_ValueError,
               "Unexpected format string character: '%c'", ch);
}
static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
  switch (ch) {
    case 'b': return "'char'";
    case 'B': return "'unsigned char'";
    case 'h': return "'short'";
    case 'H': return "'unsigned short'";
    case 'i': return "'int'";
    case 'I': return "'unsigned int'";
    case 'l': return "'long'";
    case 'L': return "'unsigned long'";
    case 'q': return "'long long'";
    case 'Q': return "'unsigned long long'";
    case 'f': return (is_complex ? "'complex float'" : "'float'");
    case 'd': return (is_complex ? "'complex double'" : "'double'");
    case 'g': return (is_complex ? "'complex long double'" : "'long double'");
    case 'T': return "a struct";
    case 'O': return "Python object";
    case 'P': return "a pointer";
    case 's': case 'p': return "a string";
    case 0: return "end";
    default: return "unparseable format string";
  }
}
static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return 2;
    case 'i': case 'I': case 'l': case 'L': return 4;
    case 'q': case 'Q': return 8;
    case 'f': return (is_complex ? 8 : 4);
    case 'd': return (is_complex ? 16 : 8);
    case 'g': {
      PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
      return 0;
    }
    case 'O': case 'P': return sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
  switch (ch) {
    case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(short);
    case 'i': case 'I': return sizeof(int);
    case 'l': case 'L': return sizeof(long);
    #ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(PY_LONG_LONG);
    #endif
    case 'f': return sizeof(float) * (is_complex ? 2 : 1);
    case 'd': return sizeof(double) * (is_complex ? 2 : 1);
    case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
    case 'O': case 'P': return sizeof(void*);
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
typedef struct { char c; short x; } __Pyx_st_short;
typedef struct { char c; int x; } __Pyx_st_int;
typedef struct { char c; long x; } __Pyx_st_long;
typedef struct { char c; float x; } __Pyx_st_float;
typedef struct { char c; double x; } __Pyx_st_double;
typedef struct { char c; long double x; } __Pyx_st_longdouble;
typedef struct { char c; void *x; } __Pyx_st_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
/* These are for computing the padding at the end of the struct to align
   on the first member of the struct. This will probably the same as above,
   but we don't have any guarantees.
 */
typedef struct { short x; char c; } __Pyx_pad_short;
typedef struct { int x; char c; } __Pyx_pad_int;
typedef struct { long x; char c; } __Pyx_pad_long;
typedef struct { float x; char c; } __Pyx_pad_float;
typedef struct { double x; char c; } __Pyx_pad_double;
typedef struct { long double x; char c; } __Pyx_pad_longdouble;
typedef struct { void *x; char c; } __Pyx_pad_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
  switch (ch) {
    case 'c': case 'b': case 'h': case 'i':
    case 'l': case 'q': case 's': case 'p':
        return 'I';
    case 'B': case 'H': case 'I': case 'L': case 'Q':
        return 'U';
    case 'f': case 'd': case 'g':
        return (is_complex ? 'C' : 'R');
    case 'O':
        return 'O';
    case 'P':
        return 'P';
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
  if (ctx->head == NULL || ctx->head->field == &ctx->root) {
    const char* expected;
    const char* quote;
    if (ctx->head == NULL) {
      expected = "end";
      quote = "";
    } else {
      expected = ctx->head->field->type->name;
      quote = "'";
    }
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected %s%s%s but got %s",
                 quote, expected, quote,
                 __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
  } else {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_StructField* parent = (ctx->head - 1)->field;
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
                 field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
                 parent->type->name, field->name);
  }
}
static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
  char group;
  size_t size, offset, arraysize = 1;
  if (ctx->enc_type == 0) return 0;
  if (ctx->head->field->type->arraysize[0]) {
    int i, ndim = 0;
    if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
        ctx->is_valid_array = ctx->head->field->type->ndim == 1;
        ndim = 1;
        if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
            PyErr_Format(PyExc_ValueError,
                         "Expected a dimension of size %zu, got %zu",
                         ctx->head->field->type->arraysize[0], ctx->enc_count);
            return -1;
        }
    }
    if (!ctx->is_valid_array) {
      PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
                   ctx->head->field->type->ndim, ndim);
      return -1;
    }
    for (i = 0; i < ctx->head->field->type->ndim; i++) {
      arraysize *= ctx->head->field->type->arraysize[i];
    }
    ctx->is_valid_array = 0;
    ctx->enc_count = 1;
  }
  group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
  do {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_TypeInfo* type = field->type;
    if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
      size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
    } else {
      size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
    }
    if (ctx->enc_packmode == '@') {
      size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
      size_t align_mod_offset;
      if (align_at == 0) return -1;
      align_mod_offset = ctx->fmt_offset % align_at;
      if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
      if (ctx->struct_alignment == 0)
          ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
                                                                 ctx->is_complex);
    }
    if (type->size != size || type->typegroup != group) {
      if (type->typegroup == 'C' && type->fields != NULL) {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        ++ctx->head;
        ctx->head->field = type->fields;
        ctx->head->parent_offset = parent_offset;
        continue;
      }
      __Pyx_BufFmt_RaiseExpected(ctx);
      return -1;
    }
    offset = ctx->head->parent_offset + field->offset;
    if (ctx->fmt_offset != offset) {
      PyErr_Format(PyExc_ValueError,
                   "Buffer dtype mismatch; next field is at offset %"PY_FORMAT_SIZE_T"d but %"PY_FORMAT_SIZE_T"d expected",
                   (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
      return -1;
    }
    ctx->fmt_offset += size;
    if (arraysize)
      ctx->fmt_offset += (arraysize - 1) * size;
    --ctx->enc_count; /* Consume from buffer string */
    while (1) {
      if (field == &ctx->root) {
        ctx->head = NULL;
        if (ctx->enc_count != 0) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
        }
        break; /* breaks both loops as ctx->enc_count == 0 */
      }
      ctx->head->field = ++field;
      if (field->type == NULL) {
        --ctx->head;
        field = ctx->head->field;
        continue;
      } else if (field->type->typegroup == 'S') {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        if (field->type->fields->type == NULL) continue; /* empty struct */
        field = field->type->fields;
        ++ctx->head;
        ctx->head->field = field;
        ctx->head->parent_offset = parent_offset;
        break;
      } else {
        break;
      }
    }
  } while (ctx->enc_count);
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  return 0;
}
static CYTHON_INLINE PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
{
    const char *ts = *tsp;
    int i = 0, number;
    int ndim = ctx->head->field->type->ndim;
;
    ++ts;
    if (ctx->new_count != 1) {
        PyErr_SetString(PyExc_ValueError,
                        "Cannot handle repeated arrays in format string");
        return NULL;
    }
    if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
    while (*ts && *ts != ')') {
        if (isspace(*ts))
            continue;
        number = __Pyx_BufFmt_ExpectNumber(&ts);
        if (number == -1) return NULL;
        if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
            return PyErr_Format(PyExc_ValueError,
                        "Expected a dimension of size %zu, got %d",
                        ctx->head->field->type->arraysize[i], number);
        if (*ts != ',' && *ts != ')')
            return PyErr_Format(PyExc_ValueError,
                                "Expected a comma in format string, got '%c'", *ts);
        if (*ts == ',') ts++;
        i++;
    }
    if (i != ndim)
        return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
                            ctx->head->field->type->ndim, i);
    if (!*ts) {
        PyErr_SetString(PyExc_ValueError,
                        "Unexpected end of format string, expected ')'");
        return NULL;
    }
    ctx->is_valid_array = 1;
    ctx->new_count = 1;
    *tsp = ++ts;
    return Py_None;
}
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
  int got_Z = 0;
  while (1) {
    switch(*ts) {
      case 0:
        if (ctx->enc_type != 0 && ctx->head == NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        if (ctx->head != NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
                return ts;
      case ' ':
      case 10:
      case 13:
        ++ts;
        break;
      case '<':
        if (!__Pyx_IsLittleEndian()) {
          PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '>':
      case '!':
        if (__Pyx_IsLittleEndian()) {
          PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '=':
      case '@':
      case '^':
        ctx->new_packmode = *ts++;
        break;
      case 'T': /* substruct */
        {
          const char* ts_after_sub;
          size_t i, struct_count = ctx->new_count;
          size_t struct_alignment = ctx->struct_alignment;
          ctx->new_count = 1;
          ++ts;
          if (*ts != '{') {
            PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
            return NULL;
          }
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0; /* Erase processed last struct element */
          ctx->enc_count = 0;
          ctx->struct_alignment = 0;
          ++ts;
          ts_after_sub = ts;
          for (i = 0; i != struct_count; ++i) {
            ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
            if (!ts_after_sub) return NULL;
          }
          ts = ts_after_sub;
          if (struct_alignment) ctx->struct_alignment = struct_alignment;
        }
        break;
      case '}': /* end of substruct; either repeat or move on */
        {
          size_t alignment = ctx->struct_alignment;
          ++ts;
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0; /* Erase processed last struct element */
          if (alignment && ctx->fmt_offset % alignment) {
            ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
          }
        }
        return ts;
      case 'x':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->fmt_offset += ctx->new_count;
        ctx->new_count = 1;
        ctx->enc_count = 0;
        ctx->enc_type = 0;
        ctx->enc_packmode = ctx->new_packmode;
        ++ts;
        break;
      case 'Z':
        got_Z = 1;
        ++ts;
        if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
          __Pyx_BufFmt_RaiseUnexpectedChar('Z');
          return NULL;
        }        /* fall through */
      case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
      case 'l': case 'L': case 'q': case 'Q':
      case 'f': case 'd': case 'g':
      case 'O': case 's': case 'p':
        if (ctx->enc_type == *ts && got_Z == ctx->is_complex &&
            ctx->enc_packmode == ctx->new_packmode) {
          ctx->enc_count += ctx->new_count;
        } else {
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_count = ctx->new_count;
          ctx->enc_packmode = ctx->new_packmode;
          ctx->enc_type = *ts;
          ctx->is_complex = got_Z;
        }
        ++ts;
        ctx->new_count = 1;
        got_Z = 0;
        break;
      case ':':
        ++ts;
        while(*ts != ':') ++ts;
        ++ts;
        break;
      case '(':
        if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
        break;
      default:
        {
          int number = __Pyx_BufFmt_ExpectNumber(&ts);
          if (number == -1) return NULL;
          ctx->new_count = (size_t)number;
        }
    }
  }
}
static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
  buf->buf = NULL;
  buf->obj = NULL;
  buf->strides = __Pyx_zeros;
  buf->shape = __Pyx_zeros;
  buf->suboffsets = __Pyx_minusones;
}
static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
        Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
        int nd, int cast, __Pyx_BufFmt_StackElem* stack)
{
  if (obj == Py_None || obj == NULL) {
    __Pyx_ZeroBuffer(buf);
    return 0;
  }
  buf->buf = NULL;
  if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
  if (buf->ndim != nd) {
    PyErr_Format(PyExc_ValueError,
                 "Buffer has wrong number of dimensions (expected %d, got %d)",
                 nd, buf->ndim);
    goto fail;
  }
  if (!cast) {
    __Pyx_BufFmt_Context ctx;
    __Pyx_BufFmt_Init(&ctx, stack, dtype);
    if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
  }
  if ((unsigned)buf->itemsize != dtype->size) {
    PyErr_Format(PyExc_ValueError,
      "Item size of buffer (%"PY_FORMAT_SIZE_T"d byte%s) does not match size of '%s' (%"PY_FORMAT_SIZE_T"d byte%s)",
      buf->itemsize, (buf->itemsize > 1) ? "s" : "",
      dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
    goto fail;
  }
  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
  return 0;
fail:;
  __Pyx_ZeroBuffer(buf);
  return -1;
}
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
  if (info->buf == NULL) return;
  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
  __Pyx_ReleaseBuffer(info);
}

static void __Pyx_RaiseBufferFallbackError(void) {
  PyErr_Format(PyExc_ValueError,
     "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
}

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

#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
    PyObject *getbuffer_cobj;

  #if PY_VERSION_HEX >= 0x02060000
    if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
  #endif

        if (PyObject_TypeCheck(obj, __pyx_ptype_8obitools_5align_5array_array)) return __pyx_pw_8obitools_5align_5array_5array_1__getbuffer__(obj, view, flags);

  #if PY_VERSION_HEX < 0x02060000
    if (obj->ob_type->tp_dict &&
        (getbuffer_cobj = PyMapping_GetItemString(obj->ob_type->tp_dict,
                                             "__pyx_getbuffer"))) {
        getbufferproc func;

      #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0)
        func = (getbufferproc) PyCapsule_GetPointer(getbuffer_cobj, "getbuffer(obj, view, flags)");
      #else
        func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj);
      #endif
        Py_DECREF(getbuffer_cobj);
        if (!func)
            goto fail;

        return func(obj, view, flags);
    } else {
        PyErr_Clear();
    }
  #endif

    PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name);

#if PY_VERSION_HEX < 0x02060000
fail:
#endif

    return -1;
}

static void __Pyx_ReleaseBuffer(Py_buffer *view) {
    PyObject *obj = view->obj;
    PyObject *releasebuffer_cobj;

    if (!obj) return;

  #if PY_VERSION_HEX >= 0x02060000
    if (PyObject_CheckBuffer(obj)) {
        PyBuffer_Release(view);
        return;
    }
  #endif

        if (PyObject_TypeCheck(obj, __pyx_ptype_8obitools_5align_5array_array)) { __pyx_pw_8obitools_5align_5array_5array_3__releasebuffer__(obj, view); return; }

  #if PY_VERSION_HEX < 0x02060000
    if (obj->ob_type->tp_dict &&
        (releasebuffer_cobj = PyMapping_GetItemString(obj->ob_type->tp_dict,
                                                      "__pyx_releasebuffer"))) {
        releasebufferproc func;

      #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0)
        func = (releasebufferproc) PyCapsule_GetPointer(releasebuffer_cobj, "releasebuffer(obj, view)");
      #else
        func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj);
      #endif

        Py_DECREF(releasebuffer_cobj);

        if (!func)
            goto fail;

        func(obj, view);
        return;
    } else {
        PyErr_Clear();
    }
  #endif

    goto nofail;

#if PY_VERSION_HEX < 0x02060000
fail:
#endif
    PyErr_WriteUnraisable(obj);

nofail:
    Py_DECREF(obj);
    view->obj = NULL;
}

#endif /*  PY_MAJOR_VERSION < 3 */

    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 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 CYTHON_INLINE int __Pyx_StrEq(const char *s1, const char *s2) {
     while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
     return *s1 == *s2;
}

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

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (!strict && (size_t)((PyTypeObject *)result)->tp_basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        if (PyErr_Warn(NULL, warning) < 0) goto bad;
        #else
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
        #endif
    }
    else if ((size_t)((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

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

#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%s does not export expected C function %s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

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