Skip to content

Commit

Permalink
Stopped BeagleTreeLikelihoodParser from requiring a GammaSiteRateMode…
Browse files Browse the repository at this point in the history
…l (only actually relevant for codon models)
  • Loading branch information
mdhall272 committed Oct 9, 2024
1 parent ed11588 commit 305b095
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/dr/evomodel/siteratemodel/SiteRateModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

package dr.evomodel.siteratemodel;

import dr.evomodel.substmodel.SubstitutionModel;
import dr.inference.model.Model;

/**
Expand Down Expand Up @@ -73,4 +74,9 @@ public interface SiteRateModel extends Model {
*/
double getProportionForCategory(int category);

// Added this because some classes still had gamma as a substitution model hard-coded. There are probably better
// ways

SubstitutionModel getSubstitutionModel();

}
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ public Object parseXMLObject(XMLObject xo) throws XMLParseException {
substitutionModel = (SubstitutionModel)xo.getElementFirstChild(SUBSTITUTION_MODEL);
}

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

int catCount = 4;
catCount = xo.getIntegerAttribute(CATEGORIES);

Expand Down Expand Up @@ -122,8 +118,11 @@ public Object parseXMLObject(XMLObject xo) throws XMLParseException {

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

siteRateModel.setSubstitutionModel(substitutionModel);
siteRateModel.addModel(substitutionModel);
if(substitutionModel!=null){
siteRateModel.setSubstitutionModel(substitutionModel);
siteRateModel.addModel(substitutionModel);
}


return siteRateModel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import dr.evomodel.branchmodel.EpochBranchModel;
import dr.evomodel.branchmodel.HomogeneousBranchModel;
import dr.evomodel.siteratemodel.GammaSiteRateModel;
import dr.evomodel.siteratemodel.SiteRateModel;
import dr.evomodel.substmodel.FrequencyModel;
import dr.evomodel.substmodel.SubstitutionModel;
import dr.evomodel.treelikelihood.AbstractTreeLikelihood;
Expand Down Expand Up @@ -76,7 +77,7 @@ public String getParserName() {

protected BeagleTreeLikelihood createTreeLikelihood(PatternList patternList, MutableTreeModel treeModel,
BranchModel branchModel,
GammaSiteRateModel siteRateModel,
SiteRateModel siteRateModel,
BranchRateModel branchRateModel,
TipStatesModel tipStatesModel,
boolean useAmbiguities, PartialsRescalingScheme scalingScheme,
Expand All @@ -103,7 +104,7 @@ public Object parseXMLObject(XMLObject xo) throws XMLParseException {

PatternList patternList = (PatternList) xo.getChild(PatternList.class);
MutableTreeModel treeModel = (MutableTreeModel) xo.getChild(MutableTreeModel.class);
GammaSiteRateModel siteRateModel = (GammaSiteRateModel) xo.getChild(GammaSiteRateModel.class);
SiteRateModel siteRateModel = (SiteRateModel) xo.getChild(SiteRateModel.class);

FrequencyModel rootFreqModel = (FrequencyModel) xo.getChild(FrequencyModel.class);

Expand Down Expand Up @@ -204,7 +205,7 @@ public Class getReturnType() {
AttributeRule.newBooleanRule(USE_AMBIGUITIES, true),
new ElementRule(PatternList.class),
new ElementRule(TreeModel.class),
new ElementRule(GammaSiteRateModel.class),
new ElementRule(SiteRateModel.class),
new ElementRule(BranchModel.class, true),
new ElementRule(SubstitutionModel.class, true),
new ElementRule(BranchRateModel.class, true),
Expand Down

0 comments on commit 305b095

Please sign in to comment.