jpayne@68: # cython: language_level=3 jpayne@68: from pysam.libchtslib cimport * jpayne@68: jpayne@68: cdef extern from "htslib_util.h": jpayne@68: jpayne@68: # add *nbytes* into the variable length data of *src* at *pos* jpayne@68: bam1_t * pysam_bam_update(bam1_t * b, jpayne@68: size_t nbytes_old, jpayne@68: size_t nbytes_new, jpayne@68: uint8_t * pos) jpayne@68: jpayne@68: # now: static jpayne@68: int aux_type2size(int) jpayne@68: jpayne@68: char * pysam_bam_get_qname(bam1_t * b) jpayne@68: uint32_t * pysam_bam_get_cigar(bam1_t * b) jpayne@68: uint8_t * pysam_bam_get_seq(bam1_t * b) jpayne@68: uint8_t * pysam_bam_get_qual(bam1_t * b) jpayne@68: uint8_t * pysam_bam_get_aux(bam1_t * b) jpayne@68: int pysam_bam_get_l_aux(bam1_t * b) jpayne@68: char pysam_bam_seqi(uint8_t * s, int i) jpayne@68: jpayne@68: uint8_t pysam_get_qual(bam1_t * b) jpayne@68: uint32_t pysam_get_n_cigar(bam1_t * b) jpayne@68: void pysam_set_qual(bam1_t * b, uint8_t v) jpayne@68: void pysam_set_n_cigar(bam1_t * b, uint32_t v) jpayne@68: void pysam_update_flag(bam1_t * b, uint16_t v, uint16_t flag) jpayne@68: jpayne@68: jpayne@68: from pysam.libcalignmentfile cimport AlignmentFile, AlignmentHeader jpayne@68: ctypedef AlignmentFile AlignmentFile_t jpayne@68: jpayne@68: jpayne@68: # Note: need to declare all C fields and methods here jpayne@68: cdef class AlignedSegment: jpayne@68: jpayne@68: # object that this AlignedSegment represents jpayne@68: cdef bam1_t * _delegate jpayne@68: jpayne@68: # the header that a read is associated with jpayne@68: cdef readonly AlignmentHeader header jpayne@68: jpayne@68: # caching of array properties for quick access jpayne@68: cdef object cache_query_qualities jpayne@68: cdef object cache_query_alignment_qualities jpayne@68: cdef object cache_query_sequence jpayne@68: cdef object cache_query_alignment_sequence jpayne@68: jpayne@68: # add an alignment tag with value to the AlignedSegment jpayne@68: # an existing tag of the same name will be replaced. jpayne@68: cpdef set_tag(self, tag, value, value_type=?, replace=?) jpayne@68: jpayne@68: # get an alignment tag from the AlignedSegment jpayne@68: cpdef get_tag(self, tag, with_value_type=?) jpayne@68: jpayne@68: # return true if tag exists jpayne@68: cpdef has_tag(self, tag) jpayne@68: jpayne@68: # returns a valid sam alignment string jpayne@68: cpdef to_string(self) jpayne@68: jpayne@68: # returns a valid sam alignment string (deprecated) jpayne@68: cpdef tostring(self, htsfile=*) jpayne@68: jpayne@68: jpayne@68: cdef class PileupColumn: jpayne@68: cdef const bam_pileup1_t ** plp jpayne@68: cdef int tid jpayne@68: cdef int pos jpayne@68: cdef int n_pu jpayne@68: cdef AlignmentHeader header jpayne@68: cdef uint32_t min_base_quality jpayne@68: cdef kstring_t buf jpayne@68: cdef char * reference_sequence jpayne@68: jpayne@68: cdef class PileupRead: jpayne@68: cdef int32_t _qpos jpayne@68: cdef AlignedSegment _alignment jpayne@68: cdef int _indel jpayne@68: cdef int _level jpayne@68: cdef uint32_t _is_del jpayne@68: cdef uint32_t _is_head jpayne@68: cdef uint32_t _is_tail jpayne@68: cdef uint32_t _is_refskip jpayne@68: jpayne@68: # factory methods jpayne@68: cdef AlignedSegment makeAlignedSegment( jpayne@68: bam1_t * src, jpayne@68: AlignmentHeader header) jpayne@68: jpayne@68: cdef PileupColumn makePileupColumn( jpayne@68: const bam_pileup1_t ** plp, jpayne@68: int tid, jpayne@68: int pos, jpayne@68: int n_pu, jpayne@68: uint32_t min_base_quality, jpayne@68: char * reference_sequence, jpayne@68: AlignmentHeader header) jpayne@68: jpayne@68: cdef PileupRead makePileupRead(const bam_pileup1_t * src, jpayne@68: AlignmentHeader header) jpayne@68: jpayne@68: cdef uint32_t get_alignment_length(bam1_t * src)