当前位置: 首页>>代码示例>>Java>>正文


Java TreeLikelihood类代码示例

本文整理汇总了Java中beast.evolution.likelihood.TreeLikelihood的典型用法代码示例。如果您正苦于以下问题:Java TreeLikelihood类的具体用法?Java TreeLikelihood怎么用?Java TreeLikelihood使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TreeLikelihood类属于beast.evolution.likelihood包,在下文中一共展示了TreeLikelihood类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testHKY85Likelihood

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
@Test
public void testHKY85Likelihood() throws Exception {
    // Set up HKY85 model: estimated freqs, kappa = 29.739445, 0 gamma categories
    Alignment data = BEASTTestCase.getAlignment();
    Tree tree = BEASTTestCase.getTree(data);

    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data);

    HKY hky = new HKY();
    hky.initByName("kappa", "29.739445", "frequencies", freqs);

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

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

    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1825.2131708068507, BEASTTestCase.PRECISION);

    likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1825.2131708068507, BEASTTestCase.PRECISION);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:27,代码来源:TreeLikelihoodTest.java

示例2: canSetSubstModel

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
public boolean canSetSubstModel(Object o) {
    final SubstitutionModel substModel = (SubstitutionModel) o;
    if (m_dataType == null) {
    	// try to find out the data type from the data in a treelikelihood in an output
    	for (Object beastObject : getOutputs()) {
    		if (beastObject instanceof TreeLikelihood) {
    			TreeLikelihood likelihood = (TreeLikelihood) beastObject;
    			m_dataType = likelihood.dataInput.get().getDataType();
    			break;
    		}
    	}
    }
    if (m_dataType != null) {
        if (!substModel.canHandleDataType(m_dataType)) {
            return false;
            //throw new Exception("substitution model cannot handle data type");
        }
    }
    return true;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:21,代码来源:SiteModelInterface.java

示例3: testJC69Likelihood

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
@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);

    JukesCantor JC = new JukesCantor();
    JC.initAndValidate();

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

    TreeLikelihood likelihood = newTreeLikelihood();
    likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1992.2056440317247, BEASTTestCase.PRECISION);

    likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1992.2056440317247, BEASTTestCase.PRECISION);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:23,代码来源:TreeLikelihoodTest.java

示例4: testAscertainedJC69Likelihood

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
@Test
public void testAscertainedJC69Likelihood() throws Exception {
    // as testJC69Likelihood but with ascertained alignment
    Alignment data = BEASTTestCase.getAscertainedAlignment();
    Tree tree = BEASTTestCase.getTree(data);

    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data,
            "estimate", false);

    HKY hky = new HKY();
    hky.initByName("kappa", "1.0", "frequencies", freqs);

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

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

    double logP = 0;
    logP = likelihood.calculateLogP();
    // the following number comes from Beast 1.6        
    assertEquals(logP, -737.7140695360017, BEASTTestCase.PRECISION);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:25,代码来源:TreeLikelihoodTest.java

示例5: testBinaryCovarionLikelihood

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
@Test
public void testBinaryCovarionLikelihood() throws Exception {
    Alignment data = BEASTTestCase.getCovarionAlignment();
    Tree tree = BEASTTestCase.getTree(data, "((English_ST:0.22743347188019544,(German_ST:0.10557648379843088,Dutch_List:0.10557648379843088):0.12185698808176457):1.5793160946109988,(Spanish:0.11078392189606047,(Italian:0.10119772534558173,French:0.10119772534558173):0.009586196550478737):1.6959656445951337)");


    RealParameter alpha = new RealParameter("0.284");
    RealParameter switchRate = new RealParameter("0.829");
    RealParameter frequencies = new RealParameter("0.683 0.317");
    RealParameter hfrequencies = new RealParameter("0.5 0.5");
    BinaryCovarion covarion = new BinaryCovarion();
    covarion.initByName("alpha", alpha, "switchRate", switchRate, "vfrequencies", frequencies, "hfrequencies", hfrequencies);

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

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

    double logP = 0;
    likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    // beast1 xml gives -1730.5363
    assertEquals(logP, -1730.53631739, BEASTTestCase.PRECISION);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:26,代码来源:TreeLikelihoodTest.java

示例6: testWVLikelihoodCore0

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
public void testWVLikelihoodCore0(){
    try{
        Alignment data = getAlignment();
        Tree tree = getTree(data);
        SiteModel siteModel = getDefaultSiteModel();

        int[] patternWeights = data.getWeights();
        NewWVTreeLikelihood newTreeLik = new NewWVTreeLikelihood(patternWeights);
        newTreeLik.initByName(
                "data", data,
                "tree", tree,
                "siteModel", siteModel
        );

        TreeLikelihood treeLik = new TreeLikelihood();
        treeLik.initByName(
                "data", data,
                "tree", tree,
                "siteModel", siteModel
        );
    }catch(Exception e){
        throw new RuntimeException(e);
    }
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:25,代码来源:WVLikelihoodCoreTest.java

示例7: calculateLogP

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
@Override
public double calculateLogP() {
    logP = 0.0;

    for (Region region : acg.getRegions(locus)) {
        Alignment margAlign = createMarginalAlignment(alignment, acg, region);
        Tree margTree = new Tree(new MarginalTree(acg, region).getRoot());
        TreeLikelihood treeLikelihood = new TreeLikelihood();
        treeLikelihood.initByName(
                "data", margAlign,
                "tree", margTree,
                "siteModel", siteModel,
                "useAmbiguities", useAmbiguitiesInput.get());

        logP += treeLikelihood.calculateLogP();
    }
    return logP;
}
 
开发者ID:tgvaughan,项目名称:bacter,代码行数:19,代码来源:ACGLikelihoodSlow.java

示例8: getTreeLikelihood

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
/**
 * find a treelikelihood object among the plug-ins by recursively inspecting plug-ins *
 */
static TreeLikelihood getTreeLikelihood(BEASTInterface beastObject)  {
    for (BEASTInterface beastObject2 : beastObject.listActiveBEASTObjects()) {
        if (beastObject2 instanceof TreeLikelihood) {
            return (TreeLikelihood) beastObject2;
        } else {
            TreeLikelihood likelihood = getTreeLikelihood(beastObject2);
            if (likelihood != null) {
                return likelihood;
            }
        }
    }
    return null;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:17,代码来源:SequenceSimulator.java

示例9: testK80Likelihood

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
@Test
public void testK80Likelihood() throws Exception {
    // Set up K80 model: uniform freqs, kappa = 27.402591, 0 gamma categories
    Alignment data = BEASTTestCase.getAlignment();
    Tree tree = BEASTTestCase.getTree(data);

    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data,
            "estimate", false);

    HKY hky = new HKY();
    hky.initByName("kappa", "27.40259", "frequencies", freqs);

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

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

    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1856.303048876734, BEASTTestCase.PRECISION);

    likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1856.303048876734, BEASTTestCase.PRECISION);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:28,代码来源:TreeLikelihoodTest.java

示例10: testHKY85GLikelihood

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
@Test
public void testHKY85GLikelihood() throws Exception {
    // Set up HKY85+G model: estimated freqs, kappa = 38.82974, 4 gamma categories, shape = 0.137064
    Alignment data = BEASTTestCase.getAlignment();
    Tree tree = BEASTTestCase.getTree(data);

    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data);

    HKY hky = new HKY();
    hky.initByName("kappa", "38.82974", "frequencies", freqs);

    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 4,
            "shape", "0.137064",
            "proportionInvariant", "0.0",
            "substModel", hky);

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

    double logP = 0;
    logP = likelihood.calculateLogP();
    System.err.println(logP - -1789.7593576610134);
    assertEquals(logP, -1789.7593576610134, BEASTTestCase.PRECISION);

    likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1789.7593576610134, BEASTTestCase.PRECISION);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:31,代码来源:TreeLikelihoodTest.java

