/**
   * Converts the {@link MultipleAlignment} into a FatCat String format. Includes summary
   * information about the alignment in the top and a multiple sequence alignment at the bottom.
   *
   * @param alignment MultipleAlignment
   * @return String multiple sequence alignment in FASTA format
   */
  public static String toFatCat(MultipleAlignment alignment) {

    // Initialize the String and put the summary information
    StringWriter fatcat = new StringWriter();
    fatcat.append(alignment.toString() + "\n\n");

    // Get the alignment sequences and the mapping
    List<Integer> mapSeqToStruct = new ArrayList<Integer>();
    List<String> alnSequences =
        MultipleAlignmentTools.getSequenceAlignment(alignment, mapSeqToStruct);

    // Get the String of the Block Numbers for Position
    String blockNumbers = "";
    for (int pos = 0; pos < alnSequences.get(0).length(); pos++) {
      int blockNr =
          MultipleAlignmentTools.getBlockForSequencePosition(alignment, mapSeqToStruct, pos);
      if (blockNr != -1) blockNumbers = blockNumbers.concat("" + (blockNr + 1));
      else blockNumbers = blockNumbers.concat(" ");
    }

    // Write the Sequence Alignment
    for (int str = 0; str < alignment.size(); str++) {
      if (str < 9) fatcat.append("Chain 0" + (str + 1) + ": " + alnSequences.get(str) + "\n");
      else fatcat.append("Chain " + (str + 1) + ": " + alnSequences.get(str) + "\n");
      if (str != alignment.size() - 1) fatcat.append("          " + blockNumbers + "\n");
    }
    return fatcat.toString();
  }
  /**
   * Converts the {@link MultipleAlignment} into a multiple sequence alignment String in FASTA
   * format.
   *
   * @param alignment MultipleAlignment
   * @return String multiple sequence alignment in FASTA format
   */
  public static String toFASTA(MultipleAlignment alignment) {

    // Get the alignment sequences
    List<String> alnSequences = MultipleAlignmentTools.getSequenceAlignment(alignment);

    String fasta = "";
    for (int st = 0; st < alignment.size(); st++) {
      // Add the structure identifier as the head of the FASTA
      fasta +=
          ">"
              + alignment.getEnsemble().getStructureNames().get(st)
              + "\n"
              + alnSequences.get(st)
              + "\n";
    }
    return fasta;
  }