public PeptideCollection getPeptidesByHits(int numHits) {
   PeptideCollection new_pc = new PeptideCollection();
   for (Peptide pg : minPeptides.values()) {
     if (pg.getNumPeptideHits() >= numHits) {
       new_pc.minPeptides.put(pg.getSequence(), pg);
     }
   }
   new_pc.updatePeptideHits();
   return new_pc;
 }
  public PeptideCollection getNonIndeterminents() {
    PeptideCollection pc = new PeptideCollection();

    for (PeptideHit p : peptideHits) {
      if (!p.isIndeterminate()) {
        pc.addPeptideHit(p);
      }
    }
    return pc;
  }
 public PeptideCollection filterByProteinCoverage(int minCoverage) {
   HashSet<String> proDiscard = new HashSet<String>();
   for (String pName : minProteins.keySet()) {
     Protein p = minProteins.get(pName);
     if (p.getCoveragePercent() < minCoverage) {
       proDiscard.add(pName);
     }
   }
   PeptideCollection new_pc = new PeptideCollection();
   for (PeptideHit ph : peptideHits) {
     new_pc.addPeptideHit(ph.maskProtein(proDiscard));
   }
   new_pc.createProteinList();
   return new_pc;
 }
 public PeptideCollection filterByPeptidePerProtein(int numPeps) {
   HashSet<String> proDiscard = new HashSet<String>();
   for (String pName : minProteins.keySet()) {
     Protein p = minProteins.get(pName);
     if (p.getNumUniquePeptides() < numPeps) {
       proDiscard.add(pName);
     }
   }
   PeptideCollection new_pc = new PeptideCollection();
   for (PeptideHit ph : peptideHits) {
     new_pc.addPeptideHit(ph.maskProtein(proDiscard));
   }
   new_pc.createProteinList();
   return new_pc;
 }
  private DefaultMutableTreeNode getClusterTree(ExperimentPanel expPanel) {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(getClusterListPanel(expPanel));
    DefaultMutableTreeNode child, grandchild;

    // Sort by cluster num
    ArrayList<Integer> sortClusterNum = new ArrayList<Integer>();
    sortClusterNum.addAll(clusters.keySet());
    Collections.sort(sortClusterNum);
    for (Integer i : sortClusterNum) {
      PeptideCollection pc = clusters.get(i);
      child = new DefaultMutableTreeNode(pc);
      root.add(child);
      grandchild = pc.getPeptideTree(expPanel, false);
      child.add(grandchild);
      grandchild = pc.getProteinTree(expPanel, false);
      child.add(grandchild);
    }
    return root;
  }
 public int compareTo(PeptideCollection pc) {
   int x = getNumElements();
   int y = pc.getNumElements();
   if (x > y) {
     return -1;
   }
   if (x < y) {
     return 1;
   }
   return 0;
 }
 private void addLinkedMembers(PeptideCollection cluster, Integer clustNum, Peptide pg) {
   for (String proName : pg.getProteins()) {
     Protein pro = minProteins.get(proName);
     pro.setCluster(clustNum);
     for (String pepName : pro.getPeptides()) {
       Peptide subPg = minPeptides.get(pepName);
       if (subPg.getCluster() == -1) {
         subPg.setCluster(clustNum);
         cluster.addPeptideGroup(subPg);
         addLinkedMembers(cluster, clustNum, subPg);
       }
     }
   }
 }
 public void updateClusters() {
   clusters = new HashMap<Integer, PeptideCollection>();
   for (Peptide pg : minPeptides.values()) {
     pg.setCluster(-1);
   }
   int cluster_num = 1;
   for (Peptide pg : minPeptides.values()) {
     if (pg.getCluster() == -1) {
       PeptideCollection newCluster = new PeptideCollection();
       newCluster.setClusterNum(cluster_num);
       pg.setCluster(cluster_num);
       newCluster.addPeptideGroup(pg);
       addLinkedMembers(newCluster, cluster_num, pg);
       newCluster.updateProteins(minProteins);
       newCluster.updateParsimony();
       clusters.put(cluster_num, newCluster);
       cluster_num++;
     }
   }
   int equivGroup = 0;
   HashSet<String> usedProteins = new HashSet<String>();
   ArrayList<Protein> equivOrder = new ArrayList<Protein>();
   equivOrder.addAll(getCountables());
   equivOrder.addAll(getSubsets());
   equivOrder.addAll(getSubsumables());
   for (Protein p : equivOrder) {
     if (!usedProteins.contains(p.getName())) {
       p.setEquivalentGroup(equivGroup);
       usedProteins.add(p.getName());
       for (Protein ps : p.getEquivalent()) {
         ps.setEquivalentGroup(equivGroup);
         usedProteins.add(ps.getName());
       }
       equivGroup++;
     }
   }
 }
  //    public PeptideCollection getCutoffCollection(double omssa, double mascot, double xtandem) {
  //        return getCutoffCollection(omssa, mascot, xtandem, false);
  //    }
  public PeptideCollection getCutoffCollection(FilterSettings fs) {
    PeptideCollection pc = new PeptideCollection();

    for (PeptideHit p : peptideHits) {
      if (fs.getUsePepProphet() && p.isPepXML()) {
        if (p.getPepProphet() >= fs.getPeptideProphetCutoff()) {
          pc.addPeptideHit(p);
        }
      } else {
        switch (p.getSourceType()) {
          case MASCOT:
            if (fs.getUseIonIdent()) {
              if (p.getIonScore() >= p.getIdent()) {
                pc.addPeptideHit(p);
              }
            } else if (p.getExpect() <= fs.getMascotCutoff()) {
              pc.addPeptideHit(p);
            }
            break;
          case OMSSA:
            if (p.getExpect() <= fs.getOmssaCutoff()) {
              pc.addPeptideHit(p);
            }
            break;
          case XTANDEM:
            if (p.getExpect() <= fs.getXtandemCutoff()) {
              pc.addPeptideHit(p);
            }
            break;
          case SEQUEST:
            if (p.getExpect() <= fs.getSequestCutoff()) {
              pc.addPeptideHit(p);
            }
            break;
          case PEPXML:
            if (!p.CanGetPepProphet() || (p.getPepProphet() >= fs.getPeptideProphetCutoff())) {
              pc.addPeptideHit(p);
            }
            break;
        }
      }
    }

    return pc;
  }