use of dr.app.beauti.options.Parameter in project beast-mcmc by beast-dev.
the class LinkedParameterComponentGenerator method generateJointParameter.
private void generateJointParameter(LinkedParameter linkedParameter, List<Parameter> parameters, XMLWriter writer) {
writer.writeOpenTag("jointParameter", new Attribute[] { new Attribute.Default<String>(XMLParser.ID, linkedParameter.getName()) });
for (Parameter parameter : parameters) {
writer.writeTag(ParameterParser.PARAMETER, new Attribute.Default<String>(XMLParser.IDREF, parameter.getName()), true);
}
writer.writeCloseTag("jointParameter");
}
use of dr.app.beauti.options.Parameter in project beast-mcmc by beast-dev.
the class HierarchicalModelComponentGenerator method generateDistribution.
private void generateDistribution(HierarchicalPhylogeneticModel hpm, XMLWriter writer) {
writer.writeOpenTag(DistributionLikelihood.DISTRIBUTION_LIKELIHOOD, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, getDistributionName(hpm)) });
// Add parameters as data
writer.writeOpenTag(DistributionLikelihoodParser.DATA);
for (Parameter parameter : hpm.getArgumentParameterList()) {
writeParameterRef(parameter.getName(), writer);
}
writer.writeCloseTag(DistributionLikelihoodParser.DATA);
// Add HPM model
writer.writeOpenTag(DistributionLikelihoodParser.DISTRIBUTION);
writer.writeOpenTag(getModelTagName(hpm), getModelAttributes(hpm));
writeParameter(NormalDistributionModelParser.MEAN, hpm.getConditionalParameterList().get(0).getName(), 1, hpm.getConditionalParameterList().get(0).getInitial(), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, writer);
writeParameter(NormalDistributionModelParser.PREC, hpm.getConditionalParameterList().get(1).getName(), 1, hpm.getConditionalParameterList().get(1).getInitial(), 0.0, Double.POSITIVE_INFINITY, writer);
writer.writeCloseTag(getModelTagName(hpm));
writer.writeCloseTag(DistributionLikelihoodParser.DISTRIBUTION);
writer.writeCloseTag(DistributionLikelihood.DISTRIBUTION_LIKELIHOOD);
}
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;
}
use of dr.app.beauti.options.Parameter in project beast-mcmc by beast-dev.
the class STARBEASTGenerator method writeGeneUnderSpecies.
private void writeGeneUnderSpecies(XMLWriter writer) {
writer.writeComment("Species Tree: Coalescent likelihood for gene trees under species tree");
// speciesCoalescent id="coalescent"
writer.writeOpenTag(MultiSpeciesCoalescentParser.SPECIES_COALESCENT, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, TraitData.TRAIT_SPECIES + "." + COALESCENT) });
writer.writeIDref(TraitData.TRAIT_SPECIES, TraitData.TRAIT_SPECIES);
writer.writeIDref(SpeciesTreeModelParser.SPECIES_TREE, SP_TREE);
writer.writeCloseTag(MultiSpeciesCoalescentParser.SPECIES_COALESCENT);
// exponentialDistributionModel id="pdist"
// writer.writeOpenTag(ExponentialDistributionModel.EXPONENTIAL_DISTRIBUTION_MODEL, new Attribute[]{
// new Attribute.Default<String>(XMLParser.ID, PDIST)});
//
// writer.writeOpenTag(DistributionModelParser.MEAN);
//
// Parameter para = options.getParameter(TraitGuesser.Traits.TRAIT_SPECIES + "." + options.POP_MEAN);
//
// writer.writeTag(ParameterParser.PARAMETER, new Attribute[]{
// new Attribute.Default<String>(XMLParser.ID, TraitGuesser.Traits.TRAIT_SPECIES + "." + options.POP_MEAN),
// new Attribute.Default<String>(ParameterParser.VALUE, Double.toString(para.initial))}, true);
//
// writer.writeCloseTag(DistributionModelParser.MEAN);
//
// writer.writeCloseTag(ExponentialDistributionModel.EXPONENTIAL_DISTRIBUTION_MODEL);
// if (options.speciesTreePrior == TreePriorType.SPECIES_YULE) {
writer.writeComment("Species tree prior: gama2 + gamma4");
writer.writeOpenTag(MixedDistributionLikelihoodParser.DISTRIBUTION_LIKELIHOOD, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, SPOPS) });
// change exponential + gamma2 into gama2 + gamma4
// <distribution0>
writer.writeOpenTag(MixedDistributionLikelihoodParser.DISTRIBUTION0);
// writer.writeIDref(ExponentialDistributionModel.EXPONENTIAL_DISTRIBUTION_MODEL, PDIST);
writer.writeOpenTag(GammaDistributionModel.GAMMA_DISTRIBUTION_MODEL);
writer.writeOpenTag(DistributionModelParser.SHAPE);
writer.writeText("2");
writer.writeCloseTag(DistributionModelParser.SHAPE);
writer.writeOpenTag(DistributionModelParser.SCALE);
Parameter para = options.starBEASTOptions.getParameter(TraitData.TRAIT_SPECIES + "." + options.starBEASTOptions.POP_MEAN);
writeParameter(para, 1, writer);
writer.writeCloseTag(DistributionModelParser.SCALE);
writer.writeCloseTag(GammaDistributionModel.GAMMA_DISTRIBUTION_MODEL);
writer.writeCloseTag(MixedDistributionLikelihoodParser.DISTRIBUTION0);
// <distribution1>
writer.writeOpenTag(MixedDistributionLikelihoodParser.DISTRIBUTION1);
writer.writeOpenTag(GammaDistributionModel.GAMMA_DISTRIBUTION_MODEL);
writer.writeOpenTag(DistributionModelParser.SHAPE);
writer.writeText("4");
writer.writeCloseTag(DistributionModelParser.SHAPE);
writer.writeOpenTag(DistributionModelParser.SCALE);
writer.writeIDref(ParameterParser.PARAMETER, TraitData.TRAIT_SPECIES + "." + options.starBEASTOptions.POP_MEAN);
writer.writeCloseTag(DistributionModelParser.SCALE);
writer.writeCloseTag(GammaDistributionModel.GAMMA_DISTRIBUTION_MODEL);
writer.writeCloseTag(MixedDistributionLikelihoodParser.DISTRIBUTION1);
// <data>
writer.writeOpenTag(MixedDistributionLikelihoodParser.DATA);
writer.writeIDref(ParameterParser.PARAMETER, SpeciesTreeModelParser.SPECIES_TREE + "." + SPLIT_POPS);
writer.writeCloseTag(MixedDistributionLikelihoodParser.DATA);
// <indicators>
writer.writeOpenTag(MixedDistributionLikelihoodParser.INDICATORS);
// Needs special treatment - you have to generate "NS" ones and 2(N-1) zeros, where N is the number of species.
// N "1", 2(N-1) "0"
writer.writeTag(ParameterParser.PARAMETER, new Attribute[] { new Attribute.Default<String>(ParameterParser.VALUE, getIndicatorsParaValue()) }, true);
writer.writeCloseTag(MixedDistributionLikelihoodParser.INDICATORS);
writer.writeCloseTag(MixedDistributionLikelihoodParser.DISTRIBUTION_LIKELIHOOD);
// } else {
// // STPopulationPrior id="stp" log_root="true"
// writer.writeOpenTag(SpeciesTreeBMPrior.STPRIOR, new Attribute[]{
// new Attribute.Default<String>(XMLParser.ID, STP),
// new Attribute.Default<String>(SpeciesTreeBMPrior.LOG_ROOT, "true")});
// writer.writeIDref(SpeciesTreeModelParser.SPECIES_TREE, SP_TREE);
//
// writer.writeOpenTag(SpeciesTreeBMPrior.TIPS);
//
// writer.writeIDref(ExponentialDistributionModel.EXPONENTIAL_DISTRIBUTION_MODEL, PDIST);
//
// writer.writeCloseTag(SpeciesTreeBMPrior.TIPS);
//
// writer.writeOpenTag(SpeciesTreeBMPrior.STSIGMA);
//
// writer.writeTag(ParameterParser.PARAMETER, new Attribute[]{
// // <parameter id="stsigma" value="1" />
// new Attribute.Default<String>(XMLParser.ID, SpeciesTreeBMPrior.STSIGMA.toLowerCase()),
// new Attribute.Default<String>(ParameterParser.VALUE, "1")}, true);
//
// writer.writeCloseTag(SpeciesTreeBMPrior.STSIGMA);
//
// writer.writeCloseTag(SpeciesTreeBMPrior.STPRIOR);
// }
}
use of dr.app.beauti.options.Parameter in project beast-mcmc by beast-dev.
the class STARBEASTGenerator method writeStartingTreeForCalibration.
public void writeStartingTreeForCalibration(XMLWriter writer) {
writer.writeComment("species starting tree for calibration");
writer.writeText("");
writer.writeOpenTag(OldCoalescentSimulatorParser.COALESCENT_TREE, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, SP_START_TREE) });
Attribute[] taxaAttribute = { new Attribute.Default<String>(XMLParser.IDREF, ALL_SPECIES) };
writer.writeOpenTag(OldCoalescentSimulatorParser.CONSTRAINED_TAXA);
writer.writeTag(TaxaParser.TAXA, taxaAttribute, true);
for (Taxa taxa : options.speciesSets) {
Parameter statistic = options.getStatistic(taxa);
Attribute mono = new Attribute.Default<Boolean>(OldCoalescentSimulatorParser.IS_MONOPHYLETIC, options.speciesSetsMono.get(taxa));
writer.writeOpenTag(OldCoalescentSimulatorParser.TMRCA_CONSTRAINT, mono);
writer.writeIDref(TaxaParser.TAXA, taxa.getId());
if (options.getPartitionTreePriors().get(0).getNodeHeightPrior() == TreePriorType.SPECIES_YULE_CALIBRATION && statistic.priorType == PriorType.UNIFORM_PRIOR) {
writeDistribution(statistic, false, writer);
}
writer.writeCloseTag(OldCoalescentSimulatorParser.TMRCA_CONSTRAINT);
}
writer.writeCloseTag(OldCoalescentSimulatorParser.CONSTRAINED_TAXA);
writer.writeOpenTag(ConstantPopulationModelParser.CONSTANT_POPULATION_MODEL, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, "spInitDemo"), new Attribute.Default<String>("units", Units.Utils.getDefaultUnitName(options.units)) });
writer.writeOpenTag(ConstantPopulationModelParser.POPULATION_SIZE);
// "initial" is "value"
double popSizeValue = options.getPartitionTreePriors().get(0).getParameter("constant.popSize").getInitial();
writer.writeTag(ParameterParser.PARAMETER, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, "sp.popSize"), new Attribute.Default<Double>(ParameterParser.VALUE, popSizeValue) }, true);
writer.writeCloseTag(ConstantPopulationModelParser.POPULATION_SIZE);
writer.writeCloseTag(ConstantPopulationModelParser.CONSTANT_POPULATION_MODEL);
writer.writeCloseTag(OldCoalescentSimulatorParser.COALESCENT_TREE);
}
Aggregations