text: user6230: 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
  
  
  user6230: 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)
  
  
original_text: 6230: <p>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.</p>
  
  <p>My output file shows features listed without the correct line breaks. Other software is then unable to parse the names of the features</p>
  
  <pre><code>misc_feature    58..60  /note="Oxidation"
  misc_feature    100..102  /note="Oxidation"
  misc_feature    241..243  /note="Oxidation"
  </code></pre>
  
  <p>It should be formatted like this</p>
  
  <pre><code>misc_feature    58..60  
                  /note="Oxidation"
  misc_feature    100..102  
                  /note="Oxidation"
  misc_feature    241..243  
                  /note="Oxidation"
  </code></pre>
  
  <p>My section of code adds a space between the location and the /note="" but the Biopython writer doesn't add line breaks.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>The Biopython source is toggling the wrapping of the feature qualifiers on <code>no_space_key</code> and <code>Bio.GenBank._BaseGenBankConsumer.remove_space_keys</code></p>
  
  <p>How do I enable wrapping of text to format output correctly?</p>
  
  <pre><code>    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
  </code></pre>
   6230: <p>I read the Biopython Genbank record source code carefully and realized I wasn’t using the Qualifier class correctly. </p>
  
  <p>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.</p>
  
  <pre><code>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)
  </code></pre>
  