/*.................................................................................................................*/ 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; }
/*................................................................................................*/ private TreeVector fillBlock(Taxa taxa) { // TODO: fill in TreeVector filledVector = new TreeVector(taxa); int vectorTreeCount = 0; for (int fillers = 0; fillers < fillerTasks.size(); fillers++) { if (fillerTasks.get(fillers) instanceof SampleOneTreeFromFile) { ((SampleOneTreeFromFile) fillerTasks.get(fillers)) .resetTreesToSample(); // One unnecessary resetting of bits on first call TreeVector tempTreeVector = new TreeVector(taxa); ((TreeBlockFiller) fillerTasks.get(fillers)).fillTreeBlock(tempTreeVector, 1); if (tempTreeVector.getNumberOfTrees() < 1) { logln( "Not enough trees were supplied by " + ((TreeBlockFiller) fillerTasks.get(fillers)).getName() + "; " + tempTreeVector.getNumberOfTrees() + " provided, one requested."); ; } if (tempTreeVector.getNumberOfTrees() > 0) { int treeCount = 0; while (treeCount < 1 && treeCount < tempTreeVector .getNumberOfTrees()) { // Check so we don't ask for more trees that are there. filledVector.addElement(tempTreeVector.getTree(treeCount), false); if (filledVector != null && tempTreeVector != null) { if (filledVector.getTree(vectorTreeCount) != null && tempTreeVector.getName() != null) { if (filledVector.getTree(vectorTreeCount).getName() != null) logln( filledVector.getTree(vectorTreeCount).getName() + " added from " + tempTreeVector.getName()); } } treeCount++; vectorTreeCount++; } } tempTreeVector.dispose(); // disposed to reduce memory demands // (fillerTask.get(fillers)). } } return filledVector; }