Exemplo n.º 1
0
  /*................................................................................................*/
  private boolean hireFillers(String directoryPath) {
    String[] files = directory.list();
    String treePath;
    for (int i = 0; i < files.length; i++) {
      if (files[i] != null) {
        String fileLowerCase = files[i].toLowerCase();
        if (fileLowerCase.endsWith(".nex") || fileLowerCase.endsWith(".nexus")) {
          treePath = directoryPath + MesquiteFile.fileSeparator + files[i];
          File treeFile = new File(treePath);
          String treeFileName = treeFile.getName();
          if (StringUtil.blank(treeFileName)) {
            return false;
          }
          TreeBlockFiller newFiller;
          newFiller =
              (TreeBlockFiller)
                  hireNamedEmployee(TreeBlockFiller.class, "#SampleOneTreeFromFile"); // treePath);
          if (newFiller != null) {
            if (((SampleOneTreeFromFile) newFiller).setFilePath(treePath)
                && ((SampleOneTreeFromFile) newFiller).processFile()) {
              fillerTasks.addElement(newFiller);
            } else
              Debugg.println(
                  "Filler "
                      + i
                      + " processFile = "
                      + ((SampleOneTreeFromFile) newFiller).processFile());
          }
        }
      }
    }

    return true;
  }
  /*.................................................................................................................*/
  public void getResults(HttpClient httpclient, String jobURL) {

    String resultsUri = getResultsDirectory(jobURL);
    if (StringUtil.notEmpty(resultsUri)) {
      Document cipresResponseDoc = cipresQuery(httpclient, resultsUri, "results");
      if (cipresResponseDoc != null) {
        CipresJobFile[] cipresJobFiles = processFilesDocument(cipresResponseDoc);
        for (int job = 0; job < cipresJobFiles.length; job++) {
          Debugg.println("fileName: " + cipresJobFiles[job].getFileName());
          Debugg.println("     downloadURL: " + cipresJobFiles[job].getDownloadURL());
          Debugg.println("     downloadTitle: " + cipresJobFiles[job].getDownloadTitle());
          Debugg.println("     length: " + cipresJobFiles[job].getLength());
        }
        previousCipresJobFiles = cipresJobFiles.clone();
      }
    }
  }
Exemplo n.º 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);
  }
  /*.................................................................................................................*/
  void getArguments(
      MultipartEntityBuilder builder,
      StringBuffer sb,
      String fileName,
      String LOCproteinModel,
      String LOCdnaModel,
      String LOCotherOptions,
      int LOCbootstrapreps,
      int LOCbootstrapSeed,
      int LOCnumRuns,
      String LOCoutgroupTaxSetString,
      String LOCMultipleModelFile,
      boolean preflight) {
    if (builder == null) return;
    /*
    if (preflight)
    	arguments += " -n preflight.out ";
    else
    	arguments += " -s " + fileName + " -n file.out ";
    */

    if (isProtein) {
      if (StringUtil.blank(LOCproteinModel))
        addArgument(builder, sb, "vparam.protein_opts_", "PROTGAMMAJTT");
      else addArgument(builder, sb, "vparam.protein_opts_", LOCproteinModel);
    } else if (StringUtil.blank(LOCdnaModel))
      addArgument(builder, sb, "vparam.dna_gtrcat_", "GTRGAMMA");
    else addArgument(builder, sb, "vparam.dna_gtrcat_", "GTRGAMMA");
    //	builder.addTextBody("vparam.dna_gtrcat_",LOCdnaModel);

    /*
    		if (StringUtil.notEmpty(LOCMultipleModelFile))
    			arguments += " -q " + ShellScriptUtil.protectForShellScript(LOCMultipleModelFile);

    		if (!StringUtil.blank(LOCotherOptions))
    			arguments += " " + LOCotherOptions;

    */

    addArgument(builder, sb, "vparam.provide_parsimony_seed_", "1");
    addArgument(builder, sb, "vparam.parsimony_seed_val_", "" + randomIntSeed);

    if (bootstrapOrJackknife()) {
      if (LOCbootstrapreps > 0) {
        addArgument(builder, sb, "vparam.choose_bootstrap_", "b");
        addArgument(builder, sb, "vparam.bootstrap_value_", "" + LOCbootstrapreps);
        addArgument(builder, sb, "vparam.seed_value_", "" + LOCbootstrapSeed);
        //	addArgument(builder, sb, "vparam.bootstrap_",""+LOCbootstrapreps);
        //	addArgument(builder, sb, "vparam.mulparambootstrap_seed_",""+LOCbootstrapSeed);
      } else Debugg.println("TOO FEW BOOTSTRAP REPS");

    } else {
      addArgument(builder, sb, "vparam.specify_runs_", "1");
      addArgument(builder, sb, "vparam.altrun_number_", "" + LOCnumRuns);
      //	if (RAxML814orLater)
      // addArgument(builder, sb, "vparam.mesquite_output_","1");
    }

    TaxaSelectionSet outgroupSet = null;
    if (!StringUtil.blank(LOCoutgroupTaxSetString)) {
      outgroupSet =
          (TaxaSelectionSet) taxa.getSpecsSet(LOCoutgroupTaxSetString, TaxaSelectionSet.class);
      if (outgroupSet != null)
        addArgument(builder, sb, "vparam.outgroup_", outgroupSet.getStringList(",", true));
      arguments += " -o " + outgroupSet.getStringList(",", true);
    }
  }