public void removeSelection() { int[] selRows = dataTable.getSelectedRows(); Set<AbstractPartitionData> partitionsToRemove = new HashSet<AbstractPartitionData>(); for (int row : selRows) { partitionsToRemove.add(options.dataPartitions.get(row)); } boolean hasIdenticalTaxa = options.hasIdenticalTaxa(); // need to check this before removing partitions // TODO: would probably be a good idea to check if the user wants to remove the last partition options.dataPartitions.removeAll(partitionsToRemove); if (options.dataPartitions.size() == 0) { // all data partitions removed so reset the taxa options.reset(); useStarBEASTCheck.setSelected(false); frame.setupStarBEAST(false); frame.statusLabel.setText(""); frame.setAllOptions(); frame.getExportAction().setEnabled(false); } else if (!hasIdenticalTaxa) { options.updateTaxonList(); } dataTableModel.fireTableDataChanged(); fireDataChanged(); }
public void removeSelection() { int[] selRows = dataTable.getSelectedRows(); Set<PartitionData> partitionsToRemove = new HashSet<PartitionData>(); for (int row : selRows) { partitionsToRemove.add(options.dataPartitions.get(row)); } // TODO: would probably be a good idea to check if the user wants to remove the last partition options.dataPartitions.removeAll(partitionsToRemove); // if (options.allowDifferentTaxa && options.dataPartitions.size() < 2) { // uncheckAllowDifferentTaxa(); // } if (options.getNonTraitsDataList().size() == 0) { // all data partitions removed so reset the taxa options.reset(); useStarBEASTCheck.setSelected(false); frame.statusLabel.setText(""); frame.setAllOptions(); frame.getExportAction().setEnabled(false); } dataTableModel.fireTableDataChanged(); fireDataChanged(); }
public void setOptions(BeautiOptions options) { this.options = options; resetPanel(); settingOptions = true; int selRow = partitionTable.getSelectedRow(); partitionTableModel.fireTableDataChanged(); if (options.getDataPartitions().size() > 0) { if (selRow < 0) { selRow = 0; } partitionTable.getSelectionModel().setSelectionInterval(selRow, selRow); setCurrentPartition(options.getDataPartitions().get(selRow)); } AncestralStatesOptionsPanel panel = optionsPanels.get(currentPartition); if (panel != null) { panel.setupPanel(); } settingOptions = false; validate(); repaint(); }
private void updateOtherFileNames(BeautiOptions options) { if (options.fileNameStem != null) { // fileNameStemField.setText(options.fileNameStem); options.logFileName = options.fileNameStem + ".log"; if (addTxt.isSelected()) options.logFileName = options.logFileName + ".txt"; logFileNameField.setText(options.logFileName); // if (options.mapTreeFileName == null) { // mapTreeFileNameField.setText(options.fileNameStem + ".MAP.tree"); // } else { // mapTreeFileNameField.setText(options.mapTreeFileName); // } updateTreeFileNameList(); treeFileNameField.setText(displayTreeList(options.treeFileName)); if (options.substTreeLog) { substTreeFileNameField.setText(displayTreeList(options.substTreeFileName)); } else { substTreeFileNameField.setText(""); } options.operatorAnalysisFileName = options.fileNameStem + ".ops"; if (addTxt.isSelected()) { options.operatorAnalysisFileName = options.operatorAnalysisFileName + ".txt"; } operatorAnalaysisFileNameField.setEnabled(options.operatorAnalysis); if (options.operatorAnalysis) { operatorAnalaysisFileNameField.setText(options.operatorAnalysisFileName); } else { operatorAnalaysisFileNameField.setText(""); } // mapTreeLogCheck.setEnabled(true); // mapTreeLogCheck.setSelected(options.mapTreeLog); // mapTreeFileNameField.setEnabled(options.mapTreeLog); substTreeLogCheck.setEnabled(true); substTreeLogCheck.setSelected(options.substTreeLog); } else { // fileNameStemField.setText(fileNameStem); // fileNameStemField.setEnabled(false); logFileNameField.setText(DEFAULT_FILE_NAME_STEM + ".log"); treeFileNameField.setText(DEFAULT_FILE_NAME_STEM + "." + STARBEASTOptions.TREE_FILE_NAME); // mapTreeLogCheck.setEnabled(false); // mapTreeFileNameField.setEnabled(false); // mapTreeFileNameField.setText("untitled"); substTreeLogCheck.setSelected(false); substTreeFileNameField.setEnabled(false); substTreeFileNameField.setText(""); operatorAnalaysisCheck.setSelected(false); operatorAnalaysisFileNameField.setText(""); } }
public void setOptions(BeautiOptions options) { this.options = options; modelsChanged(); useStarBEASTCheck.setEnabled( options.getNonTraitsDataList().size() > 0); // single partition is allowed createImportTraitButton.setEnabled(options.getNonTraitsDataList().size() > 0); dataTableModel.fireTableDataChanged(); }
public void linkTrees() { // keep previous PartitionTreePrior for reuse int[] selRows = dataTable.getSelectedRows(); List<AbstractPartitionData> selectedPartitionData = new ArrayList<AbstractPartitionData>(); for (int row : selRows) { AbstractPartitionData partition = options.dataPartitions.get(row); if (!selectedPartitionData.contains(partition)) selectedPartitionData.add(partition); } if (selectedPartitionData.size() > 1) { if (!options.hasIdenticalTaxa(selectedPartitionData)) { String errMsg = "To share a tree, partitions need to have identical taxa."; if (selectedPartitionData.get(0).getDataType().getType() == DataType.MICRO_SAT) errMsg += "\nThe data must be all diploid or all haploid when you want to link the tree."; JOptionPane.showMessageDialog( this, errMsg, "Illegal Configuration", JOptionPane.ERROR_MESSAGE); return; } } Object[] treeArray = options.getPartitionTreeModels(selectedPartitionData).toArray(); if (selectTreeDialog == null) { selectTreeDialog = new SelectTreeDialog(frame); } int result = selectTreeDialog.showDialog(treeArray); if (result != JOptionPane.CANCEL_OPTION) { PartitionTreeModel model = selectTreeDialog.getTree(); if (selectTreeDialog.getMakeCopy()) { model.setName(selectTreeDialog.getName()); } PartitionTreePrior prior = model.getPartitionTreePrior(); options.linkTreePriors(prior); for (AbstractPartitionData partition : selectedPartitionData) { partition.setPartitionTreeModel(model); } for (Taxa taxa : options.taxonSets) { // Issue 454: all the taxon sets are deleted when link/unlink tree PartitionTreeModel prevModel = options.taxonSetsTreeModel.get(taxa); if (prevModel != model) options.taxonSetsTreeModel.put(taxa, model); } } modelsChanged(); fireDataChanged(); repaint(); }
public void linkModels() { int[] selRows = dataTable.getSelectedRows(); List<AbstractPartitionData> selectedPartitionData = new ArrayList<AbstractPartitionData>(); DataType dateType = null; for (int row : selRows) { AbstractPartitionData partition = options.dataPartitions.get(row); if (dateType == null) { dateType = partition.getDataType(); } else { if (partition.getDataType() != dateType) { JOptionPane.showMessageDialog( this, "Can only link the models for data partitions \n" + "of the same data type (e.g., nucleotides)", "Unable to link models", JOptionPane.ERROR_MESSAGE); return; } } if (!selectedPartitionData.contains(partition)) selectedPartitionData.add(partition); } Object[] modelArray = options.getPartitionSubstitutionModels(selectedPartitionData).toArray(); if (selectModelDialog == null) { selectModelDialog = new SelectModelDialog(frame); } int result = selectModelDialog.showDialog(modelArray); if (result != JOptionPane.CANCEL_OPTION) { PartitionSubstitutionModel model = selectModelDialog.getModel(); if (selectModelDialog.getMakeCopy()) { model.setName(selectModelDialog.getName()); } for (AbstractPartitionData partition : selectedPartitionData) { partition.setPartitionSubstitutionModel(model); } } if (options.getPartitionSubstitutionModels(Microsatellite.INSTANCE).size() <= 1) { options.shareMicroSat = true; } modelsChanged(); fireDataChanged(); repaint(); }
public void linkTrees() { // keep previous PartitionTreePrior for reuse int[] selRows = dataTable.getSelectedRows(); List<PartitionData> selectedPartitionData = new ArrayList<PartitionData>(); for (int row : selRows) { PartitionData partition = options.dataPartitions.get(row); if (!selectedPartitionData.contains(partition)) selectedPartitionData.add(partition); } if (options.allowDifferentTaxa) { // BEAST cannot handle multi <taxa> ref for 1 tree if (selectedPartitionData.size() > 1) { if (!options.validateDiffTaxa(selectedPartitionData)) { JOptionPane.showMessageDialog( this, "To accommodate different taxa for each partition trees cannot be linked.", "Illegal Configuration", JOptionPane.ERROR_MESSAGE); return; } } } Object[] treeArray = options.getPartitionTreeModels(selectedPartitionData).toArray(); if (selectTreeDialog == null) { selectTreeDialog = new SelectTreeDialog(frame); } int result = selectTreeDialog.showDialog(treeArray); if (result != JOptionPane.CANCEL_OPTION) { PartitionTreeModel model = selectTreeDialog.getTree(); if (selectTreeDialog.getMakeCopy()) { model.setName(selectTreeDialog.getName()); } PartitionTreePrior prior = model.getPartitionTreePrior(); options.linkTreePriors(prior); for (PartitionData partition : selectedPartitionData) { partition.setPartitionTreeModel(model); } } modelsChanged(); fireDataChanged(); options.taxonSets.clear(); options.taxonSetsMono.clear(); repaint(); }
private void selectionChanged() { if (settingOptions) return; int selRow = partitionTable.getSelectedRow(); if (selRow >= options.getDataPartitions().size()) { selRow = 0; partitionTable.getSelectionModel().setSelectionInterval(selRow, selRow); } if (selRow >= 0) { setCurrentPartition(options.getDataPartitions().get(selRow)); // frame.modelSelectionChanged(!isUsed(selRow)); } }
public void linkClocks() { // keep previous PartitionTreePrior for reuse int[] selRows = dataTable.getSelectedRows(); List<PartitionData> selectedPartitionData = new ArrayList<PartitionData>(); for (int row : selRows) { PartitionData partition = options.dataPartitions.get(row); if (!selectedPartitionData.contains(partition)) selectedPartitionData.add(partition); } Object[] modelArray = options.getPartitionClockModels(selectedPartitionData).toArray(); if (selectClockDialog == null) { selectClockDialog = new SelectClockDialog(frame); } int result = selectClockDialog.showDialog(modelArray); if (result != JOptionPane.CANCEL_OPTION) { PartitionClockModel model = selectClockDialog.getModel(); if (selectClockDialog.getMakeCopy()) { model.setName(selectClockDialog.getName()); } for (PartitionData partition : selectedPartitionData) { partition.setPartitionClockModel(model); } } modelsChanged(); fireDataChanged(); repaint(); }
public void unlinkTrees() { // reuse previous PartitionTreePrior int[] selRows = dataTable.getSelectedRows(); for (int row : selRows) { PartitionData partition = options.dataPartitions.get(row); PartitionTreeModel model = partition.getPartitionTreeModel(); if (!model.getName().equals(partition.getName()) && partition.getTraitType() == null) { // not a trait PartitionTreeModel newTree = new PartitionTreeModel(options, partition); // this prevents partition not broken, and used for unsharing tree prior only, // because sharing uses shareSameTreePrior, unsharing uses getPartitionTreePrior // newTree.setPartitionTreePrior(newPrior); // important partition.setPartitionTreeModel(newTree); } } options.linkTreePriors(frame.getCurrentPartitionTreePrior()); modelsChanged(); fireDataChanged(); options.taxonSets.clear(); options.taxonSetsMono.clear(); repaint(); }
private void resetPanel() { if (!options.hasData()) { currentPartition = null; optionsPanels.clear(); optionsPanelParent.removeAll(); } }
public void setOptions(BeautiOptions options) { this.options = options; chainLengthField.setValue(options.chainLength); echoEveryField.setValue(options.echoEvery); logEveryField.setValue(options.logEvery); if (options.fileNameStem != null) { fileNameStemField.setText(options.fileNameStem); } else { fileNameStemField.setText(DEFAULT_FILE_NAME_STEM); fileNameStemField.setEnabled(false); } operatorAnalaysisCheck.setSelected(options.operatorAnalysis); updateOtherFileNames(options); if (options.contains(Microsatellite.INSTANCE)) { samplePriorCheckBox.setSelected(false); samplePriorCheckBox.setVisible(false); } else { samplePriorCheckBox.setVisible(true); samplePriorCheckBox.setSelected(options.samplePriorOnly); } optionsPanel.validate(); optionsPanel.repaint(); }
public boolean createFromTraits(List<TraitData> traits) { int selRow = -1; if (selectTraitDialog == null) { selectTraitDialog = new SelectTraitDialog(frame); } if (traits == null || traits.size() == 0) { int result = selectTraitDialog.showDialog(options.traits, null); if (result != JOptionPane.CANCEL_OPTION) { TraitData trait = selectTraitDialog.getTrait(); String name = trait.getName(); if (selectTraitDialog.getMakeCopy()) { name = selectTraitDialog.getName(); } selRow = options.createPartitionForTraits(name, trait); } else { return false; } } else { if (traits.size() > 1) { // a set of traits have been passed to the function int result = selectTraitDialog.showDialog(null, null); if (result != JOptionPane.CANCEL_OPTION) { String name = selectTraitDialog.getName(); selRow = options.createPartitionForTraits(name, traits); } else { return false; } } else { selRow = options.createPartitionForTraits(traits.get(0).getName(), traits); } } modelsChanged(); dataTableModel.fireTableDataChanged(); if (selRow != -1) { dataTable.getSelectionModel().setSelectionInterval(selRow, selRow); } fireDataChanged(); repaint(); return true; }
private boolean parameterExists(String name) { for (Parameter parameter : options.selectParameters()) { if (parameter.getName().equals(name)) { return true; } } return false; }
private void modelsChanged() { TableColumn col = dataTable.getColumnModel().getColumn(5); col.setCellEditor(new ComboBoxCellEditor()); col = dataTable.getColumnModel().getColumn(6); col.setCellEditor(new ComboBoxCellEditor()); col = dataTable.getColumnModel().getColumn(7); col.setCellEditor( new DefaultCellEditor(new JComboBox(options.getNonTraitPartitionTreeModels().toArray()))); }
private void fireDataChanged() { // options.updateLinksBetweenPDPCMPSMPTMPTPP(); options.updatePartitionAllLinks(); if (!(options.clockModelOptions.getRateOptionClockModel() == FixRateType.TIP_CALIBRATED || options.clockModelOptions.getRateOptionClockModel() == FixRateType.NODE_CALIBRATED || options.clockModelOptions.getRateOptionClockModel() == FixRateType.RATE_CALIBRATED)) { // TODO correct? options.clockModelOptions.fixRateOfFirstClockPartition(); } frame.setDirty(); }
private void updateTreeFileNameList() { options.treeFileName.clear(); options.substTreeFileName.clear(); String treeFN; for (PartitionTreeModel tree : options.getPartitionTreeModels()) { if (options.substTreeLog) { treeFN = options.fileNameStem + "." + tree.getPrefix() + "(time)." + STARBEASTOptions.TREE_FILE_NAME; } else { treeFN = options.fileNameStem + "." + tree.getPrefix() + STARBEASTOptions.TREE_FILE_NAME; // stem.partitionName.tree } if (addTxt.isSelected()) treeFN = treeFN + ".txt"; options.treeFileName.add(treeFN); if (options.substTreeLog) { treeFN = options.fileNameStem + "." + tree.getPrefix() + "(subst)." + STARBEASTOptions.TREE_FILE_NAME; if (addTxt.isSelected()) treeFN = treeFN + ".txt"; options.substTreeFileName.add(treeFN); } } if (options.useStarBEAST) { treeFN = options.fileNameStem + "." + options.starBEASTOptions.SPECIES_TREE_FILE_NAME; if (addTxt.isSelected()) treeFN = treeFN + ".txt"; options.treeFileName.add(treeFN); // TODO: species sub tree } }
public void getOptions(BeautiOptions options) { options.fileNameStem = fileNameStemField.getText(); options.logFileName = logFileNameField.getText(); // options.mapTreeLog = mapTreeLogCheck.isSelected(); // options.mapTreeFileName = mapTreeFileNameField.getText(); options.substTreeLog = substTreeLogCheck.isSelected(); updateTreeFileNameList(); options.operatorAnalysis = operatorAnalaysisCheck.isSelected(); options.operatorAnalysisFileName = operatorAnalaysisFileNameField.getText(); options.samplePriorOnly = samplePriorCheckBox.isSelected(); }
/** * Write the marginalLikelihoodEstimator, pathSamplingAnalysis and steppingStoneSamplingAnalysis * blocks. * * @param writer XMLWriter */ public void writeMLE(XMLWriter writer, MarginalLikelihoodEstimationOptions options) { if (options.performMLE) { writer.writeComment("Define marginal likelihood estimator (PS/SS) settings"); List<Attribute> attributes = new ArrayList<Attribute>(); // attributes.add(new Attribute.Default<String>(XMLParser.ID, "mcmc")); attributes.add( new Attribute.Default<Integer>( MarginalLikelihoodEstimator.CHAIN_LENGTH, options.mleChainLength)); attributes.add( new Attribute.Default<Integer>( MarginalLikelihoodEstimator.PATH_STEPS, options.pathSteps)); attributes.add( new Attribute.Default<String>( MarginalLikelihoodEstimator.PATH_SCHEME, options.pathScheme)); if (!options.pathScheme.equals(MarginalLikelihoodEstimator.LINEAR)) { attributes.add( new Attribute.Default<Double>( MarginalLikelihoodEstimator.ALPHA, options.schemeParameter)); } writer.writeOpenTag(MarginalLikelihoodEstimator.MARGINAL_LIKELIHOOD_ESTIMATOR, attributes); writer.writeOpenTag("samplers"); writer.writeIDref("mcmc", "mcmc"); writer.writeCloseTag("samplers"); attributes = new ArrayList<Attribute>(); attributes.add(new Attribute.Default<String>(XMLParser.ID, "pathLikelihood")); writer.writeOpenTag(PathLikelihood.PATH_LIKELIHOOD, attributes); writer.writeOpenTag(PathLikelihood.SOURCE); writer.writeIDref(CompoundLikelihoodParser.POSTERIOR, CompoundLikelihoodParser.POSTERIOR); writer.writeCloseTag(PathLikelihood.SOURCE); writer.writeOpenTag(PathLikelihood.DESTINATION); writer.writeIDref(CompoundLikelihoodParser.PRIOR, CompoundLikelihoodParser.PRIOR); writer.writeCloseTag(PathLikelihood.DESTINATION); writer.writeCloseTag(PathLikelihood.PATH_LIKELIHOOD); attributes = new ArrayList<Attribute>(); attributes.add(new Attribute.Default<String>(XMLParser.ID, "MLELog")); attributes.add(new Attribute.Default<Integer>("logEvery", options.mleLogEvery)); attributes.add(new Attribute.Default<String>("fileName", options.mleFileName)); writer.writeOpenTag("log", attributes); writer.writeIDref("pathLikelihood", "pathLikelihood"); writer.writeCloseTag("log"); writer.writeCloseTag(MarginalLikelihoodEstimator.MARGINAL_LIKELIHOOD_ESTIMATOR); writer.writeComment("Path sampling estimator from collected samples"); attributes = new ArrayList<Attribute>(); attributes.add(new Attribute.Default<String>("fileName", options.mleFileName)); writer.writeOpenTag(PathSamplingAnalysis.PATH_SAMPLING_ANALYSIS, attributes); writer.writeTag( "likelihoodColumn", new Attribute.Default<String>("name", "pathLikelihood.delta"), true); writer.writeTag( "thetaColumn", new Attribute.Default<String>("name", "pathLikelihood.theta"), true); writer.writeCloseTag(PathSamplingAnalysis.PATH_SAMPLING_ANALYSIS); writer.writeComment("Stepping-stone sampling estimator from collected samples"); attributes = new ArrayList<Attribute>(); attributes.add(new Attribute.Default<String>("fileName", options.mleFileName)); writer.writeOpenTag( SteppingStoneSamplingAnalysis.STEPPING_STONE_SAMPLING_ANALYSIS, attributes); writer.writeTag( "likelihoodColumn", new Attribute.Default<String>("name", "pathLikelihood.delta"), true); writer.writeTag( "thetaColumn", new Attribute.Default<String>("name", "pathLikelihood.theta"), true); writer.writeCloseTag(SteppingStoneSamplingAnalysis.STEPPING_STONE_SAMPLING_ANALYSIS); } else if (options.performMLEGSS) { // First define necessary components for the tree working prior if (options.choiceTreeWorkingPrior.equals("Product of exponential distributions")) { // more general product of exponentials needs to be constructed if (DEBUG) { System.err.println("productOfExponentials selected: " + options.choiceTreeWorkingPrior); } List<Attribute> attributes = new ArrayList<Attribute>(); attributes.add(new Attribute.Default<String>(XMLParser.ID, "exponentials")); attributes.add(new Attribute.Default<String>("fileName", beautiOptions.logFileName)); attributes.add( new Attribute.Default<String>("burnin", "" + beautiOptions.chainLength * 0.10)); attributes.add( new Attribute.Default<String>("parameterColumn", "coalescentEventsStatistic")); attributes.add( new Attribute.Default<String>( "dimension", "" + (beautiOptions.taxonList.getTaxonCount() - 1))); writer.writeOpenTag( TreeWorkingPriorParsers.PRODUCT_OF_EXPONENTIALS_POSTERIOR_MEANS_LOESS, attributes); writer.writeTag( TreeModel.TREE_MODEL, new Attribute.Default<String>(XMLParser.ID, TreeModel.TREE_MODEL), true); writer.writeCloseTag(TreeWorkingPriorParsers.PRODUCT_OF_EXPONENTIALS_POSTERIOR_MEANS_LOESS); } else { // matching coalescent model has to be constructed // getting the coalescent model if (DEBUG) { System.err.println( "matching coalescent model selected: " + options.choiceTreeWorkingPrior); System.err.println(beautiOptions.getPartitionTreePriors().get(0).getNodeHeightPrior()); } /*for (PartitionTreePrior prior : options.getPartitionTreePriors()) { treePriorGenerator.writeTreePriorModel(prior, writer); writer.writeText(""); }*/ // TODO: extend for more than 1 coalescent model? TreePriorType nodeHeightPrior = beautiOptions.getPartitionTreePriors().get(0).getNodeHeightPrior(); switch (nodeHeightPrior) { case CONSTANT: writer.writeComment("A working prior for the constant population size model."); writer.writeOpenTag( ConstantPopulationModelParser.CONSTANT_POPULATION_MODEL, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, modelPrefix + "constantReference"), new Attribute.Default<String>( "units", Units.Utils.getDefaultUnitName(beautiOptions.units)) }); writer.writeOpenTag(ConstantPopulationModelParser.POPULATION_SIZE); writeParameter( "constantReference.popSize", "constant.popSize", beautiOptions.logFileName, (int) (options.mleChainLength * 0.10), writer); writer.writeCloseTag(ConstantPopulationModelParser.POPULATION_SIZE); writer.writeCloseTag(ConstantPopulationModelParser.CONSTANT_POPULATION_MODEL); writer.writeComment("A working prior for the coalescent."); writer.writeOpenTag( CoalescentLikelihoodParser.COALESCENT_LIKELIHOOD, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, modelPrefix + "coalescentReference") }); writer.writeOpenTag(CoalescentLikelihoodParser.MODEL); writer.writeIDref( ConstantPopulationModelParser.CONSTANT_POPULATION_MODEL, beautiOptions.getPartitionTreePriors().get(0).getPrefix() + "constantReference"); writer.writeCloseTag(CoalescentLikelihoodParser.MODEL); writer.writeOpenTag(CoalescentLikelihoodParser.POPULATION_TREE); writer.writeIDref(TreeModel.TREE_MODEL, modelPrefix + TreeModel.TREE_MODEL); writer.writeCloseTag(CoalescentLikelihoodParser.POPULATION_TREE); writer.writeCloseTag(CoalescentLikelihoodParser.COALESCENT_LIKELIHOOD); break; case EXPONENTIAL: writer.writeComment("A working prior for the exponential growth model."); writer.writeOpenTag( ExponentialGrowthModelParser.EXPONENTIAL_GROWTH_MODEL, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, modelPrefix + "exponentialReference"), new Attribute.Default<String>( "units", Units.Utils.getDefaultUnitName(beautiOptions.units)) }); writer.writeOpenTag(ExponentialGrowthModelParser.POPULATION_SIZE); writeParameter( "exponentialReference.popSize", "exponential.popSize", beautiOptions.logFileName, (int) (options.mleChainLength * 0.10), writer); writer.writeCloseTag(ExponentialGrowthModelParser.POPULATION_SIZE); writer.writeOpenTag(ExponentialGrowthModelParser.GROWTH_RATE); writeParameter( "exponentialReference.growthRate", "exponential.growthRate", beautiOptions.logFileName, (int) (options.mleChainLength * 0.10), writer); writer.writeCloseTag(ExponentialGrowthModelParser.GROWTH_RATE); writer.writeCloseTag(ExponentialGrowthModelParser.EXPONENTIAL_GROWTH_MODEL); writer.writeComment("A working prior for the coalescent."); writer.writeOpenTag( CoalescentLikelihoodParser.COALESCENT_LIKELIHOOD, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, modelPrefix + "coalescentReference") }); writer.writeOpenTag(CoalescentLikelihoodParser.MODEL); writer.writeIDref( ExponentialGrowthModelParser.EXPONENTIAL_GROWTH_MODEL, beautiOptions.getPartitionTreePriors().get(0).getPrefix() + "constantReference"); writer.writeCloseTag(CoalescentLikelihoodParser.MODEL); writer.writeOpenTag(CoalescentLikelihoodParser.POPULATION_TREE); writer.writeIDref(TreeModel.TREE_MODEL, modelPrefix + TreeModel.TREE_MODEL); writer.writeCloseTag(CoalescentLikelihoodParser.POPULATION_TREE); writer.writeCloseTag(CoalescentLikelihoodParser.COALESCENT_LIKELIHOOD); break; case LOGISTIC: writer.writeComment("A working prior for the logistic growth model."); writer.writeOpenTag( LogisticGrowthModelParser.LOGISTIC_GROWTH_MODEL, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, modelPrefix + "logisticReference"), new Attribute.Default<String>( "units", Units.Utils.getDefaultUnitName(beautiOptions.units)) }); writer.writeOpenTag(LogisticGrowthModelParser.POPULATION_SIZE); writeParameter( "logisticReference.popSize", "logistic.popSize", beautiOptions.logFileName, (int) (options.mleChainLength * 0.10), writer); writer.writeCloseTag(LogisticGrowthModelParser.POPULATION_SIZE); writer.writeOpenTag(LogisticGrowthModelParser.GROWTH_RATE); writeParameter( "logisticReference.growthRate", "logistic.growthRate", beautiOptions.logFileName, (int) (options.mleChainLength * 0.10), writer); writer.writeCloseTag(LogisticGrowthModelParser.GROWTH_RATE); writer.writeOpenTag(LogisticGrowthModelParser.TIME_50); writeParameter( "logisticReference.t50", "logistic.t50", beautiOptions.logFileName, (int) (options.mleChainLength * 0.10), writer); writer.writeCloseTag(LogisticGrowthModelParser.TIME_50); writer.writeCloseTag(LogisticGrowthModelParser.LOGISTIC_GROWTH_MODEL); writer.writeComment("A working prior for the coalescent."); writer.writeOpenTag( CoalescentLikelihoodParser.COALESCENT_LIKELIHOOD, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, modelPrefix + "coalescentReference") }); writer.writeOpenTag(CoalescentLikelihoodParser.MODEL); writer.writeIDref( LogisticGrowthModelParser.LOGISTIC_GROWTH_MODEL, beautiOptions.getPartitionTreePriors().get(0).getPrefix() + "constantReference"); writer.writeCloseTag(CoalescentLikelihoodParser.MODEL); writer.writeOpenTag(CoalescentLikelihoodParser.POPULATION_TREE); writer.writeIDref(TreeModel.TREE_MODEL, modelPrefix + TreeModel.TREE_MODEL); writer.writeCloseTag(CoalescentLikelihoodParser.POPULATION_TREE); writer.writeCloseTag(CoalescentLikelihoodParser.COALESCENT_LIKELIHOOD); break; case EXPANSION: writer.writeComment("A working prior for the expansion growth model."); writer.writeOpenTag( ExpansionModelParser.EXPANSION_MODEL, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, modelPrefix + "expansionReference"), new Attribute.Default<String>( "units", Units.Utils.getDefaultUnitName(beautiOptions.units)) }); writer.writeOpenTag(ExpansionModelParser.POPULATION_SIZE); writeParameter( "expansionReference.popSize", "expansion.popSize", beautiOptions.logFileName, (int) (options.mleChainLength * 0.10), writer); writer.writeCloseTag(ExpansionModelParser.POPULATION_SIZE); writer.writeOpenTag(ExpansionModelParser.GROWTH_RATE); writeParameter( "expansionReference.growthRate", "expansion.growthRate", beautiOptions.logFileName, (int) (options.mleChainLength * 0.10), writer); writer.writeCloseTag(ExpansionModelParser.GROWTH_RATE); writer.writeOpenTag(ExpansionModelParser.ANCESTRAL_POPULATION_PROPORTION); writeParameter( "expansionReference.ancestralProportion", "expansion.ancestralProportion", beautiOptions.logFileName, (int) (options.mleChainLength * 0.10), writer); writer.writeCloseTag(ExpansionModelParser.ANCESTRAL_POPULATION_PROPORTION); writer.writeCloseTag(ExpansionModelParser.EXPANSION_MODEL); writer.writeComment("A working prior for the coalescent."); writer.writeOpenTag( CoalescentLikelihoodParser.COALESCENT_LIKELIHOOD, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, modelPrefix + "coalescentReference") }); writer.writeOpenTag(CoalescentLikelihoodParser.MODEL); writer.writeIDref( ExpansionModelParser.EXPANSION_MODEL, beautiOptions.getPartitionTreePriors().get(0).getPrefix() + "constantReference"); writer.writeCloseTag(CoalescentLikelihoodParser.MODEL); writer.writeOpenTag(CoalescentLikelihoodParser.POPULATION_TREE); writer.writeIDref(TreeModel.TREE_MODEL, modelPrefix + TreeModel.TREE_MODEL); writer.writeCloseTag(CoalescentLikelihoodParser.POPULATION_TREE); writer.writeCloseTag(CoalescentLikelihoodParser.COALESCENT_LIKELIHOOD); break; default: // Do not switch to product of exponentials as the coalescentEventsStatistic has not // been logged // TODO: show menu that explains mismatch between prior and working prior? // TODO: but show it when the MCM option is wrongfully being selected, don't do anything // here } } writer.writeComment("Define marginal likelihood estimator (GSS) settings"); List<Attribute> attributes = new ArrayList<Attribute>(); attributes.add( new Attribute.Default<Integer>( MarginalLikelihoodEstimator.CHAIN_LENGTH, options.mleChainLength)); attributes.add( new Attribute.Default<Integer>( MarginalLikelihoodEstimator.PATH_STEPS, options.pathSteps)); attributes.add( new Attribute.Default<String>( MarginalLikelihoodEstimator.PATH_SCHEME, options.pathScheme)); if (!options.pathScheme.equals(MarginalLikelihoodEstimator.LINEAR)) { attributes.add( new Attribute.Default<Double>( MarginalLikelihoodEstimator.ALPHA, options.schemeParameter)); } writer.writeOpenTag(MarginalLikelihoodEstimator.MARGINAL_LIKELIHOOD_ESTIMATOR, attributes); writer.writeOpenTag("samplers"); writer.writeIDref("mcmc", "mcmc"); writer.writeCloseTag("samplers"); attributes = new ArrayList<Attribute>(); attributes.add(new Attribute.Default<String>(XMLParser.ID, "pathLikelihood")); writer.writeOpenTag(PathLikelihood.PATH_LIKELIHOOD, attributes); writer.writeOpenTag(PathLikelihood.SOURCE); writer.writeIDref(CompoundLikelihoodParser.POSTERIOR, CompoundLikelihoodParser.POSTERIOR); writer.writeCloseTag(PathLikelihood.SOURCE); writer.writeOpenTag(PathLikelihood.DESTINATION); writer.writeOpenTag(CompoundLikelihoodParser.WORKING_PRIOR); ArrayList<Parameter> parameters = beautiOptions.selectParameters(); for (Parameter param : parameters) { if (DEBUG) { System.err.println(param.toString() + " " + param.priorType.toString()); } // should leave out those parameters set by the coalescent if (param.priorType != PriorType.NONE_TREE_PRIOR) { // TODO: frequencies is multidimensional, is that automatically dealt with? writer.writeOpenTag( WorkingPriorParsers.NORMAL_REFERENCE_PRIOR, new Attribute[] { new Attribute.Default<String>("fileName", beautiOptions.logFileName), new Attribute.Default<String>("parameterColumn", param.getName()), new Attribute.Default<String>("burnin", "" + beautiOptions.chainLength * 0.10) }); writeParameterIdref(writer, param); writer.writeCloseTag(WorkingPriorParsers.NORMAL_REFERENCE_PRIOR); } } if (options.choiceTreeWorkingPrior.equals("Product of exponential distributions")) { writer.writeIDref("productOfExponentialsPosteriorMeansLoess", "exponentials"); } else { writer.writeIDref(CoalescentLikelihoodParser.COALESCENT_LIKELIHOOD, "coalescentReference"); } writer.writeCloseTag(CompoundLikelihoodParser.WORKING_PRIOR); writer.writeCloseTag(PathLikelihood.DESTINATION); writer.writeCloseTag(PathLikelihood.PATH_LIKELIHOOD); attributes = new ArrayList<Attribute>(); attributes.add(new Attribute.Default<String>(XMLParser.ID, "MLELog")); attributes.add(new Attribute.Default<Integer>("logEvery", options.mleLogEvery)); attributes.add(new Attribute.Default<String>("fileName", options.mleFileName)); writer.writeOpenTag("log", attributes); writer.writeIDref("pathLikelihood", "pathLikelihood"); writer.writeCloseTag("log"); writer.writeCloseTag(MarginalLikelihoodEstimator.MARGINAL_LIKELIHOOD_ESTIMATOR); writer.writeComment("Generalized stepping-stone sampling estimator from collected samples"); attributes = new ArrayList<Attribute>(); attributes.add(new Attribute.Default<String>("fileName", options.mleFileName)); writer.writeOpenTag( GeneralizedSteppingStoneSamplingAnalysis.GENERALIZED_STEPPING_STONE_SAMPLING_ANALYSIS, attributes); writer.writeTag( "sourceColumn", new Attribute.Default<String>("name", "pathLikelihood.source"), true); writer.writeTag( "destinationColumn", new Attribute.Default<String>("name", "pathLikelihood.destination"), true); writer.writeTag( "thetaColumn", new Attribute.Default<String>("name", "pathLikelihood.theta"), true); writer.writeCloseTag( GeneralizedSteppingStoneSamplingAnalysis.GENERALIZED_STEPPING_STONE_SAMPLING_ANALYSIS); } }
private boolean modelExists(String modelName) { HierarchicalModelComponentOptions comp = (HierarchicalModelComponentOptions) options.getComponentOptions(HierarchicalModelComponentOptions.class); return comp.modelExists(modelName); }
private void fireDataChanged() { options.updatePartitionAllLinks(); frame.setDirty(); }