nodes: 0, module; 1, function_definition; 2, function_name:pprint_sequence; 3, parameters; 4, block; 5, identifier:sequence; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, comment:# The maximum length for positions is the 10_log of the length of the; 14, comment:# sequence.; 15, expression_statement; 16, expression_statement; 17, for_statement; 18, return_statement; 19, identifier:annotations; 20, None; 21, identifier:block_length; 22, integer:10; 23, identifier:blocks_per_line; 24, integer:6; 25, identifier:format; 26, identifier:PlaintextFormat; 27, comment:"""
      Pretty-print sequence for use with a monospace font.
  
          >>> sequence = 'MIMANQPLWLDSEVEMNHYQQSHIKSKSPYFPEDKHICWIKIFKAFGT' * 4
          >>> print pprint_sequence(sequence, format=PlaintextFormat)
            1  MIMANQPLWL DSEVEMNHYQ QSHIKSKSPY FPEDKHICWI KIFKAFGTMI MANQPLWLDS
           61  EVEMNHYQQS HIKSKSPYFP EDKHICWIKI FKAFGTMIMA NQPLWLDSEV EMNHYQQSHI
          121  KSKSPYFPED KHICWIKIFK AFGTMIMANQ PLWLDSEVEM NHYQQSHIKS KSPYFPEDKH
          181  ICWIKIFKAF GT
  
      :arg sequence: Sequence to pretty-print.
      :type sequence: str or any sliceable yielding slices representable as
          strings.
      :arg annotations: For each annotation level, a list of (`start`, `stop`)
          pairs defining an annotated region.
      :type annotations: list
      :arg block_length: Length of space-separated blocks.
      :type block_length: int
      :arg blocks_per_line: Number of blocks per line.
      :type blocks_per_line: int
      :arg format: Output format to use for pretty-printing. Some formats are
          pre-defined as :data:`HtmlFormat`, :data:`AnsiFormat`, and
          :data:`PlaintextFormat`.
      :type format: :class:`Format`
  
      :return: Pretty-printed version of `sequence`.
      :rtype: str
  
      All regions (`start`, `stop`) are defined as in slicing notation, so
      zero-based and `stop` is not included.
  
      The `annotations` argument is a list of annotations. An annotation is a
      list of regions as (`start`, `stop`) tuples. The level of each annotation
      is its index in `annotations`.
  
      Annotation regions can overlap (overlap within one level is ignored) and
      do not need to be sorted.
  
      The number of annotation levels supported depends on `format`.
      :data:`HtmlFormat` supports 10 levels, :data:`AnsiFormat` supports 3
      levels and annotations are ignored completely with
      :data:`PlaintextFormat`.
      """; 28, assignment; 29, assignment; 30, assignment; 31, assignment; 32, identifier:p; 33, call; 34, comment:# Partitioning of the block starting at position p.; 35, block; 36, identifier:result; 37, identifier:annotations; 38, boolean_operator; 39, identifier:partitioning; 40, call; 41, identifier:margin; 42, binary_operator:int(math.floor(math.log(max(len(sequence), 1), 10))
                   + 1) + len(format.margin[0]); 43, identifier:result; 44, binary_operator:(format.margin[0] + '1').rjust(margin) + format.margin[1] + ' '; 45, identifier:range; 46, argument_list; 47, expression_statement; 48, expression_statement; 49, for_statement; 50, if_statement; 51, identifier:annotations; 52, list; 53, identifier:partition_range; 54, argument_list; 55, call; 56, call; 57, binary_operator:(format.margin[0] + '1').rjust(margin) + format.margin[1]; 58, string; 59, integer:0; 60, call; 61, identifier:block_length; 62, assignment; 63, augmented_assignment; 64, pattern_list; 65, identifier:block; 66, block; 67, parenthesized_expression; 68, block; 69, call; 70, identifier:annotations; 71, identifier:int; 72, argument_list; 73, identifier:len; 74, argument_list; 75, call; 76, subscript; 77, string_content:; 78, identifier:len; 79, argument_list; 80, identifier:block; 81, list_comprehension; 82, identifier:result; 83, string; 84, identifier:start; 85, identifier:stop; 86, identifier:levels; 87, expression_statement; 88, expression_statement; 89, boolean_operator; 90, expression_statement; 91, identifier:len; 92, argument_list; 93, binary_operator:math.floor(math.log(max(len(sequence), 1), 10))
                   + 1; 94, subscript; 95, attribute; 96, argument_list; 97, attribute; 98, integer:1; 99, identifier:sequence; 100, tuple; 101, for_in_clause; 102, if_clause; 103, string_content:; 104, assignment; 105, augmented_assignment; 106, not_operator; 107, comparison_operator:p + block_length < len(sequence); 108, augmented_assignment; 109, identifier:sequence; 110, call; 111, integer:1; 112, attribute; 113, integer:0; 114, parenthesized_expression; 115, identifier:rjust; 116, identifier:margin; 117, identifier:format; 118, identifier:margin; 119, call; 120, call; 121, identifier:levels; 122, pattern_list; 123, identifier:partitioning; 124, boolean_operator; 125, identifier:delimiters; 126, list_comprehension; 127, identifier:result; 128, parenthesized_expression; 129, binary_operator:(p + block_length) % (block_length * blocks_per_line); 130, binary_operator:p + block_length; 131, call; 132, identifier:result; 133, parenthesized_expression; 134, attribute; 135, argument_list; 136, identifier:format; 137, identifier:margin; 138, binary_operator:format.margin[0] + '1'; 139, identifier:max; 140, argument_list; 141, identifier:min; 142, argument_list; 143, identifier:start; 144, identifier:stop; 145, identifier:levels; 146, comparison_operator:start < p + block_length; 147, comparison_operator:stop > p; 148, tuple; 149, for_in_clause; 150, if_clause; 151, binary_operator:''.join(left for left, right in reversed(delimiters)) +
                         str(sequence[start:stop]) +
                         ''.join(right for left, right in delimiters); 152, parenthesized_expression; 153, parenthesized_expression; 154, identifier:p; 155, identifier:block_length; 156, identifier:len; 157, argument_list; 158, binary_operator:'\n' + (format.margin[0] +
                                 str(p + block_length + 1)).rjust(margin) +
                         format.margin[1] + ' '; 159, identifier:math; 160, identifier:floor; 161, call; 162, subscript; 163, string; 164, identifier:start; 165, identifier:p; 166, identifier:stop; 167, binary_operator:p + block_length; 168, identifier:start; 169, binary_operator:p + block_length; 170, identifier:stop; 171, identifier:p; 172, identifier:left; 173, identifier:right; 174, pattern_list; 175, call; 176, comparison_operator:level in levels; 177, binary_operator:''.join(left for left, right in reversed(delimiters)) +
                         str(sequence[start:stop]); 178, call; 179, binary_operator:p + block_length; 180, binary_operator:block_length * blocks_per_line; 181, identifier:sequence; 182, binary_operator:'\n' + (format.margin[0] +
                                 str(p + block_length + 1)).rjust(margin) +
                         format.margin[1]; 183, string; 184, attribute; 185, argument_list; 186, attribute; 187, integer:0; 188, string_content:1; 189, identifier:p; 190, identifier:block_length; 191, identifier:p; 192, identifier:block_length; 193, identifier:level; 194, tuple_pattern; 195, identifier:enumerate; 196, argument_list; 197, identifier:level; 198, identifier:levels; 199, call; 200, call; 201, attribute; 202, generator_expression; 203, identifier:p; 204, identifier:block_length; 205, identifier:block_length; 206, identifier:blocks_per_line; 207, binary_operator:'\n' + (format.margin[0] +
                                 str(p + block_length + 1)).rjust(margin); 208, subscript; 209, string_content:; 210, identifier:math; 211, identifier:log; 212, call; 213, integer:10; 214, identifier:format; 215, identifier:margin; 216, identifier:left; 217, identifier:right; 218, attribute; 219, attribute; 220, generator_expression; 221, identifier:str; 222, argument_list; 223, string; 224, identifier:join; 225, identifier:right; 226, for_in_clause; 227, string; 228, call; 229, attribute; 230, integer:1; 231, identifier:max; 232, argument_list; 233, identifier:format; 234, identifier:annotations; 235, string; 236, identifier:join; 237, identifier:left; 238, for_in_clause; 239, subscript; 240, pattern_list; 241, identifier:delimiters; 242, string_content; 243, attribute; 244, argument_list; 245, identifier:format; 246, identifier:margin; 247, call; 248, integer:1; 249, pattern_list; 250, call; 251, identifier:sequence; 252, slice; 253, identifier:left; 254, identifier:right; 255, escape_sequence:\n; 256, parenthesized_expression; 257, identifier:rjust; 258, identifier:margin; 259, identifier:len; 260, argument_list; 261, identifier:left; 262, identifier:right; 263, identifier:reversed; 264, argument_list; 265, identifier:start; 266, identifier:stop; 267, binary_operator:format.margin[0] +
                                 str(p + block_length + 1); 268, identifier:sequence; 269, identifier:delimiters; 270, subscript; 271, call; 272, attribute; 273, integer:0; 274, identifier:str; 275, argument_list; 276, identifier:format; 277, identifier:margin; 278, binary_operator:p + block_length + 1; 279, binary_operator:p + block_length; 280, integer:1; 281, identifier:p; 282, identifier:block_length
code: def pprint_sequence(sequence, annotations=None, block_length=10,
                      blocks_per_line=6, format=PlaintextFormat):
      """
      Pretty-print sequence for use with a monospace font.
  
          >>> sequence = 'MIMANQPLWLDSEVEMNHYQQSHIKSKSPYFPEDKHICWIKIFKAFGT' * 4
          >>> print pprint_sequence(sequence, format=PlaintextFormat)
            1  MIMANQPLWL DSEVEMNHYQ QSHIKSKSPY FPEDKHICWI KIFKAFGTMI MANQPLWLDS
           61  EVEMNHYQQS HIKSKSPYFP EDKHICWIKI FKAFGTMIMA NQPLWLDSEV EMNHYQQSHI
          121  KSKSPYFPED KHICWIKIFK AFGTMIMANQ PLWLDSEVEM NHYQQSHIKS KSPYFPEDKH
          181  ICWIKIFKAF GT
  
      :arg sequence: Sequence to pretty-print.
      :type sequence: str or any sliceable yielding slices representable as
          strings.
      :arg annotations: For each annotation level, a list of (`start`, `stop`)
          pairs defining an annotated region.
      :type annotations: list
      :arg block_length: Length of space-separated blocks.
      :type block_length: int
      :arg blocks_per_line: Number of blocks per line.
      :type blocks_per_line: int
      :arg format: Output format to use for pretty-printing. Some formats are
          pre-defined as :data:`HtmlFormat`, :data:`AnsiFormat`, and
          :data:`PlaintextFormat`.
      :type format: :class:`Format`
  
      :return: Pretty-printed version of `sequence`.
      :rtype: str
  
      All regions (`start`, `stop`) are defined as in slicing notation, so
      zero-based and `stop` is not included.
  
      The `annotations` argument is a list of annotations. An annotation is a
      list of regions as (`start`, `stop`) tuples. The level of each annotation
      is its index in `annotations`.
  
      Annotation regions can overlap (overlap within one level is ignored) and
      do not need to be sorted.
  
      The number of annotation levels supported depends on `format`.
      :data:`HtmlFormat` supports 10 levels, :data:`AnsiFormat` supports 3
      levels and annotations are ignored completely with
      :data:`PlaintextFormat`.
      """
      annotations = annotations or []
  
      partitioning = partition_range(len(sequence), annotations)
  
      # The maximum length for positions is the 10_log of the length of the
      # sequence.
      margin = int(math.floor(math.log(max(len(sequence), 1), 10))
                   + 1) + len(format.margin[0])
      result = (format.margin[0] + '1').rjust(margin) + format.margin[1] + ' '
  
      for p in range(0, len(sequence), block_length):
          # Partitioning of the block starting at position p.
          block = [(max(start, p), min(stop, p + block_length), levels)
                   for start, stop, levels in partitioning
                   if start < p + block_length and stop > p]
  
          result += ' '
          for start, stop, levels in block:
              delimiters = [(left, right) for level, (left, right)
                            in enumerate(format.annotations) if level in levels]
              result += (''.join(left for left, right in reversed(delimiters)) +
                         str(sequence[start:stop]) +
                         ''.join(right for left, right in delimiters))
  
          if (not (p + block_length) % (block_length * blocks_per_line) and
              p + block_length < len(sequence)):
              result += ('\n' + (format.margin[0] +
                                 str(p + block_length + 1)).rjust(margin) +
                         format.margin[1] + ' ')
  
      return result