Search in sources :

Example 1 with LinkedGroup

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

the class LinkageConstraintsParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    ArrayList<LinkedGroup> groups = new ArrayList<LinkedGroup>();
    for (int i = 0; i < xo.getChildCount(); i++) {
        Object child = xo.getChild(i);
        if (child instanceof LinkedGroup) {
            groups.add((LinkedGroup) child);
        }
    }
    LinkageConstraints lc = new LinkageConstraints(groups);
    return lc;
}
Also used : LinkedGroup(dr.evolution.LinkedGroup) ArrayList(java.util.ArrayList) LinkageConstraints(dr.evolution.LinkageConstraints)

Example 2 with LinkedGroup

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

the class LinkedGroupParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    TaxonList taxa = null;
    double linkageProbability = 0.9999999999;
    if (xo.hasAttribute("probability")) {
        linkageProbability = xo.getDoubleAttribute("probability");
    }
    taxa = (TaxonList) xo.getChild(TaxonList.class);
    LinkedGroup lg = new LinkedGroup(taxa, linkageProbability);
    return lg;
}
Also used : TaxonList(dr.evolution.util.TaxonList) LinkedGroup(dr.evolution.LinkedGroup)

Example 3 with LinkedGroup

use of dr.evolution.LinkedGroup 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)

Aggregations

LinkedGroup (dr.evolution.LinkedGroup)3 TaxonList (dr.evolution.util.TaxonList)2 LinkageConstraints (dr.evolution.LinkageConstraints)1 Taxon (dr.evolution.util.Taxon)1 ArrayList (java.util.ArrayList)1