Search in sources :

Example 6 with Parameter

use of dr.app.beauti.options.Parameter in project beast-mcmc by beast-dev.

the class SelectParametersDialog method showDialog.

public int showDialog(String message, List<Parameter> parameterList) {
    optionPanel.removeAll();
    if (message != null && !message.isEmpty()) {
        optionPanel.addSpanningComponent(new JLabel(message));
    }
    parameterCombo.removeAllItems();
    for (Parameter parameter : parameterList) {
        parameterCombo.addItem(parameter);
    }
    optionPanel.addComponentWithLabel("Parameter:", parameterCombo);
    JOptionPane optionPane = new JOptionPane(optionPanel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
    int result = JOptionPane.CANCEL_OPTION;
    final JDialog dialog = optionPane.createDialog(frame, "Add Parameter");
    dialog.pack();
    dialog.setVisible(true);
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value != -1) {
        result = value;
    }
    return result;
}
Also used : Parameter(dr.app.beauti.options.Parameter) EmptyBorder(javax.swing.border.EmptyBorder)

Example 7 with Parameter

use of dr.app.beauti.options.Parameter in project beast-mcmc by beast-dev.

the class HierarchicalPriorDialog method getArguments.

public void getArguments() {
    for (Parameter parameter : parameterList) {
        parameter.priorType = (PriorType) priorCombo.getSelectedItem();
    }
    // Get hyperpriors
    optionsPanels.get(PriorType.NORMAL_PRIOR).getArguments(parameter);
    optionsPanels.get(PriorType.GAMMA_PRIOR).getArguments(parameter);
}
Also used : Parameter(dr.app.beauti.options.Parameter)

Example 8 with Parameter

use of dr.app.beauti.options.Parameter in project beast-mcmc by beast-dev.

the class HierarchicalPriorDialog method setupComponents.

private void setupComponents() {
    panel.removeAll();
    JPanel mainPanel = new JPanel(new GridBagLayout());
    panel.add(mainPanel);
    OptionsPanel[] optionsPanel = new OptionsPanel[4];
    JPanel[] panel = new JPanel[4];
    for (int i = 0; i < 4; ++i) {
        optionsPanel[i] = new OptionsPanel(12, (OSType.isMac() ? 6 : 24));
        panel[i] = new JPanel(new FlowLayout(FlowLayout.CENTER));
        if (i > 1) {
            panel[i].setLayout(new BoxLayout(panel[i], BoxLayout.PAGE_AXIS));
        }
        panel[i].add(optionsPanel[i]);
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = i % 2;
        gbc.gridy = i / 2;
        mainPanel.add(panel[i], gbc);
    }
    optionsPanel[0].addComponent(new JLabel("Select HPM for parameters: "));
    OptionsPanel list = new OptionsPanel();
    list.setBackground(Color.WHITE);
    list.setOpaque(true);
    for (Parameter p : parameterList) {
        JLabel label = new JLabel("\t" + p.getName());
        label.setForeground(Color.DARK_GRAY);
        list.addSpanningComponent(label);
    }
    optionsPanel[0].addSpanningComponent(list);
    PriorType modelType;
    optionsPanel[1].addComponentWithLabel("Hierarchical Distribution: ", priorCombo);
    modelType = (PriorType) priorCombo.getSelectedItem();
    optionsPanel[1].addSeparator();
    String modelName = "untitled";
    nameField = new JTextField(modelName);
    nameField.setColumns(10);
    optionsPanel[1].addComponentWithLabel("Unique Name: ", nameField);
    optionsPanel[2].addSeparator();
    optionsPanel[3].addSeparator();
    optionsPanel[2].addSpanningComponent(new JLabel("Population Mean Hyperprior: Normal"));
    optionsPanel[3].addSpanningComponent(new JLabel("Population Precision Hyperprior: Gamma"));
    optionsPanel[2].addSpanningComponent(optionsPanels.get(PriorType.NORMAL_PRIOR));
    optionsPanel[3].addSpanningComponent(optionsPanels.get(PriorType.GAMMA_PRIOR));
    optionsPanel[2].addSeparator();
    optionsPanel[3].addSeparator();
    setupChart();
    for (int i = 0; i < 2; ++i) {
        chart[i].setPreferredSize(new Dimension(300, 200));
        chart[i].setFontSize(8);
        panel[2 + i].add(chart[i]);
        panel[2 + i].add(quantilePanel[i]);
    }
    setArguments(modelType);
    mainPanel.repaint();
}
Also used : PriorType(dr.app.beauti.types.PriorType) Parameter(dr.app.beauti.options.Parameter) OptionsPanel(jam.panels.OptionsPanel)

Example 9 with Parameter

use of dr.app.beauti.options.Parameter in project beast-mcmc by beast-dev.

the class JointPriorDialog method addParameter.

