/* 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___nwsdnabyprot
#define __PYX_HAVE_API__obitools__align___nwsdnabyprot
#include "stdlib.h"
#include "string.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


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

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

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


/* Type Conversion Predeclarations */

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

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

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

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

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


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

/*--- Type declarations ---*/
struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming;
struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt;
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;
};
struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignCell;
struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix;
struct __pyx_opt_args_8obitools_5align_13_nwsdnabyprot_allocateCodonMatrix;

/* "obitools/align/_nwsdnabyprot.pxd":3
 * from _dynamic cimport *
 * 
 * cdef struct CodonAlignCell :             # <<<<<<<<<<<<<<
 *     double score
 *     int   path
 */
struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignCell {
  double score;
  int path;
  int frame;
};

/* "obitools/align/_nwsdnabyprot.pxd":8
 *     int   frame
 * 
 * cdef struct CodonAlignMatrix :             # <<<<<<<<<<<<<<
 *     CodonAlignCell*  matrix
 *     int*        bestVJump
 */
struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix {
  struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignCell *matrix;
  int *bestVJump;
  int *bestHJump;
  int msize;
  int vsize;
  int hsize;
};

/* "obitools/align/_nwsdnabyprot.pxd":16
 *     int         hsize
 * 
 * cdef CodonAlignMatrix* allocateCodonMatrix(int hsize, int vsize,CodonAlignMatrix *matrix=?)             # <<<<<<<<<<<<<<
 * cdef void freeCodonMatrix(CodonAlignMatrix* matrix)
 * cdef void resetCodonMatrix(CodonAlignMatrix* matrix)
 */
struct __pyx_opt_args_8obitools_5align_13_nwsdnabyprot_allocateCodonMatrix {
  int __pyx_n;
  struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *matrix;
};

/* "_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/_nwsdnabyprot.pxd":22
 * cdef double iupacPartialCodonMatch(char[3] c1, char[3] c2)
 * 
 * cdef class NWSDNAByProt(DynamicProgramming):             # <<<<<<<<<<<<<<
 *     cdef double _match
 *     cdef double _mismatch
 */
struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt {
  struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming __pyx_base;
  double _match;
  double _mismatch;
  int _sframe;
  PyObject *_gc;
};



/* "_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/_nwsdnabyprot.pyx":73
 *             iupacPartialMatch(c1[2],c2[2])) / 3.0
 * 
 * cdef class NWSDNAByProt(DynamicProgramming):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self,match=4,
 */

struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt {
  struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming __pyx_base;
  void (*getPossibleCodon)(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *, char *, int, int, int);
  double (*aaScore)(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *, char, char);
  double (*matchScore)(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *, int, int, int);
};
static struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_vtabptr_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt;
#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_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 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 long __Pyx_mod_long(long, long); /* proto */

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

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

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

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

static CYTHON_INLINE void __Pyx_RaiseImportError(PyObject *name);

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

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

static int __Pyx_check_binary_version(void);

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

#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 'obitools.align._dynamic' */
static PyTypeObject *__pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming = 0;
static void (*__pyx_f_8obitools_5align_8_dynamic_freeSequence)(struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *); /*proto*/
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 void (*__pyx_f_8obitools_5align_8_dynamic_freePath)(struct __pyx_t_8obitools_5align_8_dynamic_alignPath *); /*proto*/
static double (*__pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch)(unsigned char, unsigned char, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'obitools.align._nwsdnabyprot' */
static PyTypeObject *__pyx_ptype_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt = 0;
static struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *__pyx_f_8obitools_5align_13_nwsdnabyprot_allocateCodonMatrix(int, int, struct __pyx_opt_args_8obitools_5align_13_nwsdnabyprot_allocateCodonMatrix *__pyx_optional_args); /*proto*/
static void __pyx_f_8obitools_5align_13_nwsdnabyprot_freeCodonMatrix(struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *); /*proto*/
static void __pyx_f_8obitools_5align_13_nwsdnabyprot_resetCodonMatrix(struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *); /*proto*/
#define __Pyx_MODULE_NAME "obitools.align._nwsdnabyprot"
int __pyx_module_is_main_obitools__align___nwsdnabyprot = 0;

/* Implementation of 'obitools.align._nwsdnabyprot' */
static PyObject *__pyx_builtin_ord;
static PyObject *__pyx_builtin_range;
static int __pyx_pf_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt___init__(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self, PyObject *__pyx_v_match, PyObject *__pyx_v_mismatch, PyObject *__pyx_v_opengap, PyObject *__pyx_v_extgap, PyObject *__pyx_v_geneticCode, PyObject *__pyx_v_startingFrame); /* proto */
static PyObject *__pyx_pf_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_5match___get__(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self); /* proto */
static int __pyx_pf_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_5match_2__set__(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self, PyObject *__pyx_v_match); /* proto */
static PyObject *__pyx_pf_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_8mismatch___get__(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self); /* proto */
static int __pyx_pf_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_8mismatch_2__set__(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self, PyObject *__pyx_v_mismatch); /* proto */
static PyObject *__pyx_pf_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_2__call__(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self); /* proto */
static char __pyx_k_1[] = "Sequence A must be set";
static char __pyx_k_2[] = "Sequence B must be set";
static char __pyx_k_3[] = "\nCreated on 6 Nov. 2009\n\n@author: coissac\n";
static char __pyx_k_4[] = "obitools.sequenceencoder.geneticcode";
static char __pyx_k_5[] = "obitools.translate";
static char __pyx_k_6[] = "obitools.alignment";
static char __pyx_k__ord[] = "ord";
static char __pyx_k__sys[] = "sys";
static char __pyx_k__gaps[] = "gaps";
static char __pyx_k__clone[] = "clone";
static char __pyx_k__frame[] = "frame";
static char __pyx_k__match[] = "match";
static char __pyx_k__range[] = "range";
static char __pyx_k__score[] = "score";
static char __pyx_k__extend[] = "extend";
static char __pyx_k__extgap[] = "extgap";
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__mismatch[] = "mismatch";
static char __pyx_k__obitools[] = "obitools";
static char __pyx_k__Alignment[] = "Alignment";
static char __pyx_k__BioSequence[] = "BioSequence";
static char __pyx_k__GeneticCode[] = "GeneticCode";
static char __pyx_k__geneticCode[] = "geneticCode";
static char __pyx_k__needToCompute[] = "needToCompute";
static char __pyx_k__startingFrame[] = "startingFrame";
static char __pyx_k__AlignedSequence[] = "AlignedSequence";
static char __pyx_k__TranslationEncoder[] = "TranslationEncoder";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_n_s_4;
static PyObject *__pyx_n_s_5;
static PyObject *__pyx_n_s_6;
static PyObject *__pyx_n_s__AlignedSequence;
static PyObject *__pyx_n_s__Alignment;
static PyObject *__pyx_n_s__BioSequence;
static PyObject *__pyx_n_s__GeneticCode;
static PyObject *__pyx_n_s__TranslationEncoder;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s__clone;
static PyObject *__pyx_n_s__extend;
static PyObject *__pyx_n_s__extgap;
static PyObject *__pyx_n_s__frame;
static PyObject *__pyx_n_s__gaps;
static PyObject *__pyx_n_s__geneticCode;
static PyObject *__pyx_n_s__match;
static PyObject *__pyx_n_s__mismatch;
static PyObject *__pyx_n_s__needToCompute;
static PyObject *__pyx_n_s__obitools;
static PyObject *__pyx_n_s__opengap;
static PyObject *__pyx_n_s__ord;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__score;
static PyObject *__pyx_n_s__startingFrame;
static PyObject *__pyx_n_s__sys;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_neg_2;
static PyObject *__pyx_int_neg_6;
static PyObject *__pyx_int_neg_8;
static PyObject *__pyx_int_neg_10;

/* "obitools/align/_nwsdnabyprot.pyx":20
 * 
 * 
 * cdef CodonAlignMatrix* allocateCodonMatrix(int hsize, int vsize,CodonAlignMatrix *matrix=NULL):             # <<<<<<<<<<<<<<
 * 
 *     vsize+=1
 */

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

  /* "obitools/align/_nwsdnabyprot.pyx":22
 * cdef CodonAlignMatrix* allocateCodonMatrix(int hsize, int vsize,CodonAlignMatrix *matrix=NULL):
 * 
 *     vsize+=1             # <<<<<<<<<<<<<<
 *     hsize+=1
 * 
 */
  __pyx_v_vsize = (__pyx_v_vsize + 1);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  /* "obitools/align/_nwsdnabyprot.pyx":46
 *         matrix.matrix = <CodonAlignCell*>realloc(matrix.matrix, matrix.msize * sizeof(CodonAlignCell))
 * 
 *     return matrix             # <<<<<<<<<<<<<<
 * 
 * cdef void freeCodonMatrix(CodonAlignMatrix* matrix):
 */
  __pyx_r = __pyx_v_matrix;
  goto __pyx_L0;

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

/* "obitools/align/_nwsdnabyprot.pyx":48
 *     return matrix
 * 
 * cdef void freeCodonMatrix(CodonAlignMatrix* matrix):             # <<<<<<<<<<<<<<
 *     if matrix is not NULL:
 *         if matrix.matrix is not NULL:
 */

static void __pyx_f_8obitools_5align_13_nwsdnabyprot_freeCodonMatrix(struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *__pyx_v_matrix) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("freeCodonMatrix", 0);

  /* "obitools/align/_nwsdnabyprot.pyx":49
 * 
 * cdef void freeCodonMatrix(CodonAlignMatrix* matrix):
 *     if matrix is not NULL:             # <<<<<<<<<<<<<<
 *         if matrix.matrix is not NULL:
 *             free(matrix.matrix)
 */
  __pyx_t_1 = (__pyx_v_matrix != NULL);
  if (__pyx_t_1) {

    /* "obitools/align/_nwsdnabyprot.pyx":50
 * cdef void freeCodonMatrix(CodonAlignMatrix* matrix):
 *     if matrix is not NULL:
 *         if matrix.matrix is not NULL:             # <<<<<<<<<<<<<<
 *             free(matrix.matrix)
 *         if matrix.bestVJump is not NULL:
 */
    __pyx_t_1 = (__pyx_v_matrix->matrix != NULL);
    if (__pyx_t_1) {

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

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

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

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

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

    /* "obitools/align/_nwsdnabyprot.pyx":56
 *         if matrix.bestHJump is not NULL:
 *             free(matrix.bestHJump)
 *         free(matrix)             # <<<<<<<<<<<<<<
 * 
 * cdef void resetCodonMatrix(CodonAlignMatrix* matrix):
 */
    free(__pyx_v_matrix);
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* "obitools/align/_nwsdnabyprot.pyx":58
 *         free(matrix)
 * 
 * cdef void resetCodonMatrix(CodonAlignMatrix* matrix):             # <<<<<<<<<<<<<<
 *     if matrix is not NULL:
 *         if matrix.matrix is not NULL:
 */

static void __pyx_f_8obitools_5align_13_nwsdnabyprot_resetCodonMatrix(struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *__pyx_v_matrix) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("resetCodonMatrix", 0);

  /* "obitools/align/_nwsdnabyprot.pyx":59
 * 
 * cdef void resetCodonMatrix(CodonAlignMatrix* matrix):
 *     if matrix is not NULL:             # <<<<<<<<<<<<<<
 *         if matrix.matrix is not NULL:
 *             bzero(<void*>matrix.matrix, matrix.msize * sizeof(CodonAlignCell))
 */
  __pyx_t_1 = (__pyx_v_matrix != NULL);
  if (__pyx_t_1) {

    /* "obitools/align/_nwsdnabyprot.pyx":60
 * cdef void resetCodonMatrix(CodonAlignMatrix* matrix):
 *     if matrix is not NULL:
 *         if matrix.matrix is not NULL:             # <<<<<<<<<<<<<<
 *             bzero(<void*>matrix.matrix, matrix.msize * sizeof(CodonAlignCell))
 *         if matrix.bestHJump is not NULL:
 */
    __pyx_t_1 = (__pyx_v_matrix->matrix != NULL);
    if (__pyx_t_1) {

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

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

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

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

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

  __Pyx_RefNannyFinishContext();
}

/* "obitools/align/_nwsdnabyprot.pyx":68
 * 
 * 
 * cdef double iupacPartialCodonMatch(char[3] c1, char[3] c2):             # <<<<<<<<<<<<<<
 *     return (iupacPartialMatch(c1[0],c2[0]) +
 *             iupacPartialMatch(c1[1],c2[1]) +
 */

static double __pyx_f_8obitools_5align_13_nwsdnabyprot_iupacPartialCodonMatch(char *__pyx_v_c1, char *__pyx_v_c2) {
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iupacPartialCodonMatch", 0);

  /* "obitools/align/_nwsdnabyprot.pyx":71
 *     return (iupacPartialMatch(c1[0],c2[0]) +
 *             iupacPartialMatch(c1[1],c2[1]) +
 *             iupacPartialMatch(c1[2],c2[2])) / 3.0             # <<<<<<<<<<<<<<
 * 
 * cdef class NWSDNAByProt(DynamicProgramming):
 */
  __pyx_r = (((__pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch((__pyx_v_c1[0]), (__pyx_v_c2[0]), 0) + __pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch((__pyx_v_c1[1]), (__pyx_v_c2[1]), 0)) + __pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch((__pyx_v_c1[2]), (__pyx_v_c2[2]), 0)) / 3.0);
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_match = 0;
  PyObject *__pyx_v_mismatch = 0;
  PyObject *__pyx_v_opengap = 0;
  PyObject *__pyx_v_extgap = 0;
  PyObject *__pyx_v_geneticCode = 0;
  PyObject *__pyx_v_startingFrame = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__match,&__pyx_n_s__mismatch,&__pyx_n_s__opengap,&__pyx_n_s__extgap,&__pyx_n_s__geneticCode,&__pyx_n_s__startingFrame,0};
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    PyObject* values[6] = {0,0,0,0,0,0};
    values[0] = ((PyObject *)__pyx_int_4);
    values[1] = ((PyObject *)__pyx_int_neg_6);
    values[2] = ((PyObject *)__pyx_int_neg_8);
    values[3] = ((PyObject *)__pyx_int_neg_2);

    /* "obitools/align/_nwsdnabyprot.pyx":79
 *                       opengap=-8,
 *                       extgap=-2,
 *                       geneticCode=None,             # <<<<<<<<<<<<<<
 *                       startingFrame=0):
 *         DynamicProgramming.__init__(self,opengap,extgap)
 */
    values[4] = ((PyObject *)Py_None);
    values[5] = ((PyObject *)__pyx_int_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  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__match);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mismatch);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__opengap);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__extgap);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__geneticCode);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__startingFrame);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_match = values[0];
    __pyx_v_mismatch = values[1];
    __pyx_v_opengap = values[2];
    __pyx_v_extgap = values[3];
    __pyx_v_geneticCode = values[4];
    __pyx_v_startingFrame = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("obitools.align._nwsdnabyprot.NWSDNAByProt.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt___init__(((struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self), __pyx_v_match, __pyx_v_mismatch, __pyx_v_opengap, __pyx_v_extgap, __pyx_v_geneticCode, __pyx_v_startingFrame);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_nwsdnabyprot.pyx":75
 * cdef class NWSDNAByProt(DynamicProgramming):
 * 
 *     def __init__(self,match=4,             # <<<<<<<<<<<<<<
 *                       mismatch=-6,
 *                       opengap=-8,
 */

static int __pyx_pf_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt___init__(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self, PyObject *__pyx_v_match, PyObject *__pyx_v_mismatch, PyObject *__pyx_v_opengap, PyObject *__pyx_v_extgap, PyObject *__pyx_v_geneticCode, PyObject *__pyx_v_startingFrame) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  double __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "obitools/align/_nwsdnabyprot.pyx":81
 *                       geneticCode=None,
 *                       startingFrame=0):
 *         DynamicProgramming.__init__(self,opengap,extgap)             # <<<<<<<<<<<<<<
 *         self._match=match
 *         self._mismatch=mismatch
 */
  __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 = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __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_INCREF(__pyx_v_opengap);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_opengap);
  __Pyx_GIVEREF(__pyx_v_opengap);
  __Pyx_INCREF(__pyx_v_extgap);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_extgap);
  __Pyx_GIVEREF(__pyx_v_extgap);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "obitools/align/_nwsdnabyprot.pyx":82
 *                       startingFrame=0):
 *         DynamicProgramming.__init__(self,opengap,extgap)
 *         self._match=match             # <<<<<<<<<<<<<<
 *         self._mismatch=mismatch
 * 
 */
  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_match); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_match = __pyx_t_4;

  /* "obitools/align/_nwsdnabyprot.pyx":83
 *         DynamicProgramming.__init__(self,opengap,extgap)
 *         self._match=match
 *         self._mismatch=mismatch             # <<<<<<<<<<<<<<
 * 
 *         if geneticCode is None:
 */
  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_mismatch); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_mismatch = __pyx_t_4;

  /* "obitools/align/_nwsdnabyprot.pyx":85
 *         self._mismatch=mismatch
 * 
 *         if geneticCode is None:             # <<<<<<<<<<<<<<
 *             self._gc = TranslationEncoder()
 *         else:
 */
  __pyx_t_5 = (__pyx_v_geneticCode == Py_None);
  if (__pyx_t_5) {

    /* "obitools/align/_nwsdnabyprot.pyx":86
 * 
 *         if geneticCode is None:
 *             self._gc = TranslationEncoder()             # <<<<<<<<<<<<<<
 *         else:
 *             self._gc = GeneticCode
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__TranslationEncoder); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->_gc);
    __Pyx_DECREF(__pyx_v_self->_gc);
    __pyx_v_self->_gc = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "obitools/align/_nwsdnabyprot.pyx":88
 *             self._gc = TranslationEncoder()
 *         else:
 *             self._gc = GeneticCode             # <<<<<<<<<<<<<<
 * 
 *         self._sframe = startingFrame
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__GeneticCode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->_gc);
    __Pyx_DECREF(__pyx_v_self->_gc);
    __pyx_v_self->_gc = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "obitools/align/_nwsdnabyprot.pyx":90
 *             self._gc = GeneticCode
 * 
 *         self._sframe = startingFrame             # <<<<<<<<<<<<<<
 * 
 *     cdef double aaScore(self,char aa1,char aa2):
 */
  __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_startingFrame); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_sframe = __pyx_t_6;

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

