use of dr.app.beauti.options.PartitionSubstitutionModel in project beast-mcmc by beast-dev.
the class CloneModelDialog method showDialog.
public int showDialog(List<PartitionSubstitutionModel> sourceModels) {
JOptionPane optionPane = new JOptionPane(optionPanel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
sourceModelCombo.removeAllItems();
for (PartitionSubstitutionModel model : sourceModels) {
sourceModelCombo.addItem(model);
}
final JDialog dialog = optionPane.createDialog(frame, "Clone model settings");
dialog.pack();
dialog.setVisible(true);
int result = JOptionPane.CANCEL_OPTION;
Integer value = (Integer) optionPane.getValue();
if (value != null && value != -1) {
result = value;
}
return result;
}
use of dr.app.beauti.options.PartitionSubstitutionModel in project beast-mcmc by beast-dev.
the class NexusApplicationImporter method parseMrBayesBlock.
/**
* Parses a 'MRBAYES' block.
*
* @param options the BEAUti options
* @param charSets a list of char sets to *add* to if any are defined in PAUP block
* @return a partition model representing the model defined in the MRBAYES block
* @throws dr.evolution.io.Importer.ImportException
* if MRBAYES block is poorly formed
* @throws java.io.IOException if I/O fails
*/
public PartitionSubstitutionModel parseMrBayesBlock(BeautiOptions options, List<CharSet> charSets) throws ImportException, IOException {
PartitionSubstitutionModel model = new PartitionSubstitutionModel(options, "nucs");
readTopLevelBlock(options, model, charSets);
return model;
}
use of dr.app.beauti.options.PartitionSubstitutionModel in project beast-mcmc by beast-dev.
the class PatternListGenerator method writePatternList.
/**
* Micro-sat
* @param partition
* @param microsatList
* @param writer
*/
public void writePatternList(PartitionPattern partition, List<Microsatellite> microsatList, XMLWriter writer) throws GeneratorException {
PartitionSubstitutionModel model = partition.getPartitionSubstitutionModel();
if (model.getDataType().getType() == DataType.MICRO_SAT) {
Patterns patterns = partition.getPatterns();
writer.writeComment("The patterns for microsatellite");
writer.writeOpenTag(MicrosatellitePatternParser.MICROSATPATTERN, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, partition.getName()) });
if (options.hasIdenticalTaxa() && !patterns.hasMask()) {
writer.writeIDref(TaxaParser.TAXA, TaxaParser.TAXA);
} else {
writer.writeIDref(TaxaParser.TAXA, partition.getName() + "." + TaxaParser.TAXA);
}
Microsatellite m = model.getMicrosatellite();
if (m == null)
throw new GeneratorException("Microsatellite is null in partition:\n" + partition.getName());
if (!microsatList.contains(m)) {
microsatList.add(m);
writer.writeTag(MicrosatelliteParser.MICROSAT, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, m.getName()), new Attribute.Default<Integer>(MicrosatelliteParser.MAX, m.getMax()), new Attribute.Default<Integer>(MicrosatelliteParser.MIN, m.getMin()), new Attribute.Default<Integer>(MicrosatelliteParser.UNIT_LENGTH, m.getUnitLength()) }, true);
} else {
writer.writeTag(MicrosatelliteParser.MICROSAT, new Attribute[] { new Attribute.Default<String>(XMLParser.IDREF, m.getName()) }, true);
}
writer.writeOpenTag(MicrosatellitePatternParser.MICROSAT_SEQ);
String seq = "";
int c = 0;
for (int i = 0; i < patterns.getTaxonCount(); i++) {
if (!patterns.isMasked(i)) {
if (c > 0)
seq += ",";
int state = patterns.getPatternState(i, 0);
if (state == Microsatellite.UNKNOWN_STATE_LENGTH) {
seq += Microsatellite.UNKNOWN_CHARACTER;
} else {
seq += Integer.toString(state);
}
c++;
}
}
writer.writeText(seq);
writer.writeCloseTag(MicrosatellitePatternParser.MICROSAT_SEQ);
writer.writeCloseTag(MicrosatellitePatternParser.MICROSATPATTERN);
} else {
}
}
use of dr.app.beauti.options.PartitionSubstitutionModel in project beast-mcmc by beast-dev.
the class SiteModelsPanel method setCurrentModels.
private void setCurrentModels(List<PartitionSubstitutionModel> models) {
modelPanelParent.removeAll();
currentModel = null;
Set<DataType> dataTypes = new HashSet<DataType>();
for (PartitionSubstitutionModel model : models) {
dataTypes.add(model.getDataType());
}
if (dataTypes.size() == 1) {
DataType dataType = dataTypes.iterator().next();
modelBorder.setTitle("Multiple " + dataType.getName() + " substitution models selected");
} else {
modelBorder.setTitle("Multiple mixed type substitution models selected");
}
cloneModelsAction.setEnabled(dataTypes.size() == 1);
repaint();
}
use of dr.app.beauti.options.PartitionSubstitutionModel in project beast-mcmc by beast-dev.
the class SiteModelsPanel method cloneModelSettings.
private void cloneModelSettings() {
if (cloneModelDialog == null) {
cloneModelDialog = new CloneModelDialog(frame);
}
Set<DataType> dataTypes = new HashSet<DataType>();
for (PartitionSubstitutionModel model : getSelectedModels()) {
dataTypes.add(model.getDataType());
}
if (dataTypes.size() == 1) {
DataType dataType = dataTypes.iterator().next();
List<PartitionSubstitutionModel> sourceModels = new ArrayList<PartitionSubstitutionModel>();
for (PartitionSubstitutionModel model : options.getPartitionSubstitutionModels()) {
if (model.getDataType().equals(dataType)) {
sourceModels.add(model);
}
}
int result = cloneModelDialog.showDialog(sourceModels);
if (result == -1 || result == JOptionPane.CANCEL_OPTION) {
return;
}
PartitionSubstitutionModel sourceModel = cloneModelDialog.getSourceModel();
for (PartitionSubstitutionModel model : getSelectedModels()) {
if (!model.equals(sourceModel)) {
model.copyFrom(sourceModel);
}
}
repaint();
}
}
Aggregations