annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/site-packages/pysam/libctabix.pxd @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
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
jpayne@69 8 # Note: this replaces python "open"!
jpayne@69 9 cdef extern from "fcntl.h":
jpayne@69 10 int open(char *pathname, int flags)
jpayne@69 11
jpayne@69 12 cdef extern from "unistd.h" nogil:
jpayne@69 13 ctypedef int ssize_t
jpayne@69 14 ssize_t read(int fd, void *buf, size_t count)
jpayne@69 15 int close(int fd)
jpayne@69 16
jpayne@69 17 from pysam.libchtslib cimport hts_idx_t, hts_itr_t, htsFile, \
jpayne@69 18 tbx_t, kstring_t, BGZF, HTSFile
jpayne@69 19
jpayne@69 20
jpayne@69 21 # These functions are put here and not in chtslib.pxd in order
jpayne@69 22 # to avoid warnings for unused functions.
jpayne@69 23 cdef extern from "pysam_stream.h" nogil:
jpayne@69 24
jpayne@69 25 ctypedef struct kstream_t:
jpayne@69 26 pass
jpayne@69 27
jpayne@69 28 ctypedef struct kseq_t:
jpayne@69 29 kstring_t name
jpayne@69 30 kstring_t comment
jpayne@69 31 kstring_t seq
jpayne@69 32 kstring_t qual
jpayne@69 33
jpayne@69 34 kseq_t *kseq_init(BGZF *)
jpayne@69 35 int kseq_read(kseq_t *)
jpayne@69 36 void kseq_destroy(kseq_t *)
jpayne@69 37 kstream_t *ks_init(BGZF *)
jpayne@69 38 void ks_destroy(kstream_t *)
jpayne@69 39
jpayne@69 40 # Retrieve characters from stream until delimiter
jpayne@69 41 # is reached placing results in str.
jpayne@69 42 int ks_getuntil(kstream_t *,
jpayne@69 43 int delimiter,
jpayne@69 44 kstring_t * str,
jpayne@69 45 int * dret)
jpayne@69 46
jpayne@69 47
jpayne@69 48 cdef class tabix_file_iterator:
jpayne@69 49 cdef BGZF * fh
jpayne@69 50 cdef kstream_t * kstream
jpayne@69 51 cdef kstring_t buffer
jpayne@69 52 cdef size_t size
jpayne@69 53 cdef Parser parser
jpayne@69 54 cdef int fd
jpayne@69 55 cdef int duplicated_fd
jpayne@69 56 cdef infile
jpayne@69 57
jpayne@69 58 cdef __cnext__(self)
jpayne@69 59
jpayne@69 60
jpayne@69 61 cdef class TabixFile(HTSFile):
jpayne@69 62 # pointer to index structure
jpayne@69 63 cdef tbx_t * index
jpayne@69 64
jpayne@69 65 cdef readonly object filename_index
jpayne@69 66
jpayne@69 67 cdef Parser parser
jpayne@69 68
jpayne@69 69 cdef encoding
jpayne@69 70
jpayne@69 71
jpayne@69 72 cdef class Parser:
jpayne@69 73 cdef encoding
jpayne@69 74 cdef parse(self, char * buffer, int len)
jpayne@69 75
jpayne@69 76
jpayne@69 77 cdef class asTuple(Parser):
jpayne@69 78 cdef parse(self, char * buffer, int len)
jpayne@69 79
jpayne@69 80
jpayne@69 81 cdef class asGTF(Parser):
jpayne@69 82 pass
jpayne@69 83
jpayne@69 84
jpayne@69 85 cdef class asGFF3(Parser):
jpayne@69 86 pass
jpayne@69 87
jpayne@69 88
jpayne@69 89 cdef class asBed(Parser):
jpayne@69 90 pass
jpayne@69 91
jpayne@69 92
jpayne@69 93 cdef class asVCF(Parser):
jpayne@69 94 pass
jpayne@69 95
jpayne@69 96
jpayne@69 97 cdef class TabixIterator:
jpayne@69 98 cdef hts_itr_t * iterator
jpayne@69 99 cdef TabixFile tabixfile
jpayne@69 100 cdef kstring_t buffer
jpayne@69 101 cdef encoding
jpayne@69 102 cdef int __cnext__(self)
jpayne@69 103
jpayne@69 104
jpayne@69 105 cdef class TabixIteratorParsed(TabixIterator):
jpayne@69 106 cdef Parser parser
jpayne@69 107
jpayne@69 108
jpayne@69 109 cdef class GZIterator:
jpayne@69 110 cdef object _filename
jpayne@69 111 cdef BGZF * gzipfile
jpayne@69 112 cdef kstream_t * kstream
jpayne@69 113 cdef kstring_t buffer
jpayne@69 114 cdef int __cnext__(self)
jpayne@69 115 cdef encoding
jpayne@69 116
jpayne@69 117
jpayne@69 118 cdef class GZIteratorHead(GZIterator):
jpayne@69 119 pass
jpayne@69 120
jpayne@69 121
jpayne@69 122 cdef class GZIteratorParsed(GZIterator):
jpayne@69 123 cdef Parser parser
jpayne@69 124
jpayne@69 125
jpayne@69 126 # Compatibility Layer for pysam < 0.8
jpayne@69 127 cdef class Tabixfile(TabixFile):
jpayne@69 128 pass