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