當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeLikelihood.getPatternLogLikelihoods方法代碼示例

本文整理匯總了Java中beast.evolution.likelihood.TreeLikelihood.getPatternLogLikelihoods方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeLikelihood.getPatternLogLikelihoods方法的具體用法?Java TreeLikelihood.getPatternLogLikelihoods怎麽用?Java TreeLikelihood.getPatternLogLikelihoods使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在beast.evolution.likelihood.TreeLikelihood的用法示例。


在下文中一共展示了TreeLikelihood.getPatternLogLikelihoods方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testMarginalisationOfLikelihoodBinary

import beast.evolution.likelihood.TreeLikelihood; //導入方法依賴的package包/類
@Test
public void testMarginalisationOfLikelihoodBinary() throws Exception {
	// test summation over all patterns adds to 1 for binary data

	Sequence German_ST =  new Sequence("German_ST", "           10110010");
	Sequence Dutch_List = new Sequence("Dutch_List", "          11010100");
	Sequence English_ST = new Sequence("English_ST", "          11101000");

    Alignment data = new Alignment();
    data.initByName("sequence", German_ST, "sequence", Dutch_List, "sequence", English_ST,
            "dataType", "binary"
    );

    Tree tree = BEASTTestCase.getTree(data, "(English_ST:0.22743347188019544,(German_ST:0.10557648379843088,Dutch_List:0.10557648379843088):0.12185698808176457):0.0;");


    RealParameter frequencies = new RealParameter("0.683 0.317");
    Frequencies freqs = new Frequencies();
    freqs.initByName("frequencies", frequencies);
    GeneralSubstitutionModel covarion = new GeneralSubstitutionModel();
    covarion.initByName("frequencies", freqs, "rates", new RealParameter("1.0 1.0"));

    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "substModel", covarion);

    TreeLikelihood likelihood = newTreeLikelihood();
    likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
    
    likelihood.initByName("useAmbiguities", false, "data", data, "tree", tree, "siteModel", siteModel);
    likelihood.calculateLogP();
    double [] logPs = likelihood.getPatternLogLikelihoods();
    double P = 0;
    for (double d : logPs) {
    	P += Math.exp(d);
    }
    assertEquals(P, 1.0, BEASTTestCase.PRECISION);
}
 
開發者ID:CompEvol,項目名稱:beast2,代碼行數:38,代碼來源:TreeLikelihoodTest.java

示例2: testMarginalisationOfLikelihoodNucleotide

import beast.evolution.likelihood.TreeLikelihood; //導入方法依賴的package包/類
@Test
public void testMarginalisationOfLikelihoodNucleotide() throws Exception {
	// test summation over all patterns adds to 1 for nucleotide data

	Sequence German_ST =  new Sequence("German_ST", "           AAAAAAAAAAAAAAAA CCCCCCCCCCCCCCCC GGGGGGGGGGGGGGGG TTTTTTTTTTTTTTTT");
	Sequence Dutch_List = new Sequence("Dutch_List", "          AAAACCCCGGGGTTTT AAAACCCCGGGGTTTT AAAACCCCGGGGTTTT AAAACCCCGGGGTTTT");
	Sequence English_ST = new Sequence("English_ST", "          ACGTACGTACGTACGT ACGTACGTACGTACGT ACGTACGTACGTACGT ACGTACGTACGTACGT");

    Alignment data = new Alignment();
    data.initByName("sequence", German_ST, "sequence", Dutch_List, "sequence", English_ST,
            "dataType", "nucleotide"
    );

    Tree tree = BEASTTestCase.getTree(data, "(English_ST:0.22743347188019544,(German_ST:0.10557648379843088,Dutch_List:0.10557648379843088):0.12185698808176457):0.0;");


    RealParameter frequencies = new RealParameter("0.2 0.3 0.4 0.1");
    Frequencies freqs = new Frequencies();
    freqs.initByName("frequencies", frequencies);
    GeneralSubstitutionModel gsm = new GeneralSubstitutionModel();
    gsm.initByName("rates", "1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0", "frequencies", freqs);

    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "substModel", gsm);

    TreeLikelihood likelihood = newTreeLikelihood();
    likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);

    likelihood.initByName("useAmbiguities", false, "data", data, "tree", tree, "siteModel", siteModel);
    likelihood.calculateLogP();
    double [] logPs = likelihood.getPatternLogLikelihoods();
    double P = 0;
    for (double d : logPs) {
    	P += Math.exp(d);
    }
    assertEquals(P, 1.0, BEASTTestCase.PRECISION);
}
 
開發者ID:CompEvol,項目名稱:beast2,代碼行數:38,代碼來源:TreeLikelihoodTest.java


注:本文中的beast.evolution.likelihood.TreeLikelihood.getPatternLogLikelihoods方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。