Skip to content

Commit de3e2e9

Browse files
Added support for writing FT annotations
1 parent e554cc3 commit de3e2e9

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

vcf/parser.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,26 @@ def _format_sample(self, fmt, sample):
753753
gt = './.' if 'GT' in fmt else ''
754754

755755
if not gt:
756-
return ':'.join([self._stringify(x) for x in sample.data])
756+
result = []
757+
for field in sample.data._fields:
758+
value = getattr(sample.data,field)
759+
if field == 'FT':
760+
result.append(self._format_filter(value))
761+
else:
762+
result.append(self._stringify(value))
763+
return ':'.join(result)
757764
# Following the VCF spec, GT is always the first item whenever it is present.
758765
else:
759-
return ':'.join([gt] + [self._stringify(x) for x in sample.data[1:]])
766+
result = []
767+
for field in sample.data._fields:
768+
value = getattr(sample.data,field)
769+
if field == 'GT':
770+
continue
771+
if field == 'FT':
772+
result.append(self._format_filter(value))
773+
else:
774+
result.append(self._stringify(value))
775+
return ':'.join([gt] + result)
760776

761777
def _stringify(self, x, none='.', delim=','):
762778
if type(x) == type([]):

0 commit comments

Comments
 (0)