use of dr.app.beauti.options.PartitionTreeModel in project beast-mcmc by beast-dev.
the class TaxonSetPanel method setCurrentTaxonSet.
protected void setCurrentTaxonSet(Taxa taxonSet) {
this.currentTaxonSet = taxonSet;
includedTaxa.clear();
excludedTaxa.clear();
if (currentTaxonSet != null) {
for (int i = 0; i < taxonSet.getTaxonCount(); i++) {
includedTaxa.add(taxonSet.getTaxon(i));
}
Collections.sort(includedTaxa);
// get taxa associated to each tree
PartitionTreeModel treeModel = options.taxonSetsTreeModel.get(currentTaxonSet);
TaxonList alignment = options.getDataPartitions(treeModel).get(0).getTaxonList();
Taxa taxa = new Taxa(alignment);
for (int i = 0; i < taxa.getTaxonCount(); i++) {
excludedTaxa.add(taxa.getTaxon(i));
}
excludedTaxa.removeAll(includedTaxa);
Collections.sort(excludedTaxa);
}
setTaxonSetTitle();
setupTaxonSetsComboBoxes();
includedTaxaTableModel.fireTableDataChanged();
excludedTaxaTableModel.fireTableDataChanged();
}
use of dr.app.beauti.options.PartitionTreeModel in project beast-mcmc by beast-dev.
the class TMRCAStatisticsGenerator method writeTMRCAStatistics.
/**
* Generate tmrca statistics
*
* @param writer the writer
*/
public void writeTMRCAStatistics(XMLWriter writer) {
List<Taxa> taxonSets;
Map<Taxa, Boolean> taxonSetsMono;
if (options.useStarBEAST) {
taxonSets = options.speciesSets;
taxonSetsMono = options.speciesSetsMono;
writer.writeComment("Species Sets");
writer.writeText("");
for (Taxa taxa : taxonSets) {
writer.writeOpenTag(TMRCAStatisticParser.TMRCA_STATISTIC, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, "tmrca(" + taxa.getId() + ")") });
// make tmrca(tree.name) eay to read in log for Tracer
writer.writeOpenTag(TMRCAStatisticParser.MRCA);
writer.writeIDref(TaxaParser.TAXA, taxa.getId());
writer.writeCloseTag(TMRCAStatisticParser.MRCA);
writer.writeIDref(SpeciesTreeModelParser.SPECIES_TREE, SP_TREE);
writer.writeCloseTag(TMRCAStatisticParser.TMRCA_STATISTIC);
if (taxonSetsMono.get(taxa)) {
// && treeModel.getPartitionTreePrior().getNodeHeightPrior() != TreePriorType.YULE
// && options.getKeysFromValue(options.taxonSetsTreeModel, treeModel).size() > 1) {
writer.writeOpenTag(MonophylyStatisticParser.MONOPHYLY_STATISTIC, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, "monophyly(" + taxa.getId() + ")") });
writer.writeOpenTag(MonophylyStatisticParser.MRCA);
writer.writeIDref(TaxaParser.TAXA, taxa.getId());
writer.writeCloseTag(MonophylyStatisticParser.MRCA);
writer.writeIDref(SpeciesTreeModelParser.SPECIES_TREE, SP_TREE);
writer.writeCloseTag(MonophylyStatisticParser.MONOPHYLY_STATISTIC);
}
}
} else {
taxonSets = options.taxonSets;
taxonSetsMono = options.taxonSetsMono;
writer.writeComment("Taxon Sets");
writer.writeText("");
for (Taxa taxa : taxonSets) {
PartitionTreeModel treeModel = options.taxonSetsTreeModel.get(taxa);
writer.writeOpenTag(TMRCAStatisticParser.TMRCA_STATISTIC, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, "tmrca(" + treeModel.getPrefix() + taxa.getId() + ")"), new Attribute.Default<Boolean>(TMRCAStatisticParser.STEM, options.taxonSetsIncludeStem.get(taxa)) });
// make tmrca(tree.name) eay to read in log for Tracer
writer.writeOpenTag(TMRCAStatisticParser.MRCA);
writer.writeIDref(TaxaParser.TAXA, taxa.getId());
writer.writeCloseTag(TMRCAStatisticParser.MRCA);
writer.writeIDref(TreeModel.TREE_MODEL, treeModel.getPrefix() + TreeModel.TREE_MODEL);
writer.writeCloseTag(TMRCAStatisticParser.TMRCA_STATISTIC);
if (taxonSetsMono.get(taxa)) {
// && treeModel.getPartitionTreePrior().getNodeHeightPrior() != TreePriorType.YULE
// && options.getKeysFromValue(options.taxonSetsTreeModel, treeModel).size() > 1) {
writer.writeOpenTag(MonophylyStatisticParser.MONOPHYLY_STATISTIC, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, "monophyly(" + taxa.getId() + ")") });
writer.writeOpenTag(MonophylyStatisticParser.MRCA);
writer.writeIDref(TaxaParser.TAXA, taxa.getId());
writer.writeCloseTag(MonophylyStatisticParser.MRCA);
writer.writeIDref(TreeModel.TREE_MODEL, treeModel.getPrefix() + TreeModel.TREE_MODEL);
writer.writeCloseTag(MonophylyStatisticParser.MONOPHYLY_STATISTIC);
}
}
}
}
use of dr.app.beauti.options.PartitionTreeModel in project beast-mcmc by beast-dev.
the class PartitionTreePriorPanel method setupPanel.
private void setupPanel() {
removeAll();
JTextArea citationText = new JTextArea(1, 40);
citationText.setLineWrap(true);
citationText.setWrapStyleWord(true);
citationText.setEditable(false);
citationText.setFont(this.getFont());
citationText.setOpaque(false);
// citationText.setBackground(this.getBackground());
// JScrollPane scrollPane = new JScrollPane(citation, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
// JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
// scrollPane.setOpaque(true);
String calYule = "Heled J, Drummond AJ (2011), Syst Biol, doi: 10.1093/sysbio/syr087 [Calibrated Yule]";
String citation;
if (treePriorCombo.getSelectedItem() == TreePriorType.SPECIES_YULE || treePriorCombo.getSelectedItem() == TreePriorType.SPECIES_YULE_CALIBRATION || treePriorCombo.getSelectedItem() == TreePriorType.SPECIES_BIRTH_DEATH) {
//*BEAST
addComponentWithLabel("Species Tree Prior:", treePriorCombo);
addComponentWithLabel("Population Size Model:", populationSizeCombo);
addLabel("Note: *BEAST only needs to select the prior for species tree.");
if (treePriorCombo.getSelectedItem() == TreePriorType.SPECIES_YULE_CALIBRATION) {
// addComponentWithLabel("Calibration Correction Type:", calibrationCorrectionCombo);
citation = calYule;
addComponentWithLabel("Citation:", citationText);
citationText.setText(citation);
}
} else {
// non *BEAST
String citationCoalescent = "Kingman JFC (1982) Stoch Proc Appl 13, 235-248 [Constant Coalescent].";
addComponentWithLabel("Tree Prior:", treePriorCombo);
if (!treesPanel.linkTreePriorCheck.isEnabled()) {
treesPanel.updateLinkTreePriorEnablility();
}
switch((TreePriorType) treePriorCombo.getSelectedItem()) {
case CONSTANT:
citation = citationCoalescent;
break;
case EXPONENTIAL:
case LOGISTIC:
case EXPANSION:
addComponentWithLabel("Parameterization for growth:", parameterizationCombo);
partitionTreePrior.setParameterization((TreePriorParameterizationType) parameterizationCombo.getSelectedItem());
//citationCoalescent + "\n" +
citation = "Griffiths RC, Tavare S (1994) Phil Trans R Soc Lond B Biol Sci 344, 403-410 [Parametric Coalescent].";
// + "\nDrummond AJ, Rambaut A, Shapiro B, Pybus OG (2005) Mol Biol Evol 22, 1185-1192.";
break;
case SKYLINE:
groupCountField.setColumns(6);
addComponentWithLabel("Number of groups:", groupCountField);
addComponentWithLabel("Skyline Model:", bayesianSkylineCombo);
//citationCoalescent + "\n" +
citation = "Drummond AJ, Rambaut A, Shapiro B, Pybus OG (2005) Mol Biol Evol 22, 1185-1192 [Skyline Coalescent].";
break;
case EXTENDED_SKYLINE:
addComponentWithLabel("Model Type:", extendedBayesianSkylineCombo);
treesPanel.linkTreePriorCheck.setSelected(true);
treesPanel.linkTreePriorCheck.setEnabled(false);
treesPanel.updateShareSameTreePriorChanged();
//citationCoalescent + "\n" +
citation = "Heled J, Drummond AJ (2008) BMC Evol Biol 8, 289 [Extended Skyline Coalescent].";
break;
case GMRF_SKYRIDE:
addComponentWithLabel("Smoothing:", gmrfBayesianSkyrideCombo);
treesPanel.linkTreePriorCheck.setSelected(true);
treesPanel.linkTreePriorCheck.setEnabled(false);
//For GMRF, one tree prior has to be associated to one tree model. The validation is in BeastGenerator.checkOptions()
addLabel("<html>For the Skyride, tree model/tree prior combination not implemented by BEAST. " + "The Skyride is only available for a single tree<br>model partition in this release. " + "Please try the Skygrid or link all tree models." + "</html>");
//citationCoalescent + "\n" +
citation = "Minin VN, Bloomquist EW, Suchard MA (2008) Mol Biol Evol 25, 1459-1471 [Skyride Coalescent].";
break;
case SKYGRID:
skyGridInterval.setColumns(6);
addComponentWithLabel("# parameters ( = # grid-points + 1):", skyGridPointsCombo);
addComponentWithLabel("Time at last point:", skyGridInterval);
addLabel("It is advisable to set this cut-off time commensurate with the expected root height for optimal model interpretability.");
treesPanel.linkTreePriorCheck.setSelected(true);
treesPanel.linkTreePriorCheck.setEnabled(false);
treesPanel.updateShareSameTreePriorChanged();
//citationCoalescent + "\n" +
citation = "Gill MS, Lemey P, Faria NR, Rambaut A, Shapiro B, Suchard MA (2013) Mol Biol Evol 30, 713-724 [SkyGrid Coalescent].";
break;
case YULE:
citation = "Gernhard T (2008) J Theor Biol 253, 769-778 [Yule Process]." + "\nYule GU (1925) Phil Trans R Soc Lond B Biol Sci 213, 21-87 [Yule Process].";
break;
case YULE_CALIBRATION:
// addComponentWithLabel("Calibration Correction Type:", calibrationCorrectionCombo);
citation = calYule;
break;
case BIRTH_DEATH:
citation = BirthDeathModelParser.getCitation();
break;
case BIRTH_DEATH_INCOMPLETE_SAMPLING:
citation = BirthDeathModelParser.getCitationRHO();
break;
case BIRTH_DEATH_SERIAL_SAMPLING:
citation = BirthDeathSerialSamplingModelParser.getCitationPsiOrg();
break;
case BIRTH_DEATH_BASIC_REPRODUCTIVE_NUMBER:
citation = BirthDeathSerialSamplingModelParser.getCitationRT();
break;
default:
throw new RuntimeException("No such tree prior has been specified so cannot refer to it");
}
if (treesPanel.options.maximumTipHeight > 0)
citation = citation + // "Rodrigo AG, Felsenstein J (1999) in Molecular Evolution of HIV (Crandall K), pp. 233-272 [Serially Sampled Data]."
"\n" + "Drummond AJ, Nicholls GK, Rodrigo AG, Solomon W (2002) Genetics 161, 1307-1320 [Serially Sampled Data].";
addComponentWithLabel("Citation:", citationText);
citationText.setText(citation);
}
// treesPanel.treeModelPanels.get(treesPanel.currentTreeModel).setOptions();
for (PartitionTreeModel model : treesPanel.treeModelPanels.keySet()) {
if (model != null) {
treesPanel.treeModelPanels.get(model).setOptions();
treesPanel.treeModelPanels.get(model).setupPanel();
}
}
// createTreeAction.setEnabled(options != null && options.dataPartitions.size() > 0);
// fireTableDataChanged();
validate();
repaint();
}
use of dr.app.beauti.options.PartitionTreeModel in project beast-mcmc by beast-dev.
the class MCMCPanel method updateTreeFileNameList.
private void updateTreeFileNameList() {
options.treeFileName.clear();
options.substTreeFileName.clear();
String treeFileName;
for (PartitionTreeModel tree : options.getPartitionTreeModels()) {
if (options.substTreeLog) {
treeFileName = getTreeFileName(tree.getPrefix() + "(time).");
} else {
treeFileName = getTreeFileName(tree.getPrefix());
}
if (addTxt.isSelected())
treeFileName = treeFileName + ".txt";
options.treeFileName.add(treeFileName);
if (options.substTreeLog) {
treeFileName = getTreeFileName(tree.getPrefix() + "(subst).");
if (addTxt.isSelected())
treeFileName = treeFileName + ".txt";
options.substTreeFileName.add(treeFileName);
}
}
if (options.useStarBEAST) {
treeFileName = options.fileNameStem + "." + options.starBEASTOptions.SPECIES_TREE_FILE_NAME;
if (addTxt.isSelected())
treeFileName = treeFileName + ".txt";
options.treeFileName.add(treeFileName);
//TODO: species sub tree
}
}
use of dr.app.beauti.options.PartitionTreeModel in project beast-mcmc by beast-dev.
the class STARBEASTGenerator method writeGeneTrees.
private void writeGeneTrees(XMLWriter writer) {
writer.writeComment("Collection of Gene Trees");
writer.writeOpenTag(SpeciesBindingsParser.GENE_TREES, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, SpeciesBindingsParser.GENE_TREES) });
boolean isSameAllPloidyType = true;
PloidyType checkSamePloidyType = options.getPartitionTreeModels().get(0).getPloidyType();
for (PartitionTreeModel model : options.getPartitionTreeModels()) {
if (checkSamePloidyType != model.getPloidyType()) {
isSameAllPloidyType = false;
break;
}
}
if (isSameAllPloidyType) {
// generate gene trees regarding each data partition
for (PartitionTreeModel model : options.getPartitionTreeModels()) {
writer.writeIDref(TreeModel.TREE_MODEL, model.getPrefix() + TreeModel.TREE_MODEL);
}
} else {
// give ploidy
for (PartitionTreeModel model : options.getPartitionTreeModels()) {
writer.writeOpenTag(SpeciesBindingsParser.GTREE, new Attribute[] { new Attribute.Default<String>(SpeciesBindingsParser.PLOIDY, Double.toString(model.getPloidyType().getValue())) });
writer.writeIDref(TreeModel.TREE_MODEL, model.getPrefix() + TreeModel.TREE_MODEL);
writer.writeCloseTag(SpeciesBindingsParser.GTREE);
}
}
writer.writeCloseTag(SpeciesBindingsParser.GENE_TREES);
}
Aggregations