# Biopython Genbank writer not splitting long lines

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

• Glad you found the solution!, The way to signal that the question is solved is posting your own question and selecting it as the one that resulted more helpful. This will unify the style for all questions and answers and make it easier for people to find the solution to your question. – llrs Sep 20 '19 at 7:14

I read the Biopython Genbank record source code carefully and realized I wasn’t using the Qualifier class correctly.

After reading the source code again, I realized I was using the data structure incorrectly. I need to use the Qualifier class to add a key and feature. This is formatted correctly and solves the problem.

feature = Feature()
# Strict Genbank format calls non-standard things misc_feature
feature.key = "misc_feature"
#need to add 1 to start list since csv counting is off
feature.location = "{}..{}".format(int(start_list[i]) +1, end_list[i])
liability_qualifier = Qualifier()
liability_qualifier.key = '/note="'
liability_qualifier.value = '\"{}\"'.format(liability).split(":")[1]
feature.qualifiers.append(liability_qualifier)

• Thanks for posting back and explaining the answer to the rest of us – Michael G. Sep 21 '19 at 22:24