use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.
the class SpeciesTreeStatistic method isCompatible.
private boolean isCompatible(NodeRef popNode, Set<String> species) {
if (popTree.isExternal(popNode)) {
Taxon speciesTaxon = (Taxon) popTree.getTaxonAttribute(popNode.getNumber(), "species");
species.add(speciesTaxon.getId());
} else {
Set<String> speciesTaxa = new HashSet<String>();
int childCount = popTree.getChildCount(popNode);
for (int i = 0; i < childCount; i++) {
if (!isCompatible(popTree.getChild(popNode, i), speciesTaxa)) {
return false;
}
}
if (species != null) {
species.addAll(speciesTaxa);
NodeRef speciesNode = TreeUtils.getCommonAncestorNode(speciesTree, speciesTaxa);
if (popTree.getNodeHeight(popNode) < speciesTree.getNodeHeight(speciesNode)) {
return false;
}
}
}
return true;
}
use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.
the class TestCalibratedYuleModel method createTreeModel.
protected TreeModel 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 TreeModel(tree);
}
use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.
the class Utils method taxaToString.
// END: taxonToString
public static String taxaToString(Taxa taxa, boolean printNames) {
String string = "";
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
string += taxonToString(taxon, printNames) + ("\n");
}
return string;
}
use of dr.evolution.util.Taxon 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.Taxon in project beast-mcmc by beast-dev.
the class Utils method removeTaxaWithAttributeValue.
// END: importTreeFromFile
public static void removeTaxaWithAttributeValue(PartitionDataList dataList, String attribute, String value) {
for (int i = 0; i < dataList.allTaxa.getTaxonCount(); i++) {
Taxon taxon = dataList.allTaxa.getTaxon(i);
if (taxon.getAttribute(attribute).toString().equalsIgnoreCase(value)) {
dataList.allTaxa.removeTaxon(taxon);
i--;
}
}
}
Aggregations