Skip to content

Commit

Permalink
Rename ReadCountModel.class to LikelihoodReadCountModel.class in Beast
Browse files Browse the repository at this point in the history
  • Loading branch information
zjzxiaohei committed Sep 12, 2024
1 parent b93c323 commit 7a0b39f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Random;


public class ReadCountModel extends Distribution {
public class LikelihoodReadCountModel extends Distribution {

public Input<Alignment> alignmentInput = new Input<>("alignment", "alignment");
public Input<ReadCount> readCountInput = new Input<>("readCount", "nucleotide read counts");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public class TreeLikelihoodWithReadCounts extends TreeLikelihood {
// public Input<RealParameter> epsilonInput = new Input<>("epsilon", "sequencing error");
// public Input<RealParameter> deltaInput = new Input<>("delta", "allelic dropout probability");

public Input<ReadCountModel> readCountModelInput = new Input<>("readCountModel", "read count model");
public Input<LikelihoodReadCountModel> readCountModelInput = new Input<>("readCountModel", "read count model");

public Input<ReadCount> readCountdataInput = new Input<>("readcount", "read count data for the beast.tree", Input.Validate.REQUIRED);


private ReadCountModel readCountModel;
private LikelihoodReadCountModel likelihoodReadCountModel;

@Override
public void initAndValidate() {
Expand Down Expand Up @@ -135,7 +135,7 @@ protected int traverse(final Node node) {
int state = genotypeAlignment.getPattern(taxonIndex, patternIndex);
// update the leaf partials using read count model
int[] states = genotypeAlignment.getDataType().getStatesForCode(state);
readCountModel.calculateLogPLeaf(node, states);
likelihoodReadCountModel.calculateLogPLeaf(node, states);
}
}
return update;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.junit.Assert.assertEquals;


public class ReadCountModelTest {
public class LikelihoodReadCountModelTest {

final double DELTA = 1e-10;

Expand All @@ -45,7 +45,7 @@ public void testAlignment() {
*/
@Test
public void testReadCountModel() throws IOException {
ReadCountModel readCountModel = new ReadCountModel();
LikelihoodReadCountModel likelihoodReadCountModel = new LikelihoodReadCountModel();

// read from file
Double epsilon = 0.06;
Expand All @@ -66,20 +66,20 @@ public void testReadCountModel() throws IOException {
RealParameter sParam = new RealParameter(s);

// init params
readCountModel.setInputValue("alignment", alignment);
readCountModel.setInputValue("readCount", readCounts);
readCountModel.setInputValue("epsilon", epsilon.toString());
readCountModel.setInputValue("delta", delta.toString());
readCountModel.setInputValue("t", t.toString());
readCountModel.setInputValue("v", v.toString());
readCountModel.setInputValue("s", sParam);
readCountModel.setInputValue("w", w.toString());
likelihoodReadCountModel.setInputValue("alignment", alignment);
likelihoodReadCountModel.setInputValue("readCount", readCounts);
likelihoodReadCountModel.setInputValue("epsilon", epsilon.toString());
likelihoodReadCountModel.setInputValue("delta", delta.toString());
likelihoodReadCountModel.setInputValue("t", t.toString());
likelihoodReadCountModel.setInputValue("v", v.toString());
likelihoodReadCountModel.setInputValue("s", sParam);
likelihoodReadCountModel.setInputValue("w", w.toString());

// ...

readCountModel.initAndValidate();
likelihoodReadCountModel.initAndValidate();

double observedLogP = readCountModel.calculateLogP();
double observedLogP = likelihoodReadCountModel.calculateLogP();
double expectedLogP = -35.6331962985386;

assertEquals(expectedLogP, observedLogP, DELTA);
Expand Down
2 changes: 1 addition & 1 deletion phylonco-beast/version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<provider classname="phylonco.beast.evolution.populationmodel.GompertzGrowth_t50"/>
<provider classname="phylonco.beast.evolution.populationmodel.ConstantGrowth"/>
<provider classname="phylonco.beast.evolution.populationmodel.StochasticVariableSelection"/>
<provider classname="phylonco.beast.evolution.readcountmodel.ReadCountModel"/>
<provider classname="phylonco.beast.evolution.readcountmodel.LikelihoodReadCountModel"/>
<provider classname="phylonco.beast.evolution.datatype.ReadCount"/>
</service>

Expand Down

0 comments on commit 7a0b39f

Please sign in to comment.