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

Update handling of INFO/END when writing records in VCF #1201

Open
wants to merge 2 commits 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
8 changes: 2 additions & 6 deletions pysam/libcbcf.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1188,20 +1188,16 @@ cdef inline bcf_sync_end(VariantRecord record):
else:
ref_len = 0

# Delete INFO/END if no alleles are present or if rlen is equal to len(ref)
# Delete INFO/END if no alleles are present or if not present in header
# Always keep END for symbolic alleles
if not has_symbolic_allele(record) and (not record.ptr.n_allele or record.ptr.rlen == ref_len):
if not has_symbolic_allele(record) and (not record.ptr.n_allele) or end_id < 0:
# If INFO/END is not defined in the header, it doesn't exist in the record
if end_id >= 0:
info = bcf_get_info(hdr, record.ptr, b'END')
if info and info.vptr:
if bcf_update_info(hdr, record.ptr, b'END', NULL, 0, info.type) < 0:
raise ValueError('Unable to delete END')
else:
# Create END header, if not present
if end_id < 0:
record.header.info.add('END', number=1, type='Integer', description='Stop position of the interval')

# Update to reflect stop position
bcf_info_set_value(record, b'END', record.ptr.pos + record.ptr.rlen)

Expand Down