Generated by Cython 0.16 on Wed Oct 17 10:03:56 2012

Raw output: fasta.c

 1: '''
 2: Created on 2012-01-17
 3: 
 4: @author: Andrew Roth
 5: '''
 6: import os
  /* "jointpysam/fasta.pyx":6
 * @author: Andrew Roth
 * '''
 * import os             # <<<<<<<<<<<<<<
 * from libc.stdlib cimport malloc, free
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__os), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 7: from libc.stdlib cimport malloc, free
 8: 
 9: cdef class FastaFile:
/* "jointpysam/fasta.pyx":9
 * from libc.stdlib cimport malloc, free
 * 
 * cdef class FastaFile:             # <<<<<<<<<<<<<<
 *     def __cinit__(self, char * file_name):
 *         self._file_name = strdup(file_name)
 */

struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile {
  int (*get_slice)(struct __pyx_obj_10jointpysam_5fasta_FastaFile *, char *, char *, int, int);
  int (*_polymer)(struct __pyx_obj_10jointpysam_5fasta_FastaFile *, char *, int, int);
  faidx_t *(*get_file_pointer)(struct __pyx_obj_10jointpysam_5fasta_FastaFile *);
  int (*compare_slice)(struct __pyx_obj_10jointpysam_5fasta_FastaFile *, int, char *, char *);
  char (*get_reference_base)(struct __pyx_obj_10jointpysam_5fasta_FastaFile *, char *, int);
  char *(*_fetch)(struct __pyx_obj_10jointpysam_5fasta_FastaFile *, char *, int, int, int *);
  int (*count_run_forward)(struct __pyx_obj_10jointpysam_5fasta_FastaFile *, char *, int, int, int);
  int (*count_run_backward)(struct __pyx_obj_10jointpysam_5fasta_FastaFile *, char *, int, int, int);
};
static struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *__pyx_vtabptr_10jointpysam_5fasta_FastaFile;
 10:     def __cinit__(self, char * file_name):
/* "jointpysam/fasta.pyx":10
 * 
 * cdef class FastaFile:
 *     def __cinit__(self, char * file_name):             # <<<<<<<<<<<<<<
 *         self._file_name = strdup(file_name)
 * 
 */

