| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.oldevomodelxml.treelikelihood; |
| 27 |
|
| 28 |
import dr.evolution.alignment.PatternList; |
| 29 |
import dr.evomodel.branchratemodel.BranchRateModel; |
| 30 |
import dr.oldevomodel.sitemodel.SiteModel; |
| 31 |
import dr.evomodel.tipstatesmodel.TipStatesModel; |
| 32 |
import dr.evomodel.tree.TreeModel; |
| 33 |
import dr.oldevomodel.treelikelihood.TreeLikelihood; |
| 34 |
import dr.xml.*; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
@Deprecated |
| 39 |
public class TreeLikelihoodParser extends AbstractXMLObjectParser { |
| 40 |
|
| 41 |
public static final String TREE_LIKELIHOOD = "treeLikelihood"; |
| 42 |
public static final String ANCESTRAL_TREE_LIKELIHOOD = "ancestralTreeLikelihood"; |
| 43 |
public static final String USE_AMBIGUITIES = "useAmbiguities"; |
| 44 |
public static final String ALLOW_MISSING_TAXA = "allowMissingTaxa"; |
| 45 |
public static final String STORE_PARTIALS = "storePartials"; |
| 46 |
public static final String SCALING_FACTOR = "scalingFactor"; |
| 47 |
public static final String SCALING_THRESHOLD = "scalingThreshold"; |
| 48 |
public static final String FORCE_JAVA_CORE = "forceJavaCore"; |
| 49 |
public static final String FORCE_RESCALING = "forceRescaling"; |
| 50 |
|
| 51 |
|
| 52 |
public String getParserName() { |
| 53 |
return TREE_LIKELIHOOD; |
| 54 |
} |
| 55 |
|
| 56 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 57 |
|
| 58 |
boolean useAmbiguities = xo.getAttribute(USE_AMBIGUITIES, false); |
| 59 |
boolean allowMissingTaxa = xo.getAttribute(ALLOW_MISSING_TAXA, false); |
| 60 |
boolean storePartials = xo.getAttribute(STORE_PARTIALS, true); |
| 61 |
boolean forceJavaCore = xo.getAttribute(FORCE_JAVA_CORE, false); |
| 62 |
|
| 63 |
if (Boolean.valueOf(System.getProperty("java.only"))) { |
| 64 |
forceJavaCore = true; |
| 65 |
} |
| 66 |
|
| 67 |
PatternList patternList = (PatternList) xo.getChild(PatternList.class); |
| 68 |
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class); |
| 69 |
SiteModel siteModel = (SiteModel) xo.getChild(SiteModel.class); |
| 70 |
|
| 71 |
BranchRateModel branchRateModel = (BranchRateModel) xo.getChild(BranchRateModel.class); |
| 72 |
|
| 73 |
TipStatesModel tipStatesModel = (TipStatesModel) xo.getChild(TipStatesModel.class); |
| 74 |
if (tipStatesModel != null && tipStatesModel.getPatternList() != null) { |
| 75 |
throw new XMLParseException("The same sequence error model cannot be used for multiple partitions"); |
| 76 |
} |
| 77 |
if (tipStatesModel != null && tipStatesModel.getModelType() == TipStatesModel.Type.STATES) { |
| 78 |
throw new XMLParseException("The state emitting TipStateModel requires BEAGLE"); |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
boolean forceRescaling = xo.getAttribute(FORCE_RESCALING, false); |
| 83 |
|
| 84 |
return new TreeLikelihood( |
| 85 |
patternList, |
| 86 |
treeModel, |
| 87 |
siteModel, |
| 88 |
branchRateModel, |
| 89 |
tipStatesModel, |
| 90 |
useAmbiguities, allowMissingTaxa, storePartials, forceJavaCore, forceRescaling); |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public String getParserDescription() { |
| 98 |
return "This element represents the likelihood of a patternlist on a tree given the site model."; |
| 99 |
} |
| 100 |
|
| 101 |
public Class getReturnType() { |
| 102 |
return TreeLikelihood.class; |
| 103 |
} |
| 104 |
|
| 105 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 106 |
return rules; |
| 107 |
} |
| 108 |
|
| 109 |
private final XMLSyntaxRule[] rules = { |
| 110 |
AttributeRule.newBooleanRule(USE_AMBIGUITIES, true), |
| 111 |
AttributeRule.newBooleanRule(ALLOW_MISSING_TAXA, true), |
| 112 |
AttributeRule.newBooleanRule(STORE_PARTIALS, true), |
| 113 |
AttributeRule.newBooleanRule(FORCE_JAVA_CORE, true), |
| 114 |
AttributeRule.newBooleanRule(FORCE_RESCALING, true), |
| 115 |
new ElementRule(PatternList.class), |
| 116 |
new ElementRule(TreeModel.class), |
| 117 |
new ElementRule(SiteModel.class), |
| 118 |
new ElementRule(BranchRateModel.class, true), |
| 119 |
new ElementRule(TipStatesModel.class, true) |
| 120 |
}; |
| 121 |
} |