code: def annotate_designs(designs, symbol='+'):
      
      max_seq_cluster = 0
      max_struct_cluster = 0
  
      for design in designs:
          max_seq_cluster = max(max_seq_cluster, design.sequence_cluster)
          max_struct_cluster = max(max_struct_cluster, design.structure_cluster)
  
      seq_digits = len(str(max_seq_cluster))
      struct_digits = len(str(max_struct_cluster))
  
      def update_header(pattern, str, header):
          if re.search(pattern, header):
              return re.sub(pattern, str, header)
          else:
              return header.rstrip() + ' ' + str
  
      for design in designs:
          seq_str = 'seq{:0{}}'.format(design.sequence_cluster, seq_digits)
          struct_str = 'struct{:0{}}'.format(design.structure_cluster, struct_digits)
  
          # Find any existing annotations.
  
          annotation_path = os.path.join(design.directory, 'notes.txt')
  
          try:
              with open(annotation_path) as file:
                  annotation_lines = [x.strip() for x in file.readlines()]
          except IOError:
              annotation_lines = []
  
          # If there are existing annotations and the first line starts with the 
          # symbol, assume that the line was previously inserted by this function
          # and should now be updated with the most recent information:
  
          if annotation_lines and annotation_lines[0].startswith(symbol):
              header = annotation_lines[0]
              header = update_header(r'seq\d+', seq_str, header)
              header = update_header(r'struct\d+', struct_str, header)
              annotation_lines[0] = header
  
          # Otherwise, insert the annotation above the existing lines.
  
          else:
              header = '{} {} {}'.format(symbol, seq_str, struct_str)
              annotation_lines.insert(0, header)
  
          with open(annotation_path, 'w') as file:
              file.write('\n'.join(annotation_lines))
docs: Automatically annotate the sequence and structure cluster for all the
      reasonable designs identified by this script.  These annotations make it
      easier to quickly focus on interesting subsets of design in the "Show My
      Designs" GUI.