Generated by Cython 0.29.26
Yellow lines hint at Python interaction.
Click on a line that starts with a "+
" to see the C code that Cython generated for it.
Raw output: opt.c
+01: # cython: profile=False
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
02: # cython: embedsignature=True
03:
04: from pysam.libcalignmentfile cimport AlignmentFile
05: from pysam.libcsamfile cimport Samfile
06: from pysam.libcfaidx cimport FastaFile
07: from pysam.libcalignedsegment cimport PileupColumn,PileupRead,pysam_bam_get_seq
08: from pysam.libchtslib cimport bam1_t, bam_pileup1_t
09: from libc.stdint cimport uint32_t, uint8_t, uint64_t, int64_t
10: from cpython cimport PyBytes_FromStringAndSize
11:
+12: cdef char* bam_nt16_rev_table = "=ACMGRSVTWYHKDBN"
__pyx_v_8bamstats_3opt_bam_nt16_rev_table = ((char *)"=ACMGRSVTWYHKDBN");
13:
14:
15:
+16: cdef inline object get_seq_base(bam1_t *src, uint32_t k):
static CYTHON_INLINE PyObject *__pyx_f_8bamstats_3opt_get_seq_base(bam1_t *__pyx_v_src, uint32_t __pyx_v_k) { uint8_t *__pyx_v_p; char *__pyx_v_s; PyObject *__pyx_v_seq = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_seq_base", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("bamstats.opt.get_seq_base", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_seq); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
17: cdef uint8_t* p
18: cdef char* s
19:
+20: if not src.core.l_qseq:
__pyx_t_1 = ((!(__pyx_v_src->core.l_qseq != 0)) != 0); if (__pyx_t_1) { /* … */ }
+21: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
22:
+23: seq = PyBytes_FromStringAndSize(NULL, 1)
__pyx_t_2 = PyBytes_FromStringAndSize(NULL, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_seq = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+24: s = <char*>seq
if (unlikely(__pyx_v_seq == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 24, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_seq); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 24, __pyx_L1_error) __pyx_v_s = ((char *)__pyx_t_3);
+25: p = pysam_bam_get_seq(src)
__pyx_v_p = pysam_bam_get_seq(__pyx_v_src);
26:
+27: s[0] = bam_nt16_rev_table[p[k//2] >> 4 * (1 - k%2) & 0xf]
(__pyx_v_s[0]) = (__pyx_v_8bamstats_3opt_bam_nt16_rev_table[(((__pyx_v_p[__Pyx_div_long(__pyx_v_k, 2)]) >> (4 * (1 - __Pyx_mod_long(__pyx_v_k, 2)))) & 0xf)]);
28:
+29: return seq
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_seq); __pyx_r = __pyx_v_seq; goto __pyx_L0;
30:
+31: def allbase(FastaFile fafile,str chrom,int reference_length,dict rec_lst):
/* Python wrapper */ static PyObject *__pyx_pw_8bamstats_3opt_1allbase(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_8bamstats_3opt_allbase[] = "allbase(FastaFile fafile, str chrom, int reference_length, dict rec_lst)"; static PyMethodDef __pyx_mdef_8bamstats_3opt_1allbase = {"allbase", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8bamstats_3opt_1allbase, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8bamstats_3opt_allbase}; static PyObject *__pyx_pw_8bamstats_3opt_1allbase(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile = 0; PyObject *__pyx_v_chrom = 0; int __pyx_v_reference_length; PyObject *__pyx_v_rec_lst = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("allbase (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fafile,&__pyx_n_s_chrom,&__pyx_n_s_reference_length,&__pyx_n_s_rec_lst,0}; PyObject* values[4] = {0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fafile)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_chrom)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("allbase", 1, 4, 4, 1); __PYX_ERR(0, 31, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reference_length)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("allbase", 1, 4, 4, 2); __PYX_ERR(0, 31, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rec_lst)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("allbase", 1, 4, 4, 3); __PYX_ERR(0, 31, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "allbase") < 0)) __PYX_ERR(0, 31, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { 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); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_fafile = ((struct __pyx_obj_5pysam_9libcfaidx_FastaFile *)values[0]); __pyx_v_chrom = ((PyObject*)values[1]); __pyx_v_reference_length = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_reference_length == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 31, __pyx_L3_error) __pyx_v_rec_lst = ((PyObject*)values[3]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("allbase", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 31, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("bamstats.opt.allbase", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fafile), __pyx_ptype_5pysam_9libcfaidx_FastaFile, 1, "fafile", 0))) __PYX_ERR(0, 31, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chrom), (&PyString_Type), 1, "chrom", 1))) __PYX_ERR(0, 31, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_rec_lst), (&PyDict_Type), 1, "rec_lst", 1))) __PYX_ERR(0, 31, __pyx_L1_error) __pyx_r = __pyx_pf_8bamstats_3opt_allbase(__pyx_self, __pyx_v_fafile, __pyx_v_chrom, __pyx_v_reference_length, __pyx_v_rec_lst); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_8bamstats_3opt_allbase(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, PyObject *__pyx_v_chrom, int __pyx_v_reference_length, PyObject *__pyx_v_rec_lst) { int __pyx_v_position; PyObject *__pyx_v_refbase = 0; PyObject *__pyx_v_rec = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("allbase", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("bamstats.opt.allbase", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_refbase); __Pyx_XDECREF(__pyx_v_rec); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple_ = PyTuple_Pack(7, __pyx_n_s_fafile, __pyx_n_s_chrom, __pyx_n_s_reference_length, __pyx_n_s_rec_lst, __pyx_n_s_position, __pyx_n_s_refbase, __pyx_n_s_rec); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); /* … */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8bamstats_3opt_1allbase, NULL, __pyx_n_s_bamstats_opt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_allbase, __pyx_t_1) < 0) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_bamstats_opt_pyx, __pyx_n_s_allbase, 31, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 31, __pyx_L1_error)
32: cdef:
33: int position
34: str refbase
+35: for position in range(reference_length):
__pyx_t_1 = __pyx_v_reference_length; __pyx_t_2 = __pyx_t_1; for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_position = __pyx_t_3;
+36: if position not in rec_lst:
__pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_position); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely(__pyx_v_rec_lst == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 36, __pyx_L1_error) } __pyx_t_5 = (__Pyx_PyDict_ContainsTF(__pyx_t_4, __pyx_v_rec_lst, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = (__pyx_t_5 != 0); if (__pyx_t_6) { /* … */ } }
+37: rec = {'Pos':None,'A':0,'C':0,'G':0,'T':0,'N':0,'DEL':0,'INS':0,'Ref':None,'Depth':0}
__pyx_t_4 = __Pyx_PyDict_NewPresized(10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_Pos, Py_None) < 0) __PYX_ERR(0, 37, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_A, __pyx_int_0) < 0) __PYX_ERR(0, 37, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_C, __pyx_int_0) < 0) __PYX_ERR(0, 37, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_G, __pyx_int_0) < 0) __PYX_ERR(0, 37, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_T, __pyx_int_0) < 0) __PYX_ERR(0, 37, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_N, __pyx_int_0) < 0) __PYX_ERR(0, 37, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_DEL, __pyx_int_0) < 0) __PYX_ERR(0, 37, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_INS, __pyx_int_0) < 0) __PYX_ERR(0, 37, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_Ref, Py_None) < 0) __PYX_ERR(0, 37, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_Depth, __pyx_int_0) < 0) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_rec, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0;
+38: refbase = fafile.fetch(reference=chrom, start=position, end=position+1).upper()
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_fafile), __pyx_n_s_fetch); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_reference, __pyx_v_chrom) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_position); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_start, __pyx_t_9) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyInt_From_long((__pyx_v_position + 1)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_end, __pyx_t_9) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_upper); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_4 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_refbase, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0;
+39: rec['Pos'] = position+1 #zero-based to one-based
__pyx_t_4 = __Pyx_PyInt_From_long((__pyx_v_position + 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_n_s_Pos, __pyx_t_4) < 0)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+40: rec['Ref'] = refbase
if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_n_s_Ref, __pyx_v_refbase) < 0)) __PYX_ERR(0, 40, __pyx_L1_error)
+41: rec_lst[position] = rec
if (unlikely(__pyx_v_rec_lst == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 41, __pyx_L1_error) } __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_position); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely(PyDict_SetItem(__pyx_v_rec_lst, __pyx_t_4, __pyx_v_rec) < 0)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
42:
43:
+44: def count_bases(str bamFile,str reference,bint truncate=False,int min_mapping_quality=0,int min_base_quality=0,str stepper='all'):
/* Python wrapper */ static PyObject *__pyx_pw_8bamstats_3opt_3count_bases(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_8bamstats_3opt_2count_bases[] = "count_bases(str bamFile, str reference, bool truncate=False, int min_mapping_quality=0, int min_base_quality=0, str stepper='all')"; static PyMethodDef __pyx_mdef_8bamstats_3opt_3count_bases = {"count_bases", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8bamstats_3opt_3count_bases, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8bamstats_3opt_2count_bases}; static PyObject *__pyx_pw_8bamstats_3opt_3count_bases(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_bamFile = 0; PyObject *__pyx_v_reference = 0; int __pyx_v_truncate; int __pyx_v_min_mapping_quality; int __pyx_v_min_base_quality; PyObject *__pyx_v_stepper = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("count_bases (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bamFile,&__pyx_n_s_reference,&__pyx_n_s_truncate,&__pyx_n_s_min_mapping_quality,&__pyx_n_s_min_base_quality,&__pyx_n_s_stepper,0}; PyObject* values[6] = {0,0,0,0,0,0}; values[5] = ((PyObject*)__pyx_n_s_all); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bamFile)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reference)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("count_bases", 0, 2, 6, 1); __PYX_ERR(0, 44, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_truncate); if (value) { values[2] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_min_mapping_quality); if (value) { values[3] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_min_base_quality); if (value) { values[4] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stepper); if (value) { values[5] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "count_bases") < 0)) __PYX_ERR(0, 44, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_bamFile = ((PyObject*)values[0]); __pyx_v_reference = ((PyObject*)values[1]); if (values[2]) { __pyx_v_truncate = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_truncate == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L3_error) } else { __pyx_v_truncate = ((int)0); } if (values[3]) { __pyx_v_min_mapping_quality = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_min_mapping_quality == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L3_error) } else { __pyx_v_min_mapping_quality = ((int)0); } if (values[4]) { __pyx_v_min_base_quality = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_min_base_quality == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L3_error) } else { __pyx_v_min_base_quality = ((int)0); } __pyx_v_stepper = ((PyObject*)values[5]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("count_bases", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 44, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("bamstats.opt.count_bases", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bamFile), (&PyString_Type), 1, "bamFile", 1))) __PYX_ERR(0, 44, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reference), (&PyString_Type), 1, "reference", 1))) __PYX_ERR(0, 44, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stepper), (&PyString_Type), 1, "stepper", 1))) __PYX_ERR(0, 44, __pyx_L1_error) __pyx_r = __pyx_pf_8bamstats_3opt_2count_bases(__pyx_self, __pyx_v_bamFile, __pyx_v_reference, __pyx_v_truncate, __pyx_v_min_mapping_quality, __pyx_v_min_base_quality, __pyx_v_stepper); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_8bamstats_3opt_2count_bases(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_bamFile, PyObject *__pyx_v_reference, int __pyx_v_truncate, int __pyx_v_min_mapping_quality, int __pyx_v_min_base_quality, PyObject *__pyx_v_stepper) { struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile = 0; PyObject *__pyx_v_chrom = 0; int __pyx_v_reference_length; struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile = 0; struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_pc = 0; PyObject *__pyx_v_rec_lst = 0; PyObject *__pyx_v_refbase = 0; PyObject *__pyx_v_alnbase = 0; int __pyx_v_i; int __pyx_v_n; int __pyx_v_position; bam_pileup1_t **__pyx_v_plp; bam_pileup1_t *__pyx_v_read; PyObject *__pyx_v_pp = NULL; PyObject *__pyx_v_rec = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("count_bases", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("bamstats.opt.count_bases", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_fafile); __Pyx_XDECREF(__pyx_v_chrom); __Pyx_XDECREF((PyObject *)__pyx_v_alignmentfile); __Pyx_XDECREF((PyObject *)__pyx_v_pc); __Pyx_XDECREF(__pyx_v_rec_lst); __Pyx_XDECREF(__pyx_v_refbase); __Pyx_XDECREF(__pyx_v_alnbase); __Pyx_XDECREF(__pyx_v_pp); __Pyx_XDECREF(__pyx_v_rec); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__3 = PyTuple_Pack(21, __pyx_n_s_bamFile, __pyx_n_s_reference, __pyx_n_s_truncate, __pyx_n_s_min_mapping_quality, __pyx_n_s_min_base_quality, __pyx_n_s_stepper, __pyx_n_s_fafile, __pyx_n_s_chrom, __pyx_n_s_reference_length, __pyx_n_s_alignmentfile, __pyx_n_s_pc, __pyx_n_s_rec_lst, __pyx_n_s_refbase, __pyx_n_s_alnbase, __pyx_n_s_i, __pyx_n_s_n, __pyx_n_s_position, __pyx_n_s_plp, __pyx_n_s_read, __pyx_n_s_pp, __pyx_n_s_rec); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); /* … */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8bamstats_3opt_3count_bases, NULL, __pyx_n_s_bamstats_opt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_count_bases, __pyx_t_1) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
45: cdef:
+46: FastaFile fafile = FastaFile(reference)
__pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_5pysam_9libcfaidx_FastaFile), __pyx_v_reference); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_fafile = ((struct __pyx_obj_5pysam_9libcfaidx_FastaFile *)__pyx_t_1); __pyx_t_1 = 0;
+47: str chrom = fafile.references[0]
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_fafile), __pyx_n_s_references); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 47, __pyx_L1_error) __pyx_v_chrom = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+48: int reference_length = fafile.lengths[0]
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_fafile), __pyx_n_s_lengths); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_reference_length = __pyx_t_3;
+49: AlignmentFile alignmentfile = AlignmentFile(bamFile)
__pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_5pysam_17libcalignmentfile_AlignmentFile), __pyx_v_bamFile); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_alignmentfile = ((struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *)__pyx_t_1); __pyx_t_1 = 0;
50: PileupColumn pc
+51: dict rec_lst={}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_rec_lst = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
52: str refbase
53: bytes alnbase
54: int i,n,position
55: bam_pileup1_t** plp
56: bam_pileup1_t* read
+57: pp = alignmentfile.pileup(max_depth=20000,stepper=stepper,truncate=truncate,min_mapping_quality=min_mapping_quality,min_base_quality=min_base_quality)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_alignmentfile), __pyx_n_s_pileup); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_max_depth, __pyx_int_20000) < 0) __PYX_ERR(0, 57, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_stepper, __pyx_v_stepper) < 0) __PYX_ERR(0, 57, __pyx_L1_error) __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_truncate); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_truncate, __pyx_t_4) < 0) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_min_mapping_quality); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_min_mapping_quality, __pyx_t_4) < 0) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_min_base_quality); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_min_base_quality, __pyx_t_4) < 0) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_pp = __pyx_t_4; __pyx_t_4 = 0;
+58: for pc in pp:
if (likely(PyList_CheckExact(__pyx_v_pp)) || PyTuple_CheckExact(__pyx_v_pp)) { __pyx_t_4 = __pyx_v_pp; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_pp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 58, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_4))) { if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 58, __pyx_L1_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 58, __pyx_L1_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 58, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5pysam_18libcalignedsegment_PileupColumn))))) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_pc, ((struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *)__pyx_t_2)); __pyx_t_2 = 0; /* … */ } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+59: rec = {'Pos':None,'A':0,'C':0,'G':0,'T':0,'N':0,'DEL':0,'INS':0,'Ref':None,'Depth':0}
__pyx_t_2 = __Pyx_PyDict_NewPresized(10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_Pos, Py_None) < 0) __PYX_ERR(0, 59, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_A, __pyx_int_0) < 0) __PYX_ERR(0, 59, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_C, __pyx_int_0) < 0) __PYX_ERR(0, 59, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_G, __pyx_int_0) < 0) __PYX_ERR(0, 59, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_T, __pyx_int_0) < 0) __PYX_ERR(0, 59, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_N, __pyx_int_0) < 0) __PYX_ERR(0, 59, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_DEL, __pyx_int_0) < 0) __PYX_ERR(0, 59, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_INS, __pyx_int_0) < 0) __PYX_ERR(0, 59, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_Ref, Py_None) < 0) __PYX_ERR(0, 59, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_Depth, __pyx_int_0) < 0) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_rec, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0;
+60: n = pc.get_num_aligned()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_pc), __pyx_n_s_get_num_aligned); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_n = __pyx_t_3;
+61: plp = pc.plp
__pyx_t_8 = __pyx_v_pc->plp; __pyx_v_plp = __pyx_t_8;
+62: position = pc.pos
__pyx_t_3 = __pyx_v_pc->pos; __pyx_v_position = __pyx_t_3;
+63: rec['Depth'] = n
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_n_s_Depth, __pyx_t_2) < 0)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+64: refbase = fafile.fetch(reference=chrom, start=position, end=position+1).upper()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_fafile), __pyx_n_s_fetch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_reference, __pyx_v_chrom) < 0) __PYX_ERR(0, 64, __pyx_L1_error) __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_position); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_start, __pyx_t_9) < 0) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyInt_From_long((__pyx_v_position + 1)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_end, __pyx_t_9) < 0) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_upper); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_2 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_refbase, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0;
+65: rec['Pos'] = position+1 #zero-based to one-based
__pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_position + 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_n_s_Pos, __pyx_t_2) < 0)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+66: rec['Ref'] = refbase
if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_n_s_Ref, __pyx_v_refbase) < 0)) __PYX_ERR(0, 66, __pyx_L1_error)
+67: for i in range(n):
__pyx_t_3 = __pyx_v_n; __pyx_t_10 = __pyx_t_3; for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_i = __pyx_t_11;
+68: read = &(plp[0][i])
__pyx_v_read = (&((__pyx_v_plp[0])[__pyx_v_i]));
+69: if read.is_del:
__pyx_t_12 = (__pyx_v_read->is_del != 0); if (__pyx_t_12) { /* … */ goto __pyx_L7; }
+70: if not read.is_refskip:
__pyx_t_12 = ((!(__pyx_v_read->is_refskip != 0)) != 0); if (__pyx_t_12) { /* … */ }
+71: rec['DEL'] += 1
__Pyx_INCREF(__pyx_n_s_DEL); __pyx_t_13 = __pyx_n_s_DEL; __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_rec, __pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_t_13, __pyx_t_7) < 0)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
72: else:
+73: alnbase = get_seq_base(read.b, read.qpos)
/*else*/ { __pyx_t_7 = __pyx_f_8bamstats_3opt_get_seq_base(__pyx_v_read->b, __pyx_v_read->qpos); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (!(likely(PyBytes_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_alnbase, ((PyObject*)__pyx_t_7)); __pyx_t_7 = 0;
+74: if alnbase == b'A':
__pyx_t_12 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_A, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 74, __pyx_L1_error) __pyx_t_14 = (__pyx_t_12 != 0); if (__pyx_t_14) { /* … */ goto __pyx_L9; }
+75: rec['A'] += 1
__Pyx_INCREF(__pyx_n_s_A); __pyx_t_13 = __pyx_n_s_A; __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_rec, __pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_7, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_t_13, __pyx_t_2) < 0)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+76: elif alnbase == b'T':
__pyx_t_14 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_T, Py_EQ)); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 76, __pyx_L1_error) __pyx_t_12 = (__pyx_t_14 != 0); if (__pyx_t_12) { /* … */ goto __pyx_L9; }
+77: rec['T'] += 1
__Pyx_INCREF(__pyx_n_s_T); __pyx_t_13 = __pyx_n_s_T; __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_rec, __pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_t_13, __pyx_t_7) < 0)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+78: elif alnbase == b'C':
__pyx_t_12 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_C, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 78, __pyx_L1_error) __pyx_t_14 = (__pyx_t_12 != 0); if (__pyx_t_14) { /* … */ goto __pyx_L9; }
+79: rec['C'] += 1
__Pyx_INCREF(__pyx_n_s_C); __pyx_t_13 = __pyx_n_s_C; __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_rec, __pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 79, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_7, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_t_13, __pyx_t_2) < 0)) __PYX_ERR(0, 79, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+80: elif alnbase == b'G':
__pyx_t_14 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_G, Py_EQ)); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 80, __pyx_L1_error) __pyx_t_12 = (__pyx_t_14 != 0); if (__pyx_t_12) { /* … */ goto __pyx_L9; }
+81: rec['G'] += 1
__Pyx_INCREF(__pyx_n_s_G); __pyx_t_13 = __pyx_n_s_G; __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_rec, __pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_t_13, __pyx_t_7) < 0)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+82: elif alnbase == b'N':
__pyx_t_12 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_N, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 82, __pyx_L1_error) __pyx_t_14 = (__pyx_t_12 != 0); if (__pyx_t_14) { /* … */ } __pyx_L9:;
+83: rec['N'] += 1
__Pyx_INCREF(__pyx_n_s_N); __pyx_t_13 = __pyx_n_s_N; __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_rec, __pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_7, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_t_13, __pyx_t_2) < 0)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+84: if read.indel > 0:
__pyx_t_14 = ((__pyx_v_read->indel > 0) != 0); if (__pyx_t_14) { /* … */ } } __pyx_L7:; }
+85: rec['INS'] += 1
__Pyx_INCREF(__pyx_n_s_INS); __pyx_t_13 = __pyx_n_s_INS; __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_rec, __pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_t_13, __pyx_t_7) < 0)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
86:
+87: rec_lst[position]=rec
__pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_position); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (unlikely(PyDict_SetItem(__pyx_v_rec_lst, __pyx_t_7, __pyx_v_rec) < 0)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+88: allbase(fafile,chrom,reference_length,rec_lst)
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_allbase); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_reference_length); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = NULL; __pyx_t_3 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_3 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[5] = {__pyx_t_9, ((PyObject *)__pyx_v_fafile), __pyx_v_chrom, __pyx_t_2, __pyx_v_rec_lst}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_3, 4+__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[5] = {__pyx_t_9, ((PyObject *)__pyx_v_fafile), __pyx_v_chrom, __pyx_t_2, __pyx_v_rec_lst}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_3, 4+__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_1 = PyTuple_New(4+__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(((PyObject *)__pyx_v_fafile)); __Pyx_GIVEREF(((PyObject *)__pyx_v_fafile)); PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_3, ((PyObject *)__pyx_v_fafile)); __Pyx_INCREF(__pyx_v_chrom); __Pyx_GIVEREF(__pyx_v_chrom); PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_3, __pyx_v_chrom); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_v_rec_lst); __Pyx_GIVEREF(__pyx_v_rec_lst); PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_3, __pyx_v_rec_lst); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
89:
+90: return rec_lst
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_rec_lst); __pyx_r = __pyx_v_rec_lst; goto __pyx_L0;
91: