Пример #1
0
  public int showDialog() {
    panel = new JPanel(new GridBagLayout());

    double lower = Double.NEGATIVE_INFINITY;
    double upper = Double.POSITIVE_INFINITY;

    if (parameter.isZeroOne) {
      lower = 0.0;
      upper = 1.0;
    } else if (parameter.isNonNegative) {
      lower = 0.0;
    }

    panel = new JPanel(new GridBagLayout());

    setupComponents();

    JOptionPane optionPane =
        new JOptionPane(
            panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));

    final JDialog dialog = optionPane.createDialog(frame, "Linked Parameter Setup");

    priorSettingsPanel.setDialog(dialog);
    priorSettingsPanel.setParameter(parameter);

    if (OSType.isMac()) {
      dialog.setMinimumSize(new Dimension(dialog.getBounds().width, 300));
    } else {
      Toolkit tk = Toolkit.getDefaultToolkit();
      Dimension d = tk.getScreenSize();
      if (d.height < 700 && panel.getHeight() > 450) {
        dialog.setSize(new Dimension(panel.getWidth() + 100, 550));
      } else {
        // setSize because optionsPanel is shrunk in dialog
        dialog.setSize(new Dimension(panel.getWidth() + 100, panel.getHeight() + 100));
      }

      //            System.out.println("panel width = " + panel.getWidth());
      //            System.out.println("panel height = " + panel.getHeight());
    }

    dialog.pack();
    dialog.setResizable(true);
    dialog.setVisible(true);

    int result = JOptionPane.CANCEL_OPTION;
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value != -1) {
      result = value;
    }

    return result;
  }
Пример #2
0
 public MapperMenuBarFactory() {
   if (OSType.isMac()) {
     registerMenuFactory(new MapperMacFileMenuFactory());
     registerMenuFactory(new DefaultEditMenuFactory());
     registerMenuFactory(new MacWindowMenuFactory());
     registerMenuFactory(new MacHelpMenuFactory());
   } else {
     registerMenuFactory(new MapperDefaultFileMenuFactory());
     registerMenuFactory(new DefaultEditMenuFactory());
     registerMenuFactory(new DefaultHelpMenuFactory());
   }
 }
