Generated by Cython 0.16 on Wed Oct 17 10:03:47 2012
Raw output: bam.c
1: '''
2: Created on 2012-01-17
3:
4: @author: Andrew Roth
5: '''
6: import os
/* "jointpysam/bam.pyx":6 * @author: Andrew Roth * ''' * import os #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * # Global constant */ __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:
8: # Global constant
9: cdef int max_pos = 2 << 29
/* "jointpysam/bam.pyx":9 * * # Global constant * cdef int max_pos = 2<
<
29 #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * cdef class BamFile: */ __pyx_v_10jointpysam_3bam_max_pos = 1073741824;
10:
11: cdef class BamFile:
/* "jointpysam/bam.pyx":11 * cdef int max_pos = 2<
<
29 * * cdef class BamFile: #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* ''' * Heavily simplified version of pysam Samfile class. Tailored specifically for extracting data from BAM files for */ struct __pyx_vtabstruct_10jointpysam_3bam_BamFile { samfile_t *(*get_file_pointer)(struct __pyx_obj_10jointpysam_3bam_BamFile *); bam_index_t *(*get_index)(struct __pyx_obj_10jointpysam_3bam_BamFile *); }; static struct __pyx_vtabstruct_10jointpysam_3bam_BamFile *__pyx_vtabptr_10jointpysam_3bam_BamFile;
12: '''
13: Heavily simplified version of pysam Samfile class. Tailored specifically for extracting data from BAM files for
14: JointSNVMix.
15: '''
16: def __cinit__(self, char * file_name):
/* "jointpysam/bam.pyx":16 * JointSNVMix. * ''' * def __cinit__(self, char * file_name): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* self._file_name = strdup(file_name) * */ static int __pyx_pf_10jointpysam_3bam_7BamFile___cinit__(struct __pyx_obj_10jointpysam_3bam_BamFile *__pyx_v_self, char *__pyx_v_file_name) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__", 0);
17: self._file_name = strdup(file_name)
/* "jointpysam/bam.pyx":17 * ''' * def __cinit__(self, char * file_name): * self._file_name = strdup(file_name) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * self._open_file() */ __pyx_v_self->_file_name = strdup(__pyx_v_file_name);
18:
19: self._open_file()
/* "jointpysam/bam.pyx":19 * self._file_name = strdup(file_name) * * self._open_file() #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * self._load_index() */ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___open_file); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20:
21: self._load_index()
/* "jointpysam/bam.pyx":21 * self._open_file() * * self._load_index() #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * self._load_references() */ __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___load_index); 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_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22:
23: self._load_references()
/* "jointpysam/bam.pyx":23 * self._load_index() * * self._load_references() #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * def __dealloc__(self): */ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___load_references); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("jointpysam.bam.BamFile.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static void __pyx_pw_10jointpysam_3bam_7BamFile_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_10jointpysam_3bam_7BamFile_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_10jointpysam_3bam_7BamFile_2__dealloc__(((struct __pyx_obj_10jointpysam_3bam_BamFile *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); }
24:
25: def __dealloc__(self):
/* "jointpysam/bam.pyx":25 * self._load_references() * * def __dealloc__(self): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* if self._file_name != NULL: * free(self._file_name) */ static void __pyx_pf_10jointpysam_3bam_7BamFile_2__dealloc__(struct __pyx_obj_10jointpysam_3bam_BamFile *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0);
26: if self._file_name != NULL:
/* "jointpysam/bam.pyx":26 * * def __dealloc__(self): * if self._file_name != NULL: #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* free(self._file_name) * */ __pyx_t_1 = (__pyx_v_self->_file_name != NULL); if (__pyx_t_1) {
27: free(self._file_name)
/* "jointpysam/bam.pyx":27 * def __dealloc__(self): * if self._file_name != NULL: * free(self._file_name) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * if self._index != NULL: */ free(__pyx_v_self->_file_name); goto __pyx_L3; } __pyx_L3:;
28:
29: if self._index != NULL:
/* "jointpysam/bam.pyx":29 * free(self._file_name) * * if self._index != NULL: #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* bam_index_destroy(self._index) * */ __pyx_t_1 = (__pyx_v_self->_index != NULL); if (__pyx_t_1) {
30: bam_index_destroy(self._index)
/* "jointpysam/bam.pyx":30 * * if self._index != NULL: * bam_index_destroy(self._index) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * if self._bam_file != NULL: */ bam_index_destroy(__pyx_v_self->_index); goto __pyx_L4; } __pyx_L4:;
31:
32: if self._bam_file != NULL:
/* "jointpysam/bam.pyx":32 * bam_index_destroy(self._index) * * if self._bam_file != NULL: #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* samclose(self._bam_file) * */ __pyx_t_1 = (__pyx_v_self->_bam_file != NULL); if (__pyx_t_1) {
33: samclose(self._bam_file)
/* "jointpysam/bam.pyx":33 * * if self._bam_file != NULL: * samclose(self._bam_file) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * def _open_file(self): */ samclose(__pyx_v_self->_bam_file); goto __pyx_L5; } __pyx_L5:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_10jointpysam_3bam_7BamFile_5_open_file(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_10jointpysam_3bam_7BamFile_5_open_file(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_open_file (wrapper)", 0); __pyx_r = __pyx_pf_10jointpysam_3bam_7BamFile_4_open_file(((struct __pyx_obj_10jointpysam_3bam_BamFile *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; }
34:
35: def _open_file(self):
/* "jointpysam/bam.pyx":35 * samclose(self._bam_file) * * def _open_file(self): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* self._bam_file = samopen(self._file_name, 'rb', NULL) * */ static PyObject *__pyx_pf_10jointpysam_3bam_7BamFile_4_open_file(struct __pyx_obj_10jointpysam_3bam_BamFile *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_open_file", 0);
36: self._bam_file = samopen(self._file_name, 'rb', NULL)
/* "jointpysam/bam.pyx":36 * * def _open_file(self): * self._bam_file = samopen(self._file_name, 'rb', NULL) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * if self._bam_file == NULL: */ __pyx_v_self->_bam_file = samopen(__pyx_v_self->_file_name, __pyx_k__rb, NULL);
37:
38: if self._bam_file == NULL:
/* "jointpysam/bam.pyx":38 * self._bam_file = samopen(self._file_name, 'rb', NULL) * * if self._bam_file == NULL: #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* raise Exception("Could not open file {0} - is it SAM/BAM format?".format(self._file_name)) * */ __pyx_t_1 = (__pyx_v_self->_bam_file == NULL); if (__pyx_t_1) {
39: raise Exception("Could not open file {0} - is it SAM/BAM format?".format(self._file_name))
/* "jointpysam/bam.pyx":39 * * if self._bam_file == NULL: * raise Exception("Could not open file {0} - is it SAM/BAM format?".format(self._file_name)) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * if self._bam_file.header == NULL: */ __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 = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyBytes_FromString(__pyx_v_self->_file_name); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __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 = 39; __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 = 39; __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 = 39; __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 = 39; __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 = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:;
40:
41: if self._bam_file.header == NULL:
/* "jointpysam/bam.pyx":41 * raise Exception("Could not open file {0} - is it SAM/BAM format?".format(self._file_name)) * * if self._bam_file.header == NULL: #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* raise Exception("File {0} does not have valid header - is it SAM/BAM format?".format(self._file_name)) * */ __pyx_t_1 = (__pyx_v_self->_bam_file->header == NULL); if (__pyx_t_1) {
42: raise Exception("File {0} does not have valid header - is it SAM/BAM format?".format(self._file_name))
/* "jointpysam/bam.pyx":42 * * if self._bam_file.header == NULL: * raise Exception("File {0} does not have valid header - is it SAM/BAM format?".format(self._file_name)) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * def _load_index(self): */ __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyBytes_FromString(__pyx_v_self->_file_name); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4)); __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L4; } __pyx_L4:; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("jointpysam.bam.BamFile._open_file", __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_3bam_7BamFile_7_load_index(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_10jointpysam_3bam_7BamFile_7_load_index(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_load_index (wrapper)", 0); __pyx_r = __pyx_pf_10jointpysam_3bam_7BamFile_6_load_index(((struct __pyx_obj_10jointpysam_3bam_BamFile *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; }
43:
44: def _load_index(self):
/* "jointpysam/bam.pyx":44 * raise Exception("File {0} does not have valid header - is it SAM/BAM format?".format(self._file_name)) * * def _load_index(self): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* self._index = bam_index_load(self._file_name) * */ static PyObject *__pyx_pf_10jointpysam_3bam_7BamFile_6_load_index(struct __pyx_obj_10jointpysam_3bam_BamFile *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_load_index", 0);
45: self._index = bam_index_load(self._file_name)
/* "jointpysam/bam.pyx":45 * * def _load_index(self): * self._index = bam_index_load(self._file_name) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * if self._index == NULL: */ __pyx_v_self->_index = bam_index_load(__pyx_v_self->_file_name);
46:
47: if self._index == NULL:
/* "jointpysam/bam.pyx":47 * self._index = bam_index_load(self._file_name) * * if self._index == NULL: #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* raise Exception("Index not found for BAM file {0}".format(self._file_name)) * */ __pyx_t_1 = (__pyx_v_self->_index == NULL); if (__pyx_t_1) {
48: raise Exception("Index not found for BAM file {0}".format(self._file_name))
/* "jointpysam/bam.pyx":48 * * if self._index == NULL: * raise Exception("Index not found for BAM file {0}".format(self._file_name)) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * def _load_references(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 = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyBytes_FromString(__pyx_v_self->_file_name); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __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 = 48; __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 = 48; __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 = 48; __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 = 48; __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 = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("jointpysam.bam.BamFile._load_index", __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_3bam_7BamFile_9_load_references(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_10jointpysam_3bam_7BamFile_9_load_references(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_load_references (wrapper)", 0); __pyx_r = __pyx_pf_10jointpysam_3bam_7BamFile_8_load_references(((struct __pyx_obj_10jointpysam_3bam_BamFile *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; }
49:
50: def _load_references(self):
/* "jointpysam/bam.pyx":50 * raise Exception("Index not found for BAM file {0}".format(self._file_name)) * * def _load_references(self): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* self._refs = [] * self._tids = {} */ static PyObject *__pyx_pf_10jointpysam_3bam_7BamFile_8_load_references(struct __pyx_obj_10jointpysam_3bam_BamFile *__pyx_v_self) { int32_t __pyx_v_i; PyObject *__pyx_v_ref = NULL; PyObject *__pyx_v_tid = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_load_references", 0);
51: self._refs = []
/* "jointpysam/bam.pyx":51 * * def _load_references(self): * self._refs = [] #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* self._tids = {} * */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __Pyx_GOTREF(__pyx_v_self->_refs); __Pyx_DECREF(((PyObject *)__pyx_v_self->_refs)); __pyx_v_self->_refs = __pyx_t_1; __pyx_t_1 = 0;
52: self._tids = {}
/* "jointpysam/bam.pyx":52 * def _load_references(self): * self._refs = [] * self._tids = {} #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * for i in range(self._bam_file.header.n_targets): */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __Pyx_GOTREF(__pyx_v_self->_tids); __Pyx_DECREF(((PyObject *)__pyx_v_self->_tids)); __pyx_v_self->_tids = __pyx_t_1; __pyx_t_1 = 0;
53:
54: for i in range(self._bam_file.header.n_targets):
/* "jointpysam/bam.pyx":54 * self._tids = {} * * for i in range(self._bam_file.header.n_targets): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* self._refs.append(self._bam_file.header.target_name[i]) * */ __pyx_t_2 = __pyx_v_self->_bam_file->header->n_targets; for (__pyx_t_3 = 0; __pyx_t_3<
__pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3;
55: self._refs.append(self._bam_file.header.target_name[i])
/* "jointpysam/bam.pyx":55 * * for i in range(self._bam_file.header.n_targets): * self._refs.append(self._bam_file.header.target_name[i]) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * for ref in self._refs: */ if (unlikely(((PyObject *)__pyx_v_self->_refs) == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = PyBytes_FromString((__pyx_v_self->_bam_file->header->target_name[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_t_4 = PyList_Append(__pyx_v_self->_refs, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; }
56:
57: for ref in self._refs:
/* "jointpysam/bam.pyx":57 * self._refs.append(self._bam_file.header.target_name[i]) * * for ref in self._refs: #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* tid = self._get_tid(ref) * */ if (unlikely(((PyObject *)__pyx_v_self->_refs) == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = ((PyObject *)__pyx_v_self->_refs); __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0; for (;;) { if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break; __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++; __Pyx_XDECREF(__pyx_v_ref); __pyx_v_ref = __pyx_t_6; __pyx_t_6 = 0;
58: tid = self._get_tid(ref)
/* "jointpysam/bam.pyx":58 * * for ref in self._refs: * tid = self._get_tid(ref) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * self._tids[ref] = tid */ __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___get_tid); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_ref); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_ref); __Pyx_GIVEREF(__pyx_v_ref); __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_v_tid); __pyx_v_tid = __pyx_t_8; __pyx_t_8 = 0;
59:
60: self._tids[ref] = tid
/* "jointpysam/bam.pyx":60 * tid = self._get_tid(ref) * * self._tids[ref] = tid #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * def get_pileup_iterator(self, reference, start=None, stop=None): */ if (PyDict_SetItem(((PyObject *)__pyx_v_self->_tids), __pyx_v_ref, __pyx_v_tid)<
0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("jointpysam.bam.BamFile._load_references", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_ref); __Pyx_XDECREF(__pyx_v_tid); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_10jointpysam_3bam_7BamFile_11get_pileup_iterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_10jointpysam_3bam_7BamFile_11get_pileup_iterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_reference = 0; PyObject *__pyx_v_start = 0; PyObject *__pyx_v_stop = 0; static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__stop,0}; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_pileup_iterator (wrapper)", 0); { PyObject* values[3] = {0,0,0};
61:
62: def get_pileup_iterator(self, reference, start=None, stop=None):
/* "jointpysam/bam.pyx":62 * self._tids[ref] = tid * * def get_pileup_iterator(self, reference, start=None, stop=None): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* if reference not in self._refs: * raise Exception("Invalid reference given `{0}`".format(reference)) */ values[1] = ((PyObject *)Py_None); values[2] = ((PyObject *)Py_None); 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: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stop); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_pileup_iterator")<
0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { 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); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_reference = values[0]; __pyx_v_start = values[1]; __pyx_v_stop = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_pileup_iterator", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("jointpysam.bam.BamFile.get_pileup_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10jointpysam_3bam_7BamFile_10get_pileup_iterator(((struct __pyx_obj_10jointpysam_3bam_BamFile *)__pyx_v_self), __pyx_v_reference, __pyx_v_start, __pyx_v_stop); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10jointpysam_3bam_7BamFile_10get_pileup_iterator(struct __pyx_obj_10jointpysam_3bam_BamFile *__pyx_v_self, PyObject *__pyx_v_reference, PyObject *__pyx_v_start, PyObject *__pyx_v_stop) { PyObject *__pyx_v_tid = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_pileup_iterator", 0);
63: if reference not in self._refs:
/* "jointpysam/bam.pyx":63 * * def get_pileup_iterator(self, reference, start=None, stop=None): * if reference not in self._refs: #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* raise Exception("Invalid reference given `{0}`".format(reference)) * */ __pyx_t_1 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_self->_refs), __pyx_v_reference))); if (unlikely(__pyx_t_1<
0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) {
64: raise Exception("Invalid reference given `{0}`".format(reference))
/* "jointpysam/bam.pyx":64 * def get_pileup_iterator(self, reference, start=None, stop=None): * if reference not in self._refs: * raise Exception("Invalid reference given `{0}`".format(reference)) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * tid = self._tids[reference] */ __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_4), __pyx_n_s__format); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __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 = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_reference); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_reference); __Pyx_GIVEREF(__pyx_v_reference); __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__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 = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:;
65:
66: tid = self._tids[reference]
/* "jointpysam/bam.pyx":66 * raise Exception("Invalid reference given `{0}`".format(reference)) * * tid = self._tids[reference] #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * if start is not None and stop is not None: */ __pyx_t_4 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_self->_tids), __pyx_v_reference); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_v_tid = __pyx_t_4; __pyx_t_4 = 0;
67:
68: if start is not None and stop is not None:
/* "jointpysam/bam.pyx":68 * tid = self._tids[reference] * * if start is not None and stop is not None: #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* return PileupIterator(self, tid=tid, start=start, stop=stop) * else: */ __pyx_t_1 = (__pyx_v_start != Py_None); if (__pyx_t_1) { __pyx_t_5 = (__pyx_v_stop != Py_None); __pyx_t_6 = __pyx_t_5; } else { __pyx_t_6 = __pyx_t_1; } if (__pyx_t_6) {
69: return PileupIterator(self, tid=tid, start=start, stop=stop)
/* "jointpysam/bam.pyx":69 * * if start is not None and stop is not None: * return PileupIterator(self, tid=tid, start=start, stop=stop) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* else: * return PileupIterator(self, tid=tid) */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__tid), __pyx_v_tid)<
0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__start), __pyx_v_start)<
0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__stop), __pyx_v_stop)<
0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10jointpysam_6pileup_PileupIterator)), ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; goto __pyx_L4; } /*else*/ {
70: else:
71: return PileupIterator(self, tid=tid)
/* "jointpysam/bam.pyx":71 * return PileupIterator(self, tid=tid, start=start, stop=stop) * else: * return PileupIterator(self, tid=tid) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * def _get_tid(self, reference): */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__tid), __pyx_v_tid)<
0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10jointpysam_6pileup_PileupIterator)), ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; } __pyx_L4:; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("jointpysam.bam.BamFile.get_pileup_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_tid); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_10jointpysam_3bam_7BamFile_13_get_tid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference); /*proto*/ static char __pyx_doc_10jointpysam_3bam_7BamFile_12_get_tid[] = "\n Use bam_parse_region to extract the tid, start and end of a reference.\n "; static PyObject *__pyx_pw_10jointpysam_3bam_7BamFile_13_get_tid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_get_tid (wrapper)", 0); __pyx_r = __pyx_pf_10jointpysam_3bam_7BamFile_12_get_tid(((struct __pyx_obj_10jointpysam_3bam_BamFile *)__pyx_v_self), ((PyObject *)__pyx_v_reference)); __Pyx_RefNannyFinishContext(); return __pyx_r; }
72:
73: def _get_tid(self, reference):
/* "jointpysam/bam.pyx":73 * return PileupIterator(self, tid=tid) * * def _get_tid(self, reference): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* ''' * Use bam_parse_region to extract the tid, start and end of a reference. */ static PyObject *__pyx_pf_10jointpysam_3bam_7BamFile_12_get_tid(struct __pyx_obj_10jointpysam_3bam_BamFile *__pyx_v_self, PyObject *__pyx_v_reference) { int __pyx_v_tid; int __pyx_v_start; int __pyx_v_end; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_get_tid", 0);
74: '''
75: Use bam_parse_region to extract the tid, start and end of a reference.
76: '''
77: cdef int tid, start, end
78:
79: bam_parse_region(self._bam_file.header, reference, & tid, & start, & end)
/* "jointpysam/bam.pyx":79 * cdef int tid, start, end * * bam_parse_region(self._bam_file.header, reference, & tid, & start, & end) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * if tid<
0: */ __pyx_t_1 = PyBytes_AsString(__pyx_v_reference); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} bam_parse_region(__pyx_v_self->_bam_file->header, __pyx_t_1, (&__pyx_v_tid), (&__pyx_v_start), (&__pyx_v_end));
80:
81: if tid < 0:
/* "jointpysam/bam.pyx":81 * bam_parse_region(self._bam_file.header, reference, & tid, & start, & end) * * if tid<
0: #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* raise Exception('BamFile.pileup : Invalid reference {0}.'.format(reference)) * */ __pyx_t_2 = (__pyx_v_tid<
0); if (__pyx_t_2) {
82: raise Exception('BamFile.pileup : Invalid reference {0}.'.format(reference))
/* "jointpysam/bam.pyx":82 * * if tid<
0: * raise Exception('BamFile.pileup : Invalid reference {0}.'.format(reference)) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * return tid */ __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __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 = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_reference); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_reference); __Pyx_GIVEREF(__pyx_v_reference); __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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 = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:;
83:
84: return tid
/* "jointpysam/bam.pyx":84 * raise Exception('BamFile.pileup : Invalid reference {0}.'.format(reference)) * * return tid #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * cdef samfile_t * get_file_pointer(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_5 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("jointpysam.bam.BamFile._get_tid", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
85:
86: cdef samfile_t * get_file_pointer(self):
/* "jointpysam/bam.pyx":86 * return tid * * cdef samfile_t * get_file_pointer(self): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* return self._bam_file * */ static samfile_t *__pyx_f_10jointpysam_3bam_7BamFile_get_file_pointer(struct __pyx_obj_10jointpysam_3bam_BamFile *__pyx_v_self) { samfile_t *__pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_file_pointer", 0);
87: return self._bam_file
/* "jointpysam/bam.pyx":87 * * cdef samfile_t * get_file_pointer(self): * return self._bam_file #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * cdef bam_index_t * get_index(self): */ __pyx_r = __pyx_v_self->_bam_file; goto __pyx_L0; __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
88:
89: cdef bam_index_t * get_index(self):
/* "jointpysam/bam.pyx":89 * return self._bam_file * * cdef bam_index_t * get_index(self): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* return self._index * */ static bam_index_t *__pyx_f_10jointpysam_3bam_7BamFile_get_index(struct __pyx_obj_10jointpysam_3bam_BamFile *__pyx_v_self) { bam_index_t *__pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_index", 0);
90: return self._index
/* "jointpysam/bam.pyx":90 * * cdef bam_index_t * get_index(self): * return self._index #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * property references: */ __pyx_r = __pyx_v_self->_index; goto __pyx_L0; __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_10jointpysam_3bam_7BamFile_10references_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10jointpysam_3bam_7BamFile_10references_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10jointpysam_3bam_7BamFile_10references___get__(((struct __pyx_obj_10jointpysam_3bam_BamFile *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; }
91:
92: property references:
93: def __get__(self):
/* "jointpysam/bam.pyx":93 * * property references: * def __get__(self): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* return tuple(self._refs) */ static PyObject *__pyx_pf_10jointpysam_3bam_7BamFile_10references___get__(struct __pyx_obj_10jointpysam_3bam_BamFile *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0);
94: return tuple(self._refs)
/* "jointpysam/bam.pyx":94 * property references: * def __get__(self): * return tuple(self._refs) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
*/ __Pyx_XDECREF(__pyx_r); if (unlikely(((PyObject *)__pyx_v_self->_refs) == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = ((PyObject *)PyList_AsTuple(__pyx_v_self->_refs)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_r = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("jointpysam.bam.BamFile.references.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }