| 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.evomodelxml.treelikelihood; |
| 27 |
|
| 28 |
import dr.evomodel.siteratemodel.GammaSiteRateModel; |
| 29 |
import dr.evomodel.treelikelihood.BeagleOperationReport; |
| 30 |
import dr.evolution.alignment.Alignment; |
| 31 |
import dr.evolution.alignment.PatternList; |
| 32 |
import dr.evolution.alignment.SitePatterns; |
| 33 |
import dr.evomodel.branchratemodel.BranchRateModel; |
| 34 |
import dr.evomodel.tree.TreeModel; |
| 35 |
import dr.xml.*; |
| 36 |
|
| 37 |
import java.io.PrintWriter; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public class BeagleOperationParser extends AbstractXMLObjectParser { |
| 44 |
|
| 45 |
|
| 46 |
public static final String OPERATION_REPORT = "beagleOperationReport"; |
| 47 |
public static final String BRANCH_FILE_NAME = "branchFileName"; |
| 48 |
public static final String OPERATION_FILE_NAME = "operationFileName"; |
| 49 |
|
| 50 |
public String getParserName() { |
| 51 |
return OPERATION_REPORT; |
| 52 |
} |
| 53 |
|
| 54 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 55 |
|
| 56 |
SitePatterns patternList = (SitePatterns) xo.getChild(PatternList.class); |
| 57 |
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class); |
| 58 |
BranchRateModel rateModel = (BranchRateModel) xo.getChild(BranchRateModel.class); |
| 59 |
Alignment alignment = (Alignment) xo.getChild(Alignment.class); |
| 60 |
GammaSiteRateModel substitutionModel = (GammaSiteRateModel) xo.getChild(GammaSiteRateModel.class); |
| 61 |
|
| 62 |
PrintWriter branch = null, operation = null; |
| 63 |
|
| 64 |
if (xo.hasAttribute(BRANCH_FILE_NAME)) { |
| 65 |
branch = XMLParser.getFilePrintWriter(xo, OPERATION_REPORT, BRANCH_FILE_NAME); |
| 66 |
} |
| 67 |
if (xo.hasAttribute(OPERATION_FILE_NAME)) { |
| 68 |
operation = XMLParser.getFilePrintWriter(xo, OPERATION_REPORT, OPERATION_FILE_NAME); |
| 69 |
} |
| 70 |
|
| 71 |
return new BeagleOperationReport(treeModel, patternList, rateModel, substitutionModel, alignment, branch, operation); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
public String getParserDescription() { |
| 79 |
return "This element represents the likelihood of a patternlist on a tree given the site model."; |
| 80 |
} |
| 81 |
|
| 82 |
public Class getReturnType() { |
| 83 |
return BeagleOperationReport.class; |
| 84 |
} |
| 85 |
|
| 86 |
public static final XMLSyntaxRule[] rules = { |
| 87 |
new ElementRule(PatternList.class, 2, 2), |
| 88 |
new ElementRule(TreeModel.class), |
| 89 |
new ElementRule(BranchRateModel.class), |
| 90 |
new ElementRule(GammaSiteRateModel.class), |
| 91 |
|
| 92 |
AttributeRule.newStringRule(BRANCH_FILE_NAME, true), |
| 93 |
AttributeRule.newStringRule(OPERATION_FILE_NAME, true), |
| 94 |
}; |
| 95 |
|
| 96 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 97 |
return rules; |
| 98 |
} |
| 99 |
} |