Search in sources :

Example 16 with TaxonList

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

the class MetagenomeDataParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    TaxonList taxa = null;
    taxa = (TaxonList) xo.getChild(TaxonList.class);
    if (taxa == null)
        taxa = (Tree) xo.getChild(Tree.class);
    Alignment alignment = (Alignment) xo.getChild(Alignment.class);
    LinkageConstraints lc = (LinkageConstraints) xo.getChild(LinkageConstraints.class);
    boolean fixedReferenceTree = false;
    if (xo.hasAttribute("fixedReferenceTree")) {
        fixedReferenceTree = xo.getBooleanAttribute("fixedReferenceTree");
    }
    MetagenomeData md = new MetagenomeData(taxa, alignment, lc, fixedReferenceTree);
    return md;
}
Also used : Alignment(dr.evolution.alignment.Alignment) TaxonList(dr.evolution.util.TaxonList) Tree(dr.evolution.tree.Tree) MetagenomeData(dr.evolution.MetagenomeData) LinkageConstraints(dr.evolution.LinkageConstraints)

Example 17 with TaxonList

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

the class HiddenLinkageLikelihood method getLogLikelihood.

public double getLogLikelihood() {
    double logL = 0;
    // first check whether the reads are linked together
    // according to the linkage constraints provided as data in the
    // input file
    ArrayList<LinkedGroup> linkedGroups = hlm.getData().getConstraints();
    for (LinkedGroup lg : linkedGroups) {
        TaxonList tl = lg.getLinkedReads();
        int found = 0;
        for (int l = 0; l < hlm.getLinkageGroupCount(); l++) {
            Set<Taxon> group = hlm.getGroup(l);
            for (int i = 0; i < tl.getTaxonCount(); i++) {
                if (group.contains(tl.getTaxon(i)))
                    found++;
            }
            if (found == tl.getTaxonCount()) {
                logL += Math.log(lg.getLinkageProbability());
                break;
            } else if (found > 0) {
                logL += Math.log(1.0 - lg.getLinkageProbability());
                break;
            }
        }
    }
    // reference tree topology
    if (hlm.getData().getFixedReferenceTree()) {
        // not yet implemented.
        logL += Double.NEGATIVE_INFINITY;
    }
    return logL;
}
Also used : TaxonList(dr.evolution.util.TaxonList) LinkedGroup(dr.evolution.LinkedGroup) Taxon(dr.evolution.util.Taxon)

Example 18 with TaxonList

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

the class ParsimonyStatisticParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    String name = xo.getAttribute(Statistic.NAME, xo.getId());
    Tree tree = (Tree) xo.getChild(Tree.class);
    XMLObject cxo = xo.getChild(STATE);
    TaxonList taxa = (TaxonList) cxo.getChild(TaxonList.class);
    try {
        return new ParsimonyStatistic(name, tree, taxa);
    } catch (TreeUtils.MissingTaxonException mte) {
        throw new XMLParseException("Taxon, " + mte + ", in " + getParserName() + "was not found in the tree.");
    }
}
Also used : TaxonList(dr.evolution.util.TaxonList) Tree(dr.evolution.tree.Tree) ParsimonyStatistic(dr.evomodel.tree.ParsimonyStatistic) TreeUtils(dr.evolution.tree.TreeUtils)

Example 19 with TaxonList

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

