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