| 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 |
import dr.evomodel.alloppnet.speciation.BirthDeathCollapseModel; |
| 29 |
import dr.evomodel.alloppnet.speciation.BirthDeathCollapseNClustersStatistic; |
| 30 |
import dr.evomodel.speciation.SpeciesTreeModel; |
| 31 |
import dr.xml.*; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public class BirthDeathCollapseNClustersStatisticParser extends AbstractXMLObjectParser { |
| 38 |
public static final String BDC_NCLUSTERS_STATISTIC = "bdcNClustersStatistic"; |
| 39 |
public static final String SPECIES_TREE = "speciesTree"; |
| 40 |
public static final String COLLAPSE_MODEL = "collapseModel"; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public String getParserName() { |
| 45 |
return BDC_NCLUSTERS_STATISTIC; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
@Override |
| 50 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 51 |
xo.getAttribute("name"); |
| 52 |
final XMLObject spptreexo = xo.getChild(SPECIES_TREE); |
| 53 |
SpeciesTreeModel spptree = (SpeciesTreeModel) spptreexo.getChild(SpeciesTreeModel.class); |
| 54 |
final XMLObject cmxo = xo.getChild(COLLAPSE_MODEL); |
| 55 |
BirthDeathCollapseModel bdcm = (BirthDeathCollapseModel)cmxo.getChild(BirthDeathCollapseModel.class); |
| 56 |
return new BirthDeathCollapseNClustersStatistic(spptree, bdcm); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
private XMLSyntaxRule[] spptreeRules() { |
| 61 |
return new XMLSyntaxRule[]{ |
| 62 |
new ElementRule(SpeciesTreeModel.class) |
| 63 |
}; |
| 64 |
} |
| 65 |
|
| 66 |
private XMLSyntaxRule[] bdcmRules() { |
| 67 |
return new XMLSyntaxRule[]{ |
| 68 |
new ElementRule(BirthDeathCollapseModel.class) |
| 69 |
}; |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
@Override |
| 75 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 76 |
return new XMLSyntaxRule[]{ |
| 77 |
AttributeRule.newStringRule("name"), |
| 78 |
new ElementRule(SPECIES_TREE, spptreeRules()), |
| 79 |
new ElementRule(COLLAPSE_MODEL, bdcmRules()) |
| 80 |
}; |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
@Override |
| 85 |
public String getParserDescription() { |
| 86 |
return "Statistic for number of collapsed nodes in species tree when using birth-death-collapse model."; |
| 87 |
} |
| 88 |
|
| 89 |
@Override |
| 90 |
public Class getReturnType() { |
| 91 |
return BirthDeathCollapseNClustersStatistic.class; |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
} |