Search in sources :

Example 6 with Taxon

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;
}
Also used : NodeRef(dr.evolution.tree.NodeRef) Taxon(dr.evolution.util.Taxon) HashSet(java.util.HashSet)

Example 7 with Taxon

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);
}
Also used : Taxa(dr.evolution.util.Taxa) ConstantPopulationModel(dr.evomodel.coalescent.ConstantPopulationModel) Taxon(dr.evolution.util.Taxon) Parameter(dr.inference.model.Parameter) SimpleTree(dr.evolution.tree.SimpleTree) Tree(dr.evolution.tree.Tree)

Example 8 with Taxon

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

Example 9 with Taxon

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;
}
Also used : Taxa(dr.evolution.util.Taxa) Taxon(dr.evolution.util.Taxon)

Example 10 with Taxon

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

Aggregations

Taxon (dr.evolution.util.Taxon)151 Taxa (dr.evolution.util.Taxa)31 ArrayList (java.util.ArrayList)24 TaxonList (dr.evolution.util.TaxonList)19 NodeRef (dr.evolution.tree.NodeRef)18 Date (dr.evolution.util.Date)18 Tree (dr.evolution.tree.Tree)15 Sequence (dr.evolution.sequence.Sequence)12 TreeModel (dr.evomodel.tree.TreeModel)12 Parameter (dr.inference.model.Parameter)12 Attribute (dr.util.Attribute)11 SimpleAlignment (dr.evolution.alignment.SimpleAlignment)10 Patterns (dr.evolution.alignment.Patterns)9 NewickImporter (dr.evolution.io.NewickImporter)7 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)7 Microsatellite (dr.evolution.datatype.Microsatellite)6 IOException (java.io.IOException)5 HashSet (java.util.HashSet)5 PatternList (dr.evolution.alignment.PatternList)4 DataType (dr.evolution.datatype.DataType)4