コード例 #1
0
  /**
   * Gets background color for cell for row ic. Override it if you want to change the color from the
   * default.
   */
  public Color getBackgroundColorOfCell(int it, boolean selected) {
    if (observedStates == null) {
      doCalcs();
      if (observedStates == null) return null;
    }
    if (observedStates.getParentData() != null) {
      captureCharacterDataFromObservedStates();

      Associable tInfo = data.getTaxaInfo(false);
      NameReference genBankColor = NameReference.getNameReference("genbankcolor");
      Object obj = tInfo.getAssociatedObject(genBankColor, it); // not saved to file
      if (obj instanceof Color) return (Color) obj;
    }
    if (bits == null || it < 0 || it > bits.getSize()) return null;
    String note = getNote(it);
    if (selected) {
      if (bits.isBitOn(it)) return ColorDistribution.darkGreen;
      else return ColorDistribution.darkRed;
    } else if (bits.isBitOn(it)) {
      if (StringUtil.blank(note)) return ColorDistribution.veryLightGreen;
      if (!(note.equalsIgnoreCase("x"))) return ColorDistribution.lightGreenYellowish;
      return ColorDistribution.lightGreenYellow;
    } else {
      if (StringUtil.blank(note)) return ColorDistribution.brown;
      if (!(note.equalsIgnoreCase("x"))) {
        return Color.red;
      }
      return ColorDistribution.lightRed;
    }
  }
コード例 #2
0
  /*.................................................................................................................*/
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("setToDefaults")) {
      setDefaultTNTCommandsSearchOptions();
      searchField.setText(searchArguments);
      bootstrapSearchField.setText(bootstrapSearchArguments);
      harvestOnlyStrictConsensusBox.setState(harvestOnlyStrictConsensus);
      resamplingAllConsensusTreesBox.setState(!resamplingAllConsensusTrees);
      bootStrapRepsField.setValue(bootstrapreps);

    } else if (e.getActionCommand().equalsIgnoreCase("setToDefaultsOtherOptions")) {
      setDefaultTNTCommandsOtherOptions();
      otherOptionsField.setText(otherOptions);
      convertGapsBox.setState(convertGapsToMissing);
    } else if (e.getActionCommand().equalsIgnoreCase("browseSearchScript")
        && searchScriptPathField != null) {
      MesquiteString directoryName = new MesquiteString();
      MesquiteString fileName = new MesquiteString();
      String path =
          MesquiteFile.openFileDialog("Choose Search Script File", directoryName, fileName);
      if (StringUtil.notEmpty(path)) searchScriptPathField.setText(path);
    } else if (e.getActionCommand().equalsIgnoreCase("browseBootSearchScript")
        && bootSearchScriptPathField != null) {

      MesquiteString directoryName = new MesquiteString();
      MesquiteString fileName = new MesquiteString();
      String path =
          MesquiteFile.openFileDialog(
              "Choose Resampling Search Script File", directoryName, fileName);
      if (StringUtil.notEmpty(path)) bootSearchScriptPathField.setText(path);
    }
  }
コード例 #3
0
 /** Called to alter data in all cells */
 public boolean operateOnData(CharacterData data) {
   if (!(data instanceof ContinuousData)) return false;
   ContinuousData cData = (ContinuousData) data;
   int numItems = cData.getNumItems();
   String[] items = new String[numItems];
   for (int i = 0; i < items.length; i++) {
     if (StringUtil.blank(cData.getItemName(i))) items[i] = "(unnamed)";
     else items[i] = cData.getItemName(i);
   }
   int d =
       ListDialog.queryList(
           containerOfModule(),
           "Rename item",
           "Rename item:",
           MesquiteString.helpString,
           items,
           0);
   if (!MesquiteInteger.isCombinable(d) || d < 0 || d >= numItems) return false;
   else {
     String s =
         MesquiteString.queryString(
             containerOfModule(), "Rename Item", "New name for " + items[d], items[d]);
     if (StringUtil.blank(s)) return false;
     cData.setItemReference(d, NameReference.getNameReference(s));
     return true;
   }
 }
コード例 #4
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);
   }
 }
