package test.beast.evolution.speciation;

import org.junit.Test;

import beast.core.parameter.RealParameter;
import beast.evolution.alignment.Alignment;
import beast.evolution.speciation.BirthDeathGernhard08Model;
import beast.evolution.tree.Tree;

import test.beast.BEASTTestCase;
import junit.framework.TestCase;

public class BirthDeathGernhard08ModelTest extends TestCase {


    @Test
    public void testJC69Likelihood() throws Exception {
        // Set up JC69 model: uniform freqs, kappa = 1, 0 gamma categories
        Alignment data = BEASTTestCase.getAlignment();
        Tree tree = BEASTTestCase.getTree(data);

        RealParameter birthDiffRate = new RealParameter("1.0");
        RealParameter relativeDeathRate = new RealParameter("0.5");
        BirthDeathGernhard08Model likelihood = new BirthDeathGernhard08Model();
        likelihood.initByName("type", "unscaled",
                "tree", tree,
                "birthDiffRate", birthDiffRate,
                "relativeDeathRate", relativeDeathRate);


        double fLogP = 0;
        fLogP = likelihood.calculateLogP(); // -3.520936119641363
        assertEquals(fLogP, 2.5878899503981287, BEASTTestCase.PRECISION);

        likelihood.initByName("type", "timesonly",
                "tree", tree,
                "birthDiffRate", birthDiffRate,
                "relativeDeathRate", relativeDeathRate);
        fLogP = likelihood.calculateLogP();
        assertEquals(fLogP, 9.16714116240823, BEASTTestCase.PRECISION);

        likelihood.initByName("type", "oriented",
                "tree", tree,
                "birthDiffRate", birthDiffRate,
                "relativeDeathRate", relativeDeathRate);
        fLogP = likelihood.calculateLogP();
        assertEquals(fLogP, 4.379649419626184, BEASTTestCase.PRECISION);

        likelihood.initByName("type", "labeled",
                "tree", tree,
                "birthDiffRate", birthDiffRate,
                "relativeDeathRate", relativeDeathRate);
        fLogP = likelihood.calculateLogP();
        assertEquals(fLogP, 1.2661341104158121, BEASTTestCase.PRECISION);
    }

}

@@ -241,17 +241,16 @@
 e.Tree;%0A
-%0A
 import t
@@ -746,24 +746,87 @@
 ter(%220.5%22);%0A
+        RealParameter originHeight = new RealParameter(%220.1%22);%0A
         Birt
@@ -2155,16 +2155,347 @@
 ISION);%0A
+        %0A        likelihood.initByName(%22type%22, %22labeled%22,%0A        %09%09%22tree%22, tree,%0A        %09%09%22birthDiffRate%22, birthDiffRate,%0A        %09%09%22relativeDeathRate%22, relativeDeathRate,%0A        %09%09%22originHeight%22, originHeight);%0A        fLogP = likelihood.calculateLogP();%0A        assertEquals(fLogP, 8.41413452832378, BEASTTestCase.PRECISION);%0A
     %7D%0A%0A%7D

Implement test case