Ejemplo n.º 1
0
 public List<DoubleList<Split, Integer>> findConflictingSplitCounts(
     int threshold, boolean thresholdIsLength) {
   findGreedySplits();
   List<DoubleList<Split, Integer>> results =
       new Vector<DoubleList<Split, Integer>>(greedySplits.size());
   // could be more efficient by storing where the greedy splits appear in the sorted list.
   for (int i : greedySplitIndex) {
     String splitStr = sortedSplits.elementAt(i);
     Split split = splits.get(splitStr);
     if (!thresholdIsLength && counts.get(splitStr) < threshold)
       break; // ignore splits with frequency below threshold
     DoubleList<Split, Integer> splitList = new DoubleList<Split, Integer>();
     splitList.add(split, counts.get(splitStr));
     // Only check splits after this one in sorted list: ones before this one are guaranteed to be
     // compatible, else this split would not be in the greedy list.
     for (int j = i + 1; j < sortedSplits.size(); j++) {
       String otherSplitString = sortedSplits.elementAt(j);
       if (!thresholdIsLength && counts.get(otherSplitString) < threshold)
         break; // ignore conflicting splits with frequency below threshold
       Split otherSplit = splits.get(otherSplitString);
       if (!split.compatible(otherSplit)) {
         splitList.add(otherSplit, counts.get(otherSplitString));
       } // if !compatible
       if (thresholdIsLength && splitList.size() == threshold)
         break; // have enough secondary splits now
     } // for otherSplit (j)
     results.add(splitList);
   } // for i over sortedSplits
   return results;
 }
Ejemplo n.º 2
0
 /**
  * Returns the sum of Internode Certainties over a greedy consensus tree.
  *
  * @return
  */
 public double treeCertainty() {
   double tc = 0;
   DoubleList<Split, Double> ic = getICs();
   for (int i = 0; i < ic.size(); i++) {
     tc += ic.getB(i);
   }
   return tc;
 }
Ejemplo n.º 3
0
 /**
  * Returns the sum of Internode Certainty All over a greedy consensus tree.
  *
  * @return
  */
 public double treeCertaintyAll(int threshold) {
   double tca = 0;
   DoubleList<Split, Double> ic = getICAs(threshold);
   for (int i = 0; i < ic.size(); i++) {
     tca += ic.getB(i);
   }
   return tca;
 }
Ejemplo n.º 4
0
 /*
  * Salichos Stamatakis and Rokas, MBE v31 p1261 (2014)
  * If only two splits are listed, returns IC, the Internode Certainty.
  * If more splits are listed, returns ICA, (IC All).
  */
 private double internodeCertainty(DoubleList<Split, Integer> splits) {
   int sum = 0;
   int n = splits.size(); // number of splits under consideration
   for (int i = 0; i < n; i++) sum += splits.getB(i);
   double ic = 1;
   if (n > 1) {
     ic = Math.log(n);
     for (int i = 0; i < n; i++) {
       double p = ((double) splits.getB(i)) / sum;
       ic += p * Math.log(p);
     }
     ic /= Math.log(n); // convert from natural log to log base n
   }
   return ic;
 }
Ejemplo n.º 5
0
 public void printInternodeCertainties(PrintWriter out) {
   DoubleList<Split, Double> ic = getICs();
   for (int i = 0; i < ic.size(); i++) {
     out.printf("IC = %f for split %s\n", ic.getB(i), ic.getA(i).toString());
   }
 }