コード例 #5
0
  /*.................................................................................................................*/
  public boolean arrowTouchInRow(
      Graphics g, int ic, int x, int y, boolean doubleClick, int modifiers) {
    if (MesquiteEvent.rightClick(modifiers)) {
      MesquitePopup popup = new MesquitePopup(table.getMatrixPanel());

      String copyMenuText = "Copy ";
      if (observedStates != null) {
        CharacterData data = observedStates.getParentData();
        if (data != null) {
          copyMenuText += data.getName() + " Data";
          copyMenuText += " [from " + data.getTaxa().getTaxonName(ic) + "]";
        }
      }
      MesquiteCommand mcCopy = makeCommand("copyData", this);
      mcCopy.setDefaultArguments("" + ic);
      MesquiteCheckMenuItem mCopyItem =
          new MesquiteCheckMenuItem(copyMenuText, this, mcCopy, null, null);
      popup.add(mCopyItem);

      String pasteMenuText = "Paste ";
      if (StringUtil.notEmpty(localCopyDataClipboard) && localCopyData != null) {
        pasteMenuText += localCopyData.getName() + " Data";
        if (StringUtil.notEmpty(localCopyDataTaxon)) {
          pasteMenuText += " [from " + localCopyDataTaxon + "] ";
        }
      }
      MesquiteCommand mcPaste = makeCommand("pasteData", this); // only if something in clipboard
      mcPaste.setDefaultArguments("" + ic);
      MesquiteCheckMenuItem mPasteItem =
          new MesquiteCheckMenuItem(pasteMenuText, this, mcPaste, null, null);
      mPasteItem.setEnabled(StringUtil.notEmpty(localCopyDataClipboard));
      popup.add(mPasteItem);

      MesquiteCommand mcDelete = makeCommand("deleteDataTouched", this);
      mcDelete.setDefaultArguments("" + ic);
      MesquiteCheckMenuItem mDeleteItem =
          new MesquiteCheckMenuItem("Delete Data", this, mcDelete, null, null);
      popup.add(mDeleteItem);

      popup.showPopup(x, y + 18);

      return true;
    }
    return false;
  }
コード例 #6
0
  /*.................................................................................................................*/
  public String preparePreferencesForXML() {
    StringBuffer buffer = new StringBuffer(200);
    StringUtil.appendXMLTag(buffer, 2, "mxram", mxram);
    StringUtil.appendXMLTag(buffer, 2, "bootStrapReps", bootstrapreps);
    StringUtil.appendXMLTag(buffer, 2, "convertGapsToMissing", convertGapsToMissing);
    StringUtil.appendXMLTag(buffer, 2, "resamplingAllConsensusTrees", resamplingAllConsensusTrees);
    StringUtil.appendXMLTag(buffer, 2, "harvestOnlyStrictConsensus", harvestOnlyStrictConsensus);
    StringUtil.appendXMLTag(buffer, 2, "searchArguments", searchArguments);
    StringUtil.appendXMLTag(buffer, 2, "bootstrapSearchArguments", bootstrapSearchArguments);
    StringUtil.appendXMLTag(buffer, 2, "searchStyle", searchStyle);
    StringUtil.appendXMLTag(buffer, 2, "otherOptions", otherOptions);

    preferencesSet = true;
    return buffer.toString();
  }
コード例 #7
0
 /*..........................................MContinuousStates................*/
 public int userQueryItem(String message, MesquiteModule module) {
   int numItems = getNumItems();
   String[] items = new String[numItems];
   for (int i = 0; i < items.length; i++) {
     if (StringUtil.blank(getItemName(i))) items[i] = "(unnamed)";
     else items[i] = getItemName(i);
   }
   return ListDialog.queryList(
       module.containerOfModule(), "Select item", message, MesquiteString.helpString, items, 0);
 }
