選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

129 行
2.6 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. # Note: this replaces python "open"!
  8. cdef extern from "fcntl.h":
  9. int open(char *pathname, int flags)
  10. cdef extern from "unistd.h" nogil:
  11. ctypedef int ssize_t
  12. ssize_t read(int fd, void *buf, size_t count)
  13. int close(int fd)
  14. from pysam.libchtslib cimport hts_idx_t, hts_itr_t, htsFile, \
  15. tbx_t, kstring_t, BGZF, HTSFile
  16. # These functions are put here and not in chtslib.pxd in order
  17. # to avoid warnings for unused functions.
  18. cdef extern from "pysam_stream.h" nogil:
  19. ctypedef struct kstream_t:
  20. pass
  21. ctypedef struct kseq_t:
  22. kstring_t name
  23. kstring_t comment
  24. kstring_t seq
  25. kstring_t qual
  26. kseq_t *kseq_init(BGZF *)
  27. int kseq_read(kseq_t *)
  28. void kseq_destroy(kseq_t *)
  29. kstream_t *ks_init(BGZF *)
  30. void ks_destroy(kstream_t *)
  31. # Retrieve characters from stream until delimiter
  32. # is reached placing results in str.
  33. int ks_getuntil(kstream_t *,
  34. int delimiter,
  35. kstring_t * str,
  36. int * dret)
  37. cdef class tabix_file_iterator:
  38. cdef BGZF * fh
  39. cdef kstream_t * kstream
  40. cdef kstring_t buffer
  41. cdef size_t size
  42. cdef Parser parser
  43. cdef int fd
  44. cdef int duplicated_fd
  45. cdef infile
  46. cdef __cnext__(self)
  47. cdef class TabixFile(HTSFile):
  48. # pointer to index structure
  49. cdef tbx_t * index
  50. cdef readonly object filename_index
  51. cdef Parser parser
  52. cdef encoding
  53. cdef class Parser:
  54. cdef encoding
  55. cdef parse(self, char * buffer, int len)
  56. cdef class asTuple(Parser):
  57. cdef parse(self, char * buffer, int len)
  58. cdef class asGTF(Parser):
  59. pass
  60. cdef class asGFF3(Parser):
  61. pass
  62. cdef class asBed(Parser):
  63. pass
  64. cdef class asVCF(Parser):
  65. pass
  66. cdef class TabixIterator:
  67. cdef hts_itr_t * iterator
  68. cdef TabixFile tabixfile
  69. cdef kstring_t buffer
  70. cdef encoding
  71. cdef int __cnext__(self)
  72. cdef class TabixIteratorParsed(TabixIterator):
  73. cdef Parser parser
  74. cdef class GZIterator:
  75. cdef object _filename
  76. cdef BGZF * gzipfile
  77. cdef kstream_t * kstream
  78. cdef kstring_t buffer
  79. cdef int __cnext__(self)
  80. cdef encoding
  81. cdef class GZIteratorHead(GZIterator):
  82. pass
  83. cdef class GZIteratorParsed(GZIterator):
  84. cdef Parser parser
  85. # Compatibility Layer for pysam < 0.8
  86. cdef class Tabixfile(TabixFile):
  87. pass