use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.
the class TraceCorrelationAssert method createSpecifiedTree.
protected void createSpecifiedTree(String t) throws Exception {
// Tree.Utils.newick(tree)
//create tree
NewickImporter importer = new NewickImporter(t);
Tree tree = importer.importTree(null);
//treeModel
treeModel = new TreeModel(tree);
}
use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.
the class TraceCorrelationAssert method createPrimateTreeModel.
//************************** data ****************************
protected TreeModel createPrimateTreeModel() {
SimpleNode[] nodes = new SimpleNode[10];
for (int n = 0; n < 10; n++) {
nodes[n] = new SimpleNode();
}
// nodes[0].setHeight(0);
// human
nodes[0].setTaxon(taxa[0]);
// chimp
nodes[1].setTaxon(taxa[1]);
// bonobo
nodes[2].setTaxon(taxa[2]);
nodes[3].setHeight(0.010772);
nodes[3].addChild(nodes[1]);
nodes[3].addChild(nodes[2]);
nodes[4].setHeight(0.024003);
nodes[4].addChild(nodes[0]);
nodes[4].addChild(nodes[3]);
// gorilla
nodes[5].setTaxon(taxa[3]);
nodes[6].setHeight(0.036038);
nodes[6].addChild(nodes[4]);
nodes[6].addChild(nodes[5]);
// orangutan
nodes[7].setTaxon(taxa[4]);
nodes[8].setHeight(0.069125);
nodes[8].addChild(nodes[6]);
nodes[8].addChild(nodes[7]);
// siamang
nodes[9].setTaxon(taxa[5]);
SimpleNode root = new SimpleNode();
root.setHeight(0.099582);
root.addChild(nodes[8]);
root.addChild(nodes[9]);
Tree tree = new SimpleTree(root);
tree.setUnits(Units.Type.YEARS);
//treeModel
return new TreeModel(tree);
}
use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.
the class OldTreesPanel method createTree.
private void createTree() {
if (generateTreeDialog == null) {
generateTreeDialog = new GenerateTreeDialog(frame);
}
int result = generateTreeDialog.showDialog(options);
if (result != JOptionPane.CANCEL_OPTION) {
GenerateTreeDialog.MethodTypes methodType = generateTreeDialog.getMethodType();
PartitionData partition = generateTreeDialog.getDataPartition();
Patterns patterns = new Patterns(partition.getAlignment());
DistanceMatrix distances = new F84DistanceMatrix(patterns);
Tree tree;
TemporalRooting temporalRooting;
switch(methodType) {
case NJ:
tree = new NeighborJoiningTree(distances);
temporalRooting = new TemporalRooting(tree);
tree = temporalRooting.findRoot(tree, TemporalRooting.RootingFunction.CORRELATION);
break;
case UPGMA:
tree = new UPGMATree(distances);
temporalRooting = new TemporalRooting(tree);
break;
default:
throw new IllegalArgumentException("unknown method type");
}
tree.setId(generateTreeDialog.getName());
options.userTrees.add(tree);
treesTableModel.fireTableDataChanged();
int row = options.userTrees.size() - 1;
treesTable.getSelectionModel().setSelectionInterval(row, row);
}
fireTreePriorsChanged();
}
use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.
the class PartitionTreeModelPanel method setupPanel.
public void setupPanel() {
removeAll();
if (options.isEBSPSharingSamePrior() || options.useStarBEAST) {
addComponentWithLabel("Ploidy type:", ploidyTypeCombo);
}
if (partitionTreeModel.getDataType().getType() != DataType.MICRO_SAT) {
addSpanningComponent(randomTreeRadio);
addSpanningComponent(upgmaTreeRadio);
addSpanningComponent(userTreeRadio);
addComponents(userTreeLabel, userTreeCombo);
userTreeCombo.removeAllItems();
if (options.userTrees.size() < 1) {
userTreeCombo.addItem(NO_TREE);
} else {
Object selectedItem = userTreeCombo.getSelectedItem();
for (Tree tree : options.userTrees) {
userTreeCombo.addItem(tree.getId());
}
if (selectedItem != null) {
userTreeCombo.setSelectedItem(selectedItem);
} else {
userTreeCombo.setSelectedIndex(0);
}
}
// addComponent(treeDisplayButton); // todo JTreeDisplay not work properly
addComponents(treeFormatLabel, treeFormatCombo);
addComponent(userTreeInfo);
}
// generateTreeAction.setEnabled(options != null && options.dataPartitions.size() > 0);
setOptions();
validate();
repaint();
}
use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.
the class PatristicDistanceMatrix method main.
public static void main(String[] args) throws IOException, Importer.ImportException {
File file = new File(args[0]);
File outFile = new File(args[1]);
PrintWriter writer = new PrintWriter(new FileWriter(outFile));
NexusImporter importer = new NexusImporter(new FileReader(file));
Tree[] trees = importer.importTrees(null);
System.out.println("Found " + trees.length + " trees.");
for (Tree tree : trees) {
PatristicDistanceMatrix matrix = new PatristicDistanceMatrix(tree);
writer.println(matrix.toString());
}
writer.flush();
writer.close();
}
Aggregations