Пример #3
0
  public MCMCPanel(BeautiFrame parent) {
    setLayout(new BorderLayout());

    // Mac OS X components have more spacing round them already
    optionsPanel = new OptionsPanel(12, (OSType.isMac() ? 6 : 24));

    this.frame = parent;

    setOpaque(false);
    optionsPanel.setOpaque(false);

    chainLengthField.setValue(100000);
    chainLengthField.setColumns(10);
    optionsPanel.addComponentWithLabel("Length of chain:", chainLengthField);
    chainLengthField.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            options.chainLength = chainLengthField.getValue();
            frame.setDirty();
          }
        });

    optionsPanel.addSeparator();

    echoEveryField.setValue(1000);
    echoEveryField.setColumns(10);
    optionsPanel.addComponentWithLabel("Echo state to screen every:", echoEveryField);
    echoEveryField.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            options.echoEvery = echoEveryField.getValue();
            frame.setDirty();
          }
        });

    logEveryField.setValue(100);
    logEveryField.setColumns(10);
    optionsPanel.addComponentWithLabel("Log parameters every:", logEveryField);
    logEveryField.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            options.logEvery = logEveryField.getValue();
            frame.setDirty();
          }
        });

    optionsPanel.addSeparator();

    fileNameStemField.setColumns(32);
    optionsPanel.addComponentWithLabel("File name stem:", fileNameStemField);
    fileNameStemField.setEditable(true);
    fileNameStemField.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            options.fileNameStem = fileNameStemField.getText();
            updateOtherFileNames(options);
            frame.setDirty();
          }
        });

    optionsPanel.addComponent(addTxt);
    if (OSType.isWindows()) {
      addTxt.setSelected(true);
    } else {
      addTxt.setSelected(false);
    }
    addTxt.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent changeEvent) {
            setOptions(options);
            frame.setDirty();
          }
        });

    optionsPanel.addSeparator();

    logFileNameField.setColumns(32);
    optionsPanel.addComponentWithLabel("Log file name:", logFileNameField);
    logFileNameField.setEditable(false);

    //        optionsPanel.addComponent(allowOverwriteLogCheck);
    //        allowOverwriteLogCheck.setSelected(false);
    //        allowOverwriteLogCheck.addChangeListener(new ChangeListener() {
    //            public void stateChanged(ChangeEvent changeEvent) {
    //            	options.allowOverwriteLog = allowOverwriteLogCheck.isSelected();
    //            }
    //        });

    treeFileNameField.setColumns(32);
    optionsPanel.addComponentWithLabel("Trees file name:", treeFileNameField);
    treeFileNameField.setEditable(false);

    //        addComponent(mapTreeLogCheck);
    //        mapTreeLogCheck.setOpaque(false);
    //        mapTreeLogCheck.addActionListener(new java.awt.event.ActionListener() {
    //            public void actionPerformed(ActionEvent e) {
    //                mapTreeFileNameField.setEnabled(mapTreeLogCheck.isSelected());
    //            }
    //        });
    //
    //        mapTreeFileNameField.setColumns(32);
    //        addComponentWithLabel("MAP tree file name:", mapTreeFileNameField);

    optionsPanel.addComponent(substTreeLogCheck);
    substTreeLogCheck.setOpaque(false);
    substTreeLogCheck.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            options.substTreeLog = substTreeLogCheck.isSelected();
            updateTreeFileNameList();
            substTreeFileNameField.setEnabled(substTreeLogCheck.isSelected());
            if (substTreeLogCheck.isSelected()) {
              substTreeFileNameField.setText(displayTreeList(options.substTreeFileName));
            } else {
              substTreeFileNameField.setText("");
            }

            frame.setDirty();
          }
        });

    substTreeFileNameField.setColumns(32);
    substTreeFileNameField.setEditable(false);
    substTreeFileNameField.setEnabled(false);
    optionsPanel.addComponentWithLabel("Substitutions trees file name:", substTreeFileNameField);

    optionsPanel.addComponent(operatorAnalaysisCheck);
    operatorAnalaysisCheck.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            options.operatorAnalysis = operatorAnalaysisCheck.isSelected();

            updateOtherFileNames(options);

            frame.setDirty();
          }
        });

    operatorAnalaysisFileNameField.setColumns(32);
    operatorAnalaysisFileNameField.setEditable(false);
    operatorAnalaysisFileNameField.setEnabled(false);
    optionsPanel.addComponentWithLabel(
        "Operator analysis file name:", operatorAnalaysisFileNameField);

    optionsPanel.addSeparator();

    optionsPanel.addComponent(samplePriorCheckBox);
    samplePriorCheckBox.setOpaque(false);
    samplePriorCheckBox.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent changeEvent) {
            frame.setDirty();
          }
        });

    //        logFileNameField.addKeyListener(listener);
    //        treeFileNameField.addKeyListener(listener);
    // mapTreeFileNameField.addKeyListener(listener);
    //        substTreeFileNameField.addKeyListener(listener);

    //        optionsPanel.setPreferredSize(new java.awt.Dimension(500, 600));

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

    JScrollPane scrollPane =
        new JScrollPane(
            panel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setOpaque(false);
    scrollPane.setBorder(null);
    scrollPane.getViewport().setOpaque(false);

    add(scrollPane, BorderLayout.CENTER);
  }