コード例 #8
0
  /*.................................................................................................................*/
  public void processSingleXMLPreference(String tag, String content) {
    if ("bootStrapReps".equalsIgnoreCase(tag)) bootstrapreps = MesquiteInteger.fromString(content);
    if ("mxram".equalsIgnoreCase(tag)) mxram = MesquiteInteger.fromString(content);
    if ("convertGapsToMissing".equalsIgnoreCase(tag))
      convertGapsToMissing = MesquiteBoolean.fromTrueFalseString(content);
    if ("resamplingAllConsensusTrees".equalsIgnoreCase(tag))
      resamplingAllConsensusTrees = MesquiteBoolean.fromTrueFalseString(content);
    if ("harvestOnlyStrictConsensus".equalsIgnoreCase(tag))
      harvestOnlyStrictConsensus = MesquiteBoolean.fromTrueFalseString(content);
    if ("searchStyle".equalsIgnoreCase(tag)) searchStyle = MesquiteInteger.fromString(content);
    if ("searchArguments".equalsIgnoreCase(tag))
      searchArguments = StringUtil.cleanXMLEscapeCharacters(content);
    if ("bootstrapSearchArguments".equalsIgnoreCase(tag))
      bootstrapSearchArguments = StringUtil.cleanXMLEscapeCharacters(content);
    if ("otherOptions".equalsIgnoreCase(tag))
      otherOptions = StringUtil.cleanXMLEscapeCharacters(content);

    // parallel, etc.
    preferencesSet = true;
  }
コード例 #9
0
 /*.................................................................................................................*/
 public void fromString(String description, MesquiteInteger stringPos, int format) {
   hasDefaultValues = false;
   ParseUtil.getToken(description, stringPos); // RMatrix
   ParseUtil.getToken(description, stringPos); // =
   ParseUtil.getToken(description, stringPos); // (
   for (int i = 0; i < getNumStates(); i++) {
     String s = ParseUtil.getToken(description, stringPos);
     if (s.equalsIgnoreCase(")") || StringUtil.blank(s)) return;
     setStateFreq(i, MesquiteDouble.fromString(s));
   }
   checkNormality(getStateFrequencies());
 }
コード例 #10
0
  /*.................................................................................................................*/
  public void processAceFileWithContig(
      CharacterData data,
      MesquiteModule ownerModule,
      String processedAceFilePath,
      String fragmentDirPath,
      AceFile ace,
      SequenceUploader uploader,
      String geneName,
      MesquiteString fullName,
      String baseName,
      MesquiteString voucherCode,
      int it) {
    DNAData editedData = ChromaseqUtil.getEditedData(data);
    DNAData originalData = ChromaseqUtil.getOriginalData(data);
    Taxa taxa = data.getTaxa();
    ace.setNameTranslation(fileNameTranslation);
    ownerModule.log(ace.contigListForLog() + StringUtil.lineEnding());
    if (processPolymorphisms) ace.processPolys(); // creates an additional CO that has polys in it
    if (renameContigsInAceFiles) ace.renameContigs(fullName.toString(), addFragName, geneName);
    ace.setLowQualityToLowerCase(qualThresholdForLowerCase);
    ace.writeToPropertiesFile(contigPropertiesFileBuffer, fullName.toString());
    if (truncateMixedEnds)
      ace.trimMixedEnds(mixedEndThreshold, mixedEndWindow, qualThresholdForTrim, addPhrapFailures);

    /*		if (uploadResultsToDatabase && StringUtil.notEmpty(databaseURL)) {
    			uploader.uploadAceFileToServer(MesquiteXMLToLUtilities.getTOLPageDatabaseURL(databaseURL), ace, processPolymorphisms, qualThresholdForTrim);
    		}
    */
    System.out.println("\n\nfasta file name: " + baseName + " ace file: " + ace);
    MesquiteFile.putFileContents(
        fragmentDirPath
            + MesquiteFile.fileSeparator
            + ChromaseqUtil.processedFastaFolder
            + MesquiteFile.fileSeparator
            + baseName
            + ".fas",
        ace.toFASTAString(processPolymorphisms, qualThresholdForTrim),
        true);
    MesquiteFile.putFileContents(processedAceFilePath, ace.toString(processPolymorphisms), true);
    ace.importSequence(
        taxa,
        editedData,
        it,
        originalData,
        ChromaseqUtil.getQualityData(data),
        ChromaseqUtil.getRegistryData(data),
        singleTaxaBlock,
        processPolymorphisms,
        maxChar,
        " contig ",
        false,
        voucherCode);
  }
