Exemple #1
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();
  }
Exemple #2
0
 public void setValueAt(Object aValue, int row, int col) {
   //            PartitionData partition = options.getPartitionDataNoSpecies().get(row);
   PartitionData partition = options.getNonTraitsDataList().get(row);
   switch (col) {
     case 0:
       String name = ((String) aValue).trim();
       if (name.length() > 0) {
         partition.setName(name);
       }
       break;
     case 5:
       //                    partition.setPloidyType((PloidyType) aValue);
       //                    break;
       //                case 6:
       partition.setPartitionSubstitutionModel((PartitionSubstitutionModel) aValue);
       break;
     case 6:
       partition.setPartitionClockModel((PartitionClockModel) aValue);
       break;
     case 7:
       partition.setPartitionTreeModel((PartitionTreeModel) aValue);
       break;
   }
   fireDataChanged();
 }
Exemple #3
0
  public void linkClocks() { // keep previous PartitionTreePrior for reuse
    int[] selRows = dataTable.getSelectedRows();

    List<PartitionData> selectedPartitionData = new ArrayList<PartitionData>();
    for (int row : selRows) {
      PartitionData partition = options.dataPartitions.get(row);

      if (!selectedPartitionData.contains(partition)) selectedPartitionData.add(partition);
    }
    Object[] modelArray = options.getPartitionClockModels(selectedPartitionData).toArray();

    if (selectClockDialog == null) {
      selectClockDialog = new SelectClockDialog(frame);
    }

    int result = selectClockDialog.showDialog(modelArray);
    if (result != JOptionPane.CANCEL_OPTION) {
      PartitionClockModel model = selectClockDialog.getModel();
      if (selectClockDialog.getMakeCopy()) {
        model.setName(selectClockDialog.getName());
      }

      for (PartitionData partition : selectedPartitionData) {
        partition.setPartitionClockModel(model);
      }
    }

    modelsChanged();

    fireDataChanged();
    repaint();
  }
Exemple #4
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);
   }
 }
Exemple #5
0
  public void linkTrees() { // keep previous PartitionTreePrior for reuse
    int[] selRows = dataTable.getSelectedRows();

    List<PartitionData> selectedPartitionData = new ArrayList<PartitionData>();
    for (int row : selRows) {
      PartitionData partition = options.dataPartitions.get(row);

      if (!selectedPartitionData.contains(partition)) selectedPartitionData.add(partition);
    }

    if (options.allowDifferentTaxa) { // BEAST cannot handle multi <taxa> ref for 1 tree
      if (selectedPartitionData.size() > 1) {
        if (!options.validateDiffTaxa(selectedPartitionData)) {
          JOptionPane.showMessageDialog(
              this,
              "To accommodate different taxa for each partition trees cannot be linked.",
              "Illegal Configuration",
              JOptionPane.ERROR_MESSAGE);
          return;
        }
      }
    }

    Object[] treeArray = options.getPartitionTreeModels(selectedPartitionData).toArray();

    if (selectTreeDialog == null) {
      selectTreeDialog = new SelectTreeDialog(frame);
    }

    int result = selectTreeDialog.showDialog(treeArray);
    if (result != JOptionPane.CANCEL_OPTION) {
      PartitionTreeModel model = selectTreeDialog.getTree();
      if (selectTreeDialog.getMakeCopy()) {
        model.setName(selectTreeDialog.getName());
      }
      PartitionTreePrior prior = model.getPartitionTreePrior();
      options.linkTreePriors(prior);

      for (PartitionData partition : selectedPartitionData) {
        partition.setPartitionTreeModel(model);
      }
    }

    modelsChanged();

    fireDataChanged();
    options.taxonSets.clear();
    options.taxonSetsMono.clear();
    repaint();
  }
Exemple #6
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();
  }
Exemple #7
0
  public void linkModels() {
    int[] selRows = dataTable.getSelectedRows();
    List<PartitionData> selectedPartitionData = new ArrayList<PartitionData>();
    DataType dateType = null;
    for (int row : selRows) {
      PartitionData partition = options.dataPartitions.get(row);
      if (dateType == null) {
        dateType = partition.getPartitionSubstitutionModel().getDataType();
      } else {
        if (partition.getPartitionSubstitutionModel().getDataType() != dateType) {
          JOptionPane.showMessageDialog(
              this,
              "Can only link the models for data partitions \n"
                  + "of the same data type (e.g., nucleotides)",
              "Unable to link models",
              JOptionPane.ERROR_MESSAGE);
        }
      }

      if (!selectedPartitionData.contains(partition)) selectedPartitionData.add(partition);
    }

    Object[] modelArray =
        options.getPartitionSubstitutionModels(dateType, selectedPartitionData).toArray();

    if (selectModelDialog == null) {
      selectModelDialog = new SelectModelDialog(frame);
    }

    int result = selectModelDialog.showDialog(modelArray);
    if (result != JOptionPane.CANCEL_OPTION) {
      PartitionSubstitutionModel model = selectModelDialog.getModel();
      if (selectModelDialog.getMakeCopy()) {
        model.setName(selectModelDialog.getName());
      }

      for (PartitionData partition : selectedPartitionData) {
        partition.setPartitionSubstitutionModel(model);
      }
    }

    modelsChanged();

    fireDataChanged();
    repaint();
  }
Exemple #8
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();
  }
Exemple #9
0
  private void showAlignment() {

    int[] selRows = dataTable.getSelectedRows();
    for (int row : selRows) {
      JFrame frame = new JFrame();
      frame.setSize(800, 600);

      PartitionData partition = options.dataPartitions.get(row);
      Alignment alignment = partition.getAlignment();

      // alignment == null if partition is trait
      // http://code.google.com/p/beast-mcmc/issues/detail?id=343
      if (alignment == null) {
        JOptionPane.showMessageDialog(
            this,
            "Cannot display traits currently. Use the traits panel to view and edit these.",
            "Illegal Argument Exception",
            JOptionPane.ERROR_MESSAGE);
        return;
      }

      AlignmentViewer viewer = new AlignmentViewer();
      if (alignment.getDataType().getType() == DataType.NUCLEOTIDES) {
        viewer.setCellDecorator(new StateCellDecorator(new NucleotideDecorator(), false));
      } else if (alignment.getDataType().getType() == DataType.AMINO_ACIDS) {
        viewer.setCellDecorator(new StateCellDecorator(new AminoAcidDecorator(), false));
      } else {
        // no colouring
      }
      viewer.setAlignmentBuffer(new BeautiAlignmentBuffer(alignment));

      JPanel panel = new JPanel(new BorderLayout());
      panel.setOpaque(false);
      panel.add(viewer, BorderLayout.CENTER);

      JPanel infoPanel = new JPanel(new BorderLayout());
      infoPanel.setOpaque(false);
      panel.add(infoPanel, BorderLayout.SOUTH);

      frame.setContentPane(panel);
      frame.setVisible(true);
    }
  }