Skip to content

Commit adb1eeb

Browse files
author
Nolan Woods
committed
Patch around daler/gffutils#144
1 parent a0e568a commit adb1eeb

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

biopython_convert/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,20 @@ def to_stats(record: SeqIO.SeqRecord) -> str:
7979
:param record: SeqIO.SeqRecord to represent
8080
:return: string containing GFF record
8181
"""
82-
attributes = {'Name': [record.name]}
82+
# 'if' statements can be removed after https://github.com/daler/gffutils/pull/144
83+
if record.name:
84+
attributes = {'Name': [record.name]}
8385
for k, v in record.annotations.items():
8486
if k in stat_annotations:
8587
if isinstance(v, list):
8688
v = [str(a) for a in v]
8789
else:
8890
v = [str(v)]
89-
attributes[k] = v
90-
attributes['desc'] = [record.description]
91-
return str(gffutils.Feature(record.id, "biopython-convert", "sequence", start=1, end=len(record), attributes=attributes))
91+
if v:
92+
attributes[k] = v
93+
if record.description:
94+
attributes['desc'] = [record.description]
95+
return str(gffutils.Feature(record.id, "biopython.convert", "sequence", start=1, end=len(record), attributes=attributes))
9296

9397

9498
def get_records(input_handle, input_type: str, jpath: str = ''):

0 commit comments

Comments
 (0)