예제 #1
0
 public static boolean checkNoContigAceFiles(CharacterData data, MesquiteModule ownerModule) {
   DNAData editedData = ChromaseqUtil.getEditedData(data);
   if (editedData == null) return false;
   int count = 0;
   boolean resave = false;
   boolean warn = false;
   for (int it = 0; it < editedData.getNumTaxa(); it++)
     if (AceFile.hasAceFilePath(editedData, it)) {
       if (!AceFile.hasAceFile(ownerModule, editedData, it)) {}
       AceFile ace = AceFile.getAceFile(ownerModule, editedData, it);
       if (ace != null) {
         if (ace.getNumContigs() <= 0 || ace.getContig(0).getNumBases() == 0) {
           if (!warn
               && !AlertDialog.query(
                   ownerModule.containerOfModule(),
                   "Reprocess and save file?",
                   "Some of the contigs need to be reprocessed, which will"
                       + " alter the modified .ace files produced by Phrap and Chromaseq.  To be compatible with these altered .ace files, the Mesquite file "
                       + "would then need to be re-saved. If instead you choose not to reprocess contigs, they will not be fully editable in Chromaseq.",
                   "Reprocess and Save",
                   "Do not reprocess",
                   -1)) {
             return false;
           } else resave = true;
           warn = true;
           ChromaseqUtil.setReprocessContig(editedData, it);
         }
       }
       count++;
     }
   return resave;
 }
  /*.................................................................................................................*/
  public boolean queryOptions() {
    if (!MesquiteThread.isScripting()) {

      duplicateExcludedCharacters =
          !AlertDialog.query(
              containerOfModule(),
              "Remove excluded characters?",
              "Remove excluded characters?",
              "Yes",
              "No");
    }
    return true;
  }
예제 #3
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);
  }