def _rm_extract_sequence_and_name(alig_str_parts, s1_name, s2_name):
  """
  parse an alignment line from a repeatmasker alignment and return the name
  of the sequence it si from and the sequence portion contained in the line.

  :param alig_str_parts: the alignment string, split around whitespace as list
  :param s1_name: the name of the first sequence in the alignment this line is
                  from
  :param s2_name: the name of the second sequence in the alignment this line is
                  from
  :return: a tuple of name and sequence string; name will always be either
           s1_name or s2_name
  :raise AlignmentIteratorError: if the line doesn't have the expected number
                                 of elements, or the name does not match
                                 either of s1_name or s2_name
  """
  # first, based on the number of parts we have we'll guess whether its a
  # reverse complement or not
  if len(alig_str_parts) == 4:
    # expect the first element to amtch something..
    nm = alig_str_parts[0]
    seq = alig_str_parts[2]
  elif len(alig_str_parts) == 5:
    # expect the second element to match something...
    nm = alig_str_parts[1]
    seq = alig_str_parts[3]
  else:
    raise AlignmentIteratorError("failed parsing alignment line '" +
                                 " ".join(alig_str_parts) + "'; reason: " +
                                 "expected this line to have 4 or 5 " +
                                 "elements, but it has " +
                                 str(len(alig_str_parts)))
  if _rm_name_match(nm, s1_name):
    return s1_name, seq
  elif _rm_name_match(nm, s2_name):
    return s2_name, seq
  else:
    raise AlignmentIteratorError("failed parsing alignment line '" +
                                 " ".join(alig_str_parts) + "'; reason: " +
                                 "extracted alignment name (" + nm + ") " +
                                 "did not match either sequence name from " +
                                 "header line (" + s1_name + " or " +
                                 s2_name + ")")
parse an alignment line from a repeatmasker alignment and return the name
  of the sequence it si from and the sequence portion contained in the line.

  :param alig_str_parts: the alignment string, split around whitespace as list
  :param s1_name: the name of the first sequence in the alignment this line is
                  from
  :param s2_name: the name of the second sequence in the alignment this line is
                  from
  :return: a tuple of name and sequence string; name will always be either
           s1_name or s2_name
  :raise AlignmentIteratorError: if the line doesn't have the expected number
                                 of elements, or the name does not match
                                 either of s1_name or s2_name