Пример #4
0
  public PartitionModelPanel(final PartitionSubstitutionModel partitionModel) {

    super(12, (OSType.isMac() ? 6 : 24));

    this.model = partitionModel;

    initCodonPartitionComponents();

    PanelUtils.setupComponent(nucSubstCombo);
    nucSubstCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setNucSubstitutionModel((NucModelType) nucSubstCombo.getSelectedItem());
          }
        });
    nucSubstCombo.setToolTipText("<html>Select the type of nucleotide substitution model.</html>");

    PanelUtils.setupComponent(aaSubstCombo);
    aaSubstCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            AminoAcidModelType type = (AminoAcidModelType) aaSubstCombo.getSelectedItem();
            model.setAaSubstitutionModel(type);
            citationText.setText(type.getCitation().toString());
          }
        });
    aaSubstCombo.setToolTipText("<html>Select the type of amino acid substitution model.</html>");

    PanelUtils.setupComponent(binarySubstCombo);
    binarySubstCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setBinarySubstitutionModel((BinaryModelType) binarySubstCombo.getSelectedItem());
            useAmbiguitiesTreeLikelihoodCheck.setSelected(
                binarySubstCombo.getSelectedItem() == BinaryModelType.BIN_COVARION);
            useAmbiguitiesTreeLikelihoodCheck.setEnabled(
                binarySubstCombo.getSelectedItem() != BinaryModelType.BIN_COVARION);
          }
        });
    binarySubstCombo.setToolTipText("<html>Select the type of binary substitution model.</html>");

    PanelUtils.setupComponent(useAmbiguitiesTreeLikelihoodCheck);
    useAmbiguitiesTreeLikelihoodCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setUseAmbiguitiesTreeLikelihood(useAmbiguitiesTreeLikelihoodCheck.isSelected());
          }
        });
    useAmbiguitiesTreeLikelihoodCheck.setToolTipText(
        "<html>Detemine useAmbiguities in &lt treeLikelihood &gt .</html>");

    PanelUtils.setupComponent(frequencyCombo);
    frequencyCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setFrequencyPolicy((FrequencyPolicyType) frequencyCombo.getSelectedItem());
          }
        });
    frequencyCombo.setToolTipText(
        "<html>Select the policy for determining the base frequencies.</html>");

    PanelUtils.setupComponent(heteroCombo);
    heteroCombo.setToolTipText(
        "<html>Select the type of site-specific rate<br>heterogeneity model.</html>");
    heteroCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {

            boolean gammaHetero =
                heteroCombo.getSelectedIndex() == 1 || heteroCombo.getSelectedIndex() == 3;

            model.setGammaHetero(gammaHetero);
            model.setInvarHetero(
                heteroCombo.getSelectedIndex() == 2 || heteroCombo.getSelectedIndex() == 3);

            if (gammaHetero) {
              gammaCatLabel.setEnabled(true);
              gammaCatCombo.setEnabled(true);
            } else {
              gammaCatLabel.setEnabled(false);
              gammaCatCombo.setEnabled(false);
            }

            if (codingCombo.getSelectedIndex() != 0) {
              heteroUnlinkCheck.setEnabled(heteroCombo.getSelectedIndex() != 0);
              heteroUnlinkCheck.setSelected(heteroCombo.getSelectedIndex() != 0);
            }
          }
        });

    PanelUtils.setupComponent(gammaCatCombo);
    gammaCatCombo.setToolTipText(
        "<html>Select the number of categories to use for<br>the discrete gamma rate heterogeneity model.</html>");
    gammaCatCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {

            model.setGammaCategories(gammaCatCombo.getSelectedIndex() + 4);
          }
        });

    setYang96Button = new JButton("Use Yang96 model");
    setYang96Button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            setYang96Model();
          }
        });
    PanelUtils.setupComponent(setYang96Button);
    setYang96Button.setToolTipText(
        "<html>Sets a 3 codon-position model with independent GTR and Gamma as described in<br>"
            + "Yang (1996) <i>J Mol Evol</i> <b>42</b>: 587–596. This model is named 3' in this paper.</html>");

    setSRD06Button = new JButton("Use SRD06 model");
    setSRD06Button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            setSRD06Model();
          }
        });
    PanelUtils.setupComponent(setSRD06Button);
    setSRD06Button.setToolTipText(
        "<html>Sets the SRD06 model as described in<br>"
            + "Shapiro, Rambaut & Drummond (2006) <i>MBE</i> <b>23</b>: 7-9.</html>");

    citationText = new JTextArea(1, 40);
    citationText.setLineWrap(true);
    citationText.setWrapStyleWord(true);
    citationText.setEditable(false);
    citationText.setFont(this.getFont());
    citationText.setOpaque(false);
    AminoAcidModelType type = (AminoAcidModelType) aaSubstCombo.getSelectedItem();
    citationText.setText(type.getCitation().toString());

    dolloCheck.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            if (dolloCheck.isSelected()) {
              binarySubstCombo.setSelectedIndex(0);
              binarySubstCombo.setEnabled(false);
              useAmbiguitiesTreeLikelihoodCheck.setSelected(true);
              useAmbiguitiesTreeLikelihoodCheck.setEnabled(false);
              frequencyCombo.setEnabled(false);
              frequencyCombo.setSelectedItem(FrequencyPolicyType.EMPIRICAL);
              heteroCombo.setSelectedIndex(0);
              heteroCombo.setEnabled(false);
              model.setBinarySubstitutionModel(BinaryModelType.BIN_DOLLO);
              model.setDolloModel(true);
              DolloComponentOptions comp =
                  (DolloComponentOptions)
                      model.getOptions().getComponentOptions(DolloComponentOptions.class);
              comp.createParameters(model.getOptions());
              comp.setActive(true);

            } else {
              binarySubstCombo.setEnabled(true);
              useAmbiguitiesTreeLikelihoodCheck.setEnabled(true);
              frequencyCombo.setEnabled(true);
              heteroCombo.setEnabled(true);
              model.setBinarySubstitutionModel(
                  (BinaryModelType) binarySubstCombo.getSelectedItem());
              model.setDolloModel(false);
            }
          }
        });

    PanelUtils.setupComponent(dolloCheck);
    //        dolloCheck.addChangeListener(new ChangeListener() {
    //            public void stateChanged(ChangeEvent e) {
    //                model.setDolloModel(true);
    //            }
    //        });
    dolloCheck.setEnabled(true);
    dolloCheck.setToolTipText(
        "<html>Activates a Stochastic Dollo model as described in<br>"
            + "Alekseyenko, Lee & Suchard (2008) <i>Syst Biol</i> <b>57</b>: 772-784.</html>");

    PanelUtils.setupComponent(discreteTraitSiteModelCombo);
    discreteTraitSiteModelCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setDiscreteSubstType(
                (DiscreteSubstModelType) discreteTraitSiteModelCombo.getSelectedItem());
          }
        });

    PanelUtils.setupComponent(continuousTraitSiteModelCombo);
    continuousTraitSiteModelCombo.setToolTipText(
        "<html>Select the model of continuous random walk, either homogenous<br>"
            + "or relaxed random walk (RRW) with a choice of distributions.</html>");
    continuousTraitSiteModelCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setContinuousSubstModelType(
                (ContinuousSubstModelType) continuousTraitSiteModelCombo.getSelectedItem());
          }
        });

    PanelUtils.setupComponent(latLongCheck);
    latLongCheck.setToolTipText(
        "<html>Specify whether this is a geographical trait representing <br>"
            + "latitude and longitude. Provides appropriate statistics to log file.</html>");

    latLongCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setIsLatitudeLongitude(latLongCheck.isSelected());
          }
        });
    latLongCheck.setEnabled(false);

    PanelUtils.setupComponent(useLambdaCheck);
    useLambdaCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            ContinuousComponentOptions component =
                (ContinuousComponentOptions)
                    model.getOptions().getComponentOptions(ContinuousComponentOptions.class);
            component.setUseLambda(model, useLambdaCheck.isSelected());
          }
        });
    useLambdaCheck.setToolTipText(
        "<html>Estimate degree of phylogenetic correlation in continuous traits using <br>"
            + "a tree transform. Inspired by Pagel (1999), described in Lemey et al (2013) <i>in prep</i></html>");

    PanelUtils.setupComponent(activateBSSVS);
    activateBSSVS.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setActivateBSSVS(activateBSSVS.isSelected());
          }
        });
    activateBSSVS.setToolTipText(
        "<html>Activates Bayesian stochastic search variable selection on the rates as described in<br>"
            + "Lemey, Rambaut, Drummond & Suchard (2009) <i>PLoS Computational Biology</i> <b>5</b>: e1000520</html>");

    // ============ micro-sat ================
    microsatName.setColumns(30);
    microsatName.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            model.getMicrosatellite().setName(microsatName.getText());
          }
        });
    microsatMax.setColumns(10);
    microsatMax.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            model.getMicrosatellite().setMax(Integer.parseInt(microsatMax.getText()));
          }
        });
    microsatMin.setColumns(10);
    microsatMin.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            model.getMicrosatellite().setMin(Integer.parseInt(microsatMin.getText()));
          }
        });

    PanelUtils.setupComponent(shareMicroSatCheck);
    shareMicroSatCheck.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            model.getOptions().shareMicroSat = shareMicroSatCheck.isSelected();
            if (shareMicroSatCheck.isSelected()) {
              model.getOptions().shareMicroSat();
            } else {
              model.getOptions().unshareMicroSat();
            }
            setOptions();
          }
        });

    PanelUtils.setupComponent(rateProportionCombo);
    rateProportionCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setRatePorportion(
                (MicroSatModelType.RateProportionality) rateProportionCombo.getSelectedItem());
          }
        });
    // rateProportionCombo.setToolTipText("<html>Select the type of microsatellite substitution
    // model.</html>");
    PanelUtils.setupComponent(mutationBiasCombo);
    mutationBiasCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setMutationBias(
                (MicroSatModelType.MutationalBias) mutationBiasCombo.getSelectedItem());
          }
        });
    PanelUtils.setupComponent(phaseCombo);
    phaseCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setPhase((MicroSatModelType.Phase) phaseCombo.getSelectedItem());
          }
        });

    setupPanel();
    setOpaque(false);
  }
