Open kcleal opened 3 years ago
Not sure if this would work (sorry I haven't managed to get pysam to build yet on my mac to test), but the seek
function could possibly be updated to the following, in libchtslib.pyx
::
def seek(self, uint64_t offset):
"""move file pointer to position *offset*, see :meth:`pysam.HTSFile.tell`."""
if not self.is_open:
raise ValueError('I/O operation on closed file')
if self.is_stream:
raise IOError('seek not available in streams')
cdef int64_t ret
if self.htsfile.format.compression == bgzf:
with nogil:
ret = bgzf_seek(hts_get_bgzfp(self.htsfile), offset, SEEK_SET)
elif self.htsfile.format.compression == no_compression:
ret = 0 if (hseek(self.htsfile.fp.hfile, offset, SEEK_SET) >= 0) else -1
# Add this elif block?
elif self.htsfile.format.format == cram:
with nogil:
ret = cram_seek(cram_fd_get_fp(self.htsfile), offset, SEEK_SET)
else:
raise NotImplementedError("seek not implemented in files compressed by method {}".format(
self.htsfile.format.compression))
return ret
Trying to call
seek
on a cram file raisesNotImplementedError
. Is seek possible on a cram file? The correspondingtell
method does seem to work.