• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ConstantPopulation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: randomTreeTest

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
private static void randomTreeTest() throws Exception {
	StringBuilder traitSB = new StringBuilder();
	List<Sequence> seqList = new ArrayList<Sequence>();

	for (int i = 0; i < 10; i++) {
		String taxonID = "t " + i;
		seqList.add(new Sequence(taxonID, "?"));

		if (i > 0)
			traitSB.append(",");
		traitSB.append(taxonID).append("=").append(i);
	}

	Alignment alignment = new Alignment(seqList, "nucleotide");
	ConstantPopulation popFunc = new ConstantPopulation();
	popFunc.initByName("popSize", new RealParameter("1.0"));
	RandomTree t = new RandomTree();
	t.initByName("taxa", alignment, "populationModel", popFunc);

	Sequence l = new Sequence("", "");

	System.out.println("Tree GTR Borrowing Test");
	Tree tree = randomYuleTree(2, 0.01);
	tree.getRoot().setMetaData("lang", l);
	System.out.println(TreeUtils.getTreeLength(tree, tree.getRoot()));
}
 
开发者ID:lutrasdebtra,项目名称:Beast-Borrowing-Plugin,代码行数:27,代码来源:BeastBorrowingPluginTest.java


示例2: initWithMRCACalibrations

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
private void initWithMRCACalibrations(List<MRCAPrior> calibrations) {
    final Tree spTree = speciesTreeInput.get();
    final RandomTree rnd = new RandomTree();
    rnd.setInputValue("taxonset", spTree.getTaxonset());

    for( final MRCAPrior cal : calibrations ) {
      rnd.setInputValue("constraint", cal);
    }
    ConstantPopulation pf = new ConstantPopulation();
    pf.setInputValue("popSize", new RealParameter("1.0"));

    rnd.setInputValue("populationModel", pf);
    rnd.initAndValidate();
    spTree.assignFromWithoutID((Tree)rnd);

    final double rootHeight = spTree.getRoot().getHeight();
    randomInitGeneTrees(rootHeight);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:19,代码来源:StarBeastStartState.java


示例3: randomInit

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
private void randomInit(final SpeciesTree speciesTree, List<MRCAPrior> calibrations) {
	final RealParameter birthRateParameter = birthRate.get();
	final Double lambda = (birthRateParameter == null) ? 1.0 : birthRateParameter.getValue();
	final Double initialPopSize = 1.0 / lambda; // scales coalescent tree height inverse to birth rate
	final RealParameter popSize = new RealParameter(initialPopSize.toString());
    final ConstantPopulation pf = new ConstantPopulation();
    pf.setInputValue("popSize", popSize);

    final RandomTree rnd = new RandomTree();
    rnd.setInputValue("taxonset", speciesTree.getTaxonset());
    if (speciesTree.hasDateTrait()) rnd.setInputValue("trait", speciesTree.getDateTrait());

    for (final MRCAPrior cal: calibrations) rnd.setInputValue("constraint", cal);

    rnd.setInputValue("populationModel", pf);
    rnd.setInputValue("populationModel", pf);
    rnd.initAndValidate();

    speciesTree.assignFromWithoutID(rnd);
    // System.out.println("BEFORE = " + speciesTree.toString());

    /*final TraitSet speciesTipDates = speciesTree.getDateTrait();
    if (speciesTree.hasDateTrait()) {
    	for (Node node: speciesTree.getNodesAsArray()) {
    		if (node.isLeaf()) {
    			final String taxonName = node.getID();
    			final double taxonHeight = speciesTipDates.getValue(taxonName);
    			node.setHeight(taxonHeight);
    			
    		}
    	}
        System.out.println("AFTER = " + speciesTree.toString());
    }*/
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:35,代码来源:StarBeastInitializer.java


示例4: init

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
@Override
public void init(Input<?> input, BEASTInterface beastObject, int itemNr, ExpandOption isExpandOption,
		boolean addButtons) {
	ConstantPopulation population = (ConstantPopulation) input.get();
	try {
		InputEditor editor = doc.inputEditorFactory.createInputEditor(population.popSizeParameter, population, doc);
		add(editor.getComponent());
	} catch (NoSuchMethodException | SecurityException | ClassNotFoundException | InstantiationException
			| IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	// TODO Auto-generated method stub
	//super.init(input, beastObject, itemNr, isExpandOption, addButtons);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:16,代码来源:ConstantPopulationInputEditor.java


示例5: testConstantPopulation

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
public void testConstantPopulation() throws Exception {
        // *********** 3 taxon **********
        Tree tree = getTree(data, trees[0]);
        TreeIntervals treeIntervals = new TreeIntervals();
        treeIntervals.initByName("tree", tree);

        ConstantPopulation cp = new ConstantPopulation();
        cp.initByName("popSize", Double.toString(pop));

        Coalescent coal = new Coalescent();
        coal.initByName("treeIntervals", treeIntervals, "populationModel", cp);

        double logL = coal.calculateLogP();

        assertEquals(logL, -(4 / pop) - 2 * Math.log(pop), PRECISION);

        // *********** 4 taxon **********
//        tree = getTree(data, trees[1]);
//        treeIntervals = new TreeIntervals();
//        treeIntervals.initByName("tree", tree);
//
//        cp = new ConstantPopulation();
//        cp.initByName("popSize", Double.toString(pop));
//
//        coal = new Coalescent();
//        coal.initByName("treeIntervals", treeIntervals, "populationModel", cp);
//
//        logL = coal.calculateLogP();
//
//        assertEquals(logL, -(4 / pop) - 2 * Math.log(pop), PRECISION);

    }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:33,代码来源:CoalescentTest.java


示例6: getTree

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
static public Tree getTree(TaxonSet taxa) throws Exception {
    Tree tree = new RandomTree();
    TraitSet dates = getDates(taxa);
    ConstantPopulation constant = new ConstantPopulation();
    constant.initByName("popSize", new RealParameter("5.0"));
    tree.initByName(
            "taxonset", taxa,
            "populationModel", constant,
            "trait", dates);
    return tree;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:12,代码来源:UnorderedAlignmentsTest.java


示例7: main

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        ConversionGraph acg = new ConversionGraph();
        ConstantPopulation popFunc = new ConstantPopulation();


        AddRemoveConversion operator = new AddRemoveConversion();
        operator.initByName("weight", 1.0,
            "acg", acg,
            "populationModel", popFunc,
            "rho", new RealParameter(Double.toString(1.0/10000.0)),
            "delta", new RealParameter("50.0"));
        popFunc.initByName("popSize", new RealParameter("1.0"));

        TaxonSet taxonSet = new TaxonSet();
        taxonSet.taxonsetInput.setValue(new Taxon("t1"), taxonSet);
        taxonSet.taxonsetInput.setValue(new Taxon("t2"), taxonSet);

        Locus locus = new Locus("locus", 10000);

        try (PrintStream ps = new PrintStream("out.txt")) {
            for (int i=0; i<100000; i++) {
                acg.initByName(
                        "locus", locus,
                        "taxonset", taxonSet,
                        "fromString", "(0:1.0,1:1.0)2:0.0;");

                operator.drawNewConversion();
                
                ps.println(acg.getConversions(locus).get(0).getStartSite() + " "
                    + acg.getConversions(locus).get(0).getEndSite());
            }
        }
    }
 
开发者ID:tgvaughan,项目名称:bacter,代码行数:35,代码来源:AddRemoveConversion.java


示例8: getRandomTree

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
public Tree getRandomTree(double popSize, Alignment dummyAlg, String[] taxa, int[] dates) throws Exception {
        TaxonSet taxonSet = new TaxonSet(dummyAlg);
        StringBuilder traitSB = new StringBuilder();
        for (int i=0; i<taxa.length; i++) {
            if (i>0)
                traitSB.append(",");
            traitSB.append(taxa[i]).append("=").append(dates[i]);
        }
//        out.println(traitSB.toString());

        TraitSet timeTrait = new TraitSet();
        timeTrait.initByName(
                "traitname", "date-backward",
                "taxa", taxonSet,
                "value", traitSB.toString());

        ConstantPopulation popFunc = new ConstantPopulation();
        popFunc.initByName("popSize", new RealParameter(Double.toString(popSize)));

        // Create RandomTree and TreeInterval instances
        RandomTree tree = new RandomTree();
//        TreeIntervals intervals = new TreeIntervals();

        tree.initByName(
                "taxa", dummyAlg,
                "populationModel", popFunc,
                "trait", timeTrait);

//        intervals.initByName("tree", tree);

        return tree;
    }
 
开发者ID:CompEvol,项目名称:NZGOT,代码行数:33,代码来源:TreeSeqSimulatorCustomized.java


示例9: getRandomTree

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
public Tree getRandomTree(double popSize, Alignment dummyAlg, String[] taxa, int[] dates) throws Exception {
        TaxonSet taxonSet = new TaxonSet(dummyAlg);
        traitSB = new StringBuilder();
        for (int i=0; i<taxa.length; i++) {
            if (i>0)
                traitSB.append(",");
            traitSB.append(taxa[i]).append("=").append(dates[i]);
        }
//        out.println(traitSB.toString());

        TraitSet timeTrait = new TraitSet();
        timeTrait.initByName(
                "traitname", traitName,
                "taxa", taxonSet,
                "value", traitSB.toString());

        ConstantPopulation popFunc = new ConstantPopulation();
        popFunc.initByName("popSize", new RealParameter(Double.toString(popSize)));

        // Create RandomTree and TreeInterval instances
        RandomTree tree = new RandomTree();
//        TreeIntervals intervals = new TreeIntervals();

        tree.initByName(
                "taxa", dummyAlg,
                "populationModel", popFunc,
                "trait", timeTrait);

//        intervals.initByName("tree", tree);

        return tree;
    }
 
开发者ID:CompEvol,项目名称:NZGOT,代码行数:33,代码来源:TreeSeqSimulator.java


示例10: testMascotUnstructured

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
@Test
public void testMascotUnstructured(){
	
	//build alignment
	Sequence sequence1 = new Sequence();
	Sequence sequence2 = new Sequence();
	Sequence sequence3 = new Sequence();
	Sequence sequence4 = new Sequence();
	Sequence sequence5 = new Sequence();
	sequence1.initByName("taxon", "a1", "value", "???");
	sequence2.initByName("taxon", "a2", "value", "???");
	sequence3.initByName("taxon", "a3", "value", "???");
	sequence4.initByName("taxon", "b1", "value", "???");
	sequence5.initByName("taxon", "b2", "value", "???");
	
	
	Alignment alignment = new Alignment();
	alignment.initByName("sequence", sequence1,"sequence", sequence2,"sequence", sequence3,"sequence", sequence4, "sequence", sequence5);
	
	
	TaxonSet taxa = new TaxonSet();
	taxa.initByName("alignment", alignment);
	
	//build trait set
	TraitSet traitSet = new TraitSet();
	traitSet.initByName("value", "a1=a,a2=a,a3=a,b1=a,b2=a", "traitname", "type", "taxa", taxa);
	
	Tree tree = new TreeParser("(((a1:1,a2:2):1,(b1:1,b2:1.5):2):1,a3:1)");
	Tree traitTree = new Tree();
	tree.initByName("taxonset", taxa, "trait", traitSet);
	StructuredTreeIntervals st = new StructuredTreeIntervals();
	st.initByName("tree",tree);
	
	// build constant dynamics
	RealParameter Ne = new RealParameter("1.5 2");
	RealParameter backwardsMigration = new RealParameter("0 0");
	int dim = 2;
	Constant constant = new Constant();
	constant.initByName("backwardsMigration", backwardsMigration, "Ne", Ne, "dimension", dim, "typeTrait", traitSet);

	
	Mascot mascot = new Mascot();
	
	mascot.initByName("structuredTreeIntervals", st, "dynamics", constant);
	
	// also set up the constant coalescent
	TreeIntervals ti = new TreeIntervals();
	ti.initByName("tree",tree);
	
	RealParameter Nec = new RealParameter("1.5");
	
	
	ConstantPopulation cp = new ConstantPopulation();
	cp.initByName("popSize", Nec);
	
	Coalescent coalescent = new Coalescent();
	coalescent.initByName("populationModel", cp, "treeIntervals", ti);
	
	Assert.assertTrue(Math.abs(mascot.calculateLogP()-coalescent.calculateLogP())<0.000000001);
}
 
开发者ID:nicfel,项目名称:Mascot,代码行数:61,代码来源:MascotTest.java


示例11: type

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
@Override
public Class<?> type() {
	return ConstantPopulation.class;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:5,代码来源:ConstantPopulationInputEditor.java


示例12: testLikelihoodUsingSimulatedData

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
@Test
public void testLikelihoodUsingSimulatedData() throws Exception {

    ConstantPopulation popFunc = new ConstantPopulation();
    popFunc.initByName("popSize", new RealParameter("1.0"));

    Locus locus = new Locus("locus", 10000);
    TaxonSet taxonSet = getTaxonSet(10);
    
    ConversionGraph acg = new SimulatedACG();
    acg.initByName(
            "rho", 5.0/locus.getSiteCount(),
            "delta", 1000.0,
            "populationModel", popFunc,
            "locus", locus,
            "taxonset", taxonSet);
    
    System.out.println(acg);

    // Site model:
    JukesCantor jc = new JukesCantor();
    jc.initByName();
    SiteModel siteModel = new SiteModel();
    siteModel.initByName(
            "mutationRate", new RealParameter("1"),
            "substModel", jc);

    // Simulate alignment:
    SimulatedAlignment alignment = new SimulatedAlignment();
    alignment.initByName(
            "acg", acg,
            "siteModel", siteModel,
            "outputFileName", "simulated_alignment.nexus",
            "useNexus", true);
    
    // Calculate likelihood:
    ACGLikelihood argLikelihood = new ACGLikelihood();
    argLikelihood.initByName(
            "locus", locus,
            "data", alignment,
            "tree", acg,
            "siteModel", siteModel);
    
    double logP = argLikelihood.calculateLogP();

    // Compare product of likelihoods of "marginal alignments" with
    // likelihood computed using RGL.
    ACGLikelihoodSlow argLikelihoodSlow = new ACGLikelihoodSlow();
    argLikelihoodSlow.initByName(
            "locus", locus,
            "data", alignment,
            "tree", acg,
            "siteModel", siteModel);

    double logPprime = argLikelihoodSlow.calculateLogP();


    double relError = 2.0*Math.abs(logP-logPprime)/Math.abs(logP + logPprime);
    System.out.format("logP=%g\nlogPprime=%g\nrelError=%g\n",
            logP, logPprime, relError);
    assertTrue(relError<1e-13);
}
 
开发者ID:tgvaughan,项目名称:bacter,代码行数:63,代码来源:ACGLikelihoodTest.java


示例13: drawNewConversion

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
/**
    * Tests that probability density of forward move calculated
by drawNewConversion() matches probability density of backward
move calculated by getConversionProb().
    * 
    * @throws Exception 
    */
   @Test
   public void testHR() throws Exception {
       
       ConstantPopulation popFunc = new ConstantPopulation();
       popFunc.initByName("popSize", new RealParameter("1.0"));

       Locus locus = new Locus("locus", 10000);
       TaxonSet taxonSet = getTaxonSet(10);

       SimulatedACG acg = new SimulatedACG();
       acg.initByName(
               "rho", 1.0/locus.getSiteCount(),
               "delta", 50.0,
               "locus", locus,
               "taxonset", taxonSet,
               "populationModel", popFunc);
       

       AddRemoveConversion operator = new AddRemoveConversion();
       
       // Loop until a valid proposal is made
       double logP1;
       List<Conversion> oldConversions;
       do {
           operator.initByName(
                   "weight", 1.0,
                   "acg", acg,
                   "delta", new RealParameter("50.0"),
                   "populationModel", popFunc);
           
           oldConversions = Lists.newArrayList(
                   acg.getConversions(locus));
       
           logP1 = operator.drawNewConversion();
       } while (Double.isInfinite(logP1));
       
       System.out.println("logP1 = " + logP1);
       
       // Identify new recomination
       Conversion newRecomb = null;
       for (Conversion recomb : acg.getConversions(locus)) {
           if (!oldConversions.contains(recomb))
               newRecomb = recomb;
       }
       assertNotNull(newRecomb);
       
       double logP2 = operator.getConversionProb(newRecomb);
       System.out.println("logP2 = " + logP2);
       
       assertTrue(Math.abs(logP1-logP2)<1e-10);
   }
 
开发者ID:tgvaughan,项目名称:bacter,代码行数:59,代码来源:AddRemoveConversionTest.java


示例14: testProbability

import beast.evolution.tree.coalescent.ConstantPopulation; //导入依赖的package包/类
/**
 * Tests whether probability of proposing a conversion lines up with
 * conversion probability found in ACGCoalescent.
 * @throws java.lang.Exception
 */
@Test
public void testProbability() throws Exception {

    ConstantPopulation popFunc = new ConstantPopulation();
    popFunc.initByName("popSize", new RealParameter("1.0"));

    Locus locus = new Locus("locus", 10000);

    TaxonSet taxonSet = getTaxonSet(10);
    
    SimulatedACG acg = new SimulatedACG();
    acg.initByName(
            "rho", 1.0/locus.getSiteCount(),
            "delta", 50.0,
            "locus", locus,
            "taxonset", taxonSet,
            "populationModel", popFunc);
    
    RealParameter rho = new RealParameter(Double.toString(1.0/locus.getSiteCount()));
    RealParameter delta = new RealParameter("50.0");

    AddRemoveConversion operator = new AddRemoveConversion();
    operator.initByName(
        "weight", 1.0,
        "acg", acg,
        "delta", delta,
        "populationModel", popFunc);

    ACGCoalescent coal = new ACGCoalescent();
    coal.initByName(
        "tree", acg,
        "populationModel", popFunc,
        "rho", rho,
        "delta", delta);
    
    double logP1 = 0.0;
    double logP2 = 0.0;
    for (Conversion conv : acg.getConversions(locus)) {
        logP1 += operator.getConversionProb(conv);
        logP2 += coal.calculateConversionLogP(conv);
    }

    System.out.println("logP1 = " + logP1);
    System.out.println("logP2 = " + logP2);

    assertTrue(Math.abs(logP1-logP2)<1e-10);

}
 
开发者ID:tgvaughan,项目名称:bacter,代码行数:54,代码来源:AddRemoveConversionTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Entitlement类代码示例发布时间:2022-05-23
下一篇:
Java ScoreboardObjective类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap