Ejemplo n.º 1
0
 /*..........................................ContinuousHistory................*/
 private void fillDistribution(Tree tree, int node, ContinuousAdjustable dist) {
   if (tree.nodeIsTerminal(node)) {
     int t = tree.taxonNumberOfNode(node);
     for (int i = 0; i < getNumItems(); i++) dist.setState(t, i, getState(node, i));
   } else
     for (int d = tree.firstDaughterOfNode(node); tree.nodeExists(d); d = tree.nextSisterOfNode(d))
       fillDistribution(tree, d, dist);
 }
Ejemplo n.º 2
0
 /*..........................................ContinuousHistory................*/
 public void calcMinMaxStates(Tree tree, int node) {
   for (int i = 0; i < getNumItems(); i++) {
     double s = getState(node, i);
     maxState = MesquiteDouble.maximum(maxState, s);
     minState = MesquiteDouble.minimum(minState, s);
   }
   for (int d = tree.firstDaughterOfNode(node); tree.nodeExists(d); d = tree.nextSisterOfNode(d))
     calcMinMaxStates(tree, d);
 }
Ejemplo n.º 3
0
 /**
  * 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;
   }
 }
Ejemplo n.º 4
0
 /**
  * This readjust procedure can be called to readjust the size of storage of states of a character
  * for nodes.
  */
 public CharacterHistory adjustSize(Tree tree) {
   if (tree.getNumNodeSpaces() == this.getNumNodes()) return this;
   else {
     ContinuousHistory soc =
         new ContinuousHistory(
             tree.getTaxa(), tree.getNumNodeSpaces(), (ContinuousData) getParentData());
     soc.setItemsAs(this);
     soc.setParentData(getParentData());
     soc.setParentCharacter(getParentCharacter());
     ((CharacterStates) soc).setExplanation(getExplanation());
     return soc;
   }
 }
Ejemplo n.º 5
0
 /** gets the current matrix. */
 public CharacterDistribution getCurrentCharacter(Tree tree) {
   if (tree == null) return null;
   else return getCurrentCharacter(tree.getTaxa());
 }
Ejemplo n.º 6
0
 /* -- the following are a preliminary attempt to allow matrix sources to know exactly what tree the
 matrix will be used with.  These can be overridden by modules to do simulations on the trees, or to see if there
 is a simulated matrix attached to the tree, or what ---*/
 public void initialize(Tree tree) {
   if (tree == null) return;
   else initialize(tree.getTaxa());
 }
Ejemplo n.º 7
0
  /*.................................................................................................................*/
  public Tree retrieveTreeBlock(TreeVector treeList, MesquiteDouble finalScore) {
    logln("Preparing to receive TNT trees.");
    boolean success = false;
    taxa = treeList.getTaxa();
    // TODO		finalScore.setValue(finalValue);

    suppressProjectPanelReset();
    CommandRecord oldCR = MesquiteThread.getCurrentCommandRecord();
    CommandRecord scr = new CommandRecord(true);
    MesquiteThread.setCurrentCommandRecord(scr);

    // define file paths and set tree files as needed.
    setFileNames();
    String[] outputFilePaths = externalProcRunner.getOutputFilePaths();

    String treeFilePath = outputFilePaths[OUT_TREEFILE];
    taxonNumberTranslation = getTaxonNumberTranslation(taxa);
    namer.setNumberTranslationTable(taxonNumberTranslation);

    runFilesAvailable();

    // read in the tree files
    success = false;
    Tree t = null;

    MesquiteBoolean readSuccess = new MesquiteBoolean(false);
    // TreeVector tv = new TreeVector(taxa);
    if (bootstrapOrJackknife()) {
      if (resamplingAllConsensusTrees)
        t =
            ZephyrUtil.readTNTTreeFile(
                this,
                treeList,
                taxa,
                treeFilePath,
                "TNT " + getResamplingKindName() + " Rep",
                0,
                readSuccess,
                false,
                false,
                null,
                namer); // set first tree number as 0 as will remove the first one later.
      else
        t =
            ZephyrUtil.readTNTTreeFile(
                this,
                treeList,
                taxa,
                treeFilePath,
                "TNT " + getResamplingKindName() + " Majority Rule Tree",
                1,
                readSuccess,
                false,
                false,
                freqRef,
                namer);
    } else
      t =
          ZephyrUtil.readTNTTreeFile(
              this,
              treeList,
              taxa,
              treeFilePath,
              "TNTTree",
              1,
              readSuccess,
              false,
              harvestOnlyStrictConsensus,
              null,
              namer);
    success = t != null;
    if (success && bootstrapOrJackknife() && resamplingAllConsensusTrees) {
      t = t.cloneTree();
      treeList.removeElementAt(0, false); // get rid of first one as this is the bootstrap tree
    }

    MesquiteThread.setCurrentCommandRecord(oldCR);
    success = readSuccess.getValue();
    if (!success) {
      logln("Execution of TNT unsuccessful [2]");
      if (!beanWritten) postBean("unsuccessful [2]", false);
      beanWritten = true;
    } else {
      if (!beanWritten) postBean("successful", false);
      beanWritten = true;
    }

    desuppressProjectPanelReset();
    if (data != null) data.decrementEditInhibition();
    //	manager.deleteElement(tv);  // get rid of temporary tree block
    externalProcRunner.finalCleanup();
    if (success) return t;
    return null;
  }