use of beast.core.Distribution in project beast2 by CompEvol.
the class BeautiDoc method collectClockModels.
private void collectClockModels() {
// collect branch rate models from model
CompoundDistribution likelihood = (CompoundDistribution) pluginmap.get("likelihood");
while (clockModels.size() < partitionNames.size()) {
try {
GenericTreeLikelihood treelikelihood = new GenericTreeLikelihood();
treelikelihood.branchRateModelInput.setValue(new StrictClockModel(), treelikelihood);
List<BeautiSubTemplate> availableBEASTObjects = inputEditorFactory.getAvailableTemplates(treelikelihood.branchRateModelInput, treelikelihood, null, this);
BEASTInterface beastObject = availableBEASTObjects.get(0).createSubNet(partitionNames.get(clockModels.size()), true);
clockModels.add((BranchRateModel.Base) beastObject);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
int k = 0;
for (Distribution d : likelihood.pDistributions.get()) {
BranchRateModel clockModel = ((GenericTreeLikelihood) d).branchRateModelInput.get();
// sanity check
Tree tree = null;
try {
for (Input<?> input : ((BEASTInterface) clockModel).listInputs()) {
if (input.getName().equals("tree")) {
tree = (Tree) input.get();
}
}
if (tree != null && tree != ((GenericTreeLikelihood) d).treeInput.get()) {
clockModel = clockModels.get(k);
Log.warning.println("WARNING: unlinking clock model for " + d.getID());
// TODO #557: this should move to the event of clock model drop box
// JOptionPane.showMessageDialog(beauti.getSelectedComponent(),
// "Cannot link all clock model(s) except strict clock with different trees !");
((GenericTreeLikelihood) d).branchRateModelInput.setValue(clockModel, d);
}
} catch (Exception e) {
// ignore
}
if (clockModel != null) {
String id = ((BEASTInterface) clockModel).getID();
id = parsePartition(id);
String partition = alignments.get(k).getID();
if (id.equals(partition)) {
clockModels.set(k, clockModel);
}
k++;
}
}
}
use of beast.core.Distribution in project beast2 by CompEvol.
the class PriorListInputEditor method pluginSelector.
@Override
protected List<BEASTInterface> pluginSelector(Input<?> input, BEASTInterface parent, List<String> tabooList) {
if (priorProviders == null) {
initProviders();
}
PriorProvider priorProvider = priorProviders.get(0);
if (priorProviders.size() > 1) {
// let user choose a PriorProvider
List<String> descriptions = new ArrayList<>();
List<PriorProvider> availableProviders = new ArrayList<>();
for (PriorProvider i : priorProviders) {
if (i.canProvidePrior(doc)) {
descriptions.add(i.getDescription());
availableProviders.add(i);
}
}
String option = (String) JOptionPane.showInputDialog(null, "Which prior do you want to add", "Option", JOptionPane.WARNING_MESSAGE, null, descriptions.toArray(), descriptions.get(0));
if (option == null) {
return null;
}
int i = descriptions.indexOf(option);
priorProvider = availableProviders.get(i);
}
List<BEASTInterface> selectedPlugins = new ArrayList<>();
List<Distribution> distrs = priorProvider.createDistribution(doc);
if (distrs == null) {
return null;
}
for (Distribution distr : distrs) {
selectedPlugins.add(distr);
}
return selectedPlugins;
}
Aggregations