public void appendPeptides(Appendable out) {
    try {
      List<String> proteins = new ArrayList<String>(proteinToHits.keySet());
      Collections.sort(proteins);
      for (String protein : proteins) {
        Set<IdentifiedPSM> pps = proteinToHits.get(protein);
        List<IdentifiedPSM> peptides = new ArrayList<IdentifiedPSM>(pps);
        Collections.sort(peptides);

        for (IdentifiedPSM psm : peptides) {
          Polypeptide peptide = (Polypeptide) psm.getPeptide(); // .getUnModified();
          out.append(peptide.toString());
          out.append("\t");
          out.append(psm.getId());
          out.append("\t");
          out.append(protein);
          out.append("\t");
          String rt = String.format("%11.3f", peptide.getRetentionTime()).trim();
          out.append(rt);
          out.append("\n");
        }
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
  public void appendProteins(Appendable out) {
    try {
      List<String> proteins = new ArrayList<String>(proteinToHits.keySet());
      Collections.sort(proteins);
      for (String protein : proteins) {
        Set<IdentifiedPSM> pps = proteinToHits.get(protein);
        List<IdentifiedPSM> psms = new ArrayList<IdentifiedPSM>(pps);
        Collections.sort(psms);

        out.append(protein);
        for (IdentifiedPSM psm : psms) {
          out.append("\t");
          IPolypeptide unModified = psm.getPeptide(); // .getUnModified();
          out.append(unModified.toString());
          out.append("\t");
          out.append(psm.getId());
        }
        out.append("\n");
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }