diff --git a/src/beast/app/draw/SNAPPTreeLikelihoodEditor.java b/src/beast/app/draw/SNAPPTreeLikelihoodEditor.java index f19da5d..f264b2b 100644 --- a/src/beast/app/draw/SNAPPTreeLikelihoodEditor.java +++ b/src/beast/app/draw/SNAPPTreeLikelihoodEditor.java @@ -3,6 +3,7 @@ import java.util.List; import javax.swing.Box; +import javax.swing.JButton; import beast.app.beauti.BeautiDoc; import beast.app.draw.InputEditor; @@ -10,7 +11,9 @@ import beast.app.draw.ParameterInputEditor; import beast.core.BEASTInterface; import beast.core.Input; +import beast.core.parameter.RealParameter; import beast.evolution.sitemodel.SiteModel; +import snap.Data; import snap.likelihood.SnAPTreeLikelihood; import snap.likelihood.SnapSubstitutionModel; @@ -26,6 +29,8 @@ public Class baseType() { } SnapSubstitutionModel substModel; + Data data; + JButton muButton; @Override public void init(Input input, BEASTInterface plugin, int itemNr, ExpandOption bExpand, boolean bAddButtons) { @@ -40,9 +45,16 @@ public void init(Input input, BEASTInterface plugin, int itemNr, ExpandOption for (Object o : (List) input.get()) { if (o instanceof SnAPTreeLikelihood) { SnAPTreeLikelihood plugin2 = (SnAPTreeLikelihood) o; + if (plugin2.dataInput.get() instanceof Data) { + data = (Data) plugin2.dataInput.get(); + } substModel = (SnapSubstitutionModel) ((SiteModel.Base) plugin2.siteModelInput.get()).substModelInput.get(); doc.getInputEditorFactory().addInputs(m_listBox, substModel, this, null, doc); doc.getInputEditorFactory().addInputs(m_listBox, plugin2, this, null, doc); + muButton = new JButton("Calc mutation rates"); + muButton.setToolTipText("Calcaulate mutation rates based on data in the alignment"); + muButton.addActionListener(e -> setUpMutationRates()); + add(muButton); } } add(m_listBox); @@ -50,7 +62,20 @@ public void init(Input input, BEASTInterface plugin, int itemNr, ExpandOption } - public InputEditor createMutationRateVEditor() throws Exception { + private Object setUpMutationRates() { + double proportionZeros = data.getProportionZeros(); + double muU = 1 / (2.0 * proportionZeros); + double muV = 1 / (2.0 * (1.0- proportionZeros)); + RealParameter pU = substModel.m_pU.get(); + pU.valuesInput.setValue(muU + "", pU); + RealParameter pV = substModel.m_pV.get(); + pV.valuesInput.setValue(muV + "", pV); + refreshPanel(); + return null; + } + + + public InputEditor createMutationRateVEditor() throws Exception { ParameterInputEditor editor = (ParameterInputEditor) doc.getInputEditorFactory().createInputEditor(substModel.m_pV, substModel, doc); editor.m_isEstimatedBox.setVisible(false); return editor; diff --git a/templates/SNAPP.xml b/templates/SNAPP.xml index 2f463c8..041614d 100644 --- a/templates/SNAPP.xml +++ b/templates/SNAPP.xml @@ -64,6 +64,7 @@ snap.likelihood.SnAPTreeLikelihood.useAmbiguities, snap.likelihood.SnAPTreeLikelihood.tree, snap.likelihood.SnAPTreeLikelihood.dominant, + snap.likelihood.SnAPTreeLikelihood.ascSiteCount, snap.likelihood.SnAPPrior.coalescenceRate ' buttonLabelMap='beast.app.beauti.BeautiInitDlg.>> details=Edit parameters, @@ -138,12 +139,12 @@ - - - - - - + + + + + +