jpayne@68: # cython: language_level=3 jpayne@68: from libc.stdint cimport int8_t, int16_t, int32_t, int64_t jpayne@68: from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t jpayne@68: from libc.stdlib cimport malloc, calloc, realloc, free jpayne@68: from libc.string cimport memcpy, memcmp, strncpy, strlen, strdup jpayne@68: from libc.stdio cimport FILE, printf jpayne@68: cimport cython jpayne@68: jpayne@68: from cpython cimport array jpayne@68: from pysam.libchtslib cimport faidx_t, kstring_t, BGZF jpayne@68: jpayne@68: # These functions are put here and not in chtslib.pxd in order jpayne@68: # to avoid warnings for unused functions. jpayne@68: cdef extern from "pysam_stream.h" nogil: jpayne@68: jpayne@68: ctypedef struct kstream_t: jpayne@68: pass jpayne@68: jpayne@68: ctypedef struct kseq_t: jpayne@68: kstring_t name jpayne@68: kstring_t comment jpayne@68: kstring_t seq jpayne@68: kstring_t qual jpayne@68: jpayne@68: kseq_t *kseq_init(BGZF *) jpayne@68: int kseq_read(kseq_t *) jpayne@68: void kseq_destroy(kseq_t *) jpayne@68: kstream_t *ks_init(BGZF *) jpayne@68: void ks_destroy(kstream_t *) jpayne@68: jpayne@68: # Retrieve characters from stream until delimiter jpayne@68: # is reached placing results in str. jpayne@68: int ks_getuntil(kstream_t *, jpayne@68: int delimiter, jpayne@68: kstring_t * str, jpayne@68: int * dret) jpayne@68: jpayne@68: cdef class FastaFile: jpayne@68: cdef bint is_remote jpayne@68: cdef object _filename, _references, _lengths, reference2length jpayne@68: cdef faidx_t* fastafile jpayne@68: cdef char* _fetch(self, char* reference, jpayne@68: int start, int end, int* length) except? NULL jpayne@68: jpayne@68: jpayne@68: cdef class FastqProxy: jpayne@68: cdef kseq_t * _delegate jpayne@68: cdef cython.str to_string(self) jpayne@68: cdef cython.str tostring(self) jpayne@68: cpdef array.array get_quality_array(self, int offset=*) jpayne@68: jpayne@68: jpayne@68: cdef class FastxRecord: jpayne@68: """ jpayne@68: Python container for pysam.libcfaidx.FastqProxy with persistence. jpayne@68: """ jpayne@68: cdef public str comment, quality, sequence, name jpayne@68: cdef cython.str to_string(self) jpayne@68: cdef cython.str tostring(self) jpayne@68: cpdef array.array get_quality_array(self, int offset=*) jpayne@68: jpayne@68: cdef class FastxFile: jpayne@68: cdef object _filename jpayne@68: cdef BGZF * fastqfile jpayne@68: cdef kseq_t * entry jpayne@68: cdef bint persist jpayne@68: cdef bint is_remote jpayne@68: jpayne@68: cdef kseq_t * getCurrent(self) jpayne@68: cdef int cnext(self) jpayne@68: jpayne@68: jpayne@68: # Compatibility Layer for pysam 0.8.1 jpayne@68: cdef class FastqFile(FastxFile): jpayne@68: pass jpayne@68: jpayne@68: jpayne@68: # Compatibility Layer for pysam < 0.8 jpayne@68: cdef class Fastafile(FastaFile): jpayne@68: pass jpayne@68: