Ejemplo n.º 1
0
 public Object getValueAt(int row, int col) {
   //            PartitionData partition = options.getPartitionDataNoSpecies().get(row);
   PartitionData partition = options.getNonTraitsDataList().get(row);
   switch (col) {
     case 0:
       return partition.getName();
     case 1:
       return partition.getFileName();
     case 2:
       return "" + partition.getTaxaCount();
     case 3:
       return "" + partition.getSiteCount(); // sequence length
     case 4:
       return partition.getDataType();
     case 5:
       //                    return partition.getPloidyType();
       //                case 6:
       return partition.getPartitionSubstitutionModel().getName();
     case 6:
       return partition.getPartitionClockModel().getName();
     case 7:
       return partition.getPartitionTreeModel().getName();
     default:
       throw new IllegalArgumentException("unknown column, " + col);
   }
 }
Ejemplo n.º 2
0
  public void unlinkTrees() { // reuse previous PartitionTreePrior
    int[] selRows = dataTable.getSelectedRows();
    for (int row : selRows) {
      PartitionData partition = options.dataPartitions.get(row);

      PartitionTreeModel model = partition.getPartitionTreeModel();
      if (!model.getName().equals(partition.getName())
          && partition.getTraitType() == null) { // not a trait
        PartitionTreeModel newTree = new PartitionTreeModel(options, partition);

        // this prevents partition not broken, and used for unsharing tree prior only,
        // because sharing uses shareSameTreePrior, unsharing uses getPartitionTreePrior
        //                newTree.setPartitionTreePrior(newPrior); // important

        partition.setPartitionTreeModel(newTree);
      }
    }

    options.linkTreePriors(frame.getCurrentPartitionTreePrior());

    modelsChanged();

    fireDataChanged();
    options.taxonSets.clear();
    options.taxonSetsMono.clear();
    repaint();
  }
Ejemplo n.º 3
0
  public void unlinkModels() {
    int[] selRows = dataTable.getSelectedRows();
    for (int row : selRows) {
      PartitionData partition = options.dataPartitions.get(row);

      PartitionSubstitutionModel model = partition.getPartitionSubstitutionModel();
      if (!model.getName().equals(partition.getName())) {
        PartitionSubstitutionModel newModel = new PartitionSubstitutionModel(options, partition);
        partition.setPartitionSubstitutionModel(newModel);
      }
    }

    modelsChanged();

    fireDataChanged();
    repaint();
  }
Ejemplo n.º 4
0
  public void unlinkClocks() { // reuse previous PartitionTreePrior
    int[] selRows = dataTable.getSelectedRows();
    for (int row : selRows) {
      PartitionData partition = options.dataPartitions.get(row);

      PartitionClockModel model = partition.getPartitionClockModel();
      if (!model.getName().equals(partition.getName())) {
        PartitionClockModel newModel = new PartitionClockModel(options, partition);
        partition.setPartitionClockModel(newModel);
      }
    }

    modelsChanged();

    fireDataChanged();
    repaint();
  }
