您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

153 行
3.4 KiB

  1. from libc.stdint cimport int8_t, int16_t, int32_t, int64_t
  2. from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t
  3. from libc.stdlib cimport malloc, calloc, realloc, free
  4. from libc.string cimport memcpy, memcmp, strncpy, strlen, strdup
  5. from libc.stdio cimport FILE, printf
  6. from pysam.libcfaidx cimport faidx_t, FastaFile
  7. from pysam.libcalignedsegment cimport AlignedSegment
  8. from pysam.libchtslib cimport *
  9. from cpython cimport array
  10. cimport cython
  11. cdef extern from *:
  12. ctypedef char* const_char_ptr "const char*"
  13. cdef extern from "htslib_util.h":
  14. char * pysam_bam_get_qname(bam1_t * b)
  15. ####################################################################
  16. # Utility types
  17. ctypedef struct __iterdata:
  18. htsFile * htsfile
  19. bam_hdr_t * header
  20. hts_itr_t * iter
  21. faidx_t * fastafile
  22. int tid
  23. char * seq
  24. int seq_len
  25. int min_mapping_quality
  26. int flag_require
  27. int flag_filter
  28. bint compute_baq
  29. bint redo_baq
  30. bint ignore_orphans
  31. int adjust_capq_threshold
  32. cdef class AlignmentHeader(object):
  33. cdef bam_hdr_t *ptr
  34. cdef class AlignmentFile(HTSFile):
  35. cdef readonly object reference_filename
  36. cdef readonly AlignmentHeader header
  37. # pointer to index
  38. cdef hts_idx_t *index
  39. # current read within iteration
  40. cdef bam1_t * b
  41. cdef bam1_t * getCurrent(self)
  42. cdef int cnext(self)
  43. # write an aligned read
  44. cpdef int write(self, AlignedSegment read) except -1
  45. cdef class IteratorRow:
  46. cdef int retval
  47. cdef bam1_t * b
  48. cdef AlignmentFile samfile
  49. cdef htsFile * htsfile
  50. cdef hts_idx_t * index
  51. cdef AlignmentHeader header
  52. cdef int owns_samfile
  53. cdef class IteratorRowRegion(IteratorRow):
  54. cdef hts_itr_t * iter
  55. cdef bam1_t * getCurrent(self)
  56. cdef int cnext(self)
  57. cdef class IteratorRowHead(IteratorRow):
  58. cdef int max_rows
  59. cdef int current_row
  60. cdef bam1_t * getCurrent(self)
  61. cdef int cnext(self)
  62. cdef class IteratorRowAll(IteratorRow):
  63. cdef bam1_t * getCurrent(self)
  64. cdef int cnext(self)
  65. cdef class IteratorRowAllRefs(IteratorRow):
  66. cdef int tid
  67. cdef IteratorRowRegion rowiter
  68. cdef class IteratorRowSelection(IteratorRow):
  69. cdef int current_pos
  70. cdef positions
  71. cdef bam1_t * getCurrent(self)
  72. cdef int cnext(self)
  73. cdef class IteratorColumn:
  74. # result of the last plbuf_push
  75. cdef IteratorRowRegion iter
  76. cdef int tid
  77. cdef int pos
  78. cdef int n_plp
  79. cdef uint32_t min_base_quality
  80. cdef const bam_pileup1_t * plp
  81. cdef bam_mplp_t pileup_iter
  82. cdef __iterdata iterdata
  83. cdef AlignmentFile samfile
  84. cdef FastaFile fastafile
  85. cdef stepper
  86. cdef int max_depth
  87. cdef bint ignore_overlaps
  88. cdef int cnext(self)
  89. cdef char * get_sequence(self)
  90. cdef _setup_iterator(self,
  91. int tid,
  92. int start,
  93. int stop,
  94. int multiple_iterators=?)
  95. cdef _setup_raw_rest_iterator(self)
  96. cdef reset(self, tid, start, stop)
  97. cdef _free_pileup_iter(self)
  98. # backwards compatibility
  99. cdef char * getSequence(self)
  100. cdef class IteratorColumnRegion(IteratorColumn):
  101. cdef int start
  102. cdef int stop
  103. cdef int truncate
  104. cdef class IteratorColumnAllRefs(IteratorColumn):
  105. pass
  106. cdef class IteratorColumnAll(IteratorColumn):
  107. pass
  108. cdef class IndexedReads:
  109. cdef AlignmentFile samfile
  110. cdef htsFile * htsfile
  111. cdef object index
  112. cdef int owns_samfile
  113. cdef AlignmentHeader header