コード例 #11
0
  /*.................................................................................................................*/
  public void reprocessAceFileDirectory(
      MesquiteFile file, MesquiteModule ownerModule, DNAData data, int it) {
    if (data == null || file == null) return;
    String aceFileDirectoryPath =
        ChromaseqUtil.getAceFileDirectory(file.getDirectoryName(), ownerModule, data, it);
    File aceFileDirectory = new File(aceFileDirectoryPath);
    boolean addFragName = false; // control of this?
    int currentRead = -1;
    String dataFilePath = MesquiteFile.composePath(data.getProject().getHomeDirectoryName(), "");
    boolean addingPhrapFailures = false;
    AceFile ace = null;
    MesquiteProject project = data.getProject();
    if (project == null) return;
    String processedAceFilePath = "";
    MesquiteString fullName = null;
    MesquiteString voucherCode = null;
    String geneName = ChromaseqUtil.getGeneName(data);
    if (aceFileDirectory.isDirectory()) {
      int numPhdFiles = getNumPhdFilesInDirectory(aceFileDirectory, aceFileDirectoryPath);
      fileNameTranslation = new String[5][numPhdFiles];
      fillNameTranslation(data, it, numPhdFiles);

      String[] files = aceFileDirectory.list();
      for (int i = 0;
          i < files.length;
          i++) { // going through the folders and finding the ace files
        if (files[i] != null) {
          String filePath = aceFileDirectoryPath + MesquiteFile.fileSeparator + files[i];
          String infoFilePath =
              aceFileDirectoryPath + MesquiteFile.fileSeparator + ChromaseqUtil.infoFileName;
          File cFile = new File(filePath);
          if (cFile.exists()) {
            if (!cFile.isDirectory()) {
              if (files[i].endsWith(ChromaseqUtil.processedACESuffix + ".ace")) {
                // don't do anything
              } else if (files[i].endsWith(".ace")
                  && !files[i].startsWith(".")
                  && !addingPhrapFailures) {
                ownerModule.logln("Processing ACE file: " + files[i]);

                String baseName =
                    files[i].substring(
                        0, files[i].length() - 4); // this is the name of the sequence
                processedAceFilePath =
                    aceFileDirectoryPath
                        + MesquiteFile.fileSeparator
                        + baseName
                        + ChromaseqUtil.processedACESuffix
                        + ".ace";

                ace =
                    new AceFile(
                        filePath,
                        processedAceFilePath,
                        dataFilePath,
                        dataFilePath,
                        ownerModule,
                        processPolymorphisms,
                        polyThreshold,
                        false);
                if (ace == null) return;

                ace.setBaseName(baseName);
                fullName = new MesquiteString(baseName);
                voucherCode = new MesquiteString();
                ChromaseqInfoFile.processInfoFile(infoFilePath, fullName, voucherCode);
                String fragmentDirPath =
                    StringUtil.getAllButLastItem(
                        StringUtil.getAllButLastItem(
                            aceFileDirectoryPath, MesquiteFile.fileSeparator),
                        MesquiteFile.fileSeparator);
                ace.setLongSequenceName(fullName.toString());
                if (ace.getNumContigs() >= 1) {
                  processAceFileWithContig(
                      data,
                      ownerModule,
                      processedAceFilePath,
                      fragmentDirPath,
                      ace,
                      null,
                      geneName,
                      fullName,
                      baseName,
                      voucherCode,
                      it);
                } else {
                  ownerModule.logln("   ACE file contains no contigs!");
                  if (project != null) {
                    addingPhrapFailures = true;
                    i = 0;
                    ace.createEmptyContigs(
                        MesquiteFile.numFilesEndingWith(
                            aceFileDirectoryPath, files, ".phd.1")); // create an empty contig
                    ace.renameContigs(fullName.toString(), addFragName, geneName);
                  }
                }

                if (!addingPhrapFailures) ace.dispose();
              } else if (files[i].endsWith(".phd.1") && addingPhrapFailures) {
                ownerModule.logln("   Importing single-read Phred file " + files[i]);
                currentRead++;
                ace.addPhdFileAsSingleReadInContig(
                    currentRead,
                    aceFileDirectoryPath,
                    files[i],
                    processPolymorphisms,
                    polyThreshold);
              }
            }
          }
        }
      }
    }

    if (addingPhrapFailures && ace != null) { // have to process AceFile that we have manually made
      MesquiteFile.putFileContents(processedAceFilePath, ace.toString(processPolymorphisms), true);
      if (project != null) {
        processAceFileWithoutContig(
            data, processedAceFilePath, ace, geneName, fullName, it, voucherCode);
      }
      ace.dispose();
    }
  }
