Search in sources :

Example 31 with DataType

use of dr.evolution.datatype.DataType 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 32 with DataType

use of dr.evolution.datatype.DataType 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)

Example 33 with DataType

use of dr.evolution.datatype.DataType in project beast-mcmc by beast-dev.

the class MarkovJumpsTreeLikelihoodParser method createTreeLikelihood.

protected BeagleTreeLikelihood createTreeLikelihood(PatternList patternList, TreeModel treeModel, BranchModel branchModel, GammaSiteRateModel siteRateModel, BranchRateModel branchRateModel, TipStatesModel tipStatesModel, boolean useAmbiguities, PartialsRescalingScheme scalingScheme, boolean delayScaling, Map<Set<String>, Parameter> partialsRestrictions, XMLObject xo) throws XMLParseException {
    DataType dataType = branchModel.getRootSubstitutionModel().getDataType();
    String stateTag = xo.getAttribute(RECONSTRUCTION_TAG_NAME, RECONSTRUCTION_TAG);
    String jumpTag = xo.getAttribute(JUMP_TAG_NAME, JUMP_TAG);
    boolean scaleRewards = xo.getAttribute(SCALE_REWARDS, true);
    boolean useMAP = xo.getAttribute(MAP_RECONSTRUCTION, false);
    boolean useMarginalLogLikelihood = xo.getAttribute(MARGINAL_LIKELIHOOD, true);
    boolean useUniformization = xo.getAttribute(USE_UNIFORMIZATION, false);
    boolean reportUnconditionedColumns = xo.getAttribute(REPORT_UNCONDITIONED_COLUMNS, false);
    int nSimulants = xo.getAttribute(NUMBER_OF_SIMULANTS, 1);
    if (patternList.areUnique()) {
        throw new XMLParseException("Markov Jumps reconstruction cannot be used with compressed (unique) patterns.");
    }
    MarkovJumpsBeagleTreeLikelihood treeLikelihood = new MarkovJumpsBeagleTreeLikelihood(patternList, treeModel, branchModel, siteRateModel, branchRateModel, tipStatesModel, useAmbiguities, scalingScheme, delayScaling, partialsRestrictions, dataType, stateTag, useMAP, useMarginalLogLikelihood, useUniformization, reportUnconditionedColumns, nSimulants);
    int registersFound = parseAllChildren(xo, treeLikelihood, dataType.getStateCount(), jumpTag, MarkovJumpsType.COUNTS, // For backwards compatibility
    false);
    XMLObject cxo = xo.getChild(COUNTS);
    if (cxo != null) {
        registersFound += parseAllChildren(cxo, treeLikelihood, dataType.getStateCount(), jumpTag, MarkovJumpsType.COUNTS, false);
    }
    cxo = xo.getChild(REWARDS);
    if (cxo != null) {
        registersFound += parseAllChildren(cxo, treeLikelihood, dataType.getStateCount(), jumpTag, MarkovJumpsType.REWARDS, scaleRewards);
    }
    if (registersFound == 0) {
    // Some default values for testing
    //            double[] registration = new double[dataType.getStateCount()*dataType.getStateCount()];
    //            MarkovJumpsCore.fillRegistrationMatrix(registration,dataType.getStateCount()); // Count all transitions
    //            Parameter registerParameter = new Parameter.Default(registration);
    //            registerParameter.setId(jumpTag);
    //            treeLikelihood.addRegister(registerParameter,
    //                                       MarkovJumpsType.COUNTS,
    //                                       false);
    // Do nothing, should run the same as AncestralStateBeagleTreeLikelihood
    }
    boolean saveCompleteHistory = xo.getAttribute(SAVE_HISTORY, false);
    if (saveCompleteHistory) {
        Parameter allCounts = new Parameter.Default(dataType.getStateCount() * dataType.getStateCount());
        for (int i = 0; i < dataType.getStateCount(); ++i) {
            for (int j = 0; j < dataType.getStateCount(); ++j) {
                if (j == i) {
                    allCounts.setParameterValue(i * dataType.getStateCount() + j, 0.0);
                } else {
                    allCounts.setParameterValue(i * dataType.getStateCount() + j, 1.0);
                }
            }
        }
        allCounts.setId(MarkovJumpsBeagleTreeLikelihood.TOTAL_COUNTS);
        treeLikelihood.setLogHistories(xo.getAttribute(LOG_HISTORY, false));
        treeLikelihood.setUseCompactHistory(xo.getAttribute(COMPACT_HISTORY, false));
        treeLikelihood.addRegister(allCounts, MarkovJumpsType.HISTORY, false);
    }
    return treeLikelihood;
}
Also used : MarkovJumpsBeagleTreeLikelihood(dr.evomodel.treelikelihood.MarkovJumpsBeagleTreeLikelihood) DataType(dr.evolution.datatype.DataType) Parameter(dr.inference.model.Parameter)

Example 34 with DataType

use of dr.evolution.datatype.DataType in project beast-mcmc by beast-dev.

the class DataPanel method linkModels.

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();
}
Also used : ArrayList(java.util.ArrayList) DataType(dr.evolution.datatype.DataType)

Example 35 with DataType

use of dr.evolution.datatype.DataType 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

DataType (dr.evolution.datatype.DataType)66 Parameter (dr.inference.model.Parameter)26 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)11 FrequencyModel (dr.oldevomodel.substmodel.FrequencyModel)11 ArrayList (java.util.ArrayList)8 Sequence (dr.evolution.sequence.Sequence)7 PartitionSubstitutionModel (dr.app.beauti.options.PartitionSubstitutionModel)4 PatternList (dr.evolution.alignment.PatternList)4 GeneralDataType (dr.evolution.datatype.GeneralDataType)4 Taxon (dr.evolution.util.Taxon)4 TaxonList (dr.evolution.util.TaxonList)4 GeneralSubstitutionModel (dr.evomodel.substmodel.GeneralSubstitutionModel)4 SVSComplexSubstitutionModel (dr.oldevomodel.substmodel.SVSComplexSubstitutionModel)4 Attribute (dr.util.Attribute)4 Codons (dr.evolution.datatype.Codons)3 HiddenDataType (dr.evolution.datatype.HiddenDataType)3 NodeRef (dr.evolution.tree.NodeRef)3 Tree (dr.evolution.tree.Tree)3 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)3 SubstitutionModel (dr.evomodel.substmodel.SubstitutionModel)3