示例11: testHKY85ILikelihood

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
@Test
public void testHKY85ILikelihood() throws Exception {
    // Set up HKY85+I model: estimated freqs, kappa = 38.564672, 0 gamma categories, prop invariant = 0.701211
    Alignment data = BEASTTestCase.getAlignment();
    Tree tree = BEASTTestCase.getTree(data);

    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data);

    HKY hky = new HKY();
    hky.initByName("kappa", "38.564672", "frequencies", freqs);

    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1,
            "shape", "0.137064",
            "proportionInvariant", "0.701211",
            "substModel", hky);

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

    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1789.912401996943, BEASTTestCase.PRECISION);

    likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1789.912401996943, BEASTTestCase.PRECISION);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:30,代码来源:TreeLikelihoodTest.java

示例12: testHKY85GILikelihood

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
@Test
public void testHKY85GILikelihood() throws Exception {
    // Set up HKY85+G+I model: estimated freqs, kappa = 39.464538, 4 gamma categories, shape = 0.587649, prop invariant = 0.486548
    Alignment data = BEASTTestCase.getAlignment();
    Tree tree = BEASTTestCase.getTree(data);

    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data);

    HKY hky = new HKY();
    hky.initByName("kappa", "39.464538", "frequencies", freqs);

    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 4,
            "shape", "0.587649",
            "proportionInvariant", "0.486548",
            "substModel", hky);

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

    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1789.639227747059, BEASTTestCase.PRECISION);

    likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1789.639227747059, BEASTTestCase.PRECISION);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:30,代码来源:TreeLikelihoodTest.java

示例13: testGTRLikelihood

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
@Test
public void testGTRLikelihood() throws Exception {
    // Set up GTR model: no gamma categories, no proportion invariant
    Alignment data = BEASTTestCase.getAlignment();
    Tree tree = BEASTTestCase.getTree(data);

    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data);

    GTR gsm = new GTR();
    gsm.initByName("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);

    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1969.145839307625, BEASTTestCase.PRECISION);

    likelihood.initByName("useAmbiguities", false, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1969.145839307625, BEASTTestCase.PRECISION);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:28,代码来源:TreeLikelihoodTest.java

示例14: testGTRILikelihood

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
@Test
public void testGTRILikelihood() throws Exception {
    // Set up GTR model: prop invariant = 0.5
    Alignment data = BEASTTestCase.getAlignment();
    Tree tree = BEASTTestCase.getTree(data);

    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data);

    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,
            "proportionInvariant", "0.5",
            "substModel", gsm);
    //siteModel.init("1.0", 1, null, "0.5", gsm);

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

    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1948.8417455357564, BEASTTestCase.PRECISION);

    likelihood.initByName("useAmbiguities", false, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1948.8417455357564, BEASTTestCase.PRECISION);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:30,代码来源:TreeLikelihoodTest.java

示例15: testGTRGLikelihood

import beast.evolution.likelihood.TreeLikelihood; //导入依赖的package包/类
@Test
public void testGTRGLikelihood() throws Exception {
    // Set up GTR model: 4 gamma categories, gamma shape = 0.5
    Alignment data = BEASTTestCase.getAlignment();
    Tree tree = BEASTTestCase.getTree(data);

    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data);

    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", 4,
            "shape", "0.5",
            "substModel", gsm);

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

    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1949.0360143622, BEASTTestCase.PRECISION);

    likelihood.initByName("useAmbiguities", false, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1949.0360143622, BEASTTestCase.PRECISION);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:29,代码来源:TreeLikelihoodTest.java


注:本文中的beast.evolution.likelihood.TreeLikelihood类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。