Ejemplo n.º 5
0
  /**
   * write tree log to file
   *
   * @param writer XMLWriter
   */
  public void writeTreeLogToFile(XMLWriter writer) {
    writer.writeComment("write tree log to file");

    if (options.useStarBEAST) { // species
      // species tree log
      writer.writeOpenTag(
          TreeLoggerParser.LOG_TREE,
          new Attribute[] {
            new Attribute.Default<String>(
                XMLParser.ID, TraitData.TRAIT_SPECIES + "." + TREE_FILE_LOG), // speciesTreeFileLog
            new Attribute.Default<String>(TreeLoggerParser.LOG_EVERY, options.logEvery + ""),
            new Attribute.Default<String>(TreeLoggerParser.NEXUS_FORMAT, "true"),
            new Attribute.Default<String>(
                TreeLoggerParser.FILE_NAME,
                options.fileNameStem + "." + options.starBEASTOptions.SPECIES_TREE_FILE_NAME),
            new Attribute.Default<String>(TreeLoggerParser.SORT_TRANSLATION_TABLE, "true")
          });

      writer.writeIDref(SpeciesTreeModelParser.SPECIES_TREE, SP_TREE);

      if (options.hasData()) {
        // we have data...
        writer.writeIDref("posterior", "posterior");
      }
      writer.writeCloseTag(TreeLoggerParser.LOG_TREE);
    }

    // gene tree log
    // TODO make code consistent to MCMCPanel
    for (PartitionTreeModel tree : options.getPartitionTreeModels()) {
      String treeFileName;
      if (options.substTreeLog) {
        treeFileName =
            options.fileNameStem
                + "."
                + tree.getPrefix()
                + "(time)."
                + STARBEASTOptions.TREE_FILE_NAME;
      } else {
        treeFileName =
            options.fileNameStem
                + "."
                + tree.getPrefix()
                + STARBEASTOptions.TREE_FILE_NAME; // stem.partitionName.tree
      }

      if (options.treeFileName.get(0).endsWith(".txt")) {
        treeFileName += ".txt";
      }

      List<Attribute> attributes = new ArrayList<Attribute>();

      attributes.add(
          new Attribute.Default<String>(
              XMLParser.ID, tree.getPrefix() + TREE_FILE_LOG)); // partionName.treeFileLog
      attributes.add(
          new Attribute.Default<String>(TreeLoggerParser.LOG_EVERY, options.logEvery + ""));
      attributes.add(new Attribute.Default<String>(TreeLoggerParser.NEXUS_FORMAT, "true"));
      attributes.add(new Attribute.Default<String>(TreeLoggerParser.FILE_NAME, treeFileName));
      attributes.add(
          new Attribute.Default<String>(TreeLoggerParser.SORT_TRANSLATION_TABLE, "true"));

      // if (options.clockModelOptions.getRateOptionClockModel() == FixRateType.RElATIVE_TO &&
      // tree.containsUncorrelatedRelaxClock()) { //TODO: Sibon's discretized branch length stuff
      //    double aveFixedRate =
      // options.clockModelOptions.getSelectedRate(options.getPartitionClockModels());
      //    attributes.add(new Attribute.Default<String>(TreeLoggerParser.NORMALISE_MEAN_RATE_TO,
      // Double.toString(aveFixedRate)));
      // }

      // generate <logTree>
      writer.writeOpenTag(TreeLoggerParser.LOG_TREE, attributes);

      //            writer.writeOpenTag(TreeLoggerParser.LOG_TREE,
      //                    new Attribute[]{
      //                            new Attribute.Default<String>(XMLParser.ID, tree.getPrefix() +
      // TREE_FILE_LOG), // partionName.treeFileLog
      //                            new Attribute.Default<String>(TreeLoggerParser.LOG_EVERY,
      // options.logEvery + ""),
      //                            new Attribute.Default<String>(TreeLoggerParser.NEXUS_FORMAT,
      // "true"),
      //                            new Attribute.Default<String>(TreeLoggerParser.FILE_NAME,
      // treeFileName),
      //                            new
      // Attribute.Default<String>(TreeLoggerParser.SORT_TRANSLATION_TABLE, "true")
      //                    });

      writer.writeIDref(TreeModel.TREE_MODEL, tree.getPrefix() + TreeModel.TREE_MODEL);

      for (PartitionClockModel model :
          options.getPartitionClockModels(options.getAllPartitionData(tree))) {
        if (options.getAllPartitionData(model).get(0).getTraitType() == null) {
          switch (model.getClockType()) {
            case STRICT_CLOCK:
              writer.writeIDref(
                  StrictClockBranchRatesParser.STRICT_CLOCK_BRANCH_RATES,
                  model.getPrefix() + BranchRateModel.BRANCH_RATES);
              break;

            case UNCORRELATED_EXPONENTIAL:
            case UNCORRELATED_LOGNORMAL:
              writer.writeIDref(
                  DiscretizedBranchRatesParser.DISCRETIZED_BRANCH_RATES,
                  options.noDuplicatedPrefix(model.getPrefix(), tree.getPrefix())
                      + BranchRateModel.BRANCH_RATES);
              break;

            case RANDOM_LOCAL_CLOCK:
              writer.writeIDref(
                  RandomLocalClockModelParser.LOCAL_BRANCH_RATES,
                  model.getPrefix() + BranchRateModel.BRANCH_RATES);
              break;

            case AUTOCORRELATED_LOGNORMAL:
              writer.writeIDref(
                  ACLikelihoodParser.AC_LIKELIHOOD,
                  options.noDuplicatedPrefix(model.getPrefix(), tree.getPrefix())
                      + BranchRateModel.BRANCH_RATES);
              break;

            default:
              throw new IllegalArgumentException("Unknown clock model");
          }
        }
      }

      if (options.hasData()) {
        // we have data...
        writer.writeIDref("posterior", "posterior");
      }

      if (options.hasDiscreteIntegerTraitsExcludeSpecies()) {
        for (PartitionData partitionData :
            options.getAllPartitionData(
                tree)) { // Each TD except Species has one AncestralTreeLikelihood
          if (partitionData.getTraitType() != null
              && (!partitionData.getName().equalsIgnoreCase(TraitData.TRAIT_SPECIES.toString())))
            writer.writeIDref(
                AncestralStateTreeLikelihoodParser.RECONSTRUCTING_TREE_LIKELIHOOD,
                partitionData.getPrefix() + TreeLikelihoodParser.TREE_LIKELIHOOD);
        }
      }

      writer.writeCloseTag(TreeLoggerParser.LOG_TREE);
    } // end For loop

    generateInsertionPoint(ComponentGenerator.InsertionPoint.IN_TREES_LOG, writer);

    if (options.substTreeLog) {
      if (options.useStarBEAST) { // species
        // TODO: species sub tree
      }

      // gene tree
      for (PartitionTreeModel tree : options.getPartitionTreeModels()) {
        // write tree log to file
        writer.writeOpenTag(
            TreeLoggerParser.LOG_TREE,
            new Attribute[] {
              new Attribute.Default<String>(XMLParser.ID, tree.getPrefix() + SUB_TREE_FILE_LOG),
              new Attribute.Default<String>(TreeLoggerParser.LOG_EVERY, options.logEvery + ""),
              new Attribute.Default<String>(TreeLoggerParser.NEXUS_FORMAT, "true"),
              new Attribute.Default<String>(
                  TreeLoggerParser.FILE_NAME,
                  options.fileNameStem
                      + "."
                      + tree.getPrefix()
                      + "(subst)."
                      + STARBEASTOptions.TREE_FILE_NAME),
              new Attribute.Default<String>(
                  TreeLoggerParser.BRANCH_LENGTHS, TreeLoggerParser.SUBSTITUTIONS)
            });
        writer.writeIDref(TreeModel.TREE_MODEL, tree.getPrefix() + TreeModel.TREE_MODEL);

        for (PartitionClockModel model :
            options.getPartitionClockModels(options.getAllPartitionData(tree))) {
          if (options.getAllPartitionData(model).get(0).getTraitType() == null) {
            switch (model.getClockType()) {
              case STRICT_CLOCK:
                writer.writeIDref(
                    StrictClockBranchRatesParser.STRICT_CLOCK_BRANCH_RATES,
                    model.getPrefix() + BranchRateModel.BRANCH_RATES);
                break;

              case UNCORRELATED_EXPONENTIAL:
              case UNCORRELATED_LOGNORMAL:
                writer.writeIDref(
                    DiscretizedBranchRatesParser.DISCRETIZED_BRANCH_RATES,
                    options.noDuplicatedPrefix(model.getPrefix(), tree.getPrefix())
                        + BranchRateModel.BRANCH_RATES);
                break;

              case RANDOM_LOCAL_CLOCK:
                writer.writeIDref(
                    RandomLocalClockModelParser.LOCAL_BRANCH_RATES,
                    model.getPrefix() + BranchRateModel.BRANCH_RATES);
                break;

              case AUTOCORRELATED_LOGNORMAL:
                writer.writeIDref(
                    ACLikelihoodParser.AC_LIKELIHOOD,
                    options.noDuplicatedPrefix(model.getPrefix(), tree.getPrefix())
                        + BranchRateModel.BRANCH_RATES);
                break;

              default:
                throw new IllegalArgumentException("Unknown clock model");
            }
          }
        }

        writer.writeCloseTag(TreeLoggerParser.LOG_TREE);
      }
    }

    generateInsertionPoint(ComponentGenerator.InsertionPoint.AFTER_TREES_LOG, writer);
  }