Skip to content

Commit

Permalink
Fix a bug(getBEASTObject for RealParam) #56
Browse files Browse the repository at this point in the history
  • Loading branch information
zjzxiaohei committed Oct 28, 2024
1 parent 4791b0f commit 2ec6f5b
Showing 1 changed file with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package phylonco.lphybeast.tobeast.generators;

import beast.base.core.BEASTInterface;
import beast.base.inference.parameter.RealParameter;
import lphy.core.model.Value;
import lphybeast.BEASTContext;
import lphybeast.GeneratorToBEAST;
Expand All @@ -13,21 +14,37 @@ public class ReadCountModelToBEAST implements GeneratorToBEAST<ReadCountModel, L
public LikelihoodReadCountModel generatorToBEAST(ReadCountModel generator, BEASTInterface value, BEASTContext context) {
LikelihoodReadCountModel likelihoodReadCountModel = new LikelihoodReadCountModel();
//Get value from LPhy
Value epsilonValue = generator.getParams().get("epsilon");
Value deltaValue = (Value) generator.getParams().get("alpha").getGenerator().getParams().get("delta");
Value tValue = (Value) generator.getParams().get("coverage").getGenerator().getParams().get("t");
Value vValue = (Value) generator.getParams().get("coverage").getGenerator().getParams().get("v");
Value sValue = (Value) generator.getParams().get("coverage").getGenerator().getParams().get("s");
Value wValue = generator.getParams().get("w");
Value alignmentValue = generator.getParams().get("D");

BEASTInterface epsilonParam = context.getBEASTObject(epsilonValue);
BEASTInterface deltaParam = context.getBEASTObject(deltaValue);
BEASTInterface tParam = context.getBEASTObject(tValue);
BEASTInterface vParam = context.getBEASTObject(vValue);
BEASTInterface sParam = context.getBEASTObject(sValue);
BEASTInterface wParam = context.getBEASTObject(wValue);
String epsilonParamName = "epsilon";
String alphaParamName = "alpha";
String deltaParamName = "delta";
String covParamName = "coverage";
String tParamName = "t";
String vParamName = "v";
String sParamName = "s";
String wParamName = "w";
String alignmentParamName = "D";

Value epsilonValue = generator.getParams().get(epsilonParamName);
Value alphaValue = generator.getParams().get(alphaParamName);
Value deltaValue = (Value) alphaValue.getGenerator().getParams().get(deltaParamName);
Value coverageValue = generator.getParams().get(covParamName);
Value tValue = (Value) coverageValue.getGenerator().getParams().get(tParamName);
Value vValue = (Value) coverageValue.getGenerator().getParams().get(vParamName);
Value sValue = (Value) coverageValue.getGenerator().getParams().get(sParamName);
Value wValue = generator.getParams().get(wParamName);
Value alignmentValue = generator.getParams().get(alignmentParamName);


RealParameter epsilonParam = context.getAsRealParameter(epsilonValue);
RealParameter deltaParam = context.getAsRealParameter(deltaValue);
RealParameter tParam = context.getAsRealParameter(tValue);
RealParameter vParam = context.getAsRealParameter(vValue);
RealParameter sParam = context.getAsRealParameter(sValue);
RealParameter wParam = context.getAsRealParameter(wValue);
BEASTInterface alignmentParam = context.getBEASTObject(alignmentValue);
if (alignmentParam == null) {
alignmentParam = context.getBEASTObject(alignmentValue.getId());
}

likelihoodReadCountModel.setInputValue("epsilon", epsilonParam);
likelihoodReadCountModel.setInputValue("delta", deltaParam);
Expand Down

0 comments on commit 2ec6f5b

Please sign in to comment.