コード例 #12
0
 /*.................................................................................................................*/
 public String preparePreferencesForXML() {
   StringBuffer buffer = new StringBuffer(200);
   StringUtil.appendXMLTag(buffer, 2, "availMemory", availMemory);
   buffer.append(super.preparePreferencesForXML());
   return buffer.toString();
 }
コード例 #13
0
  /*.................................................................................................................*/
  void formCommandFile(String dataFileName, int firstOutgroup) {
    if (parallel) {
      commands = "";
    }
    commands += getTNTCommand("mxram " + mxram);

    commands += getTNTCommand("report+0/1/0");
    commands += getTNTCommand("log " + logFileName);
    commands += getTNTCommand("p " + dataFileName);
    commands += getTNTCommand("vversion");
    if (MesquiteInteger.isCombinable(firstOutgroup) && firstOutgroup >= 0)
      commands += getTNTCommand("outgroup " + firstOutgroup);
    if (bootstrapOrJackknife()) {
      if (parallel) {
        commands += indentTNTCommand("ptnt begin parallelRun " + numSlaves + "/ram x 2 = ");
      }
      if (StringUtil.notEmpty(bootSearchScriptPath)) {
        String script = MesquiteFile.getFileContentsAsString(bootSearchScriptPath);
        if (StringUtil.notEmpty(script)) commands += script;
      } else
        commands += StringUtil.lineEnding() + bootstrapSearchArguments + StringUtil.lineEnding();
      String saveTreesString = "";
      if (resamplingAllConsensusTrees) saveTreesString = " savetrees ";
      String bootSearchString = " [xmult; bb]";
      bootSearchString = "";

      if (parallel) {
        int numRepsPerSlave = bootstrapreps / numSlaves;
        if (numRepsPerSlave * numSlaves < bootstrapreps) numRepsPerSlave++;
        if (searchStyle == BOOTSTRAPSEARCH)
          commands +=
              getTNTCommand(
                  "resample boot cut 50 "
                      + saveTreesString
                      + " replications "
                      + numRepsPerSlave
                      + " [xmult; bb] savetrees"); // + getComDelim();
        else if (searchStyle == JACKKNIFESEARCH)
          commands +=
              getTNTCommand(
                  "resample jak cut 50 "
                      + saveTreesString
                      + " replications "
                      + numRepsPerSlave
                      + " [xmult; bb] savetrees"); // + getComDelim();
        else if (searchStyle == SYMSEARCH)
          commands +=
              getTNTCommand(
                  "resample sym cut 50 "
                      + saveTreesString
                      + " replications "
                      + numRepsPerSlave
                      + " [xmult; bb] savetrees"); // + getComDelim();
        else if (searchStyle == POISSONSEARCH)
          commands +=
              getTNTCommand(
                  "resample poisson cut 50 "
                      + saveTreesString
                      + " replications "
                      + numRepsPerSlave
                      + " [xmult; bb] savetrees"); // + getComDelim();
        commands += getTNTCommand("return");
        commands += getTNTCommand("ptnt wait parallelRun");
        commands += getTNTCommand("ptnt get parallelRun");
      } else {
        if (!resamplingAllConsensusTrees) {
          commands += getTNTCommand("macro=");
          commands += getTNTCommand("ttags =");
        }
        commands += getTNTCommand("tsave *" + treeFileName);
        if (bootstrapAllowed) {
          if (searchStyle == BOOTSTRAPSEARCH)
            commands +=
                getTNTCommand(
                    "resample boot "
                        + saveTreesString
                        + " replications "
                        + bootstrapreps
                        + bootSearchString); // + getComDelim();
          else if (searchStyle == JACKKNIFESEARCH)
            commands +=
                getTNTCommand(
                    "resample jak cut 50 "
                        + saveTreesString
                        + " replications "
                        + bootstrapreps
                        + bootSearchString); // + getComDelim();
          else if (searchStyle == SYMSEARCH)
            commands +=
                getTNTCommand(
                    "resample sym cut 50 "
                        + saveTreesString
                        + " replications "
                        + bootstrapreps
                        + bootSearchString); // + getComDelim();
          else if (searchStyle == POISSONSEARCH)
            commands +=
                getTNTCommand(
                    "resample poisson cut 50 "
                        + saveTreesString
                        + " replications "
                        + bootstrapreps
                        + bootSearchString); // + getComDelim();
        }
        if (!resamplingAllConsensusTrees) commands += getTNTCommand("save *");
        else commands += getTNTCommand("save");
        commands += getTNTCommand("tsave/");
        if (!resamplingAllConsensusTrees) {
          commands += getTNTCommand("ttags -/");
          commands += getTNTCommand("macro-");
        }
      }

      // commands += getTNTCommand("proc/") ;

      commands += getTNTCommand("log/");

      //	if (!parallel)
      commands += getTNTCommand("quit");
    } else {
      // commands += getTNTCommand("tsave !5 " + treeFileName) ;   // if showing intermediate trees
      commands += getTNTCommand("tsave *" + treeFileName);
      if (StringUtil.notEmpty(searchScriptPath)) {
        String script = MesquiteFile.getFileContentsAsString(searchScriptPath);
        if (StringUtil.notEmpty(script)) commands += script;
      } else commands += searchArguments;
      commands += otherOptions;
      if (harvestOnlyStrictConsensus) commands += getTNTCommand("nelsen *");
      commands += getTNTCommand("save");
      commands += getTNTCommand("log/");

      commands += getTNTCommand("tsave/");
      commands += getTNTCommand("quit");
    }
  }
