Exemplo n.º 1
0
/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/align/_core.pyx":5
 * """
 * 
 * def coord_to_col( int start, char * text, int pos ):             # <<<<<<<<<<<<<<
 *     cdef int col
 *     col = 0
 */

static PyObject *__pyx_pf_2bx_5align_5_core_coord_to_col(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2bx_5align_5_core_coord_to_col(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_start;
  char *__pyx_v_text;
  int __pyx_v_pos;
  int __pyx_v_col;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_start,&__pyx_kp_text,&__pyx_kp_pos,0};
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_start);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_text);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("coord_to_col", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_pos);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("coord_to_col", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "coord_to_col") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_start = __pyx_PyInt_int(values[0]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_text = __Pyx_PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_text) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_pos = __pyx_PyInt_int(values[2]); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_start = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_text = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_text) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_pos = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("coord_to_col", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("bx.align._core.coord_to_col");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/align/_core.pyx":7
 * def coord_to_col( int start, char * text, int pos ):
 *     cdef int col
 *     col = 0             # <<<<<<<<<<<<<<
 *     while start < pos:
 *         # Note: ord( '-' ) = 45
 */
  __pyx_v_col = 0;

  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/align/_core.pyx":8
 *     cdef int col
 *     col = 0
 *     while start < pos:             # <<<<<<<<<<<<<<
 *         # Note: ord( '-' ) = 45
 *         if text[col] != 45:
 */
  while (1) {
    __pyx_1 = (__pyx_v_start < __pyx_v_pos);
    if (!__pyx_1) break;

    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/align/_core.pyx":10
 *     while start < pos:
 *         # Note: ord( '-' ) = 45
 *         if text[col] != 45:             # <<<<<<<<<<<<<<
 *             start = start + 1
 *         col = col + 1
 */
    __pyx_1 = ((__pyx_v_text[__pyx_v_col]) != 45);
    if (__pyx_1) {

      /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/align/_core.pyx":11
 *         # Note: ord( '-' ) = 45
 *         if text[col] != 45:
 *             start = start + 1             # <<<<<<<<<<<<<<
 *         col = col + 1
 *     return col
 */
      __pyx_v_start = (__pyx_v_start + 1);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/align/_core.pyx":12
 *         if text[col] != 45:
 *             start = start + 1
 *         col = col + 1             # <<<<<<<<<<<<<<
 *     return col
 */
    __pyx_v_col = (__pyx_v_col + 1);
  }

  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/align/_core.pyx":13
 *             start = start + 1
 *         col = col + 1
 *     return col             # <<<<<<<<<<<<<<
 */
  __pyx_2 = PyInt_FromLong(__pyx_v_col); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("bx.align._core.coord_to_col");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}
Exemplo n.º 2
0
/* "/home/abhinav/projects/fb-puzzles/breathalyzer/levenshtein.pyx":4
 *      int levenshtein_distance(char *s,char *t)
 * 
 * def levenshtein(char* s1, char* s2):             # <<<<<<<<<<<<<<
 *     return levenshtein_distance(s1, s2)
 */

static PyObject *__pyx_pf_11levenshtein_levenshtein(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_11levenshtein_levenshtein(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_s1;
  char *__pyx_v_s2;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__s1,&__pyx_n_s__s2,0};
  __Pyx_RefNannySetupContext("levenshtein");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_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;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__s1);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__s2);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("levenshtein", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "levenshtein") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_s1 = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_s1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_s2 = __Pyx_PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_s2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_s1 = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_s1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_s2 = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_s2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("levenshtein", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("levenshtein.levenshtein");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/abhinav/projects/fb-puzzles/breathalyzer/levenshtein.pyx":5
 * 
 * def levenshtein(char* s1, char* s2):
 *     return levenshtein_distance(s1, s2)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(levenshtein_distance(__pyx_v_s1, __pyx_v_s2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __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("levenshtein.levenshtein");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}