Esempio n. 1
0
 public void processCompletedOutputFiles(String[] outputFilePaths) {
   if (outputFilePaths.length > 1 && !StringUtil.blank(outputFilePaths[1])) {
     ZephyrUtil.copyLogFile(this, "TNT", outputFilePaths[1]);
   }
   if (outputFilePaths.length > 2 && !StringUtil.blank(outputFilePaths[2])) {
     ZephyrUtil.copyOutputText(this, outputFilePaths[2], commands);
   }
 }
Esempio n. 2
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;
  }
Esempio n. 3
0
  /*.................................................................................................................*/
  public Tree getTrees(
      TreeVector trees,
      Taxa taxa,
      MCharactersDistribution matrix,
      long seed,
      MesquiteDouble finalScore) {
    if (!initializeGetTrees(CategoricalData.class, taxa, matrix)) return null;
    setTNTSeed(seed);
    isProtein = data instanceof ProteinData;

    // David: if isDoomed() then module is closing down; abort somehow

    // write data file
    String tempDir =
        MesquiteFileUtil.createDirectoryForFiles(
            this, MesquiteFileUtil.IN_SUPPORT_DIR, "TNT", "-Run.");
    if (tempDir == null) return null;
    String dataFileName = "data.ss"; // replace this with actual file name?
    String dataFilePath = tempDir + dataFileName;

    FileInterpreterI exporter = ZephyrUtil.getFileInterpreter(this, "#InterpretTNT");
    if (exporter == null) return null;
    boolean fileSaved = false;
    String translationTable = namer.getTranslationTable(taxa);
    ((InterpretHennig86Base) exporter).setTaxonNamer(namer);

    fileSaved = ZephyrUtil.saveExportFile(this, exporter, dataFilePath, data, selectedTaxaOnly);
    if (!fileSaved) return null;

    String translationFileName = IOUtil.translationTableFileName;
    setTaxonTranslation(taxa);
    taxonNumberTranslation = getTaxonNumberTranslation(taxa);
    namer.setNumberTranslationTable(taxonNumberTranslation);

    setFileNames();

    TaxaSelectionSet outgroupSet =
        (TaxaSelectionSet) taxa.getSpecsSet(outgroupTaxSetString, TaxaSelectionSet.class);
    int firstOutgroup = MesquiteInteger.unassigned;
    if (outgroupSet != null) firstOutgroup = outgroupSet.firstBitOn();
    formCommandFile(dataFileName, firstOutgroup);
    logln("\n\nCommands given to TNT:");
    logln(commands);
    logln("");

    MesquiteString arguments = new MesquiteString();
    arguments.setValue(" proc " + commandsFileName);

    String programCommand = externalProcRunner.getExecutableCommand();

    int numInputFiles = 3;
    String[] fileContents = new String[numInputFiles];
    String[] fileNames = new String[numInputFiles];
    for (int i = 0; i < numInputFiles; i++) {
      fileContents[i] = "";
      fileNames[i] = "";
    }
    fileContents[0] = MesquiteFile.getFileContentsAsString(dataFilePath);
    fileNames[0] = dataFileName;
    fileContents[1] = commands;
    fileNames[1] = commandsFileName;
    fileContents[2] = translationTable;
    fileNames[2] = translationFileName;

    // ----------//
    boolean success =
        runProgramOnExternalProcess(
            programCommand, arguments, fileContents, fileNames, ownerModule.getName());

    if (!isDoomed()) {
      if (success) {
        desuppressProjectPanelReset();
        return retrieveTreeBlock(trees, finalScore); // here's where we actually process everything.
      } else {
        if (!beanWritten) postBean("unsuccessful [1]", false);
        beanWritten = true;
      }
    }
    desuppressProjectPanelReset();
    if (data == null) data.decrementEditInhibition();
    externalProcRunner.finalCleanup();
    return null;
  }