public boolean addParameter() {
    if (selectParametersDialog == null) {
        selectParametersDialog = new SelectParametersDialog(frame);
    }
    List<Parameter> availableParameters = new ArrayList<Parameter>(compatibleParameterList);
    availableParameters.removeAll(dependentParameterList);
    int result = selectParametersDialog.showDialog("Select parameter to add to this Linked Parameter", availableParameters);
    if (result == JOptionPane.OK_OPTION) {
        Parameter parameter = selectParametersDialog.getSelectedParameter();
        dependentParameterList.add(parameter);
        parametersTableModel.fireTableDataChanged();
    } else if (result == JOptionPane.CANCEL_OPTION) {
        return false;
    }
    return true;
}
Also used : LinkedParameter(dr.app.beauti.components.linkedparameters.LinkedParameter) Parameter(dr.app.beauti.options.Parameter)

Example 10 with Parameter

use of dr.app.beauti.options.Parameter in project beast-mcmc by beast-dev.

the class STARBEASTGenerator method writeSpeciesTreeLikelihood.

private void writeSpeciesTreeLikelihood(XMLWriter writer) {
    TreePriorType nodeHeightPrior = options.getPartitionTreePriors().get(0).getNodeHeightPrior();
    if (nodeHeightPrior == TreePriorType.SPECIES_BIRTH_DEATH) {
        writer.writeComment("Species Tree Likelihood: Birth Death Model");
        writer.writeOpenTag(SpeciationLikelihoodParser.SPECIATION_LIKELIHOOD, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, SPECIATION_LIKE) });
        writer.writeOpenTag(SpeciationLikelihoodParser.MODEL);
        writer.writeIDref(BirthDeathModelParser.BIRTH_DEATH_MODEL, BirthDeathModelParser.BIRTH_DEATH);
        writer.writeCloseTag(SpeciationLikelihoodParser.MODEL);
    } else if (nodeHeightPrior == TreePriorType.SPECIES_YULE || nodeHeightPrior == TreePriorType.SPECIES_YULE_CALIBRATION) {
        writer.writeComment("Species Tree Likelihood: Yule Model");
        writer.writeOpenTag(SpeciationLikelihoodParser.SPECIATION_LIKELIHOOD, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, SPECIATION_LIKE) });
        writer.writeOpenTag(SpeciationLikelihoodParser.MODEL);
        writer.writeIDref(YuleModelParser.YULE_MODEL, YuleModelParser.YULE);
        writer.writeCloseTag(SpeciationLikelihoodParser.MODEL);
        if (nodeHeightPrior == TreePriorType.SPECIES_YULE_CALIBRATION) {
            // should be only 1 calibrated node with monophyletic for species tree at moment
            if (options.speciesSets.size() == 1 && options.speciesSetsMono.size() == 1) {
                Taxa t = options.speciesSets.get(0);
                Parameter nodeCalib = options.getStatistic(t);
                writer.writeOpenTag(SpeciationLikelihoodParser.CALIBRATION, new Attribute[] { new Attribute.Default<String>(SpeciationLikelihoodParser.CORRECTION, CalibrationPoints.CorrectionType.EXACT.toString()) });
                writer.writeOpenTag(SpeciationLikelihoodParser.POINT);
                writer.writeIDref(TaxaParser.TAXA, t.getId());
                writeDistribution(nodeCalib, true, writer);
                writer.writeCloseTag(SpeciationLikelihoodParser.POINT);
                writer.writeCloseTag(SpeciationLikelihoodParser.CALIBRATION);
                if (!options.treeModelOptions.isNodeCalibrated(nodeCalib)) {
                }
            } else {
                throw new IllegalArgumentException("Calibrated Yule model is only applied to 1 calibrated node with monophyletic for species tree at moment !");
            }
        }
    } else {
        throw new IllegalArgumentException("Get wrong species tree prior using *BEAST : " + nodeHeightPrior.toString());
    }
    // <sp> tree
    writer.writeOpenTag(SpeciesTreeModelParser.SPECIES_TREE);
    writer.writeIDref(SpeciesTreeModelParser.SPECIES_TREE, SP_TREE);
    writer.writeCloseTag(SpeciesTreeModelParser.SPECIES_TREE);
    writer.writeCloseTag(SpeciationLikelihoodParser.SPECIATION_LIKELIHOOD);
}
Also used : Taxa(dr.evolution.util.Taxa) Attribute(dr.util.Attribute) Parameter(dr.app.beauti.options.Parameter) TreePriorType(dr.app.beauti.types.TreePriorType)

Aggregations

Parameter (dr.app.beauti.options.Parameter)10 Attribute (dr.util.Attribute)6 TreePriorType (dr.app.beauti.types.TreePriorType)2 Taxa (dr.evolution.util.Taxa)2 LinkedParameter (dr.app.beauti.components.linkedparameters.LinkedParameter)1 PriorType (dr.app.beauti.types.PriorType)1 OptionsPanel (jam.panels.OptionsPanel)1 EmptyBorder (javax.swing.border.EmptyBorder)1