Debian Codegraph @

pysam/libcalignmentfile.pxd

raw
1 # cython: language_level=3
2 from libc.stdint cimport int8_t, int16_t, int32_t, int64_t
3 from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t
4 from libc.stdlib cimport malloc, calloc, realloc, free
5 from libc.string cimport memcpy, memcmp, strncpy, strlen, strdup
6 from libc.stdio cimport FILE, printf
7
8 from pysam.libcfaidx cimport faidx_t, FastaFile
9 from pysam.libcalignedsegment cimport AlignedSegment
10 from pysam.libchtslib cimport *
11
12 from cpython cimport array
13 cimport cython
14
15 cdef extern from *:
16 ctypedef char* const_char_ptr "const char*"
17
18 cdef extern from "htslib_util.h":
19
20 char * pysam_bam_get_qname(bam1_t * b)
21
22 ####################################################################
23 # Utility types
24
25 ctypedef struct __iterdata:
26 htsFile * htsfile
27 bam_hdr_t * header
28 hts_itr_t * iter
29 faidx_t * fastafile
30 int tid
31 char * seq
32 int seq_len
33 int min_mapping_quality
34 int flag_require
35 int flag_filter
36 bint compute_baq
37 bint redo_baq
38 bint ignore_orphans
39 int adjust_capq_threshold
40
41
42 cdef class AlignmentHeader(object):
43 cdef bam_hdr_t *ptr
44
45 cdef class AlignmentFile(HTSFile):
46 cdef readonly object reference_filename
47 cdef readonly AlignmentHeader header
48
49 # pointer to index
50 cdef hts_idx_t *index
51
52 # current read within iteration
53 cdef bam1_t * b
54
55 cdef bam1_t * getCurrent(self)
56 cdef int cnext(self)
57
58 # write an aligned read
59 cpdef int write(self, AlignedSegment read) except -1
60
61
62 cdef class IteratorRow:
63 cdef int retval
64 cdef bam1_t * b
65 cdef AlignmentFile samfile
66 cdef htsFile * htsfile
67 cdef hts_idx_t * index
68 cdef AlignmentHeader header
69 cdef int owns_samfile
70
71
72 cdef class IteratorRowRegion(IteratorRow):
73 cdef hts_itr_t * iter
74 cdef bam1_t * getCurrent(self)
75 cdef int cnext(self)
76
77
78 cdef class IteratorRowHead(IteratorRow):
79 cdef int max_rows
80 cdef int current_row
81 cdef bam1_t * getCurrent(self)
82 cdef int cnext(self)
83
84
85 cdef class IteratorRowAll(IteratorRow):
86 cdef bam1_t * getCurrent(self)
87 cdef int cnext(self)
88
89
90 cdef class IteratorRowAllRefs(IteratorRow):
91 cdef int tid
92 cdef IteratorRowRegion rowiter
93
94
95 cdef class IteratorRowSelection(IteratorRow):
96 cdef int current_pos
97 cdef positions
98 cdef bam1_t * getCurrent(self)
99 cdef int cnext(self)
100
101
102 cdef class IteratorColumn:
103
104 # result of the last plbuf_push
105 cdef IteratorRowRegion iter
106 cdef int tid
107 cdef int pos
108 cdef int n_plp
109 cdef uint32_t min_base_quality
110 cdef const bam_pileup1_t * plp
111 cdef bam_mplp_t pileup_iter
112 cdef __iterdata iterdata
113 cdef AlignmentFile samfile
114 cdef FastaFile fastafile
115 cdef stepper
116 cdef int max_depth
117 cdef bint ignore_overlaps
118
119 cdef int cnext(self)
120 cdef char * get_sequence(self)
121 cdef _setup_iterator(self,
122 int tid,
123 int start,
124 int stop,
125 int multiple_iterators=?)
126 cdef _setup_raw_rest_iterator(self)
127
128 cdef reset(self, tid, start, stop)
129 cdef _free_pileup_iter(self)
130 # backwards compatibility
131 cdef char * getSequence(self)
132
133
134 cdef class IteratorColumnRegion(IteratorColumn):
135 cdef int start
136 cdef int stop
137 cdef int truncate
138
139
140 cdef class IteratorColumnAllRefs(IteratorColumn):
141 pass
142
143
144 cdef class IteratorColumnAll(IteratorColumn):
145 pass
146
147
148 cdef class IndexedReads:
149 cdef AlignmentFile samfile
150 cdef htsFile * htsfile
151 cdef object index
152 cdef int owns_samfile
153 cdef AlignmentHeader header