original_docstring: 
      Plot a pairwise or multiple sequence alignment.
  
      The output is similar to a string representation of an
      :class:`Alignment`, but with enhanced styling, symbol coloring and
      optional sequence labels and sequence position numbering.
      How each symbol of the alignment is drawn is determined by the
      given :class:`SymbolPlotter` object.
  
      Parameters
      ----------
      axes : Axes
          A *Matplotlib* axes, that is used as plotting area.
      alignment : Alignment
          The pairwise or multiple sequence alignment to be plotted.
      symbol_plotter : SymbolPlotter
          Defines how the symbols in the alignment are drawn.
      symbols_per_line : int, optional
          The amount of alignment columns that are diplayed per line.
      show_numbers : bool, optional
          If true, the sequence position of the symbols in the last
          alignment column of a line is shown on the right side of the
          plot.
          If the last symbol is a gap, the position of the last actual
          symbol before this gap is taken.
          If the first symbol did not occur up to this point,
          no number is shown for this line.
          By default the first symbol of a sequence has the position 1,
          but this behavior can be changed using the `number_functions`
          parameter.
      number_size : float, optional
          The font size of the position numbers
      number_functions : list of [(None or Callable(int -> int)], optional
          By default the position of the first symbol in a sequence is 1,
          i.e. the sequence position is the sequence index incremented by
          1.
          The behavior can be changed with this parameter:
          If supplied, the length of the list must match the number of
          sequences in the alignment.
          Every entry is a function that maps a sequence index (*int*) to
          a sequence position (*int*) for the respective sequence.
          A ``None`` entry means, that the default numbering is applied
          for the sequence.
      labels : list of str, optional
          The sequence labels.
          Must be the same size and order as the sequences in the
          alignment.
      label_size : float, optional
          Font size of the labels
      show_line_position : bool, optional
          If true the position within a line is plotted below the
          alignment.
      spacing : float, optional
          The spacing between the alignment lines. 1.0 means that the size
          is equal to the size of a symbol box.
      
      See also
      --------
      plot_alignment_similarity_based
      plot_alignment_type_based
  
      Notes
      -----
      The labels are placed on the Y-axis of the `axes` and the numbers
      are placed on the Y-axis of the `axes` twin.
      The position within a line is placed on the X-axis of the `axes`.
      Further modification of these can be performed using the usual
      *Matplotlib* API.
      
docstring: Plot a pairwise or multiple sequence alignment.
  The output is similar to a string representation of an
docstring_tokens: Plot a pairwise or multiple sequence alignment . The output is similar to a string representation of an
code: def plot_alignment(axes, alignment, symbol_plotter, symbols_per_line=50,
                     show_numbers=False, number_size=None, number_functions=None,
                     labels=None, label_size=None,
                     show_line_position=False,
                     spacing=1):
      """
      Plot a pairwise or multiple sequence alignment.
  
      The output is similar to a string representation of an
      :class:`Alignment`, but with enhanced styling, symbol coloring and
      optional sequence labels and sequence position numbering.
      How each symbol of the alignment is drawn is determined by the
      given :class:`SymbolPlotter` object.
  
      Parameters
      ----------
      axes : Axes
          A *Matplotlib* axes, that is used as plotting area.
      alignment : Alignment
          The pairwise or multiple sequence alignment to be plotted.
      symbol_plotter : SymbolPlotter
          Defines how the symbols in the alignment are drawn.
      symbols_per_line : int, optional
          The amount of alignment columns that are diplayed per line.
      show_numbers : bool, optional
          If true, the sequence position of the symbols in the last
          alignment column of a line is shown on the right side of the
          plot.
          If the last symbol is a gap, the position of the last actual
          symbol before this gap is taken.
          If the first symbol did not occur up to this point,
          no number is shown for this line.
          By default the first symbol of a sequence has the position 1,
          but this behavior can be changed using the `number_functions`
          parameter.
      number_size : float, optional
          The font size of the position numbers
      number_functions : list of [(None or Callable(int -> int)], optional
          By default the position of the first symbol in a sequence is 1,
          i.e. the sequence position is the sequence index incremented by
          1.
          The behavior can be changed with this parameter:
          If supplied, the length of the list must match the number of
          sequences in the alignment.
          Every entry is a function that maps a sequence index (*int*) to
          a sequence position (*int*) for the respective sequence.
          A ``None`` entry means, that the default numbering is applied
          for the sequence.
      labels : list of str, optional
          The sequence labels.
          Must be the same size and order as the sequences in the
          alignment.
      label_size : float, optional
          Font size of the labels
      show_line_position : bool, optional
          If true the position within a line is plotted below the
          alignment.
      spacing : float, optional
          The spacing between the alignment lines. 1.0 means that the size
          is equal to the size of a symbol box.
      
      See also
      --------
      plot_alignment_similarity_based
      plot_alignment_type_based
  
      Notes
      -----
      The labels are placed on the Y-axis of the `axes` and the numbers
      are placed on the Y-axis of the `axes` twin.
      The position within a line is placed on the X-axis of the `axes`.
      Further modification of these can be performed using the usual
      *Matplotlib* API.
      """
      from matplotlib.transforms import Bbox
  
      if number_functions is None:
          number_functions = [lambda x: x + 1] * len(alignment.sequences)
      else:
          if len(number_functions) != len(alignment.sequences):
              raise ValueError(
                  f"The amount of renumbering functions is "
                  f"{len(number_functions)} but the amount if sequences in the "
                  f"alignment is {len(alignment.sequences)}"
              )
          for i, func in enumerate(number_functions):
              if func is None:
                  number_functions[i] = (lambda x: x + 1)
  
      seq_num = alignment.trace.shape[1]
      seq_len = alignment.trace.shape[0]
      line_count = seq_len // symbols_per_line
      # Only extend line count by 1 if there is a remainder
      # (remaining symbols)
      if seq_len % symbols_per_line != 0:
          line_count += 1
  
  
      ### Draw symbols ###
      x = 0
      y = 0
      y_start = 0
      line_pos = 0
      for i in range(seq_len):
          y = y_start
          for j in range(seq_num):
              bbox = Bbox([[x,y],[x+1,y+1]])
              symbol_plotter.plot_symbol(bbox, alignment, i, j)
              y += 1
          line_pos += 1
          if line_pos >= symbols_per_line:
              line_pos = 0
              x = 0
              y_start += seq_num + spacing
          else:
              x += 1
      
      ### Draw labels ###
      ticks = []
      tick_labels = []
      if labels is not None:
          # Labels at center height of each line of symbols -> 0.5
          y = 0.5
          for i in range(line_count):
              for j in range(seq_num):
                  ticks.append(y)
                  tick_labels.append(labels[j])
                  y += 1
              y += spacing
      axes.set_yticks(ticks)
      axes.set_yticklabels(tick_labels)
      
      ### Draw numbers  ###
      # Create twin to allow different tick labels on right side
      number_axes = axes.twinx()
      ticks = []
      tick_labels = []
      if show_numbers:
          # Numbers at center height of each line of symbols -> 0.5
          y = 0.5
          for i in range(line_count):
              for j in range(seq_num):
                  if i == line_count-1:
                      # Last line -> get number of last column in trace
                      trace_pos = len(alignment.trace) -1
                  else:
                      trace_pos = (i+1) * symbols_per_line -1
                  seq_index = _get_last_valid_index(
                      alignment, trace_pos, j
                  )
                  # if -1 -> terminal gap
                  # -> skip number for this sequence in this line
                  if seq_index != -1:
                      # Convert sequence index to position
                      # (default index + 1)
                      number = number_functions[j](seq_index)
                      ticks.append(y)
                      tick_labels.append(str(number))
                  y += 1
              y += spacing
      number_axes.set_yticks(ticks)
      number_axes.set_yticklabels(tick_labels)
  
  
      axes.set_xlim(0, symbols_per_line)
      # Y-axis starts from top
      lim = seq_num*line_count + spacing*(line_count-1)
      axes.set_ylim(lim, 0)
      number_axes.set_ylim(lim, 0)
      axes.set_frame_on(False)
      number_axes.set_frame_on(False)
      # Remove ticks and set label and number size
      axes.yaxis.set_tick_params(
          left=False, right=False, labelsize=label_size
      )
      number_axes.yaxis.set_tick_params(
          left=False, right=False, labelsize=number_size
      )
      
      if show_line_position:
          axes.xaxis.set_tick_params(
              top=False, bottom=True, labeltop=False, labelbottom=True
          )
      else:
          axes.xaxis.set_tick_params(
              top=False, bottom=False, labeltop=False, labelbottom=False
          )
code_tokens: def plot_alignment ( axes , alignment , symbol_plotter , symbols_per_line = 50 , show_numbers = False , number_size = None , number_functions = None , labels = None , label_size = None , show_line_position = False , spacing = 1 ) : from matplotlib . transforms import Bbox if number_functions is None : number_functions = [ lambda x : x + 1 ] * len ( alignment . sequences ) else : if len ( number_functions ) != len ( alignment . sequences ) : raise ValueError ( f"The amount of renumbering functions is " f"{len(number_functions)} but the amount if sequences in the " f"alignment is {len(alignment.sequences)}" ) for i , func in enumerate ( number_functions ) : if func is None : number_functions [ i ] = ( lambda x : x + 1 ) seq_num = alignment . trace . shape [ 1 ] seq_len = alignment . trace . shape [ 0 ] line_count = seq_len // symbols_per_line if seq_len % symbols_per_line != 0 : line_count += 1 x = 0 y = 0 y_start = 0 line_pos = 0 for i in range ( seq_len ) : y = y_start for j in range ( seq_num ) : bbox = Bbox ( [ [ x , y ] , [ x + 1 , y + 1 ] ] ) symbol_plotter . plot_symbol ( bbox , alignment , i , j ) y += 1 line_pos += 1 if line_pos >= symbols_per_line : line_pos = 0 x = 0 y_start += seq_num + spacing else : x += 1 ticks = [ ] tick_labels = [ ] if labels is not None : y = 0.5 for i in range ( line_count ) : for j in range ( seq_num ) : ticks . append ( y ) tick_labels . append ( labels [ j ] ) y += 1 y += spacing axes . set_yticks ( ticks ) axes . set_yticklabels ( tick_labels ) number_axes = axes . twinx ( ) ticks = [ ] tick_labels = [ ] if show_numbers : y = 0.5 for i in range ( line_count ) : for j in range ( seq_num ) : if i == line_count - 1 : trace_pos = len ( alignment . trace ) - 1 else : trace_pos = ( i + 1 ) * symbols_per_line - 1 seq_index = _get_last_valid_index ( alignment , trace_pos , j ) if seq_index != - 1 : number = number_functions [ j ] ( seq_index ) ticks . append ( y ) tick_labels . append ( str ( number ) ) y += 1 y += spacing number_axes . set_yticks ( ticks ) number_axes . set_yticklabels ( tick_labels ) axes . set_xlim ( 0 , symbols_per_line ) lim = seq_num * line_count + spacing * ( line_count - 1 ) axes . set_ylim ( lim , 0 ) number_axes . set_ylim ( lim , 0 ) axes . set_frame_on ( False ) number_axes . set_frame_on ( False ) axes . yaxis . set_tick_params ( left = False , right = False , labelsize = label_size ) number_axes . yaxis . set_tick_params ( left = False , right = False , labelsize = number_size ) if show_line_position : axes . xaxis . set_tick_params ( top = False , bottom = True , labeltop = False , labelbottom = True ) else : axes . xaxis . set_tick_params ( top = False , bottom = False , labeltop = False , labelbottom = False )
short_docstring: Plot a pairwise or multiple sequence alignment.
short_docstring_tokens: Plot a pairwise or multiple sequence alignment .
comment: """
      Plot a pairwise or multiple sequence alignment.
  
      The output is similar to a string representation of an
      :class:`Alignment`, but with enhanced styling, symbol coloring and
      optional sequence labels and sequence position numbering.
      How each symbol of the alignment is drawn is determined by the
      given :class:`SymbolPlotter` object.
  
      Parameters
      ----------
      axes : Axes
          A *Matplotlib* axes, that is used as plotting area.
      alignment : Alignment
          The pairwise or multiple sequence alignment to be plotted.
      symbol_plotter : SymbolPlotter
          Defines how the symbols in the alignment are drawn.
      symbols_per_line : int, optional
          The amount of alignment columns that are diplayed per line.
      show_numbers : bool, optional
          If true, the sequence position of the symbols in the last
          alignment column of a line is shown on the right side of the
          plot.
          If the last symbol is a gap, the position of the last actual
          symbol before this gap is taken.
          If the first symbol did not occur up to this point,
          no number is shown for this line.
          By default the first symbol of a sequence has the position 1,
          but this behavior can be changed using the `number_functions`
          parameter.
      number_size : float, optional
          The font size of the position numbers
      number_functions : list of [(None or Callable(int -> int)], optional
          By default the position of the first symbol in a sequence is 1,
          i.e. the sequence position is the sequence index incremented by
          1.
          The behavior can be changed with this parameter:
          If supplied, the length of the list must match the number of
          sequences in the alignment.
          Every entry is a function that maps a sequence index (*int*) to
          a sequence position (*int*) for the respective sequence.
          A ``None`` entry means, that the default numbering is applied
          for the sequence.
      labels : list of str, optional
          The sequence labels.
          Must be the same size and order as the sequences in the
          alignment.
      label_size : float, optional
          Font size of the labels
      show_line_position : bool, optional
          If true the position within a line is plotted below the
          alignment.
      spacing : float, optional
          The spacing between the alignment lines. 1.0 means that the size
          is equal to the size of a symbol box.
      
      See also
      --------
      plot_alignment_similarity_based
      plot_alignment_type_based
  
      Notes
      -----
      The labels are placed on the Y-axis of the `axes` and the numbers
      are placed on the Y-axis of the `axes` twin.
      The position within a line is placed on the X-axis of the `axes`.
      Further modification of these can be performed using the usual
      *Matplotlib* API.
      """$SEP$# Only extend line count by 1 if there is a remainder$SEP$# (remaining symbols)$SEP$### Draw symbols ###$SEP$### Draw labels ###$SEP$# Labels at center height of each line of symbols -> 0.5$SEP$### Draw numbers  ###$SEP$# Create twin to allow different tick labels on right side$SEP$# Numbers at center height of each line of symbols -> 0.5$SEP$# Last line -> get number of last column in trace$SEP$# if -1 -> terminal gap$SEP$# -> skip number for this sequence in this line$SEP$# Convert sequence index to position$SEP$# (default index + 1)$SEP$# Y-axis starts from top$SEP$# Remove ticks and set label and number size