Пример #5
0
  // Main entry point
  public static void main(String[] args) {

    if (args.length > 1) {

      if (args.length != 3) {
        System.err.println("Usage: beauti <input_file> <template_file> <output_file>");
        return;
      }

      String inputFileName = args[0];
      String templateFileName = args[1];
      String outputFileName = args[2];

      new CommandLineBeauti(inputFileName, templateFileName, outputFileName);

    } else {

      if (args.length == 1 && args[0].equalsIgnoreCase("-developer")) {
        developer = true;
      }

      if (OSType.isMac()) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("apple.awt.showGrowBox", "true");
        System.setProperty("apple.awt.graphics.UseQuartz", "true");
        UIManager.put("SystemFont", new Font("Lucida Grande", Font.PLAIN, 13));
        UIManager.put("SmallSystemFont", new Font("Lucida Grande", Font.PLAIN, 11));
      }

      try {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        java.net.URL url = BeautiApp.class.getResource("images/beauti.png");
        Icon icon = null;

        if (url != null) {
          icon = new ImageIcon(url);
        }

        final String nameString = "Old BEAUti";
        final String versionString = version.getVersionString();
        String aboutString =
            "<html><div style=\"font-family:sans-serif;\"><center>"
                + "<div style=\"font-size:12;\"><p>(Old) Bayesian Evolutionary Analysis Utility<br>"
                + "Version "
                + versionString
                + ", "
                + version.getDateString()
                + "</p>"
                + "<p>by Andrew Rambaut and Alexei J. Drummond</p></div>"
                + "<hr><div style=\"font-size:10;\">Part of the BEAST package:"
                + version.getHTMLCredits()
                + "</div></center></div></html>";

        String websiteURLString = "http://beast.bio.ed.ac.uk/";
        String helpURLString = "http://beast.bio.ed.ac.uk/BEAUti/";

        BeautiApp app =
            new BeautiApp(nameString, aboutString, icon, websiteURLString, helpURLString);
        app.setDocumentFrameFactory(
            new DocumentFrameFactory() {
              public DocumentFrame createDocumentFrame(
                  Application app, MenuBarFactory menuBarFactory) {
                return new BeautiFrame(nameString);
              }
            });
        app.initialize();
        app.doNew();
      } catch (Exception e) {
        JOptionPane.showMessageDialog(
            new JFrame(),
            "Fatal exception: " + e,
            "Please report this to the authors",
            JOptionPane.ERROR_MESSAGE);
        e.printStackTrace();
      }
    }
  }