Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

154 linhas
3.5 KiB

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