| 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.branchmodel; |
| 27 |
|
| 28 |
import dr.evomodel.branchmodel.BranchSpecificBranchModel; |
| 29 |
import dr.evomodel.branchmodel.ExternalInternalBranchModel; |
| 30 |
import dr.evomodel.substmodel.SubstitutionModel; |
| 31 |
import dr.evomodel.tree.TreeModel; |
| 32 |
import dr.xml.*; |
| 33 |
|
| 34 |
import java.util.logging.Logger; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public class ExternalInternalBranchModelParser extends AbstractXMLObjectParser { |
| 40 |
|
| 41 |
public static final String EXTERNAL_INTERNAL_BRANCH_MODEL = "externalInternalBranchModel"; |
| 42 |
public static final String EXTERNAL_BRANCHES = "externalBranches"; |
| 43 |
|
| 44 |
public String getParserName() { |
| 45 |
return EXTERNAL_INTERNAL_BRANCH_MODEL; |
| 46 |
} |
| 47 |
|
| 48 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 49 |
|
| 50 |
Logger.getLogger("dr.evomodel").info("\nUsing external-internal branch model."); |
| 51 |
|
| 52 |
TreeModel tree = (TreeModel) xo.getChild(TreeModel.class); |
| 53 |
SubstitutionModel internalSubstitutionModel = (SubstitutionModel) xo.getChild(SubstitutionModel.class); |
| 54 |
SubstitutionModel externalSubstitutionModel = (SubstitutionModel) xo.getElementFirstChild(EXTERNAL_BRANCHES); |
| 55 |
|
| 56 |
return new ExternalInternalBranchModel(tree, externalSubstitutionModel, internalSubstitutionModel); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
public String getParserDescription() { |
| 64 |
return |
| 65 |
"This element provides a branch model which allows different substitution models" + |
| 66 |
"on internal and external branches of the tree."; |
| 67 |
} |
| 68 |
|
| 69 |
public Class getReturnType() { |
| 70 |
return BranchSpecificBranchModel.class; |
| 71 |
} |
| 72 |
|
| 73 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 74 |
return rules; |
| 75 |
} |
| 76 |
|
| 77 |
private final XMLSyntaxRule[] rules = { |
| 78 |
new ElementRule(TreeModel.class, "The tree"), |
| 79 |
new ElementRule(SubstitutionModel.class, "The substitution model for internal branches"), |
| 80 |
new ElementRule(EXTERNAL_BRANCHES, |
| 81 |
new XMLSyntaxRule[]{ |
| 82 |
new ElementRule(SubstitutionModel.class, "The external branch substitution model"), |
| 83 |
}, false) |
| 84 |
}; |
| 85 |
|
| 86 |
} |