/* "obitools/align/_nwsdnabyprot.pyx":92
 *         self._sframe = startingFrame
 * 
 *     cdef double aaScore(self,char aa1,char aa2):             # <<<<<<<<<<<<<<
 *         if aa1==aa2 or aa1=='X' or aa2=='X':
 *             return self._match
 */

static double __pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_aaScore(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self, char __pyx_v_aa1, char __pyx_v_aa2) {
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("aaScore", 0);

  /* "obitools/align/_nwsdnabyprot.pyx":93
 * 
 *     cdef double aaScore(self,char aa1,char aa2):
 *         if aa1==aa2 or aa1=='X' or aa2=='X':             # <<<<<<<<<<<<<<
 *             return self._match
 *         else:
 */
  __pyx_t_1 = (__pyx_v_aa1 == __pyx_v_aa2);
  if (!__pyx_t_1) {
    __pyx_t_2 = (__pyx_v_aa1 == 'X');
    if (!__pyx_t_2) {
      __pyx_t_3 = (__pyx_v_aa2 == 'X');
      __pyx_t_4 = __pyx_t_3;
    } else {
      __pyx_t_4 = __pyx_t_2;
    }
    __pyx_t_2 = __pyx_t_4;
  } else {
    __pyx_t_2 = __pyx_t_1;
  }
  if (__pyx_t_2) {

    /* "obitools/align/_nwsdnabyprot.pyx":94
 *     cdef double aaScore(self,char aa1,char aa2):
 *         if aa1==aa2 or aa1=='X' or aa2=='X':
 *             return self._match             # <<<<<<<<<<<<<<
 *         else:
 *             return self._mismatch
 */
    __pyx_r = __pyx_v_self->_match;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "obitools/align/_nwsdnabyprot.pyx":96
 *             return self._match
 *         else:
 *             return self._mismatch             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_r = __pyx_v_self->_mismatch;
    goto __pyx_L0;
  }
  __pyx_L3:;

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

/* "obitools/align/_nwsdnabyprot.pyx":100
 * 
 * 
 *     cdef void getPossibleCodon(self,char[3] codon,int h, int v,int frame):             # <<<<<<<<<<<<<<
 *         cdef CodonAlignMatrix* matrix
 *         cdef CodonAlignCell* smatrix
 */

static void __pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_getPossibleCodon(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self, char *__pyx_v_codon, int __pyx_v_h, int __pyx_v_v, int __pyx_v_frame) {
  struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *__pyx_v_matrix;
  struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignCell *__pyx_v_smatrix;
  int __pyx_v_path;
  int __pyx_v_vv;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("getPossibleCodon", 0);

  /* "obitools/align/_nwsdnabyprot.pyx":106
 *         cdef int vv
 * 
 *         matrix = <CodonAlignMatrix*>self.matrix             # <<<<<<<<<<<<<<
 *         smatrix= matrix.matrix
 *         path   = smatrix[self.index(h,v)].path
 */
  __pyx_v_matrix = ((struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *)__pyx_v_self->__pyx_base.matrix);

  /* "obitools/align/_nwsdnabyprot.pyx":107
 * 
 *         matrix = <CodonAlignMatrix*>self.matrix
 *         smatrix= matrix.matrix             # <<<<<<<<<<<<<<
 *         path   = smatrix[self.index(h,v)].path
 * 
 */
  __pyx_v_smatrix = __pyx_v_matrix->matrix;

  /* "obitools/align/_nwsdnabyprot.pyx":108
 *         matrix = <CodonAlignMatrix*>self.matrix
 *         smatrix= matrix.matrix
 *         path   = smatrix[self.index(h,v)].path             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_path = (__pyx_v_smatrix[((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_h, __pyx_v_v)]).path;

  /* "obitools/align/_nwsdnabyprot.pyx":122
 *                 codon[2]='*'
 * 
 *         elif frame==1 :             # <<<<<<<<<<<<<<
 *             vv=v
 *             if v>1:
 */
  switch (__pyx_v_frame) {

    /* "obitools/align/_nwsdnabyprot.pyx":111
 * 
 * 
 *         if frame == 0:             # <<<<<<<<<<<<<<
 *             codon[0]=self.vSeq.sequence[v-1]
 *             if v < (self.vSeq.length):
 */
    case 0:

    /* "obitools/align/_nwsdnabyprot.pyx":112
 * 
 *         if frame == 0:
 *             codon[0]=self.vSeq.sequence[v-1]             # <<<<<<<<<<<<<<
 *             if v < (self.vSeq.length):
 *                 codon[1]=self.vSeq.sequence[v]
 */
    (__pyx_v_codon[0]) = (__pyx_v_self->__pyx_base.vSeq->sequence[(__pyx_v_v - 1)]);

    /* "obitools/align/_nwsdnabyprot.pyx":113
 *         if frame == 0:
 *             codon[0]=self.vSeq.sequence[v-1]
 *             if v < (self.vSeq.length):             # <<<<<<<<<<<<<<
 *                 codon[1]=self.vSeq.sequence[v]
 *             else:
 */
    __pyx_t_1 = (__pyx_v_v < __pyx_v_self->__pyx_base.vSeq->length);
    if (__pyx_t_1) {

      /* "obitools/align/_nwsdnabyprot.pyx":114
 *             codon[0]=self.vSeq.sequence[v-1]
 *             if v < (self.vSeq.length):
 *                 codon[1]=self.vSeq.sequence[v]             # <<<<<<<<<<<<<<
 *             else:
 *                 codon[1]='*'
 */
      (__pyx_v_codon[1]) = (__pyx_v_self->__pyx_base.vSeq->sequence[__pyx_v_v]);
      goto __pyx_L3;
    }
    /*else*/ {

      /* "obitools/align/_nwsdnabyprot.pyx":116
 *                 codon[1]=self.vSeq.sequence[v]
 *             else:
 *                 codon[1]='*'             # <<<<<<<<<<<<<<
 *             if v < (self.vSeq.length-1):
 *                 codon[2]=self.vSeq.sequence[v+1]
 */
      (__pyx_v_codon[1]) = '*';
    }
    __pyx_L3:;

    /* "obitools/align/_nwsdnabyprot.pyx":117
 *             else:
 *                 codon[1]='*'
 *             if v < (self.vSeq.length-1):             # <<<<<<<<<<<<<<
 *                 codon[2]=self.vSeq.sequence[v+1]
 *             else:
 */
    __pyx_t_1 = (__pyx_v_v < (__pyx_v_self->__pyx_base.vSeq->length - 1));
    if (__pyx_t_1) {

      /* "obitools/align/_nwsdnabyprot.pyx":118
 *                 codon[1]='*'
 *             if v < (self.vSeq.length-1):
 *                 codon[2]=self.vSeq.sequence[v+1]             # <<<<<<<<<<<<<<
 *             else:
 *                 codon[2]='*'
 */
      (__pyx_v_codon[2]) = (__pyx_v_self->__pyx_base.vSeq->sequence[(__pyx_v_v + 1)]);
      goto __pyx_L4;
    }
    /*else*/ {

      /* "obitools/align/_nwsdnabyprot.pyx":120
 *                 codon[2]=self.vSeq.sequence[v+1]
 *             else:
 *                 codon[2]='*'             # <<<<<<<<<<<<<<
 * 
 *         elif frame==1 :
 */
      (__pyx_v_codon[2]) = '*';
    }
    __pyx_L4:;
    break;

    /* "obitools/align/_nwsdnabyprot.pyx":122
 *                 codon[2]='*'
 * 
 *         elif frame==1 :             # <<<<<<<<<<<<<<
 *             vv=v
 *             if v>1:
 */
    case 1:

    /* "obitools/align/_nwsdnabyprot.pyx":123
 * 
 *         elif frame==1 :
 *             vv=v             # <<<<<<<<<<<<<<
 *             if v>1:
 *                 if path==0:
 */
    __pyx_v_vv = __pyx_v_v;

    /* "obitools/align/_nwsdnabyprot.pyx":124
 *         elif frame==1 :
 *             vv=v
 *             if v>1:             # <<<<<<<<<<<<<<
 *                 if path==0:
 *                     vv-=1
 */
    __pyx_t_1 = (__pyx_v_v > 1);
    if (__pyx_t_1) {

      /* "obitools/align/_nwsdnabyprot.pyx":125
 *             vv=v
 *             if v>1:
 *                 if path==0:             # <<<<<<<<<<<<<<
 *                     vv-=1
 *                 while(path!=0):
 */
      __pyx_t_1 = (__pyx_v_path == 0);
      if (__pyx_t_1) {

        /* "obitools/align/_nwsdnabyprot.pyx":126
 *             if v>1:
 *                 if path==0:
 *                     vv-=1             # <<<<<<<<<<<<<<
 *                 while(path!=0):
 *                     if path < 0:
 */
        __pyx_v_vv = (__pyx_v_vv - 1);
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "obitools/align/_nwsdnabyprot.pyx":127
 *                 if path==0:
 *                     vv-=1
 *                 while(path!=0):             # <<<<<<<<<<<<<<
 *                     if path < 0:
 *                         vv+=path
 */
      while (1) {
        __pyx_t_1 = (__pyx_v_path != 0);
        if (!__pyx_t_1) break;

        /* "obitools/align/_nwsdnabyprot.pyx":128
 *                     vv-=1
 *                 while(path!=0):
 *                     if path < 0:             # <<<<<<<<<<<<<<
 *                         vv+=path
 *                     else:
 */
        __pyx_t_1 = (__pyx_v_path < 0);
        if (__pyx_t_1) {

          /* "obitools/align/_nwsdnabyprot.pyx":129
 *                 while(path!=0):
 *                     if path < 0:
 *                         vv+=path             # <<<<<<<<<<<<<<
 *                     else:
 *                         h-=path
 */
          __pyx_v_vv = (__pyx_v_vv + __pyx_v_path);
          goto __pyx_L9;
        }
        /*else*/ {

          /* "obitools/align/_nwsdnabyprot.pyx":131
 *                         vv+=path
 *                     else:
 *                         h-=path             # <<<<<<<<<<<<<<
 *                     path   = smatrix[self.index(h,vv)].path
 *                 codon[0]=self.vSeq.sequence[vv-1]
 */
          __pyx_v_h = (__pyx_v_h - __pyx_v_path);
        }
        __pyx_L9:;

        /* "obitools/align/_nwsdnabyprot.pyx":132
 *                     else:
 *                         h-=path
 *                     path   = smatrix[self.index(h,vv)].path             # <<<<<<<<<<<<<<
 *                 codon[0]=self.vSeq.sequence[vv-1]
 *             else:
 */
        __pyx_v_path = (__pyx_v_smatrix[((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_h, __pyx_v_vv)]).path;
      }

      /* "obitools/align/_nwsdnabyprot.pyx":133
 *                         h-=path
 *                     path   = smatrix[self.index(h,vv)].path
 *                 codon[0]=self.vSeq.sequence[vv-1]             # <<<<<<<<<<<<<<
 *             else:
 *                 codon[0]='*'
 */
      (__pyx_v_codon[0]) = (__pyx_v_self->__pyx_base.vSeq->sequence[(__pyx_v_vv - 1)]);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "obitools/align/_nwsdnabyprot.pyx":135
 *                 codon[0]=self.vSeq.sequence[vv-1]
 *             else:
 *                 codon[0]='*'             # <<<<<<<<<<<<<<
 *             codon[1]=self.vSeq.sequence[v-1]
 *             if v < (self.vSeq.length):
 */
      (__pyx_v_codon[0]) = '*';
    }
    __pyx_L5:;

    /* "obitools/align/_nwsdnabyprot.pyx":136
 *             else:
 *                 codon[0]='*'
 *             codon[1]=self.vSeq.sequence[v-1]             # <<<<<<<<<<<<<<
 *             if v < (self.vSeq.length):
 *                 codon[2]=self.vSeq.sequence[v]
 */
    (__pyx_v_codon[1]) = (__pyx_v_self->__pyx_base.vSeq->sequence[(__pyx_v_v - 1)]);

    /* "obitools/align/_nwsdnabyprot.pyx":137
 *                 codon[0]='*'
 *             codon[1]=self.vSeq.sequence[v-1]
 *             if v < (self.vSeq.length):             # <<<<<<<<<<<<<<
 *                 codon[2]=self.vSeq.sequence[v]
 *             else:
 */
    __pyx_t_1 = (__pyx_v_v < __pyx_v_self->__pyx_base.vSeq->length);
    if (__pyx_t_1) {

      /* "obitools/align/_nwsdnabyprot.pyx":138
 *             codon[1]=self.vSeq.sequence[v-1]
 *             if v < (self.vSeq.length):
 *                 codon[2]=self.vSeq.sequence[v]             # <<<<<<<<<<<<<<
 *             else:
 *                 codon[2]='*'
 */
      (__pyx_v_codon[2]) = (__pyx_v_self->__pyx_base.vSeq->sequence[__pyx_v_v]);
      goto __pyx_L10;
    }
    /*else*/ {

      /* "obitools/align/_nwsdnabyprot.pyx":140
 *                 codon[2]=self.vSeq.sequence[v]
 *             else:
 *                 codon[2]='*'             # <<<<<<<<<<<<<<
 *         else:
 *             vv=v
 */
      (__pyx_v_codon[2]) = '*';
    }
    __pyx_L10:;
    break;
    default:

    /* "obitools/align/_nwsdnabyprot.pyx":142
 *                 codon[2]='*'
 *         else:
 *             vv=v             # <<<<<<<<<<<<<<
 *             if v>1:
 *                 if path==0:
 */
    __pyx_v_vv = __pyx_v_v;

    /* "obitools/align/_nwsdnabyprot.pyx":143
 *         else:
 *             vv=v
 *             if v>1:             # <<<<<<<<<<<<<<
 *                 if path==0:
 *                     vv-=1
 */
    __pyx_t_1 = (__pyx_v_v > 1);
    if (__pyx_t_1) {

      /* "obitools/align/_nwsdnabyprot.pyx":144
 *             vv=v
 *             if v>1:
 *                 if path==0:             # <<<<<<<<<<<<<<
 *                     vv-=1
 *                 while(path!=0):
 */
      __pyx_t_1 = (__pyx_v_path == 0);
      if (__pyx_t_1) {

        /* "obitools/align/_nwsdnabyprot.pyx":145
 *             if v>1:
 *                 if path==0:
 *                     vv-=1             # <<<<<<<<<<<<<<
 *                 while(path!=0):
 *                     if path < 0:
 */
        __pyx_v_vv = (__pyx_v_vv - 1);
        goto __pyx_L12;
      }
      __pyx_L12:;

      /* "obitools/align/_nwsdnabyprot.pyx":146
 *                 if path==0:
 *                     vv-=1
 *                 while(path!=0):             # <<<<<<<<<<<<<<
 *                     if path < 0:
 *                         vv+=path
 */
      while (1) {
        __pyx_t_1 = (__pyx_v_path != 0);
        if (!__pyx_t_1) break;

        /* "obitools/align/_nwsdnabyprot.pyx":147
 *                     vv-=1
 *                 while(path!=0):
 *                     if path < 0:             # <<<<<<<<<<<<<<
 *                         vv+=path
 *                     else:
 */
        __pyx_t_1 = (__pyx_v_path < 0);
        if (__pyx_t_1) {

          /* "obitools/align/_nwsdnabyprot.pyx":148
 *                 while(path!=0):
 *                     if path < 0:
 *                         vv+=path             # <<<<<<<<<<<<<<
 *                     else:
 *                         h-=path
 */
          __pyx_v_vv = (__pyx_v_vv + __pyx_v_path);
          goto __pyx_L15;
        }
        /*else*/ {

          /* "obitools/align/_nwsdnabyprot.pyx":150
 *                         vv+=path
 *                     else:
 *                         h-=path             # <<<<<<<<<<<<<<
 *                     path   = smatrix[self.index(h,vv)].path
 *                 codon[1]=self.vSeq.sequence[vv-1]
 */
          __pyx_v_h = (__pyx_v_h - __pyx_v_path);
        }
        __pyx_L15:;

        /* "obitools/align/_nwsdnabyprot.pyx":151
 *                     else:
 *                         h-=path
 *                     path   = smatrix[self.index(h,vv)].path             # <<<<<<<<<<<<<<
 *                 codon[1]=self.vSeq.sequence[vv-1]
 *                 vv-=1
 */
        __pyx_v_path = (__pyx_v_smatrix[((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_h, __pyx_v_vv)]).path;
      }

      /* "obitools/align/_nwsdnabyprot.pyx":152
 *                         h-=path
 *                     path   = smatrix[self.index(h,vv)].path
 *                 codon[1]=self.vSeq.sequence[vv-1]             # <<<<<<<<<<<<<<
 *                 vv-=1
 *                 h-=1
 */
      (__pyx_v_codon[1]) = (__pyx_v_self->__pyx_base.vSeq->sequence[(__pyx_v_vv - 1)]);

      /* "obitools/align/_nwsdnabyprot.pyx":153
 *                     path   = smatrix[self.index(h,vv)].path
 *                 codon[1]=self.vSeq.sequence[vv-1]
 *                 vv-=1             # <<<<<<<<<<<<<<
 *                 h-=1
 *                 path   = smatrix[self.index(h,vv)].path
 */
      __pyx_v_vv = (__pyx_v_vv - 1);

      /* "obitools/align/_nwsdnabyprot.pyx":154
 *                 codon[1]=self.vSeq.sequence[vv-1]
 *                 vv-=1
 *                 h-=1             # <<<<<<<<<<<<<<
 *                 path   = smatrix[self.index(h,vv)].path
 *             else:
 */
      __pyx_v_h = (__pyx_v_h - 1);

      /* "obitools/align/_nwsdnabyprot.pyx":155
 *                 vv-=1
 *                 h-=1
 *                 path   = smatrix[self.index(h,vv)].path             # <<<<<<<<<<<<<<
 *             else:
 *                 codon[1]='*'
 */
      __pyx_v_path = (__pyx_v_smatrix[((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_h, __pyx_v_vv)]).path;
      goto __pyx_L11;
    }
    /*else*/ {

      /* "obitools/align/_nwsdnabyprot.pyx":157
 *                 path   = smatrix[self.index(h,vv)].path
 *             else:
 *                 codon[1]='*'             # <<<<<<<<<<<<<<
 *             if v>2:
 *                 if path==0:
 */
      (__pyx_v_codon[1]) = '*';
    }
    __pyx_L11:;

    /* "obitools/align/_nwsdnabyprot.pyx":158
 *             else:
 *                 codon[1]='*'
 *             if v>2:             # <<<<<<<<<<<<<<
 *                 if path==0:
 *                     vv-=1
 */
    __pyx_t_1 = (__pyx_v_v > 2);
    if (__pyx_t_1) {

      /* "obitools/align/_nwsdnabyprot.pyx":159
 *                 codon[1]='*'
 *             if v>2:
 *                 if path==0:             # <<<<<<<<<<<<<<
 *                     vv-=1
 *                 while(path!=0):
 */
      __pyx_t_1 = (__pyx_v_path == 0);
      if (__pyx_t_1) {

        /* "obitools/align/_nwsdnabyprot.pyx":160
 *             if v>2:
 *                 if path==0:
 *                     vv-=1             # <<<<<<<<<<<<<<
 *                 while(path!=0):
 *                     if path < 0:
 */
        __pyx_v_vv = (__pyx_v_vv - 1);
        goto __pyx_L17;
      }
      __pyx_L17:;

      /* "obitools/align/_nwsdnabyprot.pyx":161
 *                 if path==0:
 *                     vv-=1
 *                 while(path!=0):             # <<<<<<<<<<<<<<
 *                     if path < 0:
 *                         vv+=path
 */
      while (1) {
        __pyx_t_1 = (__pyx_v_path != 0);
        if (!__pyx_t_1) break;

        /* "obitools/align/_nwsdnabyprot.pyx":162
 *                     vv-=1
 *                 while(path!=0):
 *                     if path < 0:             # <<<<<<<<<<<<<<
 *                         vv+=path
 *                     else:
 */
        __pyx_t_1 = (__pyx_v_path < 0);
        if (__pyx_t_1) {

          /* "obitools/align/_nwsdnabyprot.pyx":163
 *                 while(path!=0):
 *                     if path < 0:
 *                         vv+=path             # <<<<<<<<<<<<<<
 *                     else:
 *                         h-=path
 */
          __pyx_v_vv = (__pyx_v_vv + __pyx_v_path);
          goto __pyx_L20;
        }
        /*else*/ {

          /* "obitools/align/_nwsdnabyprot.pyx":165
 *                         vv+=path
 *                     else:
 *                         h-=path             # <<<<<<<<<<<<<<
 *                     path   = smatrix[self.index(h,vv)].path
 *                 codon[0]=self.vSeq.sequence[vv-1]
 */
          __pyx_v_h = (__pyx_v_h - __pyx_v_path);
        }
        __pyx_L20:;

        /* "obitools/align/_nwsdnabyprot.pyx":166
 *                     else:
 *                         h-=path
 *                     path   = smatrix[self.index(h,vv)].path             # <<<<<<<<<<<<<<
 *                 codon[0]=self.vSeq.sequence[vv-1]
 *                 codon[0]=self.vSeq.sequence[v-3]
 */
        __pyx_v_path = (__pyx_v_smatrix[((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_h, __pyx_v_vv)]).path;
      }

      /* "obitools/align/_nwsdnabyprot.pyx":167
 *                         h-=path
 *                     path   = smatrix[self.index(h,vv)].path
 *                 codon[0]=self.vSeq.sequence[vv-1]             # <<<<<<<<<<<<<<
 *                 codon[0]=self.vSeq.sequence[v-3]
 *             else:
 */
      (__pyx_v_codon[0]) = (__pyx_v_self->__pyx_base.vSeq->sequence[(__pyx_v_vv - 1)]);

      /* "obitools/align/_nwsdnabyprot.pyx":168
 *                     path   = smatrix[self.index(h,vv)].path
 *                 codon[0]=self.vSeq.sequence[vv-1]
 *                 codon[0]=self.vSeq.sequence[v-3]             # <<<<<<<<<<<<<<
 *             else:
 *                 codon[0]='*'
 */
      (__pyx_v_codon[0]) = (__pyx_v_self->__pyx_base.vSeq->sequence[(__pyx_v_v - 3)]);
      goto __pyx_L16;
    }
    /*else*/ {

      /* "obitools/align/_nwsdnabyprot.pyx":170
 *                 codon[0]=self.vSeq.sequence[v-3]
 *             else:
 *                 codon[0]='*'             # <<<<<<<<<<<<<<
 *             codon[2]=self.vSeq.sequence[v-1]
 * 
 */
      (__pyx_v_codon[0]) = '*';
    }
    __pyx_L16:;

    /* "obitools/align/_nwsdnabyprot.pyx":171
 *             else:
 *                 codon[0]='*'
 *             codon[2]=self.vSeq.sequence[v-1]             # <<<<<<<<<<<<<<
 * 
 * 
 */
    (__pyx_v_codon[2]) = (__pyx_v_self->__pyx_base.vSeq->sequence[(__pyx_v_v - 1)]);
    break;
  }

  __Pyx_RefNannyFinishContext();
}

/* "obitools/align/_nwsdnabyprot.pyx":174
 * 
 * 
 *     cdef double matchScore(self,int h, int v, int qframe):             # <<<<<<<<<<<<<<
 *         cdef double score
 *         cdef int frame
 */

static double __pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_matchScore(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self, int __pyx_v_h, int __pyx_v_v, int __pyx_v_qframe) {
  double __pyx_v_score;
  int __pyx_v_frame;
  char __pyx_v_codon[3];
  char __pyx_v_qcodon[3];
  char __pyx_v_aa;
  char __pyx_v_qaa;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  char __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("matchScore", 0);

  /* "obitools/align/_nwsdnabyprot.pyx":182
 *         cdef char qaa
 * 
 *         frame=((h - 1 + self._sframe) % 3)             # <<<<<<<<<<<<<<
 * 
 *                         # extract reference codon
 */
  __pyx_v_frame = __Pyx_mod_long(((__pyx_v_h - 1) + __pyx_v_self->_sframe), 3);

  /* "obitools/align/_nwsdnabyprot.pyx":196
 *             else:
 *                 codon[2]='*'
 *         elif frame==1 :             # <<<<<<<<<<<<<<
 *             if h>1:
 *                 codon[0]=self.hSeq.sequence[h-2]
 */
  switch (__pyx_v_frame) {

    /* "obitools/align/_nwsdnabyprot.pyx":186
 *                         # extract reference codon
 * 
 *         if frame==0:             # <<<<<<<<<<<<<<
 *             codon[0]=self.hSeq.sequence[h-1]
 *             if h < (self.hSeq.length):
 */
    case 0:

    /* "obitools/align/_nwsdnabyprot.pyx":187
 * 
 *         if frame==0:
 *             codon[0]=self.hSeq.sequence[h-1]             # <<<<<<<<<<<<<<
 *             if h < (self.hSeq.length):
 *                 codon[1]=self.hSeq.sequence[h]
 */
    (__pyx_v_codon[0]) = (__pyx_v_self->__pyx_base.hSeq->sequence[(__pyx_v_h - 1)]);

    /* "obitools/align/_nwsdnabyprot.pyx":188
 *         if frame==0:
 *             codon[0]=self.hSeq.sequence[h-1]
 *             if h < (self.hSeq.length):             # <<<<<<<<<<<<<<
 *                 codon[1]=self.hSeq.sequence[h]
 *             else:
 */
    __pyx_t_1 = (__pyx_v_h < __pyx_v_self->__pyx_base.hSeq->length);
    if (__pyx_t_1) {

      /* "obitools/align/_nwsdnabyprot.pyx":189
 *             codon[0]=self.hSeq.sequence[h-1]
 *             if h < (self.hSeq.length):
 *                 codon[1]=self.hSeq.sequence[h]             # <<<<<<<<<<<<<<
 *             else:
 *                 codon[1]='*'
 */
      (__pyx_v_codon[1]) = (__pyx_v_self->__pyx_base.hSeq->sequence[__pyx_v_h]);
      goto __pyx_L3;
    }
    /*else*/ {

      /* "obitools/align/_nwsdnabyprot.pyx":191
 *                 codon[1]=self.hSeq.sequence[h]
 *             else:
 *                 codon[1]='*'             # <<<<<<<<<<<<<<
 *             if h < (self.hSeq.length-1):
 *                 codon[2]=self.hSeq.sequence[h+1]
 */
      (__pyx_v_codon[1]) = '*';
    }
    __pyx_L3:;

    /* "obitools/align/_nwsdnabyprot.pyx":192
 *             else:
 *                 codon[1]='*'
 *             if h < (self.hSeq.length-1):             # <<<<<<<<<<<<<<
 *                 codon[2]=self.hSeq.sequence[h+1]
 *             else:
 */
    __pyx_t_1 = (__pyx_v_h < (__pyx_v_self->__pyx_base.hSeq->length - 1));
    if (__pyx_t_1) {

      /* "obitools/align/_nwsdnabyprot.pyx":193
 *                 codon[1]='*'
 *             if h < (self.hSeq.length-1):
 *                 codon[2]=self.hSeq.sequence[h+1]             # <<<<<<<<<<<<<<
 *             else:
 *                 codon[2]='*'
 */
      (__pyx_v_codon[2]) = (__pyx_v_self->__pyx_base.hSeq->sequence[(__pyx_v_h + 1)]);
      goto __pyx_L4;
    }
    /*else*/ {

      /* "obitools/align/_nwsdnabyprot.pyx":195
 *                 codon[2]=self.hSeq.sequence[h+1]
 *             else:
 *                 codon[2]='*'             # <<<<<<<<<<<<<<
 *         elif frame==1 :
 *             if h>1:
 */
      (__pyx_v_codon[2]) = '*';
    }
    __pyx_L4:;
    break;

    /* "obitools/align/_nwsdnabyprot.pyx":196
 *             else:
 *                 codon[2]='*'
 *         elif frame==1 :             # <<<<<<<<<<<<<<
 *             if h>1:
 *                 codon[0]=self.hSeq.sequence[h-2]
 */
    case 1:

    /* "obitools/align/_nwsdnabyprot.pyx":197
 *                 codon[2]='*'
 *         elif frame==1 :
 *             if h>1:             # <<<<<<<<<<<<<<
 *                 codon[0]=self.hSeq.sequence[h-2]
 *             else:
 */
    __pyx_t_1 = (__pyx_v_h > 1);
    if (__pyx_t_1) {

      /* "obitools/align/_nwsdnabyprot.pyx":198
 *         elif frame==1 :
 *             if h>1:
 *                 codon[0]=self.hSeq.sequence[h-2]             # <<<<<<<<<<<<<<
 *             else:
 *                 codon[0]='*'
 */
      (__pyx_v_codon[0]) = (__pyx_v_self->__pyx_base.hSeq->sequence[(__pyx_v_h - 2)]);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "obitools/align/_nwsdnabyprot.pyx":200
 *                 codon[0]=self.hSeq.sequence[h-2]
 *             else:
 *                 codon[0]='*'             # <<<<<<<<<<<<<<
 *             codon[1]=self.hSeq.sequence[h-1]
 *             if h < (self.hSeq.length):
 */
      (__pyx_v_codon[0]) = '*';
    }
    __pyx_L5:;

    /* "obitools/align/_nwsdnabyprot.pyx":201
 *             else:
 *                 codon[0]='*'
 *             codon[1]=self.hSeq.sequence[h-1]             # <<<<<<<<<<<<<<
 *             if h < (self.hSeq.length):
 *                 codon[2]=self.hSeq.sequence[h]
 */
    (__pyx_v_codon[1]) = (__pyx_v_self->__pyx_base.hSeq->sequence[(__pyx_v_h - 1)]);

    /* "obitools/align/_nwsdnabyprot.pyx":202
 *                 codon[0]='*'
 *             codon[1]=self.hSeq.sequence[h-1]
 *             if h < (self.hSeq.length):             # <<<<<<<<<<<<<<
 *                 codon[2]=self.hSeq.sequence[h]
 *             else:
 */
    __pyx_t_1 = (__pyx_v_h < __pyx_v_self->__pyx_base.hSeq->length);
    if (__pyx_t_1) {

      /* "obitools/align/_nwsdnabyprot.pyx":203
 *             codon[1]=self.hSeq.sequence[h-1]
 *             if h < (self.hSeq.length):
 *                 codon[2]=self.hSeq.sequence[h]             # <<<<<<<<<<<<<<
 *             else:
 *                 codon[2]='*'
 */
      (__pyx_v_codon[2]) = (__pyx_v_self->__pyx_base.hSeq->sequence[__pyx_v_h]);
      goto __pyx_L6;
    }
    /*else*/ {

      /* "obitools/align/_nwsdnabyprot.pyx":205
 *                 codon[2]=self.hSeq.sequence[h]
 *             else:
 *                 codon[2]='*'             # <<<<<<<<<<<<<<
 *         else:
 *             if h>2:
 */
      (__pyx_v_codon[2]) = '*';
    }
    __pyx_L6:;
    break;
    default:

    /* "obitools/align/_nwsdnabyprot.pyx":207
 *                 codon[2]='*'
 *         else:
 *             if h>2:             # <<<<<<<<<<<<<<
 *                 codon[0]=self.hSeq.sequence[h-3]
 *             else:
 */
    __pyx_t_1 = (__pyx_v_h > 2);
    if (__pyx_t_1) {

      /* "obitools/align/_nwsdnabyprot.pyx":208
 *         else:
 *             if h>2:
 *                 codon[0]=self.hSeq.sequence[h-3]             # <<<<<<<<<<<<<<
 *             else:
 *                 codon[0]='*'
 */
      (__pyx_v_codon[0]) = (__pyx_v_self->__pyx_base.hSeq->sequence[(__pyx_v_h - 3)]);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "obitools/align/_nwsdnabyprot.pyx":210
 *                 codon[0]=self.hSeq.sequence[h-3]
 *             else:
 *                 codon[0]='*'             # <<<<<<<<<<<<<<
 *             if h>1:
 *                 codon[1]=self.hSeq.sequence[h-2]
 */
      (__pyx_v_codon[0]) = '*';
    }
    __pyx_L7:;

    /* "obitools/align/_nwsdnabyprot.pyx":211
 *             else:
 *                 codon[0]='*'
 *             if h>1:             # <<<<<<<<<<<<<<
 *                 codon[1]=self.hSeq.sequence[h-2]
 *             else:
 */
    __pyx_t_1 = (__pyx_v_h > 1);
    if (__pyx_t_1) {

      /* "obitools/align/_nwsdnabyprot.pyx":212
 *                 codon[0]='*'
 *             if h>1:
 *                 codon[1]=self.hSeq.sequence[h-2]             # <<<<<<<<<<<<<<
 *             else:
 *                 codon[1]='*'
 */
      (__pyx_v_codon[1]) = (__pyx_v_self->__pyx_base.hSeq->sequence[(__pyx_v_h - 2)]);
      goto __pyx_L8;
    }
    /*else*/ {

      /* "obitools/align/_nwsdnabyprot.pyx":214
 *                 codon[1]=self.hSeq.sequence[h-2]
 *             else:
 *                 codon[1]='*'             # <<<<<<<<<<<<<<
 *             codon[2]=self.hSeq.sequence[h-1]
 * 
 */
      (__pyx_v_codon[1]) = '*';
    }
    __pyx_L8:;

    /* "obitools/align/_nwsdnabyprot.pyx":215
 *             else:
 *                 codon[1]='*'
 *             codon[2]=self.hSeq.sequence[h-1]             # <<<<<<<<<<<<<<
 * 
 *         aa=ord(self._gc[str(codon)])
 */
    (__pyx_v_codon[2]) = (__pyx_v_self->__pyx_base.hSeq->sequence[(__pyx_v_h - 1)]);
    break;
  }

  /* "obitools/align/_nwsdnabyprot.pyx":217
 *             codon[2]=self.hSeq.sequence[h-1]
 * 
 *         aa=ord(self._gc[str(codon)])             # <<<<<<<<<<<<<<
 * 
 *         self.getPossibleCodon(qcodon,h,v,qframe)
 */
  __pyx_t_2 = PyBytes_FromString(__pyx_v_codon); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetItem(__pyx_v_self->_gc, __pyx_t_2); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsChar(__pyx_t_3); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_aa = __pyx_t_4;

  /* "obitools/align/_nwsdnabyprot.pyx":219
 *         aa=ord(self._gc[str(codon)])
 * 
 *         self.getPossibleCodon(qcodon,h,v,qframe)             # <<<<<<<<<<<<<<
 *         qaa=ord(self._gc[str(qcodon)])
 *         score = iupacPartialMatch(self.hSeq.sequence[h-1],self.vSeq.sequence[v-1])
 */
  ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->getPossibleCodon(__pyx_v_self, __pyx_v_qcodon, __pyx_v_h, __pyx_v_v, __pyx_v_qframe);

  /* "obitools/align/_nwsdnabyprot.pyx":220
 * 
 *         self.getPossibleCodon(qcodon,h,v,qframe)
 *         qaa=ord(self._gc[str(qcodon)])             # <<<<<<<<<<<<<<
 *         score = iupacPartialMatch(self.hSeq.sequence[h-1],self.vSeq.sequence[v-1])
 *         score = self._match * score + self._mismatch * (1-score) + self.aaScore(aa,qaa)
 */
  __pyx_t_3 = PyBytes_FromString(__pyx_v_qcodon); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetItem(__pyx_v_self->_gc, __pyx_t_3); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_ord, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsChar(__pyx_t_2); if (unlikely((__pyx_t_4 == (char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_qaa = __pyx_t_4;

  /* "obitools/align/_nwsdnabyprot.pyx":221
 *         self.getPossibleCodon(qcodon,h,v,qframe)
 *         qaa=ord(self._gc[str(qcodon)])
 *         score = iupacPartialMatch(self.hSeq.sequence[h-1],self.vSeq.sequence[v-1])             # <<<<<<<<<<<<<<
 *         score = self._match * score + self._mismatch * (1-score) + self.aaScore(aa,qaa)
 * 
 */
  __pyx_v_score = __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);

  /* "obitools/align/_nwsdnabyprot.pyx":222
 *         qaa=ord(self._gc[str(qcodon)])
 *         score = iupacPartialMatch(self.hSeq.sequence[h-1],self.vSeq.sequence[v-1])
 *         score = self._match * score + self._mismatch * (1-score) + self.aaScore(aa,qaa)             # <<<<<<<<<<<<<<
 * 
 * #        print >>sys.stderr, h,frame,chr(aa),chr(codon[0])+chr(codon[1])+chr(codon[2]),
 */
  __pyx_v_score = (((__pyx_v_self->_match * __pyx_v_score) + (__pyx_v_self->_mismatch * (1.0 - __pyx_v_score))) + ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->aaScore(__pyx_v_self, __pyx_v_aa, __pyx_v_qaa));

  /* "obitools/align/_nwsdnabyprot.pyx":227
 * #        print >>sys.stderr, chr(qaa),chr(qcodon[0])+chr(qcodon[1])+chr(qcodon[2]), score
 * 
 *         return score             # <<<<<<<<<<<<<<
 * 
 *     cdef double doAlignment(self) except? 0:
 */
  __pyx_r = __pyx_v_score;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("obitools.align._nwsdnabyprot.NWSDNAByProt.matchScore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_nwsdnabyprot.pyx":229
 *         return score
 * 
 *     cdef double doAlignment(self) except? 0:             # <<<<<<<<<<<<<<
 *         cdef int i  # vertical index
 *         cdef int j  # horizontal index
 */

static double __pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_doAlignment(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_idx;
  int __pyx_v_jump;
  int __pyx_v_delta;
  double __pyx_v_score;
  double __pyx_v_scoremax;
  int __pyx_v_path;
  int __pyx_v_frame;
  int __pyx_v_fframe;
  struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *__pyx_v_matrix;
  struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignCell *__pyx_v_smatrix;
  PyObject *__pyx_v_fscost = 0;
  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_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  double __pyx_t_11;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("doAlignment", 0);

  /* "obitools/align/_nwsdnabyprot.pyx":244
 *         cdef CodonAlignCell* smatrix
 * 
 *         cdef fscost=-10             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_INCREF(__pyx_int_neg_10);
  __pyx_v_fscost = __pyx_int_neg_10;

  /* "obitools/align/_nwsdnabyprot.pyx":247
 * 
 * 
 *         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 = 247; __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 = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "obitools/align/_nwsdnabyprot.pyx":248
 * 
 *         if self.needToCompute:
 *             self.allocate()             # <<<<<<<<<<<<<<
 *             self.reset()
 * 
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__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 = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "obitools/align/_nwsdnabyprot.pyx":249
 *         if self.needToCompute:
 *             self.allocate()
 *             self.reset()             # <<<<<<<<<<<<<<
 * 
 *             matrix = <CodonAlignMatrix*>self.matrix
 */
    ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.reset(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self));

    /* "obitools/align/_nwsdnabyprot.pyx":251
 *             self.reset()
 * 
 *             matrix = <CodonAlignMatrix*>self.matrix             # <<<<<<<<<<<<<<
 *             smatrix= matrix.matrix
 *             smatrix[0].frame=(self._sframe-1) % 3
 */
    __pyx_v_matrix = ((struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *)__pyx_v_self->__pyx_base.matrix);

    /* "obitools/align/_nwsdnabyprot.pyx":252
 * 
 *             matrix = <CodonAlignMatrix*>self.matrix
 *             smatrix= matrix.matrix             # <<<<<<<<<<<<<<
 *             smatrix[0].frame=(self._sframe-1) % 3
 * 
 */
    __pyx_v_smatrix = __pyx_v_matrix->matrix;

    /* "obitools/align/_nwsdnabyprot.pyx":253
 *             matrix = <CodonAlignMatrix*>self.matrix
 *             smatrix= matrix.matrix
 *             smatrix[0].frame=(self._sframe-1) % 3             # <<<<<<<<<<<<<<
 * 
 *             for j in range(1,self.hSeq.length+1):
 */
    (__pyx_v_smatrix[0]).frame = __Pyx_mod_long((__pyx_v_self->_sframe - 1), 3);

    /* "obitools/align/_nwsdnabyprot.pyx":255
 *             smatrix[0].frame=(self._sframe-1) % 3
 * 
 *             for j in range(1,self.hSeq.length+1):             # <<<<<<<<<<<<<<
 *                 idx = self.index(j,0)
 *                 smatrix[idx].score = self._opengap + (self._extgap * (j-1))
 */
    __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/_nwsdnabyprot.pyx":256
 * 
 *             for j in range(1,self.hSeq.length+1):
 *                 idx = self.index(j,0)             # <<<<<<<<<<<<<<
 *                 smatrix[idx].score = self._opengap + (self._extgap * (j-1))
 *                 smatrix[idx].path  = j
 */
      __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__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/_nwsdnabyprot.pyx":257
 *             for j in range(1,self.hSeq.length+1):
 *                 idx = self.index(j,0)
 *                 smatrix[idx].score = self._opengap + (self._extgap * (j-1))             # <<<<<<<<<<<<<<
 *                 smatrix[idx].path  = j
 *                 smatrix[idx].frame = smatrix[0].frame
 */
      (__pyx_v_smatrix[__pyx_v_idx]).score = (__pyx_v_self->__pyx_base._opengap + (__pyx_v_self->__pyx_base._extgap * (__pyx_v_j - 1)));

      /* "obitools/align/_nwsdnabyprot.pyx":258
 *                 idx = self.index(j,0)
 *                 smatrix[idx].score = self._opengap + (self._extgap * (j-1))
 *                 smatrix[idx].path  = j             # <<<<<<<<<<<<<<
 *                 smatrix[idx].frame = smatrix[0].frame
 * 
 */
      (__pyx_v_smatrix[__pyx_v_idx]).path = __pyx_v_j;

      /* "obitools/align/_nwsdnabyprot.pyx":259
 *                 smatrix[idx].score = self._opengap + (self._extgap * (j-1))
 *                 smatrix[idx].path  = j
 *                 smatrix[idx].frame = smatrix[0].frame             # <<<<<<<<<<<<<<
 * 
 *             for i in range(1,self.vSeq.length+1):
 */
      (__pyx_v_smatrix[__pyx_v_idx]).frame = (__pyx_v_smatrix[0]).frame;
    }

    /* "obitools/align/_nwsdnabyprot.pyx":261
 *                 smatrix[idx].frame = smatrix[0].frame
 * 
 *             for i in range(1,self.vSeq.length+1):             # <<<<<<<<<<<<<<
 *                 idx = self.index(0,i)
 *                 smatrix[idx].score = self._opengap + (self._extgap * (i-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/_nwsdnabyprot.pyx":262
 * 
 *             for i in range(1,self.vSeq.length+1):
 *                 idx = self.index(0,i)             # <<<<<<<<<<<<<<
 *                 smatrix[idx].score = self._opengap + (self._extgap * (i-1))
 *                 smatrix[idx].path  = -i
 */
      __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__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/_nwsdnabyprot.pyx":263
 *             for i in range(1,self.vSeq.length+1):
 *                 idx = self.index(0,i)
 *                 smatrix[idx].score = self._opengap + (self._extgap * (i-1))             # <<<<<<<<<<<<<<
 *                 smatrix[idx].path  = -i
 *                 smatrix[idx].frame = smatrix[0].frame
 */
      (__pyx_v_smatrix[__pyx_v_idx]).score = (__pyx_v_self->__pyx_base._opengap + (__pyx_v_self->__pyx_base._extgap * (__pyx_v_i - 1)));

      /* "obitools/align/_nwsdnabyprot.pyx":264
 *                 idx = self.index(0,i)
 *                 smatrix[idx].score = self._opengap + (self._extgap * (i-1))
 *                 smatrix[idx].path  = -i             # <<<<<<<<<<<<<<
 *                 smatrix[idx].frame = smatrix[0].frame
 * 
 */
      (__pyx_v_smatrix[__pyx_v_idx]).path = (-__pyx_v_i);

      /* "obitools/align/_nwsdnabyprot.pyx":265
 *                 smatrix[idx].score = self._opengap + (self._extgap * (i-1))
 *                 smatrix[idx].path  = -i
 *                 smatrix[idx].frame = smatrix[0].frame             # <<<<<<<<<<<<<<
 * 
 *             for i in range(1,self.vSeq.length+1):
 */
      (__pyx_v_smatrix[__pyx_v_idx]).frame = (__pyx_v_smatrix[0]).frame;
    }

    /* "obitools/align/_nwsdnabyprot.pyx":267
 *                 smatrix[idx].frame = smatrix[0].frame
 * 
 *             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/_nwsdnabyprot.pyx":268
 * 
 *             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/_nwsdnabyprot.pyx":271
 * 
 *                     # 1 - came from diagonal
 *                     idx = self.index(j-1,i-1)             # <<<<<<<<<<<<<<
 *                     fframe=smatrix[idx].frame
 *                     fframe=(fframe + 1) % 3
 */
        __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__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/_nwsdnabyprot.pyx":272
 *                     # 1 - came from diagonal
 *                     idx = self.index(j-1,i-1)
 *                     fframe=smatrix[idx].frame             # <<<<<<<<<<<<<<
 *                     fframe=(fframe + 1) % 3
 *                     # print "computing cell : %d,%d --> %d/%d" % (j,i,self.index(j,i),self.matrix.msize),
 */
        __pyx_v_fframe = (__pyx_v_smatrix[__pyx_v_idx]).frame;

        /* "obitools/align/_nwsdnabyprot.pyx":273
 *                     idx = self.index(j-1,i-1)
 *                     fframe=smatrix[idx].frame
 *                     fframe=(fframe + 1) % 3             # <<<<<<<<<<<<<<
 *                     # print "computing cell : %d,%d --> %d/%d" % (j,i,self.index(j,i),self.matrix.msize),
 *                     scoremax = smatrix[idx].score + \
 */
        __pyx_v_fframe = __Pyx_mod_long((__pyx_v_fframe + 1), 3);

        /* "obitools/align/_nwsdnabyprot.pyx":276
 *                     # print "computing cell : %d,%d --> %d/%d" % (j,i,self.index(j,i),self.matrix.msize),
 *                     scoremax = smatrix[idx].score + \
 *                                self.matchScore(j,i,0) + \             # <<<<<<<<<<<<<<
 *                                (fframe > -1 and fframe != 0) * fscost
 *                     path = 0
 */
        __pyx_t_1 = PyFloat_FromDouble(((__pyx_v_smatrix[__pyx_v_idx]).score + ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->matchScore(__pyx_v_self, __pyx_v_j, __pyx_v_i, 0))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);

        /* "obitools/align/_nwsdnabyprot.pyx":277
 *                     scoremax = smatrix[idx].score + \
 *                                self.matchScore(j,i,0) + \
 *                                (fframe > -1 and fframe != 0) * fscost             # <<<<<<<<<<<<<<
 *                     path = 0
 *                     frame= 0
 */
        __pyx_t_2 = (__pyx_v_fframe > -1);
        if (__pyx_t_2) {
          __pyx_t_7 = (__pyx_v_fframe != 0);
          __pyx_t_8 = __pyx_t_7;
        } else {
          __pyx_t_8 = __pyx_t_2;
        }
        __pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = PyNumber_Multiply(__pyx_t_9, __pyx_v_fscost); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = PyNumber_Add(__pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_v_scoremax = __pyx_t_11;

        /* "obitools/align/_nwsdnabyprot.pyx":278
 *                                self.matchScore(j,i,0) + \
 *                                (fframe > -1 and fframe != 0) * fscost
 *                     path = 0             # <<<<<<<<<<<<<<
 *                     frame= 0
 * 
 */
        __pyx_v_path = 0;

        /* "obitools/align/_nwsdnabyprot.pyx":279
 *                                (fframe > -1 and fframe != 0) * fscost
 *                     path = 0
 *                     frame= 0             # <<<<<<<<<<<<<<
 * 
 *                     score    = smatrix[idx].score + \
 */
        __pyx_v_frame = 0;

        /* "obitools/align/_nwsdnabyprot.pyx":282
 * 
 *                     score    = smatrix[idx].score + \
 *                                self.matchScore(j,i,1) + \             # <<<<<<<<<<<<<<
 *                                (fframe > -1 and fframe != 1) * fscost
 *                     if score > scoremax or (fframe==1 and score==scoremax):
 */
        __pyx_t_9 = PyFloat_FromDouble(((__pyx_v_smatrix[__pyx_v_idx]).score + ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->matchScore(__pyx_v_self, __pyx_v_j, __pyx_v_i, 1))); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);

        /* "obitools/align/_nwsdnabyprot.pyx":283
 *                     score    = smatrix[idx].score + \
 *                                self.matchScore(j,i,1) + \
 *                                (fframe > -1 and fframe != 1) * fscost             # <<<<<<<<<<<<<<
 *                     if score > scoremax or (fframe==1 and score==scoremax):
 *                         scoremax = score
 */
        __pyx_t_8 = (__pyx_v_fframe > -1);
        if (__pyx_t_8) {
          __pyx_t_2 = (__pyx_v_fframe != 1);
          __pyx_t_7 = __pyx_t_2;
        } else {
          __pyx_t_7 = __pyx_t_8;
        }
        __pyx_t_10 = __Pyx_PyBool_FromLong(__pyx_t_7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_1 = PyNumber_Multiply(__pyx_t_10, __pyx_v_fscost); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = PyNumber_Add(__pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_10); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_v_score = __pyx_t_11;

        /* "obitools/align/_nwsdnabyprot.pyx":284
 *                                self.matchScore(j,i,1) + \
 *                                (fframe > -1 and fframe != 1) * fscost
 *                     if score > scoremax or (fframe==1 and score==scoremax):             # <<<<<<<<<<<<<<
 *                         scoremax = score
 *                         frame = 1
 */
        __pyx_t_7 = (__pyx_v_score > __pyx_v_scoremax);
        if (!__pyx_t_7) {
          __pyx_t_8 = (__pyx_v_fframe == 1);
          if (__pyx_t_8) {
            __pyx_t_2 = (__pyx_v_score == __pyx_v_scoremax);
            __pyx_t_12 = __pyx_t_2;
          } else {
            __pyx_t_12 = __pyx_t_8;
          }
          __pyx_t_8 = __pyx_t_12;
        } else {
          __pyx_t_8 = __pyx_t_7;
        }
        if (__pyx_t_8) {

          /* "obitools/align/_nwsdnabyprot.pyx":285
 *                                (fframe > -1 and fframe != 1) * fscost
 *                     if score > scoremax or (fframe==1 and score==scoremax):
 *                         scoremax = score             # <<<<<<<<<<<<<<
 *                         frame = 1
 * 
 */
          __pyx_v_scoremax = __pyx_v_score;

          /* "obitools/align/_nwsdnabyprot.pyx":286
 *                     if score > scoremax or (fframe==1 and score==scoremax):
 *                         scoremax = score
 *                         frame = 1             # <<<<<<<<<<<<<<
 * 
 *                     score    = smatrix[idx].score + \
 */
          __pyx_v_frame = 1;
          goto __pyx_L12;
        }
        __pyx_L12:;

        /* "obitools/align/_nwsdnabyprot.pyx":289
 * 
 *                     score    = smatrix[idx].score + \
 *                                self.matchScore(j,i,2) + \             # <<<<<<<<<<<<<<
 *                                (fframe > -1 and fframe != 2) * fscost
 *                     if score > scoremax or (fframe==2 and score==scoremax) :
 */
        __pyx_t_10 = PyFloat_FromDouble(((__pyx_v_smatrix[__pyx_v_idx]).score + ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->matchScore(__pyx_v_self, __pyx_v_j, __pyx_v_i, 2))); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);

        /* "obitools/align/_nwsdnabyprot.pyx":290
 *                     score    = smatrix[idx].score + \
 *                                self.matchScore(j,i,2) + \
 *                                (fframe > -1 and fframe != 2) * fscost             # <<<<<<<<<<<<<<
 *                     if score > scoremax or (fframe==2 and score==scoremax) :
 *                         scoremax = score
 */
        __pyx_t_8 = (__pyx_v_fframe > -1);
        if (__pyx_t_8) {
          __pyx_t_7 = (__pyx_v_fframe != 2);
          __pyx_t_12 = __pyx_t_7;
        } else {
          __pyx_t_12 = __pyx_t_8;
        }
        __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_12); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_9 = PyNumber_Multiply(__pyx_t_1, __pyx_v_fscost); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyNumber_Add(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_score = __pyx_t_11;

        /* "obitools/align/_nwsdnabyprot.pyx":291
 *                                self.matchScore(j,i,2) + \
 *                                (fframe > -1 and fframe != 2) * fscost
 *                     if score > scoremax or (fframe==2 and score==scoremax) :             # <<<<<<<<<<<<<<
 *                         scoremax = score
 *                         frame = 2
 */
        __pyx_t_12 = (__pyx_v_score > __pyx_v_scoremax);
        if (!__pyx_t_12) {
          __pyx_t_8 = (__pyx_v_fframe == 2);
          if (__pyx_t_8) {
            __pyx_t_7 = (__pyx_v_score == __pyx_v_scoremax);
            __pyx_t_2 = __pyx_t_7;
          } else {
            __pyx_t_2 = __pyx_t_8;
          }
          __pyx_t_8 = __pyx_t_2;
        } else {
          __pyx_t_8 = __pyx_t_12;
        }
        if (__pyx_t_8) {

          /* "obitools/align/_nwsdnabyprot.pyx":292
 *                                (fframe > -1 and fframe != 2) * fscost
 *                     if score > scoremax or (fframe==2 and score==scoremax) :
 *                         scoremax = score             # <<<<<<<<<<<<<<
 *                         frame = 2
 * 
 */
          __pyx_v_scoremax = __pyx_v_score;

          /* "obitools/align/_nwsdnabyprot.pyx":293
 *                     if score > scoremax or (fframe==2 and score==scoremax) :
 *                         scoremax = score
 *                         frame = 2             # <<<<<<<<<<<<<<
 * 
 *                     # print >>sys.stderr,j,i,frame,scoremax
 */
          __pyx_v_frame = 2;
          goto __pyx_L13;
        }
        __pyx_L13:;

        /* "obitools/align/_nwsdnabyprot.pyx":299
 * 
 *                     # 2 - open horizontal gap
 *                     idx = self.index(j-1,i)             # <<<<<<<<<<<<<<
 *                     score = smatrix[idx].score + \
 *                             self._opengap
 */
        __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__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/_nwsdnabyprot.pyx":301
 *                     idx = self.index(j-1,i)
 *                     score = smatrix[idx].score + \
 *                             self._opengap             # <<<<<<<<<<<<<<
 *                     if score > scoremax :
 *                         scoremax = score
 */
        __pyx_v_score = ((__pyx_v_smatrix[__pyx_v_idx]).score + __pyx_v_self->__pyx_base._opengap);

        /* "obitools/align/_nwsdnabyprot.pyx":302
 *                     score = smatrix[idx].score + \
 *                             self._opengap
 *                     if score > scoremax :             # <<<<<<<<<<<<<<
 *                         scoremax = score
 *                         path = +1
 */
        __pyx_t_8 = (__pyx_v_score > __pyx_v_scoremax);
        if (__pyx_t_8) {

          /* "obitools/align/_nwsdnabyprot.pyx":303
 *                             self._opengap
 *                     if score > scoremax :
 *                         scoremax = score             # <<<<<<<<<<<<<<
 *                         path = +1
 *                         frame= smatrix[idx].frame
 */
          __pyx_v_scoremax = __pyx_v_score;

          /* "obitools/align/_nwsdnabyprot.pyx":304
 *                     if score > scoremax :
 *                         scoremax = score
 *                         path = +1             # <<<<<<<<<<<<<<
 *                         frame= smatrix[idx].frame
 * 
 */
          __pyx_v_path = 1;

          /* "obitools/align/_nwsdnabyprot.pyx":305
 *                         scoremax = score
 *                         path = +1
 *                         frame= smatrix[idx].frame             # <<<<<<<<<<<<<<
 * 
 *                     # 3 - open vertical gap
 */
          __pyx_v_frame = (__pyx_v_smatrix[__pyx_v_idx]).frame;
          goto __pyx_L14;
        }
        __pyx_L14:;

        /* "obitools/align/_nwsdnabyprot.pyx":308
 * 
 *                     # 3 - open vertical gap
 *                     idx = self.index(j,i-1)             # <<<<<<<<<<<<<<
 *                     score = smatrix[idx].score + \
 *                             self._opengap
 */
        __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__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/_nwsdnabyprot.pyx":310
 *                     idx = self.index(j,i-1)
 *                     score = smatrix[idx].score + \
 *                             self._opengap             # <<<<<<<<<<<<<<
 *                     if score > scoremax :
 *                         scoremax = score
 */
        __pyx_v_score = ((__pyx_v_smatrix[__pyx_v_idx]).score + __pyx_v_self->__pyx_base._opengap);

        /* "obitools/align/_nwsdnabyprot.pyx":311
 *                     score = smatrix[idx].score + \
 *                             self._opengap
 *                     if score > scoremax :             # <<<<<<<<<<<<<<
 *                         scoremax = score
 *                         path = -1
 */
        __pyx_t_8 = (__pyx_v_score > __pyx_v_scoremax);
        if (__pyx_t_8) {

          /* "obitools/align/_nwsdnabyprot.pyx":312
 *                             self._opengap
 *                     if score > scoremax :
 *                         scoremax = score             # <<<<<<<<<<<<<<
 *                         path = -1
 *                         frame= smatrix[idx].frame
 */
          __pyx_v_scoremax = __pyx_v_score;

          /* "obitools/align/_nwsdnabyprot.pyx":313
 *                     if score > scoremax :
 *                         scoremax = score
 *                         path = -1             # <<<<<<<<<<<<<<
 *                         frame= smatrix[idx].frame
 * 
 */
          __pyx_v_path = -1;

          /* "obitools/align/_nwsdnabyprot.pyx":314
 *                         scoremax = score
 *                         path = -1
 *                         frame= smatrix[idx].frame             # <<<<<<<<<<<<<<
 * 
 *                     # 4 - extend horizontal gap
 */
          __pyx_v_frame = (__pyx_v_smatrix[__pyx_v_idx]).frame;
          goto __pyx_L15;
        }
        __pyx_L15:;

        /* "obitools/align/_nwsdnabyprot.pyx":317
 * 
 *                     # 4 - extend horizontal gap
 *                     jump = matrix.bestHJump[i]             # <<<<<<<<<<<<<<
 *                     if jump >= 0:
 *                         idx = self.index(jump,i)
 */
        __pyx_v_jump = (__pyx_v_matrix->bestHJump[__pyx_v_i]);

        /* "obitools/align/_nwsdnabyprot.pyx":318
 *                     # 4 - extend horizontal gap
 *                     jump = matrix.bestHJump[i]
 *                     if jump >= 0:             # <<<<<<<<<<<<<<
 *                         idx = self.index(jump,i)
 *                         delta = j-jump
 */
        __pyx_t_8 = (__pyx_v_jump >= 0);
        if (__pyx_t_8) {

          /* "obitools/align/_nwsdnabyprot.pyx":319
 *                     jump = matrix.bestHJump[i]
 *                     if jump >= 0:
 *                         idx = self.index(jump,i)             # <<<<<<<<<<<<<<
 *                         delta = j-jump
 *                         score = smatrix[idx].score + \
 */
          __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_jump, __pyx_v_i);

          /* "obitools/align/_nwsdnabyprot.pyx":320
 *                     if jump >= 0:
 *                         idx = self.index(jump,i)
 *                         delta = j-jump             # <<<<<<<<<<<<<<
 *                         score = smatrix[idx].score + \
 *                                 self._extgap * delta
 */
          __pyx_v_delta = (__pyx_v_j - __pyx_v_jump);

          /* "obitools/align/_nwsdnabyprot.pyx":322
 *                         delta = j-jump
 *                         score = smatrix[idx].score + \
 *                                 self._extgap * delta             # <<<<<<<<<<<<<<
 *                         if score > scoremax :
 *                             scoremax = score
 */
          __pyx_v_score = ((__pyx_v_smatrix[__pyx_v_idx]).score + (__pyx_v_self->__pyx_base._extgap * __pyx_v_delta));

          /* "obitools/align/_nwsdnabyprot.pyx":323
 *                         score = smatrix[idx].score + \
 *                                 self._extgap * delta
 *                         if score > scoremax :             # <<<<<<<<<<<<<<
 *                             scoremax = score
 *                             path = delta+1
 */
          __pyx_t_8 = (__pyx_v_score > __pyx_v_scoremax);
          if (__pyx_t_8) {

            /* "obitools/align/_nwsdnabyprot.pyx":324
 *                                 self._extgap * delta
 *                         if score > scoremax :
 *                             scoremax = score             # <<<<<<<<<<<<<<
 *                             path = delta+1
 *                             frame= smatrix[idx].frame
 */
            __pyx_v_scoremax = __pyx_v_score;

            /* "obitools/align/_nwsdnabyprot.pyx":325
 *                         if score > scoremax :
 *                             scoremax = score
 *                             path = delta+1             # <<<<<<<<<<<<<<
 *                             frame= smatrix[idx].frame
 * 
 */
            __pyx_v_path = (__pyx_v_delta + 1);

            /* "obitools/align/_nwsdnabyprot.pyx":326
 *                             scoremax = score
 *                             path = delta+1
 *                             frame= smatrix[idx].frame             # <<<<<<<<<<<<<<
 * 
 *                     # 5 - extend vertical gap
 */
            __pyx_v_frame = (__pyx_v_smatrix[__pyx_v_idx]).frame;
            goto __pyx_L17;
          }
          __pyx_L17:;
          goto __pyx_L16;
        }
        __pyx_L16:;

        /* "obitools/align/_nwsdnabyprot.pyx":329
 * 
 *                     # 5 - extend vertical gap
 *                     jump = matrix.bestVJump[j]             # <<<<<<<<<<<<<<
 *                     if jump >= 0:
 *                         idx = self.index(j,jump)
 */
        __pyx_v_jump = (__pyx_v_matrix->bestVJump[__pyx_v_j]);

        /* "obitools/align/_nwsdnabyprot.pyx":330
 *                     # 5 - extend vertical gap
 *                     jump = matrix.bestVJump[j]
 *                     if jump >= 0:             # <<<<<<<<<<<<<<
 *                         idx = self.index(j,jump)
 *                         delta = i-jump
 */
        __pyx_t_8 = (__pyx_v_jump >= 0);
        if (__pyx_t_8) {

          /* "obitools/align/_nwsdnabyprot.pyx":331
 *                     jump = matrix.bestVJump[j]
 *                     if jump >= 0:
 *                         idx = self.index(j,jump)             # <<<<<<<<<<<<<<
 *                         delta = i-jump
 *                         score = smatrix[idx].score + \
 */
          __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__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_jump);

          /* "obitools/align/_nwsdnabyprot.pyx":332
 *                     if jump >= 0:
 *                         idx = self.index(j,jump)
 *                         delta = i-jump             # <<<<<<<<<<<<<<
 *                         score = smatrix[idx].score + \
 *                                 self._extgap * delta
 */
          __pyx_v_delta = (__pyx_v_i - __pyx_v_jump);

          /* "obitools/align/_nwsdnabyprot.pyx":334
 *                         delta = i-jump
 *                         score = smatrix[idx].score + \
 *                                 self._extgap * delta             # <<<<<<<<<<<<<<
 *                         if score > scoremax :
 *                             scoremax = score
 */
          __pyx_v_score = ((__pyx_v_smatrix[__pyx_v_idx]).score + (__pyx_v_self->__pyx_base._extgap * __pyx_v_delta));

          /* "obitools/align/_nwsdnabyprot.pyx":335
 *                         score = smatrix[idx].score + \
 *                                 self._extgap * delta
 *                         if score > scoremax :             # <<<<<<<<<<<<<<
 *                             scoremax = score
 *                             path = -delta-1
 */
          __pyx_t_8 = (__pyx_v_score > __pyx_v_scoremax);
          if (__pyx_t_8) {

            /* "obitools/align/_nwsdnabyprot.pyx":336
 *                                 self._extgap * delta
 *                         if score > scoremax :
 *                             scoremax = score             # <<<<<<<<<<<<<<
 *                             path = -delta-1
 *                             frame= smatrix[idx].frame
 */
            __pyx_v_scoremax = __pyx_v_score;

            /* "obitools/align/_nwsdnabyprot.pyx":337
 *                         if score > scoremax :
 *                             scoremax = score
 *                             path = -delta-1             # <<<<<<<<<<<<<<
 *                             frame= smatrix[idx].frame
 * 
 */
            __pyx_v_path = ((-__pyx_v_delta) - 1);

            /* "obitools/align/_nwsdnabyprot.pyx":338
 *                             scoremax = score
 *                             path = -delta-1
 *                             frame= smatrix[idx].frame             # <<<<<<<<<<<<<<
 * 
 *                     idx = self.index(j,i)
 */
            __pyx_v_frame = (__pyx_v_smatrix[__pyx_v_idx]).frame;
            goto __pyx_L19;
          }
          __pyx_L19:;
          goto __pyx_L18;
        }
        __pyx_L18:;

        /* "obitools/align/_nwsdnabyprot.pyx":340
 *                             frame= smatrix[idx].frame
 * 
 *                     idx = self.index(j,i)             # <<<<<<<<<<<<<<
 *                     smatrix[idx].score = scoremax
 *                     smatrix[idx].path  = path
 */
        __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__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/_nwsdnabyprot.pyx":341
 * 
 *                     idx = self.index(j,i)
 *                     smatrix[idx].score = scoremax             # <<<<<<<<<<<<<<
 *                     smatrix[idx].path  = path
 *                     smatrix[idx].frame = frame
 */
        (__pyx_v_smatrix[__pyx_v_idx]).score = __pyx_v_scoremax;

        /* "obitools/align/_nwsdnabyprot.pyx":342
 *                     idx = self.index(j,i)
 *                     smatrix[idx].score = scoremax
 *                     smatrix[idx].path  = path             # <<<<<<<<<<<<<<
 *                     smatrix[idx].frame = frame
 * 
 */
        (__pyx_v_smatrix[__pyx_v_idx]).path = __pyx_v_path;

        /* "obitools/align/_nwsdnabyprot.pyx":343
 *                     smatrix[idx].score = scoremax
 *                     smatrix[idx].path  = path
 *                     smatrix[idx].frame = frame             # <<<<<<<<<<<<<<
 * 
 *                     if path == -1:
 */
        (__pyx_v_smatrix[__pyx_v_idx]).frame = __pyx_v_frame;

        /* "obitools/align/_nwsdnabyprot.pyx":347
 *                     if path == -1:
 *                         matrix.bestVJump[j]=i
 *                     elif path == +1 :             # <<<<<<<<<<<<<<
 *                         matrix.bestHJump[i]=j
 * 
 */
        switch (__pyx_v_path) {

          /* "obitools/align/_nwsdnabyprot.pyx":345
 *                     smatrix[idx].frame = frame
 * 
 *                     if path == -1:             # <<<<<<<<<<<<<<
 *                         matrix.bestVJump[j]=i
 *                     elif path == +1 :
 */
          case -1:

          /* "obitools/align/_nwsdnabyprot.pyx":346
 * 
 *                     if path == -1:
 *                         matrix.bestVJump[j]=i             # <<<<<<<<<<<<<<
 *                     elif path == +1 :
 *                         matrix.bestHJump[i]=j
 */
          (__pyx_v_matrix->bestVJump[__pyx_v_j]) = __pyx_v_i;
          break;

          /* "obitools/align/_nwsdnabyprot.pyx":347
 *                     if path == -1:
 *                         matrix.bestVJump[j]=i
 *                     elif path == +1 :             # <<<<<<<<<<<<<<
 *                         matrix.bestHJump[i]=j
 * 
 */
          case 1:

          /* "obitools/align/_nwsdnabyprot.pyx":348
 *                         matrix.bestVJump[j]=i
 *                     elif path == +1 :
 *                         matrix.bestHJump[i]=j             # <<<<<<<<<<<<<<
 * 
 *         self.sequenceChanged=False
 */
          (__pyx_v_matrix->bestHJump[__pyx_v_i]) = __pyx_v_j;
          break;
        }
      }
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "obitools/align/_nwsdnabyprot.pyx":350
 *                         matrix.bestHJump[i]=j
 * 
 *         self.sequenceChanged=False             # <<<<<<<<<<<<<<
 *         self.scoreChanged=False
 * 
 */
  __pyx_v_self->__pyx_base.sequenceChanged = 0;

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

  /* "obitools/align/_nwsdnabyprot.pyx":353
 *         self.scoreChanged=False
 * 
 *         idx = self.index(self.hSeq.length,self.vSeq.length)             # <<<<<<<<<<<<<<
 *         return smatrix[idx].score
 * 
 */
  __pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__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/_nwsdnabyprot.pyx":354
 * 
 *         idx = self.index(self.hSeq.length,self.vSeq.length)
 *         return smatrix[idx].score             # <<<<<<<<<<<<<<
 * 
 *     cdef void backtrack(self):
 */
  __pyx_r = (__pyx_v_smatrix[__pyx_v_idx]).score;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("obitools.align._nwsdnabyprot.NWSDNAByProt.doAlignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0.0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_fscost);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static void __pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_backtrack(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_p;
  struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *__pyx_v_matrix;
  struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignCell *__pyx_v_smatrix;
  __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/_nwsdnabyprot.pyx":365
 * 
 * 
 *         self.doAlignment()             # <<<<<<<<<<<<<<
 * 
 *         matrix = <CodonAlignMatrix*>self.matrix
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__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 = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "obitools/align/_nwsdnabyprot.pyx":367
 *         self.doAlignment()
 * 
 *         matrix = <CodonAlignMatrix*>self.matrix             # <<<<<<<<<<<<<<
 *         smatrix= matrix.matrix
 * 
 */
  __pyx_v_matrix = ((struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *)__pyx_v_self->__pyx_base.matrix);

  /* "obitools/align/_nwsdnabyprot.pyx":368
 * 
 *         matrix = <CodonAlignMatrix*>self.matrix
 *         smatrix= matrix.matrix             # <<<<<<<<<<<<<<
 * 
 *         i=self.vSeq.length
 */
  __pyx_v_smatrix = __pyx_v_matrix->matrix;

  /* "obitools/align/_nwsdnabyprot.pyx":370
 *         smatrix= matrix.matrix
 * 
 *         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/_nwsdnabyprot.pyx":371
 * 
 *         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/_nwsdnabyprot.pyx":372
 *         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/_nwsdnabyprot.pyx":374
 *         self.path=allocatePath(i,j,self.path)
 * 
 *         while (i or j):             # <<<<<<<<<<<<<<
 *             p=smatrix[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/_nwsdnabyprot.pyx":375
 * 
 *         while (i or j):
 *             p=smatrix[self.index(j,i)].path             # <<<<<<<<<<<<<<
 *             self.path.path[self.path.length]=p
 *             self.path.length+=1
 */
    __pyx_v_p = (__pyx_v_smatrix[((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__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/_nwsdnabyprot.pyx":376
 *         while (i or j):
 *             p=smatrix[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/_nwsdnabyprot.pyx":377
 *             p=smatrix[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/_nwsdnabyprot.pyx":379
 *             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/_nwsdnabyprot.pyx":380
 *             #path.append(p)
 *             if p==0:
 *                 i-=1             # <<<<<<<<<<<<<<
 *                 j-=1
 *             elif p < 0:
 */
      __pyx_v_i = (__pyx_v_i - 1);

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

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

      /* "obitools/align/_nwsdnabyprot.pyx":383
 *                 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/_nwsdnabyprot.pyx":385
 *                 i+=p
 *             else:
 *                 j-=p             # <<<<<<<<<<<<<<
 * 
 *         #path.reverse()
 */
      __pyx_v_j = (__pyx_v_j - __pyx_v_p);
    }
    __pyx_L5:;
  }

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

  /* "obitools/align/_nwsdnabyprot.pyx":390
 *         #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._nwsdnabyprot.NWSDNAByProt.backtrack", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

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

/* "obitools/align/_nwsdnabyprot.pyx":395
 * 
 *     property match:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._match
 * 
 */

static PyObject *__pyx_pf_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_5match___get__(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__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/_nwsdnabyprot.pyx":396
 *     property match:
 *         def __get__(self):
 *             return self._match             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self,match):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->_match); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __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._nwsdnabyprot.NWSDNAByProt.match.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_5match_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_match); /*proto*/
static int __pyx_pw_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_5match_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_match) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_5match_2__set__(((struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self), ((PyObject *)__pyx_v_match));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_nwsdnabyprot.pyx":398
 *             return self._match
 * 
 *         def __set__(self,match):             # <<<<<<<<<<<<<<
 *             self._match=match
 *             self.scoreChanged=True
 */

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

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

  /* "obitools/align/_nwsdnabyprot.pyx":400
 *         def __set__(self,match):
 *             self._match=match
 *             self.scoreChanged=True             # <<<<<<<<<<<<<<
 * 
 *     property mismatch:
 */
  __pyx_v_self->__pyx_base.scoreChanged = 1;

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

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

/* "obitools/align/_nwsdnabyprot.pyx":403
 * 
 *     property mismatch:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._mismatch
 * 
 */

static PyObject *__pyx_pf_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_8mismatch___get__(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__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/_nwsdnabyprot.pyx":404
 *     property mismatch:
 *         def __get__(self):
 *             return self._mismatch             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self,mismatch):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->_mismatch); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __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._nwsdnabyprot.NWSDNAByProt.mismatch.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_8mismatch_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mismatch); /*proto*/
static int __pyx_pw_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_8mismatch_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mismatch) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_8mismatch_2__set__(((struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self), ((PyObject *)__pyx_v_mismatch));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "obitools/align/_nwsdnabyprot.pyx":406
 *             return self._mismatch
 * 
 *         def __set__(self,mismatch):             # <<<<<<<<<<<<<<
 *             self._mismatch=mismatch
 *             self.scoreChanged=True
 */

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

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

  /* "obitools/align/_nwsdnabyprot.pyx":408
 *         def __set__(self,mismatch):
 *             self._mismatch=mismatch
 *             self.scoreChanged=True             # <<<<<<<<<<<<<<
 * 
 *     cdef int allocate(self) except -1:
 */
  __pyx_v_self->__pyx_base.scoreChanged = 1;

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

/* "obitools/align/_nwsdnabyprot.pyx":410
 *             self.scoreChanged=True
 * 
 *     cdef int allocate(self) except -1:             # <<<<<<<<<<<<<<
 * 
 *         assert self.horizontalSeq is not None,'Sequence A must be set'
 */

static int __pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_allocate(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self) {
  long __pyx_v_lenH;
  long __pyx_v_lenV;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *__pyx_t_2;
  struct __pyx_opt_args_8obitools_5align_13_nwsdnabyprot_allocateCodonMatrix __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("allocate", 0);

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

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

  /* "obitools/align/_nwsdnabyprot.pyx":415
 *         assert self.verticalSeq is not None,'Sequence B must be set'
 * 
 *         cdef long lenH=self.hSeq.length             # <<<<<<<<<<<<<<
 *         cdef long lenV=self.vSeq.length
 * 
 */
  __pyx_v_lenH = __pyx_v_self->__pyx_base.hSeq->length;

  /* "obitools/align/_nwsdnabyprot.pyx":416
 * 
 *         cdef long lenH=self.hSeq.length
 *         cdef long lenV=self.vSeq.length             # <<<<<<<<<<<<<<
 * 
 *         self.matrix=<AlignMatrix*>allocateCodonMatrix(lenH,lenV,<CodonAlignMatrix*>self.matrix)
 */
  __pyx_v_lenV = __pyx_v_self->__pyx_base.vSeq->length;

  /* "obitools/align/_nwsdnabyprot.pyx":418
 *         cdef long lenV=self.vSeq.length
 * 
 *         self.matrix=<AlignMatrix*>allocateCodonMatrix(lenH,lenV,<CodonAlignMatrix*>self.matrix)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  __pyx_t_3.__pyx_n = 1;
  __pyx_t_3.matrix = ((struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *)__pyx_v_self->__pyx_base.matrix);
  __pyx_t_2 = __pyx_f_8obitools_5align_13_nwsdnabyprot_allocateCodonMatrix(__pyx_v_lenH, __pyx_v_lenV, &__pyx_t_3); 
  __pyx_v_self->__pyx_base.matrix = ((struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *)__pyx_t_2);

  /* "obitools/align/_nwsdnabyprot.pyx":419
 * 
 *         self.matrix=<AlignMatrix*>allocateCodonMatrix(lenH,lenV,<CodonAlignMatrix*>self.matrix)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef void reset(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

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

/* "obitools/align/_nwsdnabyprot.pyx":421
 *         return 0
 * 
 *     cdef void reset(self):             # <<<<<<<<<<<<<<
 *         self.scoreChanged=True
 *         resetCodonMatrix(<CodonAlignMatrix*>self.matrix)
 */

static void __pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_reset(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset", 0);

  /* "obitools/align/_nwsdnabyprot.pyx":422
 * 
 *     cdef void reset(self):
 *         self.scoreChanged=True             # <<<<<<<<<<<<<<
 *         resetCodonMatrix(<CodonAlignMatrix*>self.matrix)
 * 
 */
  __pyx_v_self->__pyx_base.scoreChanged = 1;

  /* "obitools/align/_nwsdnabyprot.pyx":423
 *     cdef void reset(self):
 *         self.scoreChanged=True
 *         resetCodonMatrix(<CodonAlignMatrix*>self.matrix)             # <<<<<<<<<<<<<<
 * 
 *     cdef void clean(self):
 */
  __pyx_f_8obitools_5align_13_nwsdnabyprot_resetCodonMatrix(((struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *)__pyx_v_self->__pyx_base.matrix));

  __Pyx_RefNannyFinishContext();
}

/* "obitools/align/_nwsdnabyprot.pyx":425
 *         resetCodonMatrix(<CodonAlignMatrix*>self.matrix)
 * 
 *     cdef void clean(self):             # <<<<<<<<<<<<<<
 *         freeCodonMatrix(<CodonAlignMatrix*>self.matrix)
 *         freeSequence(self.hSeq)
 */

static void __pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_clean(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clean", 0);

  /* "obitools/align/_nwsdnabyprot.pyx":426
 * 
 *     cdef void clean(self):
 *         freeCodonMatrix(<CodonAlignMatrix*>self.matrix)             # <<<<<<<<<<<<<<
 *         freeSequence(self.hSeq)
 *         freeSequence(self.vSeq)
 */
  __pyx_f_8obitools_5align_13_nwsdnabyprot_freeCodonMatrix(((struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *)__pyx_v_self->__pyx_base.matrix));

  /* "obitools/align/_nwsdnabyprot.pyx":427
 *     cdef void clean(self):
 *         freeCodonMatrix(<CodonAlignMatrix*>self.matrix)
 *         freeSequence(self.hSeq)             # <<<<<<<<<<<<<<
 *         freeSequence(self.vSeq)
 *         freePath(self.path)
 */
  __pyx_f_8obitools_5align_8_dynamic_freeSequence(__pyx_v_self->__pyx_base.hSeq);

  /* "obitools/align/_nwsdnabyprot.pyx":428
 *         freeCodonMatrix(<CodonAlignMatrix*>self.matrix)
 *         freeSequence(self.hSeq)
 *         freeSequence(self.vSeq)             # <<<<<<<<<<<<<<
 *         freePath(self.path)
 * 
 */
  __pyx_f_8obitools_5align_8_dynamic_freeSequence(__pyx_v_self->__pyx_base.vSeq);

  /* "obitools/align/_nwsdnabyprot.pyx":429
 *         freeSequence(self.hSeq)
 *         freeSequence(self.vSeq)
 *         freePath(self.path)             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self):
 */
  __pyx_f_8obitools_5align_8_dynamic_freePath(__pyx_v_self->__pyx_base.path);

  __Pyx_RefNannyFinishContext();
}

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

/* "obitools/align/_nwsdnabyprot.pyx":431
 *         freePath(self.path)
 * 
 *     def __call__(self):             # <<<<<<<<<<<<<<
 *         cdef list hgaps=[]
 *         cdef list vgaps=[]
 */

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

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

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

  /* "obitools/align/_nwsdnabyprot.pyx":434
 *         cdef list hgaps=[]
 *         cdef list vgaps=[]
 *         cdef list vframe=[]             # <<<<<<<<<<<<<<
 *         cdef list b
 *         cdef int  hp=0
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_vframe = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "obitools/align/_nwsdnabyprot.pyx":436
 *         cdef list vframe=[]
 *         cdef list b
 *         cdef int  hp=0             # <<<<<<<<<<<<<<
 *         cdef int  vp=0
 *         cdef int  lenh=0
 */
  __pyx_v_hp = 0;

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

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

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

  /* "obitools/align/_nwsdnabyprot.pyx":448
 * 
 * 
 *         if self._needToCompute():             # <<<<<<<<<<<<<<
 *             score = self.doAlignment()
 *             self.backtrack()
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._needToCompute(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self));
  if (__pyx_t_2) {

    /* "obitools/align/_nwsdnabyprot.pyx":449
 * 
 *         if self._needToCompute():
 *             score = self.doAlignment()             # <<<<<<<<<<<<<<
 *             self.backtrack()
 * 
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__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_3 == 0.0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_score = __pyx_t_3;

    /* "obitools/align/_nwsdnabyprot.pyx":450
 *         if self._needToCompute():
 *             score = self.doAlignment()
 *             self.backtrack()             # <<<<<<<<<<<<<<
 * 
 *             h=self.path.hStart
 */
    ((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.backtrack(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self));

    /* "obitools/align/_nwsdnabyprot.pyx":452
 *             self.backtrack()
 * 
 *             h=self.path.hStart             # <<<<<<<<<<<<<<
 *             v=self.path.vStart
 *             matrix = <CodonAlignMatrix*>self.matrix
 */
    __pyx_v_h = __pyx_v_self->__pyx_base.path->hStart;

    /* "obitools/align/_nwsdnabyprot.pyx":453
 * 
 *             h=self.path.hStart
 *             v=self.path.vStart             # <<<<<<<<<<<<<<
 *             matrix = <CodonAlignMatrix*>self.matrix
 *             smatrix= matrix.matrix
 */
    __pyx_v_v = __pyx_v_self->__pyx_base.path->vStart;

    /* "obitools/align/_nwsdnabyprot.pyx":454
 *             h=self.path.hStart
 *             v=self.path.vStart
 *             matrix = <CodonAlignMatrix*>self.matrix             # <<<<<<<<<<<<<<
 *             smatrix= matrix.matrix
 * 
 */
    __pyx_v_matrix = ((struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *)__pyx_v_self->__pyx_base.matrix);

    /* "obitools/align/_nwsdnabyprot.pyx":455
 *             v=self.path.vStart
 *             matrix = <CodonAlignMatrix*>self.matrix
 *             smatrix= matrix.matrix             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_smatrix = __pyx_v_matrix->matrix;

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

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

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

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

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

        /* "obitools/align/_nwsdnabyprot.pyx":463
 *                     hp+=1
 *                     vp+=1
 *                     lenh+=1             # <<<<<<<<<<<<<<
 *                     lenv+=1
 *                     v+=1
 */
        __pyx_v_lenh = (__pyx_v_lenh + 1);

        /* "obitools/align/_nwsdnabyprot.pyx":464
 *                     vp+=1
 *                     lenh+=1
 *                     lenv+=1             # <<<<<<<<<<<<<<
 *                     v+=1
 *                     h+=1
 */
        __pyx_v_lenv = (__pyx_v_lenv + 1);

        /* "obitools/align/_nwsdnabyprot.pyx":465
 *                     lenh+=1
 *                     lenv+=1
 *                     v+=1             # <<<<<<<<<<<<<<
 *                     h+=1
 *                     vframe.append(smatrix[self.index(h,v)].frame)
 */
        __pyx_v_v = (__pyx_v_v + 1);

        /* "obitools/align/_nwsdnabyprot.pyx":466
 *                     lenv+=1
 *                     v+=1
 *                     h+=1             # <<<<<<<<<<<<<<
 *                     vframe.append(smatrix[self.index(h,v)].frame)
 *                 elif p>0:
 */
        __pyx_v_h = (__pyx_v_h + 1);

        /* "obitools/align/_nwsdnabyprot.pyx":467
 *                     v+=1
 *                     h+=1
 *                     vframe.append(smatrix[self.index(h,v)].frame)             # <<<<<<<<<<<<<<
 *                 elif p>0:
 *                     hp+=p
 */
        __pyx_t_1 = PyInt_FromLong((__pyx_v_smatrix[((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_h, __pyx_v_v)]).frame); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = PyList_Append(__pyx_v_vframe, __pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L6;
      }

      /* "obitools/align/_nwsdnabyprot.pyx":468
 *                     h+=1
 *                     vframe.append(smatrix[self.index(h,v)].frame)
 *                 elif p>0:             # <<<<<<<<<<<<<<
 *                     hp+=p
 *                     lenh+=p
 */
      __pyx_t_2 = (__pyx_v_p > 0);
      if (__pyx_t_2) {

        /* "obitools/align/_nwsdnabyprot.pyx":469
 *                     vframe.append(smatrix[self.index(h,v)].frame)
 *                 elif p>0:
 *                     hp+=p             # <<<<<<<<<<<<<<
 *                     lenh+=p
 *                     vgaps.append([vp,p])
 */
        __pyx_v_hp = (__pyx_v_hp + __pyx_v_p);

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

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

        /* "obitools/align/_nwsdnabyprot.pyx":472
 *                     lenh+=p
 *                     vgaps.append([vp,p])
 *                     vp=0             # <<<<<<<<<<<<<<
 *                     h+=p
 *                     #vframe.extend(['*']*p)
 */
        __pyx_v_vp = 0;

        /* "obitools/align/_nwsdnabyprot.pyx":473
 *                     vgaps.append([vp,p])
 *                     vp=0
 *                     h+=p             # <<<<<<<<<<<<<<
 *                     #vframe.extend(['*']*p)
 *                 else:
 */
        __pyx_v_h = (__pyx_v_h + __pyx_v_p);
        goto __pyx_L6;
      }
      /*else*/ {

        /* "obitools/align/_nwsdnabyprot.pyx":476
 *                     #vframe.extend(['*']*p)
 *                 else:
 *                     vp-=p             # <<<<<<<<<<<<<<
 *                     lenv-=p
 *                     hgaps.append([hp,-p])
 */
        __pyx_v_vp = (__pyx_v_vp - __pyx_v_p);

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

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

        /* "obitools/align/_nwsdnabyprot.pyx":479
 *                     lenv-=p
 *                     hgaps.append([hp,-p])
 *                     hp=0             # <<<<<<<<<<<<<<
 *                     v-=p
 *                     vframe.extend([smatrix[self.index(h,v)].frame]*-p)
 */
        __pyx_v_hp = 0;

        /* "obitools/align/_nwsdnabyprot.pyx":480
 *                     hgaps.append([hp,-p])
 *                     hp=0
 *                     v-=p             # <<<<<<<<<<<<<<
 *                     vframe.extend([smatrix[self.index(h,v)].frame]*-p)
 * 
 */
        __pyx_v_v = (__pyx_v_v - __pyx_v_p);

        /* "obitools/align/_nwsdnabyprot.pyx":481
 *                     hp=0
 *                     v-=p
 *                     vframe.extend([smatrix[self.index(h,v)].frame]*-p)             # <<<<<<<<<<<<<<
 * 
 *             if hp:
 */
        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_vframe), __pyx_n_s__extend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = PyInt_FromLong((__pyx_v_smatrix[((struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_h, __pyx_v_v)]).frame); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyList_New(1 * (((-__pyx_v_p)<0) ? 0:(-__pyx_v_p))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        { Py_ssize_t __pyx_temp;
          for (__pyx_temp=0; __pyx_temp < (-__pyx_v_p); __pyx_temp++) {
            __Pyx_INCREF(__pyx_t_6);
            PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_6);
          }
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_7));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
        __pyx_t_7 = 0;
        __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __pyx_L6:;
    }

    /* "obitools/align/_nwsdnabyprot.pyx":483
 *                     vframe.extend([smatrix[self.index(h,v)].frame]*-p)
 * 
 *             if hp:             # <<<<<<<<<<<<<<
 *                 hgaps.append([hp,0])
 *             if vp:
 */
    if (__pyx_v_hp) {

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

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

      /* "obitools/align/_nwsdnabyprot.pyx":486
 *                 hgaps.append([hp,0])
 *             if vp:
 *                 vgaps.append([vp,0])             # <<<<<<<<<<<<<<
 * 
 *             if lenh < self.hSeq.length:
 */
      __pyx_t_6 = PyInt_FromLong(__pyx_v_vp); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_int_0);
      PyList_SET_ITEM(__pyx_t_7, 1, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      __pyx_t_6 = 0;
      __pyx_t_5 = PyList_Append(__pyx_v_vgaps, ((PyObject *)__pyx_t_7)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "obitools/align/_nwsdnabyprot.pyx":488
 *                 vgaps.append([vp,0])
 * 
 *             if lenh < self.hSeq.length:             # <<<<<<<<<<<<<<
 *                 hseq=self.horizontalSeq[self.path.hStart:self.path.hStart+lenh]
 *             else:
 */
    __pyx_t_2 = (__pyx_v_lenh < __pyx_v_self->__pyx_base.hSeq->length);
    if (__pyx_t_2) {

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

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

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

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

    /* "obitools/align/_nwsdnabyprot.pyx":496
 *             hseq.gaps=hgaps
 * 
 *             if lenv < self.vSeq.length:             # <<<<<<<<<<<<<<
 *                 vseq=self.verticalSeq[self.path.vStart:self.path.vStart+lenv]
 *             else:
 */
    __pyx_t_2 = (__pyx_v_lenv < __pyx_v_self->__pyx_base.vSeq->length);
    if (__pyx_t_2) {

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

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

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

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

    /* "obitools/align/_nwsdnabyprot.pyx":504
 *             vseq.gaps=vgaps
 * 
 *             ali=Alignment()             # <<<<<<<<<<<<<<
 *             ali.append(hseq)
 *             ali.append(vseq)
 */
    __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__Alignment); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_ali = __pyx_t_6;
    __pyx_t_6 = 0;

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

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

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

    /* "obitools/align/_nwsdnabyprot.pyx":509
 * 
 *             ali.score=score
 *             self.alignment=ali             # <<<<<<<<<<<<<<
 *         ali=self.alignment.clone()
 *         ali[1]['frame']=vframe
 */
    __Pyx_INCREF(__pyx_v_ali);
    __Pyx_GIVEREF(__pyx_v_ali);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.alignment);
    __Pyx_DECREF(__pyx_v_self->__pyx_base.alignment);
    __pyx_v_self->__pyx_base.alignment = __pyx_v_ali;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "obitools/align/_nwsdnabyprot.pyx":510
 *             ali.score=score
 *             self.alignment=ali
 *         ali=self.alignment.clone()             # <<<<<<<<<<<<<<
 *         ali[1]['frame']=vframe
 *         ali.score=self.alignment.score
 */
  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self->__pyx_base.alignment, __pyx_n_s__clone); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_XDECREF(__pyx_v_ali);
  __pyx_v_ali = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "obitools/align/_nwsdnabyprot.pyx":511
 *             self.alignment=ali
 *         ali=self.alignment.clone()
 *         ali[1]['frame']=vframe             # <<<<<<<<<<<<<<
 *         ali.score=self.alignment.score
 *         return ali
 */
  __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_ali, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__frame), ((PyObject *)__pyx_v_vframe)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

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

  /* "obitools/align/_nwsdnabyprot.pyx":513
 *         ali[1]['frame']=vframe
 *         ali.score=self.alignment.score
 *         return ali             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ali);
  __pyx_r = __pyx_v_ali;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("obitools.align._nwsdnabyprot.NWSDNAByProt.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_hgaps);
  __Pyx_XDECREF(__pyx_v_vgaps);
  __Pyx_XDECREF(__pyx_v_vframe);
  __Pyx_XDECREF(__pyx_v_ali);
  __Pyx_XDECREF(__pyx_v_hseq);
  __Pyx_XDECREF(__pyx_v_vseq);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt __pyx_vtable_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt;

static PyObject *__pyx_tp_new_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *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_13_nwsdnabyprot_NWSDNAByProt *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming*)__pyx_vtabptr_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt;
  p->_gc = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt(PyObject *o) {
  struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *p = (struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)o;
  Py_XDECREF(p->_gc);
  __pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming->tp_dealloc(o);
}

static int __pyx_tp_traverse_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *p = (struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)o;
  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;
  }
  if (p->_gc) {
    e = (*v)(p->_gc, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt(PyObject *o) {
  struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *p = (struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *)o;
  PyObject* tmp;
  if (__pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming->tp_clear) {
    __pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming->tp_clear(o);
  }
  tmp = ((PyObject*)p->_gc);
  p->_gc = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_match(PyObject *o, void *x) {
  return __pyx_pw_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_5match_1__get__(o);
}

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

static PyObject *__pyx_getprop_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_mismatch(PyObject *o, void *x) {
  return __pyx_pw_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_8mismatch_1__get__(o);
}

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

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

static struct PyGetSetDef __pyx_getsets_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt[] = {
  {(char *)"match", __pyx_getprop_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_match, __pyx_setprop_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_match, 0, 0},
  {(char *)"mismatch", __pyx_getprop_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_mismatch, __pyx_setprop_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_mismatch, 0, 0},
  {0, 0, 0, 0, 0}
};

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

static PyBufferProcs __pyx_tp_as_buffer_NWSDNAByProt = {
  #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_13_nwsdnabyprot_NWSDNAByProt = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("obitools.align._nwsdnabyprot.NWSDNAByProt"), /*tp_name*/
  sizeof(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt, /*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_NWSDNAByProt, /*tp_as_number*/
  &__pyx_tp_as_sequence_NWSDNAByProt, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_NWSDNAByProt, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_3__call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_NWSDNAByProt, /*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_13_nwsdnabyprot_NWSDNAByProt, /*tp_traverse*/
  __pyx_tp_clear_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt, /*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}
};

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

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_n_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 1},
  {&__pyx_n_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 1},
  {&__pyx_n_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 1},
  {&__pyx_n_s__AlignedSequence, __pyx_k__AlignedSequence, sizeof(__pyx_k__AlignedSequence), 0, 0, 1, 1},
  {&__pyx_n_s__Alignment, __pyx_k__Alignment, sizeof(__pyx_k__Alignment), 0, 0, 1, 1},
  {&__pyx_n_s__BioSequence, __pyx_k__BioSequence, sizeof(__pyx_k__BioSequence), 0, 0, 1, 1},
  {&__pyx_n_s__GeneticCode, __pyx_k__GeneticCode, sizeof(__pyx_k__GeneticCode), 0, 0, 1, 1},
  {&__pyx_n_s__TranslationEncoder, __pyx_k__TranslationEncoder, sizeof(__pyx_k__TranslationEncoder), 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__clone, __pyx_k__clone, sizeof(__pyx_k__clone), 0, 0, 1, 1},
  {&__pyx_n_s__extend, __pyx_k__extend, sizeof(__pyx_k__extend), 0, 0, 1, 1},
  {&__pyx_n_s__extgap, __pyx_k__extgap, sizeof(__pyx_k__extgap), 0, 0, 1, 1},
  {&__pyx_n_s__frame, __pyx_k__frame, sizeof(__pyx_k__frame), 0, 0, 1, 1},
  {&__pyx_n_s__gaps, __pyx_k__gaps, sizeof(__pyx_k__gaps), 0, 0, 1, 1},
  {&__pyx_n_s__geneticCode, __pyx_k__geneticCode, sizeof(__pyx_k__geneticCode), 0, 0, 1, 1},
  {&__pyx_n_s__match, __pyx_k__match, sizeof(__pyx_k__match), 0, 0, 1, 1},
  {&__pyx_n_s__mismatch, __pyx_k__mismatch, sizeof(__pyx_k__mismatch), 0, 0, 1, 1},
  {&__pyx_n_s__needToCompute, __pyx_k__needToCompute, sizeof(__pyx_k__needToCompute), 0, 0, 1, 1},
  {&__pyx_n_s__obitools, __pyx_k__obitools, sizeof(__pyx_k__obitools), 0, 0, 1, 1},
  {&__pyx_n_s__opengap, __pyx_k__opengap, sizeof(__pyx_k__opengap), 0, 0, 1, 1},
  {&__pyx_n_s__ord, __pyx_k__ord, sizeof(__pyx_k__ord), 0, 0, 1, 1},
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  {&__pyx_n_s__score, __pyx_k__score, sizeof(__pyx_k__score), 0, 0, 1, 1},
  {&__pyx_n_s__startingFrame, __pyx_k__startingFrame, sizeof(__pyx_k__startingFrame), 0, 0, 1, 1},
  {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ord = __Pyx_GetName(__pyx_b, __pyx_n_s__ord); if (!__pyx_builtin_ord) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __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);
  __Pyx_RefNannyFinishContext();
  return 0;
}

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_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_2 = PyInt_FromLong(-2); if (unlikely(!__pyx_int_neg_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_6 = PyInt_FromLong(-6); if (unlikely(!__pyx_int_neg_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_8 = PyInt_FromLong(-8); if (unlikely(!__pyx_int_neg_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_10 = PyInt_FromLong(-10); if (unlikely(!__pyx_int_neg_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init_nwsdnabyprot(void); /*proto*/
PyMODINIT_FUNC init_nwsdnabyprot(void)
#else
PyMODINIT_FUNC PyInit__nwsdnabyprot(void); /*proto*/
PyMODINIT_FUNC PyInit__nwsdnabyprot(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__nwsdnabyprot(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("_nwsdnabyprot"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_3), 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_obitools__align___nwsdnabyprot) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  if (__Pyx_ExportFunction("allocateCodonMatrix", (void (*)(void))__pyx_f_8obitools_5align_13_nwsdnabyprot_allocateCodonMatrix, "struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *(int, int, struct __pyx_opt_args_8obitools_5align_13_nwsdnabyprot_allocateCodonMatrix *__pyx_optional_args)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("freeCodonMatrix", (void (*)(void))__pyx_f_8obitools_5align_13_nwsdnabyprot_freeCodonMatrix, "void (struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("resetCodonMatrix", (void (*)(void))__pyx_f_8obitools_5align_13_nwsdnabyprot_resetCodonMatrix, "void (struct __pyx_t_8obitools_5align_13_nwsdnabyprot_CodonAlignMatrix *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("iupacPartialCodonMatch", (void (*)(void))__pyx_f_8obitools_5align_13_nwsdnabyprot_iupacPartialCodonMatch, "double (char *, char *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- 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_13_nwsdnabyprot_NWSDNAByProt = &__pyx_vtable_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt;
  __pyx_vtable_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt.__pyx_base = *__pyx_vtabptr_8obitools_5align_8_dynamic_DynamicProgramming;
  __pyx_vtable_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt.__pyx_base.allocate = (int (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_allocate;
  __pyx_vtable_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt.__pyx_base.doAlignment = (double (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_doAlignment;
  __pyx_vtable_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt.__pyx_base.reset = (void (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_reset;
  __pyx_vtable_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt.__pyx_base.backtrack = (void (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_backtrack;
  __pyx_vtable_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt.__pyx_base.clean = (void (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_clean;
  __pyx_vtable_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt.getPossibleCodon = (void (*)(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *, char *, int, int, int))__pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_getPossibleCodon;
  __pyx_vtable_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt.aaScore = (double (*)(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *, char, char))__pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_aaScore;
  __pyx_vtable_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt.matchScore = (double (*)(struct __pyx_obj_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt *, int, int, int))__pyx_f_8obitools_5align_13_nwsdnabyprot_12NWSDNAByProt_matchScore;
  __pyx_type_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt.tp_base = __pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming;
  if (PyType_Ready(&__pyx_type_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt.tp_dict, __pyx_vtabptr_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "NWSDNAByProt", (PyObject *)&__pyx_type_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt = &__pyx_type_8obitools_5align_13_nwsdnabyprot_NWSDNAByProt;
  /*--- Type import code ---*/
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("obitools.align._dynamic"); 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, "freeSequence", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_freeSequence, "void (struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_1, "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_1, "freePath", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_freePath, "void (struct __pyx_t_8obitools_5align_8_dynamic_alignPath *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_1, "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_1); __pyx_t_1 = 0;
  /*--- Execution code ---*/

  /* "obitools/align/_nwsdnabyprot.pyx":8
 * #@PydevCodeAnalysisIgnore
 * 
 * import sys             # <<<<<<<<<<<<<<
 * 
 * from _nwsdnabyprot cimport *
 */
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "obitools/align/_nwsdnabyprot.pyx":12
 * from _nwsdnabyprot cimport *
 * 
 * from obitools.sequenceencoder.geneticcode import TranslationEncoder             # <<<<<<<<<<<<<<
 * from obitools.translate import GeneticCode
 * from obitools import BioSequence
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__TranslationEncoder));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__TranslationEncoder));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__TranslationEncoder));
  __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_4), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__TranslationEncoder);
  if (__pyx_t_2 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__TranslationEncoder);
    if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__TranslationEncoder, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "obitools/align/_nwsdnabyprot.pyx":13
 * 
 * from obitools.sequenceencoder.geneticcode import TranslationEncoder
 * from obitools.translate import GeneticCode             # <<<<<<<<<<<<<<
 * from obitools import BioSequence
 * from obitools.alignment import AlignedSequence
 */
  __pyx_t_3 = PyList_New(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_INCREF(((PyObject *)__pyx_n_s__GeneticCode));
  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__GeneticCode));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__GeneticCode));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_5), ((PyObject *)__pyx_t_3), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__GeneticCode);
  if (__pyx_t_3 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__GeneticCode);
    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);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__GeneticCode, __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;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "obitools/align/_nwsdnabyprot.pyx":14
 * from obitools.sequenceencoder.geneticcode import TranslationEncoder
 * from obitools.translate import GeneticCode
 * from obitools import BioSequence             # <<<<<<<<<<<<<<
 * from obitools.alignment import AlignedSequence
 * from obitools.alignment import Alignment
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__BioSequence));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__BioSequence));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__BioSequence));
  __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s__obitools), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__BioSequence);
  if (__pyx_t_2 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__BioSequence);
    if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BioSequence, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "obitools/align/_nwsdnabyprot.pyx":15
 * from obitools.translate import GeneticCode
 * from obitools import BioSequence
 * from obitools.alignment import AlignedSequence             # <<<<<<<<<<<<<<
 * from obitools.alignment import Alignment
 * 
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__AlignedSequence));
  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__AlignedSequence));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__AlignedSequence));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_6), ((PyObject *)__pyx_t_3), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__AlignedSequence);
  if (__pyx_t_3 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__AlignedSequence);
    if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__AlignedSequence, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "obitools/align/_nwsdnabyprot.pyx":16
 * from obitools import BioSequence
 * from obitools.alignment import AlignedSequence
 * from obitools.alignment import Alignment             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Alignment));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__Alignment));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Alignment));
  __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_6), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__Alignment);
  if (__pyx_t_2 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__Alignment);
    if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Alignment, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "obitools/align/_nwsdnabyprot.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;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  if (__pyx_m) {
    __Pyx_AddTraceback("init obitools.align._nwsdnabyprot", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init obitools.align._nwsdnabyprot");
  }
  __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_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 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 long __Pyx_mod_long(long a, long b) {
    long r = a % b;
    r += ((r != 0) & ((r ^ b) < 0)) * b;
    return r;
}

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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