Search in sources :

Example 41 with Tree

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);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) NewickImporter(dr.evolution.io.NewickImporter) SimpleTree(dr.evolution.tree.SimpleTree) Tree(dr.evolution.tree.Tree)

Example 42 with 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);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) SimpleTree(dr.evolution.tree.SimpleTree) Tree(dr.evolution.tree.Tree) SimpleTree(dr.evolution.tree.SimpleTree) SimpleNode(dr.evolution.tree.SimpleNode)

Example 43 with 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();
}
Also used : F84DistanceMatrix(dr.evolution.distance.F84DistanceMatrix) NeighborJoiningTree(dr.evolution.tree.NeighborJoiningTree) PartitionData(dr.app.beauti.options.PartitionData) UPGMATree(dr.evolution.tree.UPGMATree) NeighborJoiningTree(dr.evolution.tree.NeighborJoiningTree) Tree(dr.evolution.tree.Tree) TemporalRooting(dr.app.pathogen.TemporalRooting) F84DistanceMatrix(dr.evolution.distance.F84DistanceMatrix) DistanceMatrix(dr.evolution.distance.DistanceMatrix) UPGMATree(dr.evolution.tree.UPGMATree) Patterns(dr.evolution.alignment.Patterns)

Example 44 with Tree

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();
}
Also used : Tree(dr.evolution.tree.Tree)

Example 45 with Tree

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();
}
Also used : NexusImporter(dr.evolution.io.NexusImporter) Tree(dr.evolution.tree.Tree)

Aggregations

Tree (dr.evolution.tree.Tree)128 NewickImporter (dr.evolution.io.NewickImporter)32 ArrayList (java.util.ArrayList)31 TreeModel (dr.evomodel.tree.TreeModel)26 Parameter (dr.inference.model.Parameter)26 NexusImporter (dr.evolution.io.NexusImporter)18 TaxonList (dr.evolution.util.TaxonList)18 Taxa (dr.evolution.util.Taxa)17 FlexibleTree (dr.evolution.tree.FlexibleTree)16 Taxon (dr.evolution.util.Taxon)15 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)15 NodeRef (dr.evolution.tree.NodeRef)14 SimpleTree (dr.evolution.tree.SimpleTree)13 ImportException (dr.evolution.io.Importer.ImportException)12 Importer (dr.evolution.io.Importer)11 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)11 BeagleSequenceSimulator (dr.app.beagle.tools.BeagleSequenceSimulator)10 Partition (dr.app.beagle.tools.Partition)10 GammaSiteRateModel (dr.evomodel.siteratemodel.GammaSiteRateModel)10 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)9