jpayne@69: # cython: language_level=3 jpayne@69: from libc.stdint cimport int8_t, int16_t, int32_t, int64_t jpayne@69: from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t jpayne@69: from libc.stdlib cimport malloc, calloc, realloc, free jpayne@69: from libc.string cimport memcpy, memcmp, strncpy, strlen, strdup jpayne@69: from libc.stdio cimport FILE, printf jpayne@69: jpayne@69: # Note: this replaces python "open"! jpayne@69: cdef extern from "fcntl.h": jpayne@69: int open(char *pathname, int flags) jpayne@69: jpayne@69: cdef extern from "unistd.h" nogil: jpayne@69: ctypedef int ssize_t jpayne@69: ssize_t read(int fd, void *buf, size_t count) jpayne@69: int close(int fd) jpayne@69: jpayne@69: from pysam.libchtslib cimport hts_idx_t, hts_itr_t, htsFile, \ jpayne@69: tbx_t, kstring_t, BGZF, HTSFile jpayne@69: jpayne@69: jpayne@69: # These functions are put here and not in chtslib.pxd in order jpayne@69: # to avoid warnings for unused functions. jpayne@69: cdef extern from "pysam_stream.h" nogil: jpayne@69: jpayne@69: ctypedef struct kstream_t: jpayne@69: pass jpayne@69: jpayne@69: ctypedef struct kseq_t: jpayne@69: kstring_t name jpayne@69: kstring_t comment jpayne@69: kstring_t seq jpayne@69: kstring_t qual jpayne@69: jpayne@69: kseq_t *kseq_init(BGZF *) jpayne@69: int kseq_read(kseq_t *) jpayne@69: void kseq_destroy(kseq_t *) jpayne@69: kstream_t *ks_init(BGZF *) jpayne@69: void ks_destroy(kstream_t *) jpayne@69: jpayne@69: # Retrieve characters from stream until delimiter jpayne@69: # is reached placing results in str. jpayne@69: int ks_getuntil(kstream_t *, jpayne@69: int delimiter, jpayne@69: kstring_t * str, jpayne@69: int * dret) jpayne@69: jpayne@69: jpayne@69: cdef class tabix_file_iterator: jpayne@69: cdef BGZF * fh jpayne@69: cdef kstream_t * kstream jpayne@69: cdef kstring_t buffer jpayne@69: cdef size_t size jpayne@69: cdef Parser parser jpayne@69: cdef int fd jpayne@69: cdef int duplicated_fd jpayne@69: cdef infile jpayne@69: jpayne@69: cdef __cnext__(self) jpayne@69: jpayne@69: jpayne@69: cdef class TabixFile(HTSFile): jpayne@69: # pointer to index structure jpayne@69: cdef tbx_t * index jpayne@69: jpayne@69: cdef readonly object filename_index jpayne@69: jpayne@69: cdef Parser parser jpayne@69: jpayne@69: cdef encoding jpayne@69: jpayne@69: jpayne@69: cdef class Parser: jpayne@69: cdef encoding jpayne@69: cdef parse(self, char * buffer, int len) jpayne@69: jpayne@69: jpayne@69: cdef class asTuple(Parser): jpayne@69: cdef parse(self, char * buffer, int len) jpayne@69: jpayne@69: jpayne@69: cdef class asGTF(Parser): jpayne@69: pass jpayne@69: jpayne@69: jpayne@69: cdef class asGFF3(Parser): jpayne@69: pass jpayne@69: jpayne@69: jpayne@69: cdef class asBed(Parser): jpayne@69: pass jpayne@69: jpayne@69: jpayne@69: cdef class asVCF(Parser): jpayne@69: pass jpayne@69: jpayne@69: jpayne@69: cdef class TabixIterator: jpayne@69: cdef hts_itr_t * iterator jpayne@69: cdef TabixFile tabixfile jpayne@69: cdef kstring_t buffer jpayne@69: cdef encoding jpayne@69: cdef int __cnext__(self) jpayne@69: jpayne@69: jpayne@69: cdef class TabixIteratorParsed(TabixIterator): jpayne@69: cdef Parser parser jpayne@69: jpayne@69: jpayne@69: cdef class GZIterator: jpayne@69: cdef object _filename jpayne@69: cdef BGZF * gzipfile jpayne@69: cdef kstream_t * kstream jpayne@69: cdef kstring_t buffer jpayne@69: cdef int __cnext__(self) jpayne@69: cdef encoding jpayne@69: jpayne@69: jpayne@69: cdef class GZIteratorHead(GZIterator): jpayne@69: pass jpayne@69: jpayne@69: jpayne@69: cdef class GZIteratorParsed(GZIterator): jpayne@69: cdef Parser parser jpayne@69: jpayne@69: jpayne@69: # Compatibility Layer for pysam < 0.8 jpayne@69: cdef class Tabixfile(TabixFile): jpayne@69: pass