Skip to content

Commit

Permalink
fix: A sample column value of 0|0 is not being parsed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Myslinski committed Jun 25, 2024
1 parent 1d9a36e commit e271b94
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
22 changes: 22 additions & 0 deletions tests/test_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,25 @@ def test_header_has_header_line_positive_no_samples():
assert not hdr.has_header_line("INFO", "AD")
assert not hdr.has_header_line("FILTER", "PASS")
assert not hdr.has_header_line("contig", "1")


def test_header_get_format_field_info():
lines = []
samples = header.SamplesInfos(["one", "two", "three"])
hdr = header.Header(lines, samples)
gt_field_info = hdr.get_format_field_info("GT")

expected = header.RESERVED_FORMAT["GT"]

assert gt_field_info is expected


def test_header_get_info_format_field_info():
lines = []
samples = header.SamplesInfos(["one", "two", "three"])
hdr = header.Header(lines, samples)
gt_field_info = hdr.get_info_field_info("AA")

expected = header.RESERVED_INFO["AA"]

assert gt_field_info is expected
10 changes: 5 additions & 5 deletions vcfpy/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,18 +396,18 @@ def add_line(self, header_line):

def get_info_field_info(self, key):
"""Return :py:class:`FieldInfo` for the given INFO field"""
return self._get_field_info("INFO", key)
return self._get_field_info("INFO", key, RESERVED_INFO)

def get_format_field_info(self, key):
"""Return :py:class:`FieldInfo` for the given INFO field"""
return self._get_field_info("FORMAT", key)
return self._get_field_info("FORMAT", key, RESERVED_FORMAT)

def _get_field_info(self, type_, key):
def _get_field_info(self, type_, key, reserved):
result = self._indices[type_].get(key)
if result:
return result
if key in RESERVED_INFO:
res = FieldInfo(RESERVED_INFO[key].type, RESERVED_INFO[key].number)
if key in reserved:
res = reserved[key]
else:
res = FieldInfo("String", HEADER_NUMBER_UNBOUNDED)
warnings.warn(
Expand Down

0 comments on commit e271b94

Please sign in to comment.