Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically translate VariantRecord on write #1270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pysam/libcbcf.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3033,6 +3033,7 @@ cdef class VariantRecord(object):
return makeVariantRecord(self.header, bcf_dup(self.ptr))

def translate(self, VariantHeader dst_header):
"""Translate the record to a new header. Number of samples must match."""
if dst_header is None:
raise ValueError('dst_header must not be None')

Expand Down Expand Up @@ -4499,9 +4500,8 @@ cdef class VariantFile(HTSFile):
with nogil:
bcf_hdr_write(self.htsfile, self.header.ptr)

#if record.header is not self.header:
# record.translate(self.header)
# raise ValueError('Writing records from a different VariantFile is not yet supported')
if record.header is not self.header:
record.translate(self.header)

if record.ptr.n_sample != bcf_hdr_nsamples(self.header.ptr):
msg = 'Invalid VariantRecord. Number of samples does not match header ({} vs {})'
Expand Down