static int __pyx_pf_10jointpysam_5fasta_9FastaFile___cinit__(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self, char *__pyx_v_file_name) {
  PyObject *__pyx_v_index_file_name = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);
 11:         self._file_name = strdup(file_name)
  /* "jointpysam/fasta.pyx":11
 * cdef class FastaFile:
 *     def __cinit__(self, char * file_name):
 *         self._file_name = strdup(file_name)             # <<<<<<<<<<<<<<
 * 
 *         self._fasta_file = fai_load(file_name)
 */
  __pyx_v_self->_file_name = strdup(__pyx_v_file_name);
 12: 
 13:         self._fasta_file = fai_load(file_name)
  /* "jointpysam/fasta.pyx":13
 *         self._file_name = strdup(file_name)
 * 
 *         self._fasta_file = fai_load(file_name)             # <<<<<<<<<<<<<<
 * 
 *         if self._fasta_file == NULL:
 */
  __pyx_v_self->_fasta_file = fai_load(__pyx_v_file_name);
 14: 
 15:         if self._fasta_file == NULL:
  /* "jointpysam/fasta.pyx":15
 *         self._fasta_file = fai_load(file_name)
 * 
 *         if self._fasta_file == NULL:             # <<<<<<<<<<<<<<
 *             raise Exception("Could not open FASTA file {0}".format(file_name))
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_fasta_file == NULL);
  if (__pyx_t_1) {
 16:             raise Exception("Could not open FASTA file {0}".format(file_name))
    /* "jointpysam/fasta.pyx":16
 * 
 *         if self._fasta_file == NULL:
 *             raise Exception("Could not open FASTA file {0}".format(file_name))             # <<<<<<<<<<<<<<
 * 
 *         index_file_name = file_name + ".fai"
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__format); 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_t_3 = PyBytes_FromString(__pyx_v_file_name); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); 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(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_4), NULL); 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_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;
 17: 
 18:         index_file_name = file_name + ".fai"
  /* "jointpysam/fasta.pyx":18
 *             raise Exception("Could not open FASTA file {0}".format(file_name))
 * 
 *         index_file_name = file_name + ".fai"             # <<<<<<<<<<<<<<
 * 
 *         if not os.path.exists(index_file_name):
 */
  __pyx_t_3 = PyBytes_FromString(__pyx_v_file_name); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = PyNumber_Add(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_index_file_name = __pyx_t_4;
  __pyx_t_4 = 0;
 19: 
 20:         if not os.path.exists(index_file_name):
  /* "jointpysam/fasta.pyx":20
 *         index_file_name = file_name + ".fai"
 * 
 *         if not os.path.exists(index_file_name):             # <<<<<<<<<<<<<<
 *             raise Exception("Index not found for FASTA file {0}".format(file_name))
 * 
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __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 = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_index_file_name);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index_file_name);
  __Pyx_GIVEREF(__pyx_v_index_file_name);
  __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = (!__pyx_t_1);
  if (__pyx_t_5) {
 21:             raise Exception("Index not found for FASTA file {0}".format(file_name))
    /* "jointpysam/fasta.pyx":21
 * 
 *         if not os.path.exists(index_file_name):
 *             raise Exception("Index not found for FASTA file {0}".format(file_name))             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_3), __pyx_n_s__format); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyBytes_FromString(__pyx_v_file_name); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("jointpysam.fasta.FastaFile.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_index_file_name);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_10jointpysam_5fasta_9FastaFile_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_10jointpysam_5fasta_9FastaFile_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_10jointpysam_5fasta_9FastaFile_2__dealloc__(((struct __pyx_obj_10jointpysam_5fasta_FastaFile *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}
 22: 
 23:     def __dealloc__(self):
/* "jointpysam/fasta.pyx":23
 *             raise Exception("Index not found for FASTA file {0}".format(file_name))
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._fasta_file != NULL:
 *             fai_destroy(self._fasta_file)
 */

static void __pyx_pf_10jointpysam_5fasta_9FastaFile_2__dealloc__(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);
 24:         if self._fasta_file != NULL:
  /* "jointpysam/fasta.pyx":24
 * 
 *     def __dealloc__(self):
 *         if self._fasta_file != NULL:             # <<<<<<<<<<<<<<
 *             fai_destroy(self._fasta_file)
 *             self._fasta_file = NULL
 */
  __pyx_t_1 = (__pyx_v_self->_fasta_file != NULL);
  if (__pyx_t_1) {
 25:             fai_destroy(self._fasta_file)
    /* "jointpysam/fasta.pyx":25
 *     def __dealloc__(self):
 *         if self._fasta_file != NULL:
 *             fai_destroy(self._fasta_file)             # <<<<<<<<<<<<<<
 *             self._fasta_file = NULL
 * 
 */
    fai_destroy(__pyx_v_self->_fasta_file);
 26:             self._fasta_file = NULL
    /* "jointpysam/fasta.pyx":26
 *         if self._fasta_file != NULL:
 *             fai_destroy(self._fasta_file)
 *             self._fasta_file = NULL             # <<<<<<<<<<<<<<
 * 
 *         if self._file_name != NULL:
 */
    __pyx_v_self->_fasta_file = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;
 27: 
 28:         if self._file_name != NULL:
  /* "jointpysam/fasta.pyx":28
 *             self._fasta_file = NULL
 * 
 *         if self._file_name != NULL:             # <<<<<<<<<<<<<<
 *             free(self._file_name)
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_file_name != NULL);
  if (__pyx_t_1) {
 29:             free(self._file_name)
    /* "jointpysam/fasta.pyx":29
 * 
 *         if self._file_name != NULL:
 *             free(self._file_name)             # <<<<<<<<<<<<<<
 * 
 *     def get_base(self, reference, position):
 */
    free(__pyx_v_self->_file_name);
    goto __pyx_L4;
  }
  __pyx_L4:;

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_10jointpysam_5fasta_9FastaFile_5get_base(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_10jointpysam_5fasta_9FastaFile_5get_base(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_reference = 0;
  PyObject *__pyx_v_position = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__position,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_base (wrapper)", 0);
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__position);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_base", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_base") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_reference = values[0];
    __pyx_v_position = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_base", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("jointpysam.fasta.FastaFile.get_base", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10jointpysam_5fasta_9FastaFile_4get_base(((struct __pyx_obj_10jointpysam_5fasta_FastaFile *)__pyx_v_self), __pyx_v_reference, __pyx_v_position);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 30: 
 31:     def get_base(self, reference, position):
/* "jointpysam/fasta.pyx":31
 *             free(self._file_name)
 * 
 *     def get_base(self, reference, position):             # <<<<<<<<<<<<<<
 *         return self.get_reference_base(reference, position)
 * 
 */

static PyObject *__pyx_pf_10jointpysam_5fasta_9FastaFile_4get_base(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self, PyObject *__pyx_v_reference, PyObject *__pyx_v_position) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_base", 0);
 32:         return self.get_reference_base(reference, position)
  /* "jointpysam/fasta.pyx":32
 * 
 *     def get_base(self, reference, position):
 *         return self.get_reference_base(reference, position)             # <<<<<<<<<<<<<<
 * 
 *     cdef int get_slice(self, char * reference, char * _s, int start, int end):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyBytes_AsString(__pyx_v_reference); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_position); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromLong(((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->get_reference_base(__pyx_v_self, __pyx_t_1, __pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("jointpysam.fasta.FastaFile.get_base", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 33: 
 34:     cdef int get_slice(self, char * reference, char * _s, int start, int end):
/* "jointpysam/fasta.pyx":34
 *         return self.get_reference_base(reference, position)
 * 
 *     cdef int get_slice(self, char * reference, char * _s, int start, int end):             # <<<<<<<<<<<<<<
 *         #print "\tpopulating slice:", start, end
 *         for i in range(0, end - start):
 */

static int __pyx_f_10jointpysam_5fasta_9FastaFile_get_slice(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self, char *__pyx_v_reference, char *__pyx_v__s, int __pyx_v_start, int __pyx_v_end) {
  PyObject *__pyx_v_i = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_slice", 0);
 35:         #print "\tpopulating slice:", start, end
 36:         for i in range(0, end - start):
  /* "jointpysam/fasta.pyx":36
 *     cdef int get_slice(self, char * reference, char * _s, int start, int end):
 *         #print "\tpopulating slice:", start, end
 *         for i in range(0, end - start):             # <<<<<<<<<<<<<<
 *             _s[i] = self.get_reference_base(reference, start + i)
 *         return 0
 */
  __pyx_t_1 = PyInt_FromLong((__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_1;
    __pyx_t_1 = 0;
 37:             _s[i] = self.get_reference_base(reference, start + i)
    /* "jointpysam/fasta.pyx":37
 *         #print "\tpopulating slice:", start, end
 *         for i in range(0, end - start):
 *             _s[i] = self.get_reference_base(reference, start + i)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyNumber_Add(__pyx_t_1, __pyx_v_i); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    (__pyx_v__s[__pyx_t_7]) = ((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->get_reference_base(__pyx_v_self, __pyx_v_reference, __pyx_t_6);
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 38:         return 0
  /* "jointpysam/fasta.pyx":38
 *         for i in range(0, end - start):
 *             _s[i] = self.get_reference_base(reference, start + i)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     def homopolymer_forward(self, contig, position):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("jointpysam.fasta.FastaFile.get_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_10jointpysam_5fasta_9FastaFile_7homopolymer_forward(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_10jointpysam_5fasta_9FastaFile_7homopolymer_forward(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_contig = 0;
  PyObject *__pyx_v_position = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__contig,&__pyx_n_s__position,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("homopolymer_forward (wrapper)", 0);
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__contig);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__position);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("homopolymer_forward", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "homopolymer_forward") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_contig = values[0];
    __pyx_v_position = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("homopolymer_forward", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("jointpysam.fasta.FastaFile.homopolymer_forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10jointpysam_5fasta_9FastaFile_6homopolymer_forward(((struct __pyx_obj_10jointpysam_5fasta_FastaFile *)__pyx_v_self), __pyx_v_contig, __pyx_v_position);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 39: 
 40:     def homopolymer_forward(self, contig, position):
/* "jointpysam/fasta.pyx":40
 *         return 0
 * 
 *     def homopolymer_forward(self, contig, position):             # <<<<<<<<<<<<<<
 *         return self.count_run_forward(contig, position, 0, 1)
 * 
 */

static PyObject *__pyx_pf_10jointpysam_5fasta_9FastaFile_6homopolymer_forward(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self, PyObject *__pyx_v_contig, PyObject *__pyx_v_position) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("homopolymer_forward", 0);
 41:         return self.count_run_forward(contig, position, 0, 1)
  /* "jointpysam/fasta.pyx":41
 * 
 *     def homopolymer_forward(self, contig, position):
 *         return self.count_run_forward(contig, position, 0, 1)             # <<<<<<<<<<<<<<
 * 
 *     def homopolymer_backward(self, contig, position):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyBytes_AsString(__pyx_v_contig); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_position); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromLong(((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->count_run_forward(__pyx_v_self, __pyx_t_1, __pyx_t_2, 0, 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("jointpysam.fasta.FastaFile.homopolymer_forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_10jointpysam_5fasta_9FastaFile_9homopolymer_backward(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_10jointpysam_5fasta_9FastaFile_9homopolymer_backward(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_contig = 0;
  PyObject *__pyx_v_position = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__contig,&__pyx_n_s__position,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("homopolymer_backward (wrapper)", 0);
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__contig);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__position);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("homopolymer_backward", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "homopolymer_backward") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_contig = values[0];
    __pyx_v_position = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("homopolymer_backward", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("jointpysam.fasta.FastaFile.homopolymer_backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10jointpysam_5fasta_9FastaFile_8homopolymer_backward(((struct __pyx_obj_10jointpysam_5fasta_FastaFile *)__pyx_v_self), __pyx_v_contig, __pyx_v_position);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 42: 
 43:     def homopolymer_backward(self, contig, position):
/* "jointpysam/fasta.pyx":43
 *         return self.count_run_forward(contig, position, 0, 1)
 * 
 *     def homopolymer_backward(self, contig, position):             # <<<<<<<<<<<<<<
 *         #print "\ttrace:", self.get_reference_base(reference, position), self.get_reference_base(reference, position - 1),
 *         return self.count_run_backward(contig, position, 0, 1)
 */

static PyObject *__pyx_pf_10jointpysam_5fasta_9FastaFile_8homopolymer_backward(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self, PyObject *__pyx_v_contig, PyObject *__pyx_v_position) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("homopolymer_backward", 0);
 44:         #print "\ttrace:", self.get_reference_base(reference, position), self.get_reference_base(reference, position - 1),
 45:         return self.count_run_backward(contig, position, 0, 1)
  /* "jointpysam/fasta.pyx":45
 *     def homopolymer_backward(self, contig, position):
 *         #print "\ttrace:", self.get_reference_base(reference, position), self.get_reference_base(reference, position - 1),
 *         return self.count_run_backward(contig, position, 0, 1)             # <<<<<<<<<<<<<<
 * 
 *     cdef faidx_t * get_file_pointer(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyBytes_AsString(__pyx_v_contig); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_position); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromLong(((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->count_run_backward(__pyx_v_self, __pyx_t_1, __pyx_t_2, 0, 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("jointpysam.fasta.FastaFile.homopolymer_backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 46: 
 47:     cdef faidx_t * get_file_pointer(self):
/* "jointpysam/fasta.pyx":47
 *         return self.count_run_backward(contig, position, 0, 1)
 * 
 *     cdef faidx_t * get_file_pointer(self):             # <<<<<<<<<<<<<<
 *         return self._fasta_file
 * 
 */

static faidx_t *__pyx_f_10jointpysam_5fasta_9FastaFile_get_file_pointer(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self) {
  faidx_t *__pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_file_pointer", 0);
 48:         return self._fasta_file
  /* "jointpysam/fasta.pyx":48
 * 
 *     cdef faidx_t * get_file_pointer(self):
 *         return self._fasta_file             # <<<<<<<<<<<<<<
 * 
 *     def n_mer_repeat(self, reference, position, n):
 */
  __pyx_r = __pyx_v_self->_fasta_file;
  goto __pyx_L0;

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

/* Python wrapper */
static PyObject *__pyx_pw_10jointpysam_5fasta_9FastaFile_11n_mer_repeat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_10jointpysam_5fasta_9FastaFile_11n_mer_repeat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_reference = 0;
  PyObject *__pyx_v_position = 0;
  PyObject *__pyx_v_n = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__position,&__pyx_n_s__n,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("n_mer_repeat (wrapper)", 0);
  {
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__position);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("n_mer_repeat", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("n_mer_repeat", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "n_mer_repeat") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_reference = values[0];
    __pyx_v_position = values[1];
    __pyx_v_n = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("n_mer_repeat", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("jointpysam.fasta.FastaFile.n_mer_repeat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10jointpysam_5fasta_9FastaFile_10n_mer_repeat(((struct __pyx_obj_10jointpysam_5fasta_FastaFile *)__pyx_v_self), __pyx_v_reference, __pyx_v_position, __pyx_v_n);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 49: 
 50:     def n_mer_repeat(self, reference, position, n):
/* "jointpysam/fasta.pyx":50
 *         return self._fasta_file
 * 
 *     def n_mer_repeat(self, reference, position, n):             # <<<<<<<<<<<<<<
 *         count = 1
 *         return self.count_run_forward(reference, position * n, count, n)
 */

static PyObject *__pyx_pf_10jointpysam_5fasta_9FastaFile_10n_mer_repeat(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self, PyObject *__pyx_v_reference, PyObject *__pyx_v_position, PyObject *__pyx_v_n) {
  long __pyx_v_count;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("n_mer_repeat", 0);
 51:         count = 1
  /* "jointpysam/fasta.pyx":51
 * 
 *     def n_mer_repeat(self, reference, position, n):
 *         count = 1             # <<<<<<<<<<<<<<
 *         return self.count_run_forward(reference, position * n, count, n)
 * 
 */
  __pyx_v_count = 1;
 52:         return self.count_run_forward(reference, position * n, count, n)
  /* "jointpysam/fasta.pyx":52
 *     def n_mer_repeat(self, reference, position, n):
 *         count = 1
 *         return self.count_run_forward(reference, position * n, count, n)             # <<<<<<<<<<<<<<
 * 
 *     cdef int count_run_forward(self, char * contig, int position, int count, int n):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyBytes_AsString(__pyx_v_reference); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyNumber_Multiply(__pyx_v_position, __pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_n); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->count_run_forward(__pyx_v_self, __pyx_t_1, __pyx_t_3, __pyx_v_count, __pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("jointpysam.fasta.FastaFile.n_mer_repeat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 53: 
 54:     cdef int count_run_forward(self, char * contig, int position, int count, int n):
/* "jointpysam/fasta.pyx":54
 *         return self.count_run_forward(reference, position * n, count, n)
 * 
 *     cdef int count_run_forward(self, char * contig, int position, int count, int n):             # <<<<<<<<<<<<<<
 *         count += 1
 *         if count >= 100:
 */

static int __pyx_f_10jointpysam_5fasta_9FastaFile_count_run_forward(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self, char *__pyx_v_contig, int __pyx_v_position, int __pyx_v_count, CYTHON_UNUSED int __pyx_v_n) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("count_run_forward", 0);
 55:         count += 1
  /* "jointpysam/fasta.pyx":55
 * 
 *     cdef int count_run_forward(self, char * contig, int position, int count, int n):
 *         count += 1             # <<<<<<<<<<<<<<
 *         if count >= 100:
 *             return count
 */
  __pyx_v_count = (__pyx_v_count + 1);
 56:         if count >= 100:
  /* "jointpysam/fasta.pyx":56
 *     cdef int count_run_forward(self, char * contig, int position, int count, int n):
 *         count += 1
 *         if count >= 100:             # <<<<<<<<<<<<<<
 *             return count
 *         if int(self.get_reference_base(contig, position)) == int(self.get_reference_base(contig, position + 1)):
 */
  __pyx_t_1 = (__pyx_v_count >= 100);
  if (__pyx_t_1) {
 57:             return count
    /* "jointpysam/fasta.pyx":57
 *         count += 1
 *         if count >= 100:
 *             return count             # <<<<<<<<<<<<<<
 *         if int(self.get_reference_base(contig, position)) == int(self.get_reference_base(contig, position + 1)):
 *             return self.count_run_forward(contig, position + 1, count, 1)
 */
    __pyx_r = __pyx_v_count;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 58:         if int(self.get_reference_base(contig, position)) == int(self.get_reference_base(contig, position + 1)):
  /* "jointpysam/fasta.pyx":58
 *         if count >= 100:
 *             return count
 *         if int(self.get_reference_base(contig, position)) == int(self.get_reference_base(contig, position + 1)):             # <<<<<<<<<<<<<<
 *             return self.count_run_forward(contig, position + 1, count, 1)
 *         return count
 */
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->get_reference_base(__pyx_v_self, __pyx_v_contig, __pyx_v_position)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __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(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __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 = PyInt_FromLong(((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->get_reference_base(__pyx_v_self, __pyx_v_contig, (__pyx_v_position + 1))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_1) {
 59:             return self.count_run_forward(contig, position + 1, count, 1)
    /* "jointpysam/fasta.pyx":59
 *             return count
 *         if int(self.get_reference_base(contig, position)) == int(self.get_reference_base(contig, position + 1)):
 *             return self.count_run_forward(contig, position + 1, count, 1)             # <<<<<<<<<<<<<<
 *         return count
 * 
 */
    __pyx_r = ((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->count_run_forward(__pyx_v_self, __pyx_v_contig, (__pyx_v_position + 1), __pyx_v_count, 1);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;
 60:         return count
  /* "jointpysam/fasta.pyx":60
 *         if int(self.get_reference_base(contig, position)) == int(self.get_reference_base(contig, position + 1)):
 *             return self.count_run_forward(contig, position + 1, count, 1)
 *         return count             # <<<<<<<<<<<<<<
 * 
 *     cdef int count_run_backward(self, char * contig, int position, int count, int n):
 */
  __pyx_r = __pyx_v_count;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("jointpysam.fasta.FastaFile.count_run_forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 61: 
 62:     cdef int count_run_backward(self, char * contig, int position, int count, int n):
/* "jointpysam/fasta.pyx":62
 *         return count
 * 
 *     cdef int count_run_backward(self, char * contig, int position, int count, int n):             # <<<<<<<<<<<<<<
 *         count += 1
 *         if count >= 100:
 */

static int __pyx_f_10jointpysam_5fasta_9FastaFile_count_run_backward(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self, char *__pyx_v_contig, int __pyx_v_position, int __pyx_v_count, CYTHON_UNUSED int __pyx_v_n) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("count_run_backward", 0);
 63:         count += 1
  /* "jointpysam/fasta.pyx":63
 * 
 *     cdef int count_run_backward(self, char * contig, int position, int count, int n):
 *         count += 1             # <<<<<<<<<<<<<<
 *         if count >= 100:
 *             return count
 */
  __pyx_v_count = (__pyx_v_count + 1);
 64:         if count >= 100:
  /* "jointpysam/fasta.pyx":64
 *     cdef int count_run_backward(self, char * contig, int position, int count, int n):
 *         count += 1
 *         if count >= 100:             # <<<<<<<<<<<<<<
 *             return count
 *         if int(self.get_reference_base(contig, position)) == int(self.get_reference_base(contig, position - 1)):
 */
  __pyx_t_1 = (__pyx_v_count >= 100);
  if (__pyx_t_1) {
 65:             return count
    /* "jointpysam/fasta.pyx":65
 *         count += 1
 *         if count >= 100:
 *             return count             # <<<<<<<<<<<<<<
 *         if int(self.get_reference_base(contig, position)) == int(self.get_reference_base(contig, position - 1)):
 *             return self.count_run_backward(contig, position - 1, count, 1)
 */
    __pyx_r = __pyx_v_count;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 66:         if int(self.get_reference_base(contig, position)) == int(self.get_reference_base(contig, position - 1)):
  /* "jointpysam/fasta.pyx":66
 *         if count >= 100:
 *             return count
 *         if int(self.get_reference_base(contig, position)) == int(self.get_reference_base(contig, position - 1)):             # <<<<<<<<<<<<<<
 *             return self.count_run_backward(contig, position - 1, count, 1)
 *         return count
 */
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->get_reference_base(__pyx_v_self, __pyx_v_contig, __pyx_v_position)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __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(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __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 = PyInt_FromLong(((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->get_reference_base(__pyx_v_self, __pyx_v_contig, (__pyx_v_position - 1))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_1) {
 67:             return self.count_run_backward(contig, position - 1, count, 1)
    /* "jointpysam/fasta.pyx":67
 *             return count
 *         if int(self.get_reference_base(contig, position)) == int(self.get_reference_base(contig, position - 1)):
 *             return self.count_run_backward(contig, position - 1, count, 1)             # <<<<<<<<<<<<<<
 *         return count
 * 
 */
    __pyx_r = ((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->count_run_backward(__pyx_v_self, __pyx_v_contig, (__pyx_v_position - 1), __pyx_v_count, 1);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;
 68:         return count
  /* "jointpysam/fasta.pyx":68
 *         if int(self.get_reference_base(contig, position)) == int(self.get_reference_base(contig, position - 1)):
 *             return self.count_run_backward(contig, position - 1, count, 1)
 *         return count             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_count;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("jointpysam.fasta.FastaFile.count_run_backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 69: 
 70: 
 71:     cdef int _polymer(self, char * reference, int position, int _n):
/* "jointpysam/fasta.pyx":71
 * 
 * 
 *     cdef int _polymer(self, char * reference, int position, int _n):             # <<<<<<<<<<<<<<
 *         #print "entering polymer"
 *         n = abs(_n)
 */

static int __pyx_f_10jointpysam_5fasta_9FastaFile__polymer(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self, char *__pyx_v_reference, int __pyx_v_position, int __pyx_v__n) {
  PyObject *__pyx_v_n = NULL;
  char *__pyx_v_home_slice;
  char *__pyx_v_slice_buffer;
  PyObject *__pyx_v_count = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_polymer", 0);
 72:         #print "entering polymer"
 73:         n = abs(_n)
  /* "jointpysam/fasta.pyx":73
 *     cdef int _polymer(self, char * reference, int position, int _n):
 *         #print "entering polymer"
 *         n = abs(_n)             # <<<<<<<<<<<<<<
 *         #print "sizeof:", sizeof(char) * n
 *         home_slice = <char *> malloc(sizeof(char) * n)
 */
  __pyx_t_1 = __Pyx_abs_int(__pyx_v__n); 
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_n = __pyx_t_2;
  __pyx_t_2 = 0;
 74:         #print "sizeof:", sizeof(char) * n
 75:         home_slice = <char *> malloc(sizeof(char) * n)
  /* "jointpysam/fasta.pyx":75
 *         n = abs(_n)
 *         #print "sizeof:", sizeof(char) * n
 *         home_slice = <char *> malloc(sizeof(char) * n)             # <<<<<<<<<<<<<<
 *         slice_buffer = <char *> malloc(sizeof(char) * n)
 *         count = 0
 */
  __pyx_t_2 = __Pyx_PyInt_FromSize_t((sizeof(char))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsSize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_home_slice = ((char *)malloc(__pyx_t_4));
 76:         slice_buffer = <char *> malloc(sizeof(char) * n)
  /* "jointpysam/fasta.pyx":76
 *         #print "sizeof:", sizeof(char) * n
 *         home_slice = <char *> malloc(sizeof(char) * n)
 *         slice_buffer = <char *> malloc(sizeof(char) * n)             # <<<<<<<<<<<<<<
 *         count = 0
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_FromSize_t((sizeof(char))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_3, __pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsSize_t(__pyx_t_2); if (unlikely((__pyx_t_4 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_slice_buffer = ((char *)malloc(__pyx_t_4));
 77:         count = 0
  /* "jointpysam/fasta.pyx":77
 *         home_slice = <char *> malloc(sizeof(char) * n)
 *         slice_buffer = <char *> malloc(sizeof(char) * n)
 *         count = 0             # <<<<<<<<<<<<<<
 * 
 *         if _n > 0:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_count = __pyx_int_0;
 78: 
 79:         if _n > 0:
  /* "jointpysam/fasta.pyx":79
 *         count = 0
 * 
 *         if _n > 0:             # <<<<<<<<<<<<<<
 *             self.get_slice(reference, home_slice, position, position + n)
 *             self.get_slice(reference, slice_buffer, position + ((count + 1) * n), position + ((count + 2) * n))
 */
  __pyx_t_5 = (__pyx_v__n > 0);
  if (__pyx_t_5) {
 80:             self.get_slice(reference, home_slice, position, position + n)
    /* "jointpysam/fasta.pyx":80
 * 
 *         if _n > 0:
 *             self.get_slice(reference, home_slice, position, position + n)             # <<<<<<<<<<<<<<
 *             self.get_slice(reference, slice_buffer, position + ((count + 1) * n), position + ((count + 2) * n))
 *         else:
 */
    __pyx_t_2 = PyInt_FromLong(__pyx_v_position); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    ((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->get_slice(__pyx_v_self, __pyx_v_reference, __pyx_v_home_slice, __pyx_v_position, __pyx_t_6);
 81:             self.get_slice(reference, slice_buffer, position + ((count + 1) * n), position + ((count + 2) * n))
    /* "jointpysam/fasta.pyx":81
 *         if _n > 0:
 *             self.get_slice(reference, home_slice, position, position + n)
 *             self.get_slice(reference, slice_buffer, position + ((count + 1) * n), position + ((count + 2) * n))             # <<<<<<<<<<<<<<
 *         else:
 *             self.get_slice(reference, home_slice, position - n + 1, position + 1)
 */
    __pyx_t_3 = PyInt_FromLong(__pyx_v_position); 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_t_2 = PyNumber_Add(__pyx_v_count, __pyx_int_1); 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_t_7 = PyNumber_Multiply(__pyx_t_2, __pyx_v_n); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Add(__pyx_t_3, __pyx_t_7); 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_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyInt_FromLong(__pyx_v_position); 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_t_7 = PyNumber_Add(__pyx_v_count, __pyx_int_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_7, __pyx_v_n); 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_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_Add(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    ((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->get_slice(__pyx_v_self, __pyx_v_reference, __pyx_v_slice_buffer, __pyx_t_6, __pyx_t_8);
    goto __pyx_L3;
  }
  /*else*/ {
 82:         else:
 83:             self.get_slice(reference, home_slice, position - n + 1, position + 1)
    /* "jointpysam/fasta.pyx":83
 *             self.get_slice(reference, slice_buffer, position + ((count + 1) * n), position + ((count + 2) * n))
 *         else:
 *             self.get_slice(reference, home_slice, position - n + 1, position + 1)             # <<<<<<<<<<<<<<
 *             self.get_slice(reference, slice_buffer, position - ((count + 2) * n) + 1, position - ((count + 1) * n) + 1)
 * 
 */
    __pyx_t_7 = PyInt_FromLong(__pyx_v_position); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_7, __pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    ((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->get_slice(__pyx_v_self, __pyx_v_reference, __pyx_v_home_slice, __pyx_t_8, (__pyx_v_position + 1));
 84:             self.get_slice(reference, slice_buffer, position - ((count + 2) * n) + 1, position - ((count + 1) * n) + 1)
    /* "jointpysam/fasta.pyx":84
 *         else:
 *             self.get_slice(reference, home_slice, position - n + 1, position + 1)
 *             self.get_slice(reference, slice_buffer, position - ((count + 2) * n) + 1, position - ((count + 1) * n) + 1)             # <<<<<<<<<<<<<<
 * 
 *         while(self.compare_slice(n, home_slice, slice_buffer) and count < 10):
 */
    __pyx_t_7 = PyInt_FromLong(__pyx_v_position); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = PyNumber_Add(__pyx_v_count, __pyx_int_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyNumber_Multiply(__pyx_t_3, __pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyInt_FromLong(__pyx_v_position); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_Add(__pyx_v_count, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyNumber_Multiply(__pyx_t_3, __pyx_v_n); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    ((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->get_slice(__pyx_v_self, __pyx_v_reference, __pyx_v_slice_buffer, __pyx_t_8, __pyx_t_6);
  }
  __pyx_L3:;
 85: 
 86:         while(self.compare_slice(n, home_slice, slice_buffer) and count < 10):
  /* "jointpysam/fasta.pyx":86
 *             self.get_slice(reference, slice_buffer, position - ((count + 2) * n) + 1, position - ((count + 1) * n) + 1)
 * 
 *         while(self.compare_slice(n, home_slice, slice_buffer) and count < 10):             # <<<<<<<<<<<<<<
 *             #print "home: \"" + home_slice + "\"\t\"" + slice_buffer + "\""
 *             count += 1
 */
  while (1) {
    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_n); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->compare_slice(__pyx_v_self, __pyx_t_6, __pyx_v_home_slice, __pyx_v_slice_buffer)) {
      __pyx_t_7 = PyObject_RichCompare(__pyx_v_count, __pyx_int_10, Py_LT); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_9 = __pyx_t_5;
    } else {
      __pyx_t_9 = ((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->compare_slice(__pyx_v_self, __pyx_t_6, __pyx_v_home_slice, __pyx_v_slice_buffer);
    }
    if (!__pyx_t_9) break;
 87:             #print "home: \"" + home_slice + "\"\t\"" + slice_buffer + "\""
 88:             count += 1
    /* "jointpysam/fasta.pyx":88
 *         while(self.compare_slice(n, home_slice, slice_buffer) and count < 10):
 *             #print "home: \"" + home_slice + "\"\t\"" + slice_buffer + "\""
 *             count += 1             # <<<<<<<<<<<<<<
 *             if _n > 0:
 *                 self.get_slice(reference, slice_buffer, position + ((count + 1) * n), position + ((count + 2) * n))
 */
    __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_count, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_v_count);
    __pyx_v_count = __pyx_t_7;
    __pyx_t_7 = 0;
 89:             if _n > 0:
    /* "jointpysam/fasta.pyx":89
 *             #print "home: \"" + home_slice + "\"\t\"" + slice_buffer + "\""
 *             count += 1
 *             if _n > 0:             # <<<<<<<<<<<<<<
 *                 self.get_slice(reference, slice_buffer, position + ((count + 1) * n), position + ((count + 2) * n))
 *             else:
 */
    __pyx_t_9 = (__pyx_v__n > 0);
    if (__pyx_t_9) {
 90:                 self.get_slice(reference, slice_buffer, position + ((count + 1) * n), position + ((count + 2) * n))
      /* "jointpysam/fasta.pyx":90
 *             count += 1
 *             if _n > 0:
 *                 self.get_slice(reference, slice_buffer, position + ((count + 1) * n), position + ((count + 2) * n))             # <<<<<<<<<<<<<<
 *             else:
 *                 self.get_slice(reference, slice_buffer, position - ((count + 2) * n) + 1, position - ((count + 1) * n) + 1)
 */
      __pyx_t_7 = PyInt_FromLong(__pyx_v_position); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = PyNumber_Add(__pyx_v_count, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyNumber_Multiply(__pyx_t_3, __pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_Add(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_3); 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_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyInt_FromLong(__pyx_v_position); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyNumber_Add(__pyx_v_count, __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = PyNumber_Multiply(__pyx_t_2, __pyx_v_n); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Add(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      ((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->get_slice(__pyx_v_self, __pyx_v_reference, __pyx_v_slice_buffer, __pyx_t_6, __pyx_t_8);
      goto __pyx_L6;
    }
    /*else*/ {
 91:             else:
 92:                 self.get_slice(reference, slice_buffer, position - ((count + 2) * n) + 1, position - ((count + 1) * n) + 1)
      /* "jointpysam/fasta.pyx":92
 *                 self.get_slice(reference, slice_buffer, position + ((count + 1) * n), position + ((count + 2) * n))
 *             else:
 *                 self.get_slice(reference, slice_buffer, position - ((count + 2) * n) + 1, position - ((count + 1) * n) + 1)             # <<<<<<<<<<<<<<
 * 
 *         free(slice_buffer)
 */
      __pyx_t_2 = PyInt_FromLong(__pyx_v_position); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = PyNumber_Add(__pyx_v_count, __pyx_int_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_7, __pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyNumber_Subtract(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_Add(__pyx_t_7, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyInt_FromLong(__pyx_v_position); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyNumber_Add(__pyx_v_count, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = PyNumber_Multiply(__pyx_t_7, __pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyNumber_Subtract(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Add(__pyx_t_7, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      ((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->get_slice(__pyx_v_self, __pyx_v_reference, __pyx_v_slice_buffer, __pyx_t_8, __pyx_t_6);
    }
    __pyx_L6:;
  }
 93: 
 94:         free(slice_buffer)
  /* "jointpysam/fasta.pyx":94
 *                 self.get_slice(reference, slice_buffer, position - ((count + 2) * n) + 1, position - ((count + 1) * n) + 1)
 * 
 *         free(slice_buffer)             # <<<<<<<<<<<<<<
 *         free(home_slice)
 *         return count
 */
  free(__pyx_v_slice_buffer);
 95:         free(home_slice)
  /* "jointpysam/fasta.pyx":95
 * 
 *         free(slice_buffer)
 *         free(home_slice)             # <<<<<<<<<<<<<<
 *         return count
 * 
 */
  free(__pyx_v_home_slice);
 96:         return count
  /* "jointpysam/fasta.pyx":96
 *         free(slice_buffer)
 *         free(home_slice)
 *         return count             # <<<<<<<<<<<<<<
 * 
 *     cdef int compare_slice(self, int n, char * first, char * second):
 */
  __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_count); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_6;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("jointpysam.fasta.FastaFile._polymer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_n);
  __Pyx_XDECREF(__pyx_v_count);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 97: 
 98:     cdef int compare_slice(self, int n, char * first, char * second):
/* "jointpysam/fasta.pyx":98
 *         return count
 * 
 *     cdef int compare_slice(self, int n, char * first, char * second):             # <<<<<<<<<<<<<<
 *         for i in range(0, n):
 *             if first[i] != second[i]:
 */

static int __pyx_f_10jointpysam_5fasta_9FastaFile_compare_slice(CYTHON_UNUSED struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self, int __pyx_v_n, char *__pyx_v_first, char *__pyx_v_second) {
  long __pyx_v_i;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compare_slice", 0);
 99:         for i in range(0, n):
  /* "jointpysam/fasta.pyx":99
 * 
 *     cdef int compare_slice(self, int n, char * first, char * second):
 *         for i in range(0, n):             # <<<<<<<<<<<<<<
 *             if first[i] != second[i]:
 *                 return 0
 */
  __pyx_t_1 = __pyx_v_n;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;
 100:             if first[i] != second[i]:
    /* "jointpysam/fasta.pyx":100
 *     cdef int compare_slice(self, int n, char * first, char * second):
 *         for i in range(0, n):
 *             if first[i] != second[i]:             # <<<<<<<<<<<<<<
 *                 return 0
 *         return 1
 */
    __pyx_t_3 = ((__pyx_v_first[__pyx_v_i]) != (__pyx_v_second[__pyx_v_i]));
    if (__pyx_t_3) {
 101:                 return 0
      /* "jointpysam/fasta.pyx":101
 *         for i in range(0, n):
 *             if first[i] != second[i]:
 *                 return 0             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
 102:         return 1
  /* "jointpysam/fasta.pyx":102
 *             if first[i] != second[i]:
 *                 return 0
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     cdef char get_reference_base(self, char * reference, int position):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 103: 
 104:     cdef char get_reference_base(self, char * reference, int position):
/* "jointpysam/fasta.pyx":104
 *         return 1
 * 
 *     cdef char get_reference_base(self, char * reference, int position):             # <<<<<<<<<<<<<<
 *         '''
 *         Retrieve a base form the file.
 */

static char __pyx_f_10jointpysam_5fasta_9FastaFile_get_reference_base(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self, char *__pyx_v_reference, int __pyx_v_position) {
  char __pyx_v_ref_base;
  int __pyx_v_len;
  char __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_reference_base", 0);
 105:         '''
 106:         Retrieve a base form the file.
 107: 
 108:         position is 1 based.
 109:         '''
 110:         cdef char ref_base
 111:         cdef int len
 112: 
 113:         len = 1
  /* "jointpysam/fasta.pyx":113
 *         cdef int len
 * 
 *         len = 1             # <<<<<<<<<<<<<<
 * 
 *         ref_base = self._fetch(reference, position, position + 1, & len)[0]
 */
  __pyx_v_len = 1;
 114: 
 115:         ref_base = self._fetch(reference, position, position + 1, & len)[0]
  /* "jointpysam/fasta.pyx":115
 *         len = 1
 * 
 *         ref_base = self._fetch(reference, position, position + 1, & len)[0]             # <<<<<<<<<<<<<<
 * 
 *         ref_base = < char > toupper(< int > ref_base)
 */
  __pyx_v_ref_base = (((struct __pyx_vtabstruct_10jointpysam_5fasta_FastaFile *)__pyx_v_self->__pyx_vtab)->_fetch(__pyx_v_self, __pyx_v_reference, __pyx_v_position, (__pyx_v_position + 1), (&__pyx_v_len))[0]);
 116: 
 117:         ref_base = < char > toupper(< int > ref_base)
  /* "jointpysam/fasta.pyx":117
 *         ref_base = self._fetch(reference, position, position + 1, & len)[0]
 * 
 *         ref_base = < char > toupper(< int > ref_base)             # <<<<<<<<<<<<<<
 * 
 *         return ref_base
 */
  __pyx_v_ref_base = ((char)toupper(((int)__pyx_v_ref_base)));
 118: 
 119:         return ref_base
  /* "jointpysam/fasta.pyx":119
 *         ref_base = < char > toupper(< int > ref_base)
 * 
 *         return ref_base             # <<<<<<<<<<<<<<
 * 
 *     # THIS IS THE ONLY PLACE WHERE ZERO INDEXED POSITIONS ARE EVEN TO BE THOUGHT ABOUT!
 */
  __pyx_r = __pyx_v_ref_base;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 120: 
 121:     # THIS IS THE ONLY PLACE WHERE ZERO INDEXED POSITIONS ARE EVEN TO BE THOUGHT ABOUT!
 122:     cdef char * _fetch(self, char * reference, int start, int end, int * length):
/* "jointpysam/fasta.pyx":122
 * 
 *     # THIS IS THE ONLY PLACE WHERE ZERO INDEXED POSITIONS ARE EVEN TO BE THOUGHT ABOUT!
 *     cdef char * _fetch(self, char * reference, int start, int end, int * length):             # <<<<<<<<<<<<<<
 *         return faidx_fetch_seq(self._fasta_file, reference, start - 1, end, length)
 * 
 */

static char *__pyx_f_10jointpysam_5fasta_9FastaFile__fetch(struct __pyx_obj_10jointpysam_5fasta_FastaFile *__pyx_v_self, char *__pyx_v_reference, int __pyx_v_start, int __pyx_v_end, int *__pyx_v_length) {
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_fetch", 0);
 123:         return faidx_fetch_seq(self._fasta_file, reference, start - 1, end, length)
  /* "jointpysam/fasta.pyx":123
 *     # THIS IS THE ONLY PLACE WHERE ZERO INDEXED POSITIONS ARE EVEN TO BE THOUGHT ABOUT!
 *     cdef char * _fetch(self, char * reference, int start, int end, int * length):
 *         return faidx_fetch_seq(self._fasta_file, reference, start - 1, end, length)             # <<<<<<<<<<<<<<
 * 
 */
  __pyx_r = faidx_fetch_seq(__pyx_v_self->_fasta_file, __pyx_v_reference, (__pyx_v_start - 1), __pyx_v_end, __pyx_v_length);
  goto __pyx_L0;

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