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
}
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;
}
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);
}
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);
}
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();
}
Aggregations