Пример #1
0
  /*.................................................................................................................*/
  public boolean transformTree(AdjustableTree tree, MesquiteString resultString, boolean notify) {
    Taxa taxa = tree.getTaxa();
    // counting how many excluded
    int count = 0;
    for (int i = 0; i < taxa.getNumTaxa(); i++) {
      if (!tree.taxonInTree(i)) count++;
    }
    if (count == 0) {
      discreetAlert(
          "The tree contains all of the taxa available in the block of taxa.  There are none available to be added");
      return true;
    }
    // getting list of excluded
    ListableVector excluded = new ListableVector(count);
    count = 0;
    for (int i = 0; i < taxa.getNumTaxa(); i++) {
      if (!tree.taxonInTree(i)) {
        excluded.addElement(taxa.getTaxon(i), false);
      }
    }

    // presenting choice
    Listable[] toInclude =
        ListDialog.queryListMultiple(
            containerOfModule(),
            "Add taxa to tree",
            "Select taxa to be added to the tree",
            MesquiteString.helpString,
            "Add",
            false,
            excluded,
            null);
    if (toInclude == null || toInclude.length == 0) return true;

    for (int i = 0; i < toInclude.length; i++) {
      int taxon = taxa.whichTaxonNumber((Taxon) toInclude[i]);
      tree.graftTaxon(taxon, tree.getRoot(), false);
    }
    if (notify && tree instanceof Listened)
      ((Listened) tree)
          .notifyListeners(this, new Notification(MesquiteListener.BRANCHES_REARRANGED));
    return true;
  }
 public void calculateNumber(Taxon taxon, MesquiteNumber result, MesquiteString resultString) {
   if (result == null) return;
   clearResultAndLastResult(result);
   Taxa taxa = taxon.getTaxa();
   int it = taxa.whichTaxonNumber(taxon);
   if (taxa != currentTaxa || observedStates == null) {
     observedStates = matrixSourceTask.getCurrentMatrix(taxa);
     currentTaxa = taxa;
   }
   if (observedStates == null || !(observedStates.getParentData() instanceof DNAData)) return;
   DNAData data = (DNAData) observedStates.getParentData();
   int count = data.getAminoAcidNumbers(it, ProteinData.TER, countEvenIfOthers.getValue());
   if (result != null) result.setValue(count);
   if (resultString != null)
     resultString.setValue(
         "Number of stop codons in taxon " + observedStates.getName() + ": " + count);
   saveLastResult(result);
   saveLastResultString(resultString);
 }