Search in sources :

Example 1 with PartitionSubstitutionModel

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;
}
Also used : EmptyBorder(javax.swing.border.EmptyBorder) PartitionSubstitutionModel(dr.app.beauti.options.PartitionSubstitutionModel)

Example 2 with PartitionSubstitutionModel

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;
}
Also used : PartitionSubstitutionModel(dr.app.beauti.options.PartitionSubstitutionModel)

Example 3 with PartitionSubstitutionModel

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 {
    }
}
Also used : Microsatellite(dr.evolution.datatype.Microsatellite) Attribute(dr.util.Attribute) PartitionSubstitutionModel(dr.app.beauti.options.PartitionSubstitutionModel) Patterns(dr.evolution.alignment.Patterns) SitePatterns(dr.evolution.alignment.SitePatterns)

Example 4 with PartitionSubstitutionModel

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();
}
Also used : DataType(dr.evolution.datatype.DataType) PartitionSubstitutionModel(dr.app.beauti.options.PartitionSubstitutionModel)

Example 5 with PartitionSubstitutionModel

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();
    }
}
Also used : DataType(dr.evolution.datatype.DataType) PartitionSubstitutionModel(dr.app.beauti.options.PartitionSubstitutionModel)

Aggregations

PartitionSubstitutionModel (dr.app.beauti.options.PartitionSubstitutionModel)17 Attribute (dr.util.Attribute)4 DataType (dr.evolution.datatype.DataType)3 AncestralStatesComponentOptions (dr.app.beauti.components.ancestralstates.AncestralStatesComponentOptions)1 SequenceErrorModelComponentOptions (dr.app.beauti.components.sequenceerror.SequenceErrorModelComponentOptions)1 AbstractPartitionData (dr.app.beauti.options.AbstractPartitionData)1 PartitionData (dr.app.beauti.options.PartitionData)1 NexusApplicationImporter (dr.app.beauti.util.NexusApplicationImporter)1 Alignment (dr.evolution.alignment.Alignment)1 CharSetAlignment (dr.evolution.alignment.CharSetAlignment)1 ConvertAlignment (dr.evolution.alignment.ConvertAlignment)1 Patterns (dr.evolution.alignment.Patterns)1 SitePatterns (dr.evolution.alignment.SitePatterns)1 Microsatellite (dr.evolution.datatype.Microsatellite)1 Importer (dr.evolution.io.Importer)1 NexusImporter (dr.evolution.io.NexusImporter)1 Tree (dr.evolution.tree.Tree)1 dr.evolution.util (dr.evolution.util)1 ArrayList (java.util.ArrayList)1 EmptyBorder (javax.swing.border.EmptyBorder)1