Search in sources :

Example 31 with Taxa

use of dr.evolution.util.Taxa in project beast-mcmc by beast-dev.

the class TreesTableModel method applyTaxa.

// END: setRow
public void applyTaxa(Tree tree) {
    // set attributes to be parsed later in Taxa panel
    Taxa taxa = new Taxa();
    for (Taxon taxon : tree.asList()) {
        double absoluteHeight = Utils.getAbsoluteTaxonHeight(taxon, tree);
        taxon.setAttribute(Utils.ABSOLUTE_HEIGHT, absoluteHeight);
        taxon.setAttribute(Utils.TREE_FILENAME, tree.getId());
        taxa.addTaxon(taxon);
        dataList.allTaxa.addTaxon(taxon);
    }
// END: taxon loop
}
Also used : Taxa(dr.evolution.util.Taxa) Taxon(dr.evolution.util.Taxon)

Example 32 with Taxa

use of dr.evolution.util.Taxa in project beast-mcmc by beast-dev.

the class Utils method importTaxaFromFile.

// END: countLines
public static Taxa importTaxaFromFile(File file) throws IOException {
    Taxa taxa = new Taxa();
    Taxon taxon;
    String[] lines = Utils.loadStrings(file.getAbsolutePath());
    for (int i = 0; i < lines.length; i++) {
        String[] line = lines[i].split("\\s+");
        taxon = new Taxon(line[TaxaEditorTableModel.NAME_INDEX]);
        taxon.setAttribute(Utils.ABSOLUTE_HEIGHT, Double.valueOf(line[TaxaEditorTableModel.HEIGHT_INDEX]));
        taxa.addTaxon(taxon);
    }
    return taxa;
}
Also used : Taxa(dr.evolution.util.Taxa) Taxon(dr.evolution.util.Taxon)

Example 33 with Taxa

use of dr.evolution.util.Taxa in project beast-mcmc by beast-dev.

the class TestCalibratedYuleModel method createTreeModel.

protected DefaultTreeModel createTreeModel(int treeSize) throws Exception {
    taxa = new Taxa();
    for (int i = 0; i < treeSize; i++) {
        taxa.addTaxon(new Taxon("T" + Integer.toString(i)));
    }
    // System.out.println("taxaSubSet_size = " + taxaSubSet.getTaxonCount());
    Parameter popSize = new Parameter.Default(treeSize);
    popSize.setId(ConstantPopulationModelParser.POPULATION_SIZE);
    ConstantPopulationModel startingTree = new ConstantPopulationModel(popSize, Units.Type.YEARS);
    Tree tree = calibration(taxa, startingTree);
    // treeModel
    return new DefaultTreeModel(tree);
}
Also used : Taxa(dr.evolution.util.Taxa) ConstantPopulationModel(dr.evomodel.coalescent.demographicmodel.ConstantPopulationModel) Taxon(dr.evolution.util.Taxon) Parameter(dr.inference.model.Parameter) SimpleTree(dr.evolution.tree.SimpleTree) Tree(dr.evolution.tree.Tree)

Example 34 with Taxa

use of dr.evolution.util.Taxa in project beast-mcmc by beast-dev.

the class FilteredTreeTraitTest method testBackboneFilter.

public void testBackboneFilter() {
    Taxa taxonList = new Taxa();
    taxonList.addTaxon(taxa[0]);
    taxonList.addTaxon(taxa[1]);
    TreeTrait backboneFilter = new TreeTrait.FilteredD(dummyTrait, new BackboneNodeFilter("backbone", tree, taxonList, true, true));
    treeTraitProvider.addTrait(backboneFilter);
    TreeTrait sumTrait = new TreeTrait.SumOverTreeD(backboneFilter);
    treeTraitProvider.addTrait(sumTrait);
    System.out.println("BackboneFilter Test");
    StringBuffer buffer = new StringBuffer();
    TreeUtils.newick(tree, tree.getRoot(), false, TreeUtils.BranchLengthType.LENGTHS_AS_TIME, // format
    null, // branchRates,
    null, new TreeTraitProvider[] { treeTraitProvider }, // idMap,
    null, buffer);
    System.out.println("Tree: " + buffer.toString());
    double traitValue = (Double) sumTrait.getTrait(tree, null);
    System.out.println("Trait: " + traitValue);
    // TODO Get real result
    assertEquals(traitValue, 7.0);
}
Also used : Taxa(dr.evolution.util.Taxa) BackboneNodeFilter(dr.evomodel.tree.BackboneNodeFilter)

Example 35 with Taxa

use of dr.evolution.util.Taxa in project beast-mcmc by beast-dev.

the class GhostTreeModelTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    Taxa ghostTaxa = new Taxa("ghost");
    ghostTaxa.addTaxon(new Taxon("g1"));
    ghostTaxa.addTaxon(new Taxon("g2"));
    Taxa corporealTaxa = new Taxa("corporeal");
    corporealTaxa.addTaxon(new Taxon("0"));
    corporealTaxa.addTaxon(new Taxon("1"));
    corporealTaxa.addTaxon(new Taxon("2"));
    Taxa allTaxa = new Taxa(ghostTaxa);
    allTaxa.addTaxa(corporealTaxa);
    NewickImporter importer = new NewickImporter("(((g1:0.5,0:1):0.5,1:1):1,(g2:1,2:1):0.5)");
    Tree superTree = importer.importTree(allTaxa);
    ghostTree = new GhostTreeModel(superTree, ghostTaxa);
    corporealTree = ghostTree.getCorporealTreeModel();
}
Also used : Taxa(dr.evolution.util.Taxa) Taxon(dr.evolution.util.Taxon) NewickImporter(dr.evolution.io.NewickImporter) Tree(dr.evolution.tree.Tree) GhostTreeModel(dr.evomodel.bigfasttree.ghosttree.GhostTreeModel)

Aggregations

Taxa (dr.evolution.util.Taxa)75 Taxon (dr.evolution.util.Taxon)34 ArrayList (java.util.ArrayList)23 Tree (dr.evolution.tree.Tree)19 TaxonList (dr.evolution.util.TaxonList)15 Attribute (dr.util.Attribute)13 DefaultTreeModel (dr.evomodel.tree.DefaultTreeModel)10 TreeModel (dr.evomodel.tree.TreeModel)10 Patterns (dr.evolution.alignment.Patterns)9 Microsatellite (dr.evolution.datatype.Microsatellite)9 IOException (java.io.IOException)8 NewickImporter (dr.evolution.io.NewickImporter)7 Parameter (dr.inference.model.Parameter)6 Date (dr.evolution.util.Date)5 GammaSiteModel (dr.oldevomodel.sitemodel.GammaSiteModel)5 SimpleAlignment (dr.evolution.alignment.SimpleAlignment)4 ImportException (dr.evolution.io.Importer.ImportException)4 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)4 CoalescentSimulator (dr.evomodel.coalescent.CoalescentSimulator)4 PartitionTreeModel (dr.app.beauti.options.PartitionTreeModel)3