コード例 #14
0
 /*.................................................................................................................*/
 String getComDelim() {
   if (externalProcRunner.isWindows()) return ";" + StringUtil.lineEnding();
   else return ";" + StringUtil.lineEnding();
 }
コード例 #15
0
  public void runFilesAvailable(int fileNum) {
    String[] logFileNames = getLogFileNames();
    if ((progIndicator != null && progIndicator.isAborted()) || logFileNames == null) return;
    String[] outputFilePaths = new String[logFileNames.length];
    outputFilePaths[fileNum] = externalProcRunner.getOutputFilePath(logFileNames[fileNum]);
    String filePath = outputFilePaths[fileNum];

    if (fileNum == 0
        && outputFilePaths.length > 0
        && !StringUtil.blank(outputFilePaths[0])
        && !bootstrapOrJackknife()) { // tree file
      if (ownerModule instanceof NewTreeProcessor) {
        String treeFilePath = filePath;
        if (taxa != null) {
          TaxaSelectionSet outgroupSet =
              (TaxaSelectionSet) taxa.getSpecsSet(outgroupTaxSetString, TaxaSelectionSet.class);
          ((NewTreeProcessor) ownerModule).newTreeAvailable(treeFilePath, outgroupSet);

        } else ((NewTreeProcessor) ownerModule).newTreeAvailable(treeFilePath, null);
      }
    } else if (fileNum == 1
        && outputFilePaths.length > 1
        && !StringUtil.blank(outputFilePaths[1])
        && !bootstrapOrJackknife()) { // log file
      if (MesquiteFile.fileExists(filePath)) {
        String s = MesquiteFile.getFileLastContents(filePath);
        if (!StringUtil.blank(s))
          if (progIndicator != null) {
            parser.setString(s);
            String rep = parser.getFirstToken(); // generation number
            logln("");
            if (MesquiteInteger.isNumber(rep)) {
              int numReps = MesquiteInteger.fromString(rep) + 1;
              progIndicator.setText(
                  "Replicate: " + numReps); // + ", ln L = " + parser.getNextToken());
              if (bootstrapOrJackknife()) {
                logln("Replicate " + numReps + " of " + bootstrapreps);
              }
              logln("Replicate " + numReps + " of " + totalNumHits);

              progIndicator.spin();
              double timePerRep = 0;
              if (MesquiteInteger.isCombinable(numReps) && numReps > 0) {
                timePerRep = timer.timeSinceVeryStartInSeconds() / numReps; // this is time per rep
              }
              int timeLeft = 0;
              if (bootstrapOrJackknife()) {
                timeLeft = (int) ((bootstrapreps - numReps) * timePerRep);
              } else {
                String token = parser.getNextToken(); // algorithm
                token = parser.getNextToken(); // Tree
                token = parser.getNextToken(); // Score
                String best = parser.getNextToken(); // Best
                logln("  Score " + token + "; best found so far " + best);
                timeLeft = (int) ((totalNumHits - numReps) * timePerRep);
              }

              logln(
                  "  Running time so far "
                      + StringUtil.secondsToHHMMSS((int) timer.timeSinceVeryStartInSeconds())
                      + ", approximate time remaining "
                      + StringUtil.secondsToHHMMSS(timeLeft));
            }
          }
        count++;
      } else if (MesquiteTrunk.debugMode) logln("*** File does not exist (" + filePath + ") ***");
    }
  }
