I am parsing a csv file of annotated sequences and using Biopython to generate Genbank files for each. I want to add annotations of the sequence features.
My output file shows features listed without the correct line breaks. Other software is then unable to parse the names of the features
misc_feature 58..60 /note="Oxidation"
misc_feature 100..102 /note="Oxidation"
misc_feature 241..243 /note="Oxidation"
It should be formatted like this
misc_feature 58..60
/note="Oxidation"
misc_feature 100..102
/note="Oxidation"
misc_feature 241..243
/note="Oxidation"
My section of code adds a space between the location and the /note="" but the Biopython writer doesn't add line breaks.
for i in range(len(start_list)):
feature = Feature()
# Strict Genbank format calls non-standard things misc_feature
feature.key = "misc_feature"
liab_type = "{}".format(liability).split(":")[1]
#need to add 1 to start list since csv counting is off
feature.location = "{}..{}".format(int(start_list[i]) +1, end_list[i]) + " " + '/note=\"{}\"'.format(liab_type)
container.features.append(feature)
i +=1
The Biopython source is toggling the wrapping of the feature qualifiers on no_space_key
and Bio.GenBank._BaseGenBankConsumer.remove_space_keys
How do I enable wrapping of text to format output correctly?
def __str__(self):
"""Return feature as a GenBank format string."""
output = Record.INTERNAL_FEATURE_FORMAT % self.key
output += _wrapped_genbank(self.location, Record.GB_FEATURE_INDENT,
split_char=',')
for qualifier in self.qualifiers:
output += " " * Record.GB_FEATURE_INDENT
# determine whether we can wrap on spaces
space_wrap = 1
for no_space_key in \
Bio.GenBank._BaseGenBankConsumer.remove_space_keys:
if no_space_key in qualifier.key:
space_wrap = 0
output += _wrapped_genbank(qualifier.key + qualifier.value,
Record.GB_FEATURE_INDENT, space_wrap)
return output