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

142 行
3.9 KiB

  1. ###############################################################################
  2. ###############################################################################
  3. ## Cython wrapper for htslib VCF/BCF reader/writer
  4. ###############################################################################
  5. #
  6. # The MIT License
  7. #
  8. # Copyright (c) 2015, 2016 Kevin Jacobs (jacobs@bioinformed.com)
  9. #
  10. # Permission is hereby granted, free of charge, to any person obtaining a
  11. # copy of this software and associated documentation files (the "Software"),
  12. # to deal in the Software without restriction, including without limitation
  13. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  14. # and/or sell copies of the Software, and to permit persons to whom the
  15. # Software is furnished to do so, subject to the following conditions:
  16. #
  17. # The above copyright notice and this permission notice shall be included in
  18. # all copies or substantial portions of the Software.
  19. #
  20. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  23. # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  26. # DEALINGS IN THE SOFTWARE.
  27. #
  28. ###############################################################################
  29. from libc.stdint cimport int8_t, int16_t, int32_t, int64_t
  30. from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t
  31. from libc.stdlib cimport malloc, calloc, realloc, free
  32. from libc.string cimport memcpy, memcmp, memmove, strncpy, strlen, strdup
  33. from pysam.libchtslib cimport *
  34. cdef class VariantHeader(object):
  35. cdef bcf_hdr_t *ptr
  36. cdef _subset_samples(self, include_samples)
  37. cdef class VariantHeaderRecord(object):
  38. cdef readonly VariantHeader header
  39. cdef bcf_hrec_t *ptr
  40. cdef class VariantHeaderRecords(object):
  41. cdef readonly VariantHeader header
  42. cdef class VariantHeaderContigs(object):
  43. cdef readonly VariantHeader header
  44. cdef class VariantHeaderSamples(object):
  45. cdef readonly VariantHeader header
  46. cdef class VariantContig(object):
  47. cdef readonly VariantHeader header
  48. cdef int id
  49. cdef class VariantMetadata(object):
  50. cdef readonly VariantHeader header
  51. cdef int type
  52. cdef int id
  53. cdef class VariantHeaderMetadata(object):
  54. cdef readonly VariantHeader header
  55. cdef int32_t type
  56. cdef class VariantRecord(object):
  57. cdef readonly VariantHeader header
  58. cdef bcf1_t *ptr
  59. cdef class VariantRecordFilter(object):
  60. cdef VariantRecord record
  61. cdef class VariantRecordFormat(object):
  62. cdef VariantRecord record
  63. cdef class VariantRecordInfo(object):
  64. cdef VariantRecord record
  65. cdef class VariantRecordSamples(object):
  66. cdef VariantRecord record
  67. cdef class VariantRecordSample(object):
  68. cdef VariantRecord record
  69. cdef readonly int32_t index
  70. cdef class BaseIndex(object):
  71. cdef tuple refs
  72. cdef dict refmap
  73. cdef class BCFIndex(BaseIndex):
  74. cdef readonly VariantHeader header
  75. cdef hts_idx_t *ptr
  76. cdef class TabixIndex(BaseIndex):
  77. cdef tbx_t *ptr
  78. cdef class BaseIterator(object):
  79. cdef VariantFile bcf
  80. cdef hts_itr_t *iter
  81. cdef class BCFIterator(BaseIterator):
  82. cdef BCFIndex index
  83. cdef class TabixIterator(BaseIterator):
  84. cdef TabixIndex index
  85. cdef kstring_t line_buffer
  86. cdef class VariantFile(HTSFile):
  87. cdef readonly VariantHeader header
  88. cdef readonly BaseIndex index
  89. cdef readonly bint drop_samples # true if sample information is to be ignored
  90. # FIXME: Temporary, use htsFormat when it is available
  91. cdef readonly bint is_reading # true if file has begun reading records
  92. cdef readonly bint header_written # true if header has already been written
  93. cpdef int write(self, VariantRecord record) except -1