コード例 #16
0
  /** for those permitting editing, indicates user has edited to incoming string. */
  public void setString(int row, String s) {

    if (StringUtil.blank(s)) setNote(row, null);
    else if (s.equalsIgnoreCase("Yes") || s.equalsIgnoreCase("No Data")) return;
    else setNote(row, s);
  }
コード例 #17
0
  /*.................................................................................................................*/
  public Object doCommand(String commandName, String arguments, CommandChecker checker) {
    if (checker.compare(
        this.getClass(), "Returns the matrix source", null, commandName, "getMatrixSource")) {
      return matrixSourceTask;
    } else if (checker.compare(
        this.getClass(), "Copies the data for selected taxon", null, commandName, "copyData")) {
      if (observedStates == null) return null;
      CharacterData data = observedStates.getParentData();
      if (data == null) return null;
      int it = MesquiteInteger.fromString(parser.getFirstToken(arguments));
      if (MesquiteInteger.isCombinable(it)) {
        StringBuffer sb = new StringBuffer();
        data.copyDataFromRowIntoBuffer(it, sb);
        if (StringUtil.notEmpty(sb.toString())) {
          localCopyDataClipboard = sb.toString();
          localCopyData = data;
          localCopyDataTaxon = data.getTaxa().getTaxonName(it);
        } else {
          localCopyDataClipboard = null;
          localCopyData = null;
          localCopyDataTaxon = null;
        }
      }
      return null;
    } else if (checker.compare(
        this.getClass(), "Pastes the data for selected taxon", null, commandName, "pasteData")) {
      if (observedStates == null) return null;
      CharacterData data = observedStates.getParentData();
      if (data == null) return null;
      int it = MesquiteInteger.fromString(parser.getFirstToken(arguments));
      if (MesquiteInteger.isCombinable(it) && StringUtil.notEmpty(localCopyDataClipboard)) {
        data.pasteDataFromStringIntoTaxon(it, localCopyDataClipboard);
      }
      return null;
    } else if (checker.compare(
        this.getClass(),
        "Pastes the data for selected taxon",
        null,
        commandName,
        "deleteDataTouched")) {
      if (observedStates == null) return null;
      CharacterData data = observedStates.getParentData();
      if (data == null) return null;
      int it = MesquiteInteger.fromString(parser.getFirstToken(arguments));
      Debugg.println("prepare to delete row: " + it);
      if (MesquiteInteger.isCombinable(it)) {
        if (!AlertDialog.query(
            containerOfModule(),
            "Delete Data?",
            "Are you sure you want to delete the data for taxon "
                + data.getTaxa().getTaxonName(it)
                + " in the matrix \""
                + data.getName()
                + "\"",
            "No",
            "Yes")) {
          zapData(data, it);
        }
      }
      return null;
    } else if (checker.compare(
        this.getClass(), "Deletes the data for selected taxa", null, commandName, "deleteData")) {
      if (observedStates == null) return null;
      captureCharacterDataFromObservedStates();
      if (data == null) return null;
      if (!AlertDialog.query(
          containerOfModule(),
          "Delete Data?",
          "Are you sure you want to delete the data for these taxa in the matrix \""
              + data.getName()
              + "\"",
          "No",
          "Yes")) zapData(data);
      return null;
    } else if (checker.compare(
        this.getClass(),
        "deleteds () and anything between",
        null,
        commandName,
        "deletePrepended")) {
      if (observedStates == null || taxa == null) return null;
      boolean anySelected = taxa.anySelected();
      int myColumn = -1;
      if (getEmployer() instanceof ListModule) {

        myColumn = ((ListModule) getEmployer()).getMyColumn(this);
        if (table != null)
          anySelected = anySelected || table.anyCellSelectedInColumnAnyWay(myColumn);
      }

      for (int it = 0; it < taxa.getNumTaxa(); it++) {
        if ((!anySelected || selected(taxa, it, myColumn))) {
          String note = getNote(it);
          while (!StringUtil.blank(note) && note.indexOf("(") >= 0) {
            int start = note.indexOf("(");
            int end = note.indexOf(")");
            String firstBit = "";
            if (start > 0) firstBit = note.substring(0, start);
            note = firstBit + note.substring(end + 1, note.length());
          }
          setNote(it, note);
        }
      }
      outputInvalid();
      parametersChanged();
      return null;
    } else if (checker.compare(this.getClass(), "deletes *", null, commandName, "deleteStar")) {
      if (observedStates == null || taxa == null) return null;
      boolean anySelected = taxa.anySelected();
      int myColumn = -1;
      if (getEmployer() instanceof ListModule) {

        myColumn = ((ListModule) getEmployer()).getMyColumn(this);
        if (table != null)
          anySelected = anySelected || table.anyCellSelectedInColumnAnyWay(myColumn);
      }
      for (int it = 0; it < taxa.getNumTaxa(); it++) {
        if ((!anySelected || selected(taxa, it, myColumn))) {
          String note = getNote(it);
          while (!StringUtil.blank(note) && note.indexOf("*") >= 0) {
            int start = note.indexOf("*");
            String firstBit = "";
            if (start > 0) firstBit = note.substring(0, start);
            note = firstBit + note.substring(start + 1, note.length());
          }
          setNote(it, note);
        }
      }
      outputInvalid();
      parametersChanged();
      return null;
    } else if (checker.compare(
        this.getClass(),
        "Prepends to the note the sequence length (including N\'s and ?\'s) for the selected taxa",
        null,
        commandName,
        "prependLength")) {
      if (observedStates == null || taxa == null) return null;
      boolean anySelected = taxa.anySelected();
      int myColumn = -1;
      if (getEmployer() instanceof ListModule) {

        myColumn = ((ListModule) getEmployer()).getMyColumn(this);
        if (table != null)
          anySelected = anySelected || table.anyCellSelectedInColumnAnyWay(myColumn);
      }
      for (int it = 0; it < taxa.getNumTaxa(); it++) {
        if (hasData(it) && (!anySelected || selected(taxa, it, myColumn))) {
          String note = getNote(it);
          if (StringUtil.blank(note)) note = "(" + sequenceLength(it) + ")";
          else note = "(" + sequenceLength(it) + ") " + note;
          setNote(it, note);
        }
      }
      outputInvalid();
      parametersChanged();
      return null;
    } else if (checker.compare(
        this.getClass(),
        "Prepends to the note the number of non-missing sites (not including N\'s and ?\'s) for the selected taxa",
        null,
        commandName,
        "prependNumSites")) {
      if (observedStates == null || taxa == null) return null;
      boolean anySelected = taxa.anySelected();
      int myColumn = -1;
      if (getEmployer() instanceof ListModule) {

        myColumn = ((ListModule) getEmployer()).getMyColumn(this);
        if (table != null)
          anySelected = anySelected || table.anyCellSelectedInColumnAnyWay(myColumn);
      }
      for (int it = 0; it < taxa.getNumTaxa(); it++) {
        if (hasData(it) && (!anySelected || selected(taxa, it, myColumn))) {
          String note = getNote(it);
          if (StringUtil.blank(note)) note = "(" + numSites(it) + ")";
          else note = "(" + numSites(it) + ") " + note;
          setNote(it, note);
        }
      }
      outputInvalid();
      parametersChanged();
      return null;
    } else if (checker.compare(
        this.getClass(),
        "Deletes the notes for the selected taxa",
        null,
        commandName,
        "deleteAnnotation")) {
      if (observedStates == null || taxa == null) return null;
      boolean anySelected = taxa.anySelected();
      int myColumn = -1;
      if (getEmployer() instanceof ListModule) {

        myColumn = ((ListModule) getEmployer()).getMyColumn(this);
        if (table != null)
          anySelected = anySelected || table.anyCellSelectedInColumnAnyWay(myColumn);
      }
      for (int it = 0; it < taxa.getNumTaxa(); it++) {
        if (hasData(it) && (!anySelected || selected(taxa, it, myColumn))) {
          setNote(it, null);
        }
      }
      outputInvalid();
      parametersChanged();
      return null;
    } else return super.doCommand(commandName, arguments, checker);
  }