示例#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();
  }
示例#2
0
  public void removeSelection() {
    int[] selRows = dataTable.getSelectedRows();
    Set<PartitionData> partitionsToRemove = new HashSet<PartitionData>();
    for (int row : selRows) {
      partitionsToRemove.add(options.dataPartitions.get(row));
    }

    // TODO: would probably be a good idea to check if the user wants to remove the last partition
    options.dataPartitions.removeAll(partitionsToRemove);

    //        if (options.allowDifferentTaxa && options.dataPartitions.size() < 2) {
    //            uncheckAllowDifferentTaxa();
    //        }

    if (options.getNonTraitsDataList().size() == 0) {
      // all data partitions removed so reset the taxa
      options.reset();
      useStarBEASTCheck.setSelected(false);
      frame.statusLabel.setText("");
      frame.setAllOptions();
      frame.getExportAction().setEnabled(false);
    }

    dataTableModel.fireTableDataChanged();

    fireDataChanged();
  }
示例#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();
  }
示例#4
0
  public void removeSelection() {
    int[] selRows = dataTable.getSelectedRows();
    Set<AbstractPartitionData> partitionsToRemove = new HashSet<AbstractPartitionData>();
    for (int row : selRows) {
      partitionsToRemove.add(options.dataPartitions.get(row));
    }

    boolean hasIdenticalTaxa =
        options.hasIdenticalTaxa(); // need to check this before removing partitions

    // TODO: would probably be a good idea to check if the user wants to remove the last partition
    options.dataPartitions.removeAll(partitionsToRemove);

    if (options.dataPartitions.size() == 0) {
      // all data partitions removed so reset the taxa
      options.reset();
      useStarBEASTCheck.setSelected(false);
      frame.setupStarBEAST(false);
      frame.statusLabel.setText("");
      frame.setAllOptions();
      frame.getExportAction().setEnabled(false);
    } else if (!hasIdenticalTaxa) {
      options.updateTaxonList();
    }

    dataTableModel.fireTableDataChanged();

    fireDataChanged();
  }
示例#5
0
  public void linkTrees() { // keep previous PartitionTreePrior for reuse
    int[] selRows = dataTable.getSelectedRows();

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

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

    if (selectedPartitionData.size() > 1) {
      if (!options.hasIdenticalTaxa(selectedPartitionData)) {
        String errMsg = "To share a tree, partitions need to have identical taxa.";
        if (selectedPartitionData.get(0).getDataType().getType() == DataType.MICRO_SAT)
          errMsg += "\nThe data must be all diploid or all haploid when you want to link the tree.";
        JOptionPane.showMessageDialog(
            this, errMsg, "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 (AbstractPartitionData partition : selectedPartitionData) {
        partition.setPartitionTreeModel(model);
      }

      for (Taxa taxa :
          options.taxonSets) { // Issue 454: all the taxon sets are deleted when link/unlink tree
        PartitionTreeModel prevModel = options.taxonSetsTreeModel.get(taxa);
        if (prevModel != model) options.taxonSetsTreeModel.put(taxa, model);
      }
    }

    modelsChanged();

    fireDataChanged();
    repaint();
  }
示例#6
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();
  }
示例#7
0
  public void linkModels() {
    int[] selRows = dataTable.getSelectedRows();
    List<AbstractPartitionData> selectedPartitionData = new ArrayList<AbstractPartitionData>();
    DataType dateType = null;
    for (int row : selRows) {
      AbstractPartitionData partition = options.dataPartitions.get(row);
      if (dateType == null) {
        dateType = partition.getDataType();
      } else {
        if (partition.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);
          return;
        }
      }

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

    Object[] modelArray = options.getPartitionSubstitutionModels(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 (AbstractPartitionData partition : selectedPartitionData) {
        partition.setPartitionSubstitutionModel(model);
      }
    }

    if (options.getPartitionSubstitutionModels(Microsatellite.INSTANCE).size() <= 1) {
      options.shareMicroSat = true;
    }

    modelsChanged();

    fireDataChanged();
    repaint();
  }
示例#8
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();
  }
示例#9
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();
  }
示例#10
0
  public void selectionChanged() {
    int[] selRows = dataTable.getSelectedRows();
    boolean hasSelection = (selRows != null && selRows.length != 0);
    frame.dataSelectionChanged(hasSelection);

    boolean canUnlink = options.dataPartitions.size() > 1 && hasSelection;
    boolean canLink = options.dataPartitions.size() > 1 && hasSelection && selRows.length > 1;

    unlinkModelsAction.setEnabled(canUnlink);
    linkModelsAction.setEnabled(canLink);

    unlinkClocksAction.setEnabled(canUnlink);
    linkClocksAction.setEnabled(canLink);

    unlinkTreesAction.setEnabled(canUnlink);
    linkTreesAction.setEnabled(canLink);
  }
示例#11
0
  private void showAlignment() {

    int[] selRows = dataTable.getSelectedRows();
    for (int row : selRows) {
      AbstractPartitionData partition = options.dataPartitions.get(row);
      Alignment alignment = null;

      if (partition instanceof PartitionData)
        alignment = ((PartitionData) partition).getAlignment();

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

      JFrame frame = new JFrame();
      frame.setSize(800, 600);

      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);
    }
  }