示例#1
0
 /*.................................................................................................................*/
 public void modifyTree(Tree tree, MesquiteTree modified, RandomBetween rng) {
   if (tree == null || modified == null) return;
   if (tree.getTaxa().anySelected()) { // error fixed in 1. 12
     int[] terminals = tree.getTerminalTaxa(tree.getRoot());
     if (terminals == null) return;
     int numTerminals = 0;
     for (int i = 0; i < terminals.length; i++)
       if (tree.getTaxa().getSelected(terminals[i])) numTerminals++;
     if (numTerminals > numExcluded) {
       int[] selTerminals = new int[numTerminals];
       int icount = 0;
       for (int i = 0; i < terminals.length; i++)
         if (tree.getTaxa().getSelected(terminals[i])) {
           selTerminals[icount] = terminals[i];
           icount++;
         }
       terminals = selTerminals;
       for (int it = 0; it < numExcluded; it++) {
         int taxon = -1;
         int count = 0;
         int ntries = 100000;
         while (terminals[taxon = rng.randomIntBetween(0, numTerminals - 1)] < 0
             && count < ntries) {
           count++;
         }
         if (count >= ntries)
           discreetAlert(
               "ERROR: Rarefy tree failed to find taxon to delete in " + ntries + " tries.");
         else {
           int nT = modified.nodeOfTaxonNumber(terminals[taxon]);
           modified.deleteClade(nT, false);
           terminals[taxon] = -1;
         }
       }
     } else
       MesquiteMessage.warnUser(
           "Sorry, the tree could not be rarefied because more taxa are to be excluded than those available");
   } else {
     int numTerminals = tree.numberOfTerminalsInClade(tree.getRoot());
     if (numTerminals > numExcluded) {
       for (int it = 0; it < numExcluded; it++) {
         int taxon = rng.randomIntBetween(0, numTerminals - it - 1);
         int nT = modified.getTerminalNode(modified.getRoot(), taxon);
         modified.deleteClade(nT, false);
       }
     } else
       MesquiteMessage.warnUser(
           "Sorry, the tree could not be rarefied because more taxa are to be excluded than those available");
   }
 }
 /*.................................................................................................................*/
 public String getStringForTree(int ic) {
   if (treesBlock == null) return "";
   Tree tree = treesBlock.getTree(ic);
   if (tree == null) return "";
   if (tree.hasPolytomies(tree.getRoot())) return "Yes";
   else return "No";
 }
 /**
  * Returns a new object indicating the states at the tips (used whether or not History is
  * reconstruction)
  */
 public CharacterDistribution getStatesAtTips(Tree tree) {
   if (observedStates != null) return (CharacterDistribution) observedStates.getAdjustableClone();
   else {
     ContinuousAdjustable d =
         new ContinuousAdjustable(tree.getTaxa(), tree.getTaxa().getNumTaxa());
     d.setItemsAs(this);
     fillDistribution(tree, tree.getRoot(), d);
     return d;
   }
 }