the class LineageSitePatternsParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Alignment alignment = (Alignment) xo.getChild(Alignment.class);
    TaxonList taxa = null;
    int from = 0;
    int to = -1;
    int every = xo.getAttribute(EVERY, 1);
    boolean strip = xo.getAttribute(STRIP, true);
    boolean unique = xo.getAttribute(UNIQUE, true);
    if (xo.hasAttribute(FROM)) {
        from = xo.getIntegerAttribute(FROM) - 1;
        if (from < 0)
            throw new XMLParseException("illegal 'from' attribute in patterns element");
    }
    if (xo.hasAttribute(TO)) {
        to = xo.getIntegerAttribute(TO) - 1;
        if (to < 0 || to < from)
            throw new XMLParseException("illegal 'to' attribute in patterns element");
    }
    if (every <= 0)
        throw new XMLParseException("illegal 'every' attribute in patterns element");
    if (xo.hasChildNamed(TAXON_LIST)) {
        taxa = (TaxonList) xo.getElementFirstChild(TAXON_LIST);
    }
    if (from > alignment.getSiteCount())
        throw new XMLParseException("illegal 'from' attribute in patterns element");
    if (to > alignment.getSiteCount())
        throw new XMLParseException("illegal 'to' attribute in patterns element");
    LineageSitePatterns patterns = new LineageSitePatterns(alignment, taxa, from, to, every, strip, unique);
    int f = from + 1;
    // fixed a *display* error by adding + 1 for consistency with f = from + 1
    int t = to + 1;
    if (to == -1)
        t = alignment.getSiteCount();
    if (xo.hasAttribute(XMLParser.ID)) {
        final Logger logger = Logger.getLogger("dr.evoxml");
        logger.info("Site patterns '" + xo.getId() + "' created from positions " + Integer.toString(f) + "-" + Integer.toString(t) + " of alignment '" + alignment.getId() + "'");
        if (every > 1) {
            logger.info("  only using every " + every + " site");
        }
        logger.info("  pattern count = " + patterns.getPatternCount());
    }
    return patterns;
}
Also used : Alignment(dr.evolution.alignment.Alignment) TaxonList(dr.evolution.util.TaxonList) Logger(java.util.logging.Logger)

Example 20 with TaxonList

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

the class TaxonSetPanel method setCurrentTaxonSet.

protected void setCurrentTaxonSet(Taxa taxonSet) {
    this.currentTaxonSet = taxonSet;
    includedTaxa.clear();
    excludedTaxa.clear();
    if (currentTaxonSet != null) {
        for (int i = 0; i < taxonSet.getTaxonCount(); i++) {
            includedTaxa.add(taxonSet.getTaxon(i));
        }
        Collections.sort(includedTaxa);
        // get taxa associated to each tree
        PartitionTreeModel treeModel = options.taxonSetsTreeModel.get(currentTaxonSet);
        TaxonList alignment = options.getDataPartitions(treeModel).get(0).getTaxonList();
        Taxa taxa = new Taxa(alignment);
        for (int i = 0; i < taxa.getTaxonCount(); i++) {
            excludedTaxa.add(taxa.getTaxon(i));
        }
        excludedTaxa.removeAll(includedTaxa);
        Collections.sort(excludedTaxa);
    }
    setTaxonSetTitle();
    setupTaxonSetsComboBoxes();
    includedTaxaTableModel.fireTableDataChanged();
    excludedTaxaTableModel.fireTableDataChanged();
}
Also used : Taxa(dr.evolution.util.Taxa) TaxonList(dr.evolution.util.TaxonList) PartitionTreeModel(dr.app.beauti.options.PartitionTreeModel)

Aggregations

TaxonList (dr.evolution.util.TaxonList)59 Tree (dr.evolution.tree.Tree)18 Taxon (dr.evolution.util.Taxon)18 TreeUtils (dr.evolution.tree.TreeUtils)15 Taxa (dr.evolution.util.Taxa)13 Parameter (dr.inference.model.Parameter)13 ArrayList (java.util.ArrayList)13 TreeModel (dr.evomodel.tree.TreeModel)11 Alignment (dr.evolution.alignment.Alignment)6 SitePatterns (dr.evolution.alignment.SitePatterns)5 SimpleTree (dr.evolution.tree.SimpleTree)5 SimpleAlignment (dr.evolution.alignment.SimpleAlignment)4 Importer (dr.evolution.io.Importer)4 ImportException (dr.evolution.io.Importer.ImportException)4 NexusImporter (dr.evolution.io.NexusImporter)4 CoalescentLikelihood (dr.evomodel.coalescent.CoalescentLikelihood)4 CoalescentSimulator (dr.evomodel.coalescent.CoalescentSimulator)4 NodeRef (dr.evolution.tree.NodeRef)3 SubstitutionModel (dr.evomodel.substmodel.SubstitutionModel)3 CompoundLikelihood (dr.inference.model.CompoundLikelihood)3