jpayne@69
|
1 # cython: language_level=3
|
jpayne@69
|
2 from libc.stdint cimport int8_t, int16_t, int32_t, int64_t
|
jpayne@69
|
3 from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t
|
jpayne@69
|
4 from libc.stdlib cimport malloc, calloc, realloc, free
|
jpayne@69
|
5 from libc.string cimport memcpy, memcmp, strncpy, strlen, strdup
|
jpayne@69
|
6 from libc.stdio cimport FILE, printf
|
jpayne@69
|
7 cimport cython
|
jpayne@69
|
8
|
jpayne@69
|
9 from cpython cimport array
|
jpayne@69
|
10 from pysam.libchtslib cimport faidx_t, kstring_t, BGZF
|
jpayne@69
|
11
|
jpayne@69
|
12 # These functions are put here and not in chtslib.pxd in order
|
jpayne@69
|
13 # to avoid warnings for unused functions.
|
jpayne@69
|
14 cdef extern from "pysam_stream.h" nogil:
|
jpayne@69
|
15
|
jpayne@69
|
16 ctypedef struct kstream_t:
|
jpayne@69
|
17 pass
|
jpayne@69
|
18
|
jpayne@69
|
19 ctypedef struct kseq_t:
|
jpayne@69
|
20 kstring_t name
|
jpayne@69
|
21 kstring_t comment
|
jpayne@69
|
22 kstring_t seq
|
jpayne@69
|
23 kstring_t qual
|
jpayne@69
|
24
|
jpayne@69
|
25 kseq_t *kseq_init(BGZF *)
|
jpayne@69
|
26 int kseq_read(kseq_t *)
|
jpayne@69
|
27 void kseq_destroy(kseq_t *)
|
jpayne@69
|
28 kstream_t *ks_init(BGZF *)
|
jpayne@69
|
29 void ks_destroy(kstream_t *)
|
jpayne@69
|
30
|
jpayne@69
|
31 # Retrieve characters from stream until delimiter
|
jpayne@69
|
32 # is reached placing results in str.
|
jpayne@69
|
33 int ks_getuntil(kstream_t *,
|
jpayne@69
|
34 int delimiter,
|
jpayne@69
|
35 kstring_t * str,
|
jpayne@69
|
36 int * dret)
|
jpayne@69
|
37
|
jpayne@69
|
38 cdef class FastaFile:
|
jpayne@69
|
39 cdef bint is_remote
|
jpayne@69
|
40 cdef object _filename, _references, _lengths, reference2length
|
jpayne@69
|
41 cdef faidx_t* fastafile
|
jpayne@69
|
42 cdef char* _fetch(self, char* reference,
|
jpayne@69
|
43 int start, int end, int* length) except? NULL
|
jpayne@69
|
44
|
jpayne@69
|
45
|
jpayne@69
|
46 cdef class FastqProxy:
|
jpayne@69
|
47 cdef kseq_t * _delegate
|
jpayne@69
|
48 cdef cython.str to_string(self)
|
jpayne@69
|
49 cdef cython.str tostring(self)
|
jpayne@69
|
50 cpdef array.array get_quality_array(self, int offset=*)
|
jpayne@69
|
51
|
jpayne@69
|
52
|
jpayne@69
|
53 cdef class FastxRecord:
|
jpayne@69
|
54 """
|
jpayne@69
|
55 Python container for pysam.libcfaidx.FastqProxy with persistence.
|
jpayne@69
|
56 """
|
jpayne@69
|
57 cdef public str comment, quality, sequence, name
|
jpayne@69
|
58 cdef cython.str to_string(self)
|
jpayne@69
|
59 cdef cython.str tostring(self)
|
jpayne@69
|
60 cpdef array.array get_quality_array(self, int offset=*)
|
jpayne@69
|
61
|
jpayne@69
|
62 cdef class FastxFile:
|
jpayne@69
|
63 cdef object _filename
|
jpayne@69
|
64 cdef BGZF * fastqfile
|
jpayne@69
|
65 cdef kseq_t * entry
|
jpayne@69
|
66 cdef bint persist
|
jpayne@69
|
67 cdef bint is_remote
|
jpayne@69
|
68
|
jpayne@69
|
69 cdef kseq_t * getCurrent(self)
|
jpayne@69
|
70 cdef int cnext(self)
|
jpayne@69
|
71
|
jpayne@69
|
72
|
jpayne@69
|
73 # Compatibility Layer for pysam 0.8.1
|
jpayne@69
|
74 cdef class FastqFile(FastxFile):
|
jpayne@69
|
75 pass
|
jpayne@69
|
76
|
jpayne@69
|
77
|
jpayne@69
|
78 # Compatibility Layer for pysam < 0.8
|
jpayne@69
|
79 cdef class Fastafile(FastaFile):
|
jpayne@69
|
80 pass
|
jpayne@69
|
81
|