generate a repeatmasker formated representation of this pairwise alignment.

  :param column_width: number of characters to output per line of alignment
  :param m_name_width: truncate names on alignment lines to this length
                       (set to None for no truncation)

def _to_repeatmasker_string(pairwise_alignment, column_width=DEFAULT_COL_WIDTH,
                            m_name_width=DEFAULT_MAX_NAME_WIDTH):
  """
  generate a repeatmasker formated representation of this pairwise alignment.

  :param column_width: number of characters to output per line of alignment
  :param m_name_width: truncate names on alignment lines to this length
                       (set to None for no truncation)
  """
  s1 = pairwise_alignment.s1
  s2 = pairwise_alignment.s2

  s1_neg = not s1.is_positive_strand()
  s2_neg = not s2.is_positive_strand()
  size = pairwise_alignment.size()

  # figure out the complement column
  s1_comp = "C" if s1_neg else " "
  s2_comp = "C" if s2_neg else " "

  # figure out the maximum name length, so we can size that column properly;
  # pre-compute the space-padded names too
  s1_len = len(s1.name)
  s2_len = len(s2.name)
  f_len = max(s1_len, s2_len)
  if m_name_width is not None:
    f_len = min(f_len, m_name_width)
  s1_n = s1.name[:f_len] + (' ' * (f_len - s1_len))
  s2_n = s2.name[:f_len] + (' ' * (f_len - s2_len))

  # figure out the max width for the coordinates column; we use size of the
  # alignment here rather than ungapped coordinates because its an upper
  # bound and easier to compute (i.e. for sure already know).
  s1_line_end_num = (s1.end if s1_neg else s1.start - 1)
  s2_line_end_num = (s2.end if s2_neg else s2.start - 1)
  max_num_len = max(len(str(s1.start + size)), len(str(s2.start + size)))

  res = ""  # our result
  i = 0     # how much of the full, gapped alignment, has been output so far?
  res += _get_repeat_masker_header(pairwise_alignment) + "\n\n"
  while i < len(pairwise_alignment.s1):
    # keep track of how much of each sequence we've output
    s1_sub = s1.gapped_relative_subsequence(i + 1, min(i + column_width + 1, len(s1) + 1))
    s2_sub = s2.gapped_relative_subsequence(i + 1, min(i + column_width + 1, len(s2) + 1))
    s1_ug_len = s1_sub.ungapped_len
    s2_ug_len = s2_sub.ungapped_len
    s1_line_start_num = (s1_line_end_num - 1 if s1_neg
                         else s1_line_end_num + 1)
    s1_line_end_num = (s1_line_start_num - s1_ug_len + 1 if s1_neg
                       else s1_line_start_num + s1_ug_len - 1)
    s2_line_start_num = (s2_line_end_num - 1 if s2_neg
                         else s2_line_end_num + 1)
    s2_line_end_num = (s2_line_start_num - s2_ug_len + 1 if s2_neg
                       else s2_line_start_num + s2_ug_len - 1)

    # output sequence one
    res += (s1_comp + " " + s1_n + " ")
    s1_line_start_num_str = str(s1_line_start_num)
    s1_num_padding = max_num_len - len(s1_line_start_num_str)
    res += (' ' * s1_num_padding) + s1_line_start_num_str + " "
    res += pairwise_alignment.s1[i:i + column_width] + " "
    res += str(s1_line_end_num) + "\n"

    # output the annotation string, if we have one; needs to be padded by the
    # number of char in the name col (f_len), the number in the coordinate
    # col (max_num_len), the one char in the complement columns, and the
    # three spaces that are used as column seperators for those.
    if ANNOTATION_KEY in pairwise_alignment.meta:
      res += (((f_len + max_num_len) * ' ') + "    " +
              pairwise_alignment.meta[ANNOTATION_KEY][i:i + column_width] + "\n")

    # output sequence two
    res += (s2_comp + " " + s2_n + " ")
    s2_line_start_num_str = str(s2_line_start_num)
    s2_num_padding = max_num_len - len(s2_line_start_num_str)
    res += (' ' * s2_num_padding) + s2_line_start_num_str + " "
    res += pairwise_alignment.s2[i:i + column_width] + " "
    res += str(s2_line_end_num) + "\n"

    res += "\n"
    i += column_width

  # otuput any meta data key-value pairs that aren't known to us.
  if pairwise_alignment.meta is not None:
    for k in pairwise_alignment.meta:
      if k not in KNOWN_KEYS:
        if k is ROUNDTRIP_KEY:
          res += (pairwise_alignment.meta[k] + "\n")
        else:
          res += (k + " = " + str(pairwise_alignment.meta[k]) + "\n")

  # remove any trailing whitespace
  res = res.strip()
  return res