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


Java TraitSet.initByName方法代码示例

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


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

示例1: testDateBackward

import beast.evolution.tree.TraitSet; //导入方法依赖的package包/类
@Test
public void testDateBackward() {
	int Nleaves = 2; 
    TraitSet timeTrait = new TraitSet();

    timeTrait.initByName(
            "traitname", "date-backward",
            "taxa", taxonSet(Nleaves),
            "value", "t0=0, t1=10");
    // The trait actually represents the age of the taxa relative to
    // each other with arbitrary zero, so we test it like this.
    assertEquals(-10.0, timeTrait.getValue("t0")-timeTrait.getValue("t1"), 1e-7);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:14,代码来源:TraitSetTest.java

示例2: testDateForward

import beast.evolution.tree.TraitSet; //导入方法依赖的package包/类
@Test
public void testDateForward() {
	int Nleaves = 2; 
    TraitSet timeTrait = new TraitSet();

    timeTrait.initByName(
            "traitname", "date-forward",
            "taxa", taxonSet(Nleaves),
            "value", "t0=0, t1=10");
    // The trait actually represents the age of the taxa relative to
    // each other with arbitrary zero, so we test it like this.
    assertEquals(10.0, timeTrait.getValue("t0")-timeTrait.getValue("t1"), 1e-7);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:14,代码来源:TraitSetTest.java

示例3: testDateForwardUnspecified

import beast.evolution.tree.TraitSet; //导入方法依赖的package包/类
@Test
public void testDateForwardUnspecified() {
	int Nleaves = 2; 
    TraitSet timeTrait = new TraitSet();

    timeTrait.initByName(
            "traitname", "date-forward",
            "taxa", taxonSet(Nleaves),
            "value", "t1=10");
    // The trait actually represents the age of the taxa relative to
    // each other with arbitrary zero, so we test it like this.
    assertEquals(0.0, timeTrait.getValue("t0")-timeTrait.getValue("t1"), 1e-7);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:14,代码来源:TraitSetTest.java

示例4: getDates

import beast.evolution.tree.TraitSet; //导入方法依赖的package包/类
static public TraitSet getDates(TaxonSet taxa) throws Exception {
    TraitSet timeTrait = new TraitSet();
    String trait = String.join(",", (Iterable<String>) IntStream.range(0, 16).mapToObj(i -> taxa.getTaxonId(i) + "=" + i / 3.0)::iterator);
    timeTrait.initByName(
            "traitname", "date-forward",
            "taxa", taxa,
            "value", trait);
    return timeTrait;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:10,代码来源:UnorderedAlignmentsTest.java

示例5: getRandomTree

import beast.evolution.tree.TraitSet; //导入方法依赖的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

示例6: getRandomTree

import beast.evolution.tree.TraitSet; //导入方法依赖的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

示例7: processTraits

import beast.evolution.tree.TraitSet; //导入方法依赖的package包/类
@Override
protected void processTraits(List<TraitSet> traitList) {
    super.processTraits(traitList);
    
    // Record trait set associated with leaf types.
    for (TraitSet traitSet : traitList) {
        if (traitSet.getTraitName().equals(typeLabel)) {
            typeTraitSet = traitSet;
            break;
        }
    }

    // Use explicitly-identified type trait set if available.
    // Seems dumb, but needed for BEAUti as ListInputEditors
    // muck things up...
    if (typeTraitInput.get() != null)
        typeTraitSet = typeTraitInput.get();

    // Construct type list.
    if (typeTraitSet == null) {
        if (getTaxonset() != null) {
            TraitSet dummyTraitSet = new TraitSet();

            StringBuilder sb = new StringBuilder();
            for (int i=0; i<getTaxonset().getTaxonCount(); i++) {
                if (i>0)
                    sb.append(",\n");
                sb.append(getTaxonset().getTaxonId(i)).append("=NOT_SET");
            }
            try {
                dummyTraitSet.initByName(
                    "traitname", "type",
                    "taxa", getTaxonset(),
                    "value", sb.toString());
                dummyTraitSet.setID("typeTraitSet.t:"
                    + BeautiDoc.parsePartition(getID()));
                setTypeTrait(dummyTraitSet);
            } catch (Exception ex) {
                System.out.println("Error setting default type trait.");
            }
        }
    }

    if (typeTraitSet != null) {

        Set<String> typeSet = new HashSet<>();

        int nTaxa = typeTraitSet.taxaInput.get().asStringList().size();
        for (int i = 0; i < nTaxa; i++)
            typeSet.add(typeTraitSet.getStringValue(i));

        // Include any addittional trait values in type list
        if (typeTraitValuesInput.get() != null) {
            for (String typeName : typeTraitValuesInput.get().split(","))
                typeSet.add(typeName);
        }

        typeList = Lists.newArrayList(typeSet);
        Collections.sort(typeList);

        System.out.println("Type trait with the following types detected:");
        for (int i = 0; i < typeList.size(); i++)
            System.out.println(typeList.get(i) + " (" + i + ")");

    }
}
 
开发者ID:nicfel,项目名称:Mascot,代码行数:67,代码来源:TreeWithTrait.java

示例8: testMascotStructured

import beast.evolution.tree.TraitSet; //导入方法依赖的package包/类
@Test
public void testMascotStructured(){
	
	//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=b,b2=b", "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 2");
	RealParameter backwardsMigration = new RealParameter("0.3 2");
	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);
	
	
	Assert.assertTrue(mascot.calculateLogP()==-6.870390751933608);
	

}
 
开发者ID:nicfel,项目名称:Mascot,代码行数:50,代码来源:MascotTest.java

示例9: testMascotUnstructured

import beast.evolution.tree.TraitSet; //导入方法依赖的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


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