Skip to content

Commit

Permalink
Fixed parsers to work properly
Browse files Browse the repository at this point in the history
  • Loading branch information
mdhall272 committed Jul 14, 2023
1 parent f2eda54 commit 39bafa4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/dr/evomodelxml/siteratemodel/GammaSiteRateModelParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public String getParserName() {
public Object parseXMLObject(XMLObject xo) throws XMLParseException {

String msg = "";
SubstitutionModel substitutionModel;
SubstitutionModel substitutionModel = null;

double muWeight = 1.0;

Expand All @@ -82,6 +82,10 @@ public Object parseXMLObject(XMLObject xo) throws XMLParseException {
msg += " with weight: " + muWeight;
}
}

if(xo.hasChildNamed(SUBSTITUTION_MODEL)){
substitutionModel = (SubstitutionModel)xo.getElementFirstChild(SUBSTITUTION_MODEL);
}

int catCount = 4;
catCount = xo.getIntegerAttribute(CATEGORIES);
Expand Down Expand Up @@ -124,7 +128,11 @@ public Object parseXMLObject(XMLObject xo) throws XMLParseException {

GammaSiteRateDelegate delegate = new GammaSiteRateDelegate("GammaSiteRateDelegate", shapeParam, catCount, type, invarParam);

return new DiscretizedSiteRateModel(SiteModel.SITE_MODEL, muParam, muWeight, delegate);
DiscretizedSiteRateModel siteRateModel = new DiscretizedSiteRateModel(SiteModel.SITE_MODEL, muParam, muWeight, delegate);

siteRateModel.setSubstitutionModel(substitutionModel);

return siteRateModel;
}

//************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ public Object parseXMLObject(XMLObject xo) throws XMLParseException {
BranchModel branchModel = (BranchModel) cxo.getChild(BranchModel.class);
if (branchModel == null) {
SubstitutionModel substitutionModel = (SubstitutionModel) cxo.getChild(SubstitutionModel.class);
if (substitutionModel == null && siteRateModel instanceof GammaSiteRateModel) {
if (substitutionModel == null && siteRateModel instanceof DiscretizedSiteRateModel) {
// for backwards compatibility the old GammaSiteRateModelParser can provide the substitution model...
substitutionModel = ((GammaSiteRateModel)siteRateModel).getSubstitutionModel();
substitutionModel = ((DiscretizedSiteRateModel)siteRateModel).getSubstitutionModel();
}
if (substitutionModel == null) {
throw new XMLParseException("No substitution model available for partition " + k + " in DataTreeLikelihood: "+xo.getId());
Expand Down

0 comments on commit 39bafa4

Please sign in to comment.