| 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.evomodel.alloppnet.parsers; |
| 27 |
|
| 28 |
|
| 29 |
import dr.evomodel.alloppnet.speciation.MulSpeciesTreeModel; |
| 30 |
import dr.evomodel.alloppnet.speciation.MulSpeciesTreePrior; |
| 31 |
import dr.evomodel.speciation.SpeciationModel; |
| 32 |
import dr.xml.AbstractXMLObjectParser; |
| 33 |
import dr.xml.ElementRule; |
| 34 |
import dr.xml.XMLObject; |
| 35 |
import dr.xml.XMLParseException; |
| 36 |
import dr.xml.XMLSyntaxRule; |
| 37 |
|
| 38 |
public class MulSpeciesTreePriorParser extends AbstractXMLObjectParser { |
| 39 |
public static final String MUL_SPECIES_TREE_PRIOR = "mulSpeciesTreePrior"; |
| 40 |
public static final String MODEL = "model"; |
| 41 |
public static final String MUL_SPECIES_TREE = "mulTree"; |
| 42 |
|
| 43 |
|
| 44 |
public String getParserName() { |
| 45 |
return MUL_SPECIES_TREE_PRIOR; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
@Override |
| 50 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 51 |
final XMLObject mxo = xo.getChild(MODEL); |
| 52 |
final SpeciationModel sppm = (SpeciationModel) mxo.getChild(SpeciationModel.class); |
| 53 |
final XMLObject mulsptxo = xo.getChild(MUL_SPECIES_TREE); |
| 54 |
final MulSpeciesTreeModel mulspt = (MulSpeciesTreeModel) mulsptxo.getChild(MulSpeciesTreeModel.class); |
| 55 |
return new MulSpeciesTreePrior(sppm, mulspt); |
| 56 |
} |
| 57 |
|
| 58 |
private XMLSyntaxRule[] modelRules() { |
| 59 |
return new XMLSyntaxRule[]{ |
| 60 |
new ElementRule(SpeciationModel.class) |
| 61 |
}; |
| 62 |
} |
| 63 |
|
| 64 |
private XMLSyntaxRule[] mulsptRules() { |
| 65 |
return new XMLSyntaxRule[]{ |
| 66 |
new ElementRule(MulSpeciesTreeModel.class) |
| 67 |
}; |
| 68 |
} |
| 69 |
|
| 70 |
@Override |
| 71 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 72 |
return new XMLSyntaxRule[]{ |
| 73 |
new ElementRule(MODEL, modelRules()), |
| 74 |
new ElementRule(MUL_SPECIES_TREE, mulsptRules()), |
| 75 |
|
| 76 |
}; |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
@Override |
| 82 |
public String getParserDescription() { |
| 83 |
return "Prior for a multiply-labelled species tree for allopolyploids."; |
| 84 |
} |
| 85 |
|
| 86 |
@Override |
| 87 |
public Class getReturnType() { |
| 88 |
return MulSpeciesTreePrior.class; |
| 89 |
} |
| 90 |
|
| 91 |
} |