use of dr.evomodel.tree.DefaultTreeModel in project beast-mcmc by beast-dev.
the class DataLikelihoodTester2 method createSpecifiedTree.
private static TreeModel createSpecifiedTree(String t) throws Exception {
NewickImporter importer = new NewickImporter(t);
Tree tree = importer.importTree(null);
// treeModel
return new DefaultTreeModel(tree);
}
use of dr.evomodel.tree.DefaultTreeModel in project beast-mcmc by beast-dev.
the class SubtreeSlideOperatorParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
boolean swapRates = xo.getAttribute(SWAP_RATES, false);
boolean swapTraits = xo.getAttribute(SWAP_TRAITS, false);
boolean scaledDirichletBranches = xo.getAttribute(DIRICHLET_BRANCHES, false);
AdaptationMode mode = AdaptationMode.DEFAULT;
if (xo.hasAttribute(AdaptableMCMCOperator.AUTO_OPTIMIZE)) {
if (xo.getBooleanAttribute(AdaptableMCMCOperator.AUTO_OPTIMIZE)) {
mode = AdaptationMode.ADAPTATION_ON;
} else {
mode = AdaptationMode.ADAPTATION_OFF;
}
}
DefaultTreeModel treeModel = (DefaultTreeModel) xo.getChild(DefaultTreeModel.class);
final double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
final double targetAcceptance = xo.getAttribute(TARGET_ACCEPTANCE, 0.234);
final double size = xo.getAttribute("size", 1.0);
if (Double.isInfinite(size) || size <= 0.0) {
throw new XMLParseException("size attribute must be positive and not infinite. was " + size + " for tree " + treeModel.getId());
}
final boolean gaussian = xo.getBooleanAttribute("gaussian");
SubtreeSlideOperator operator = new SubtreeSlideOperator(treeModel, weight, size, gaussian, swapRates, swapTraits, scaledDirichletBranches, mode, targetAcceptance);
return operator;
}
use of dr.evomodel.tree.DefaultTreeModel in project beast-mcmc by beast-dev.
the class TreeBitRandomWalkOperatorParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
DefaultTreeModel treeModel = (DefaultTreeModel) xo.getChild(DefaultTreeModel.class);
String trait1 = null;
String trait2 = null;
if (xo.hasAttribute(INDICTATOR_TRAIT))
trait1 = xo.getStringAttribute(INDICTATOR_TRAIT);
if (xo.hasAttribute(TRAIT2))
trait2 = xo.getStringAttribute(TRAIT2);
int k = xo.getAttribute("k", 1);
boolean swapTrait2 = xo.getAttribute(SWAP_TRAIT2, true);
return new TreeBitRandomWalkOperator(treeModel, trait1, trait2, weight, k, swapTrait2);
}
use of dr.evomodel.tree.DefaultTreeModel in project beast-mcmc by beast-dev.
the class TreeBitMoveOperatorParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
DefaultTreeModel treeModel = (DefaultTreeModel) xo.getChild(DefaultTreeModel.class);
String trait1 = null;
String trait2 = null;
if (xo.hasAttribute(INDICTATOR_TRAIT))
trait1 = xo.getStringAttribute(INDICTATOR_TRAIT);
if (xo.hasAttribute(TRAIT2))
trait2 = xo.getStringAttribute(TRAIT2);
return new TreeBitMoveOperator(treeModel, trait1, trait2, weight);
}
use of dr.evomodel.tree.DefaultTreeModel in project beast-mcmc by beast-dev.
the class BeagleSeqSimTest method simulateAminoAcid.
// END: simulateThreePartitions
static void simulateAminoAcid() {
try {
System.out.println("Test case 4: simulateAminoAcid");
MathUtils.setSeed(666);
int sequenceLength = 10;
ArrayList<Partition> partitionsList = new ArrayList<Partition>();
// create tree
NewickImporter importer = new NewickImporter("(SimSeq1:73.7468,(SimSeq2:25.256989999999995,SimSeq3:45.256989999999995):18.48981);");
Tree tree = importer.importTree(null);
DefaultTreeModel treeModel = new DefaultTreeModel(tree);
// create site model
GammaSiteRateModel siteRateModel = new GammaSiteRateModel("siteModel");
// create branch rate model
BranchRateModel branchRateModel = new DefaultBranchRateModel();
// create Frequency Model
Parameter freqs = new Parameter.Default(new double[] { 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05 });
FrequencyModel freqModel = new FrequencyModel(AminoAcids.INSTANCE, freqs);
// create substitution model
EmpiricalRateMatrix rateMatrix = Blosum62.INSTANCE;
EmpiricalAminoAcidModel empiricalAminoAcidModel = new EmpiricalAminoAcidModel(rateMatrix, freqModel);
HomogeneousBranchModel substitutionModel = new HomogeneousBranchModel(empiricalAminoAcidModel);
// create partition
Partition partition1 = new //
Partition(//
treeModel, //
substitutionModel, //
siteRateModel, //
branchRateModel, //
freqModel, // from
0, // to
sequenceLength - 1, // every
1);
partitionsList.add(partition1);
// feed to sequence simulator and generate data
BeagleSequenceSimulator simulator = new BeagleSequenceSimulator(partitionsList);
System.out.println(simulator.simulate(simulateInPar, false).toString());
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
// END: try-catch
}
Aggregations