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

Java Alignment类代码示例

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

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



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

示例1: testHKY85Likelihood

import beast.evolution.alignment.Alignment; //导入依赖的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: testCompoundAlignment

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
public void testCompoundAlignment() {
	// Test whether basic functionality (data type size, manual recovery of
	// component-wise values) is guaranteed.
	Alignment a0 = alignment0();
	CompoundDataType c = datatype0();
	CompoundAlignment compound = new CompoundAlignment();
	compound.initByName("alignment", a0, "dataType", "userDataType", "userDataType", c);

	assertEquals("The compound alignment should have one column", compound.getSiteCount(), 1);

	Integer expectedStateCount = 1;
	for (int stateCount : c.getStateCounts()) {
		expectedStateCount *= stateCount;
	}
	assertEquals("The state count of the only column should be the product of all `alignment` state counts",
			compound.getStateCounts().get(0), expectedStateCount);
}
 
开发者ID:Anaphory,项目名称:correlatedcharacters,代码行数:18,代码来源:CompoundAlignmentTest.java


示例3: testCompoundAlignmentWithoutDataType

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
public void testCompoundAlignmentWithoutDataType() {
	// Test whether basic functionality (data type size, manual recovery of
	// component-wise values) is guaranteed.
	Alignment a0 = alignment0();
	CompoundDataType c = datatype0();
	CompoundAlignment compound = new CompoundAlignment();
	compound.initByName("alignment", a0);

	assertEquals("The compound alignment should have one column", 1, compound.getSiteCount());

	Integer expectedStateCount = 1;
	for (int stateCount : c.getStateCounts()) {
		expectedStateCount *= stateCount;
	}
	assertEquals("The state count of the only column should be the product of all `alignment` state counts",
			expectedStateCount, compound.getStateCounts().get(0));
}
 
开发者ID:Anaphory,项目名称:correlatedcharacters,代码行数:18,代码来源:CompoundAlignmentTest.java


示例4: testRecoverCompoundAlignment

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
public void testRecoverCompoundAlignment() {
	// Test whether CompoundDataType.compoundState2componentState can
	// recover the patterns from individual alignments.
	CompoundAlignment compound = null;
	compound = new CompoundAlignment();
	Alignment a0 = alignment0();
	CompoundDataType c = datatype0();
	compound.initByName("alignment", a0, "dataType", "userDataType", "userDataType", c);

	for (int taxon = 0; taxon < compound.getTaxonCount(); ++taxon) {
		int p = compound.getPattern(taxon, 0);
		for (int component = 0; component < c.getComponentCount(); ++component) {
			assertEquals(
					String.format("In taxon %s: Site %d incorrectly reconstructed from %d.",
							compound.getTaxaNames().get(taxon), component, p),
					a0.getPattern(taxon, component), c.compoundState2componentState(p, component));
		}
	}
}
 
开发者ID:Anaphory,项目名称:correlatedcharacters,代码行数:20,代码来源:CompoundAlignmentTest.java


示例5: randomTreeTest

import beast.evolution.alignment.Alignment; //导入依赖的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


示例6: setStates

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
/**
 * Sets the partials from a sequence in an alignment.
 *
 * @param beagle        beagle
 * @param nodeIndex     nodeIndex
 * @param taxon         the taxon
 */
protected final void setStates(Beagle beagle,
                               int nodeIndex, int taxon) {
    Alignment data = dataInput.get();
    int i;

    int[] states = new int[patternCount];

    for (i = 0; i < patternCount; i++) {
        int code = data.getPattern(taxon, i);
        int[] statesForCode = data.getDataType().getStatesForCode(code);
        if (statesForCode.length==1)
            states[i] = statesForCode[0];
        else
            states[i] = code; // Causes ambiguous states to be ignored.
    }

    beagle.setTipStates(nodeIndex, states);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:26,代码来源:BeagleTreeLikelihood.java


示例7: getAscertainmentCorrectedLogLikelihood

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
private double getAscertainmentCorrectedLogLikelihood(Alignment patternList,
                                                      double[] patternLogLikelihoods,
                                                      int[] patternWeights,
                                                      double [] frequencies) {
	if (constantPattern != null) {
     proportionInvariant = m_siteModel.getProportionInvariant();
     for (int k : constantPattern) {
     	int i = k / m_nStateCount;
     	int j = k % m_nStateCount;
     	patternLogLikelihoods[i] = (Math.log(Math.exp(patternLogLikelihoods[i]) + proportionInvariant * frequencies[j]));
     }
	}
	
    double logL = 0.0;
    double ascertainmentCorrection = patternList.getAscertainmentCorrection(patternLogLikelihoods);
    for (int i = 0; i < patternCount; i++) {
        logL += (patternLogLikelihoods[i] - ascertainmentCorrection) * patternWeights[i];
    }
    return logL;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:21,代码来源:BeagleTreeLikelihood.java


示例8: NewWVTreeLikelihood

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
public NewWVTreeLikelihood(int[] patternWeights,
                           Alignment data,
                           Tree tree,
                           boolean useAmbiguities,
                           SiteModel siteModel,
                           BranchRateModel.Base branchRateModel){
    this.patternWeights = patternWeights;
    storedPatternWeights = new int[patternWeights.length];
    this.data = data;
    this.tree = tree;
    this.useAmbiguities = useAmbiguities;
    m_siteModel = siteModel;
    this.branchRateModel = branchRateModel;
    this.substitutionModel = (SubstitutionModel.Base)m_siteModel.getSubstitutionModel();
    setup();
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:17,代码来源:NewWVTreeLikelihood.java


示例9: run

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
@Override
public void run() throws IllegalArgumentException, IllegalAccessException, IOException, XMLParserException {
	for (int i = 0; i < iterationsInput.get(); i++) {
     Alignment alignment = simulate();
     
     // Write output to stdout or file
     PrintStream pstream;
     if (m_outputFileName == null)
         pstream = System.out;
     else
         pstream = new PrintStream(m_outputFileName);
     pstream.println(new XMLProducer().toRawXML(alignment));
     for (MergeDataWith merge : mergeListInput.get()) {
     	merge.process(alignment, i);
     }
	}
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:18,代码来源:SequenceSimulator.java


示例10: traverse

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
/**
 * recursively walk through the tree top down, and add sequence to alignment whenever
 * a leave node is reached.
 *
 * @param node           reference to the current node, for which we visit all children
 * @param parentSequence randomly generated sequence of the parent node
 * @param category       array of categories for each of the sites
 * @param alignment
 * @
 */
void traverse(Node node, int[] parentSequence, int[] category, Alignment alignment)  {
    for (int childIndex = 0; childIndex < 2; childIndex++) {
        Node child = (childIndex == 0 ? node.getLeft() : node.getRight());
        for (int i = 0; i < m_categoryCount; i++) {
            getTransitionProbabilities(m_tree, child, i, m_probabilities[i]);
        }

        int[] seq = new int[m_sequenceLength];
        double[] cProb = new double[m_stateCount];
        for (int i = 0; i < m_sequenceLength; i++) {
            System.arraycopy(m_probabilities[category[i]], parentSequence[i] * m_stateCount, cProb, 0, m_stateCount);
            seq[i] = Randomizer.randomChoicePDF(cProb);
        }

        if (child.isLeaf()) {
            alignment.sequenceInput.setValue(intArray2Sequence(seq, child), alignment);
        } else {
            traverse(child, seq, category, alignment);
        }
    }
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:32,代码来源:SequenceSimulator.java


示例11: readDataBlock

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
/**
 * Reads a 'DATA' block.
 */
private Alignment readDataBlock(/*TaxonList taxonList*/) throws ImportException, IOException {

    taxonCount = 0;
    siteCount = 0;
    dataType = null;

    readDataBlockHeader("MATRIX", DATA_BLOCK);

    SimpleAlignment alignment = new SimpleAlignment();
    readSequenceData(alignment, null);
    alignment.updateSiteCount();

    findEndBlock();

    return alignment;
}
 
开发者ID:armanbilge,项目名称:B3,代码行数:20,代码来源:NexusImporter.java


示例12: mergeSequences

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
/**
 * Merge sequence data with xml specification.
 * @throws ParserConfigurationException
 * @throws IOException
 * @throws SAXException
 * @throws XMLParserException
 */
void mergeSequences(String xml) throws XMLParserException, SAXException, IOException, ParserConfigurationException {
    if (xml == null) {
        xml = processTemplate(STANDARD_TEMPLATE);
    }
    loadTemplate(xml);
    // create XML for alignments
    if (beautiConfig != null) {
        for (Alignment alignment : alignments) {
            beautiConfig.partitionTemplate.get().createSubNet(alignment, this, true);
        }
    } else {
        // replace alignment
        for (BEASTInterface beastObject : pluginmap.values()) {
            if (beastObject instanceof Alignment) {
                // use toArray to prevent ConcurrentModificationException
                for (Object output : beastObject.getOutputs().toArray()) {
                    replaceInputs((BEASTInterface) output, beastObject, alignments.get(0));
                }
            }
        }
        return;
    }
    determinePartitions();

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


示例13: loadExternalJars

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
/**
 * load external jars in beast directories *
 */
public static void loadExternalJars() throws IOException {
    processDeleteList();

    addInstalledPackages(packages);

    processInstallList(packages);

    checkInstalledDependencies(packages);

    for (String jarDirName : getBeastDirectories()) {
    	loadPacakge(jarDirName);
    }
    externalJarsLoaded = true;
    Alignment.findDataTypes();
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:19,代码来源:AddOnManager.java


示例14: testNarrowExchange4Taxa

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
@Test 
public void testNarrowExchange4Taxa() throws Exception {
	
       int runs = 10000;
       Randomizer.setSeed(666);
       // test that going from source tree to target tree 
       // is as likely as going the other way around
       // taking the HR in account.
       Sequence A = new Sequence("A", "A");
       Sequence B = new Sequence("B", "A");
       Sequence C = new Sequence("C", "A");
       Sequence D = new Sequence("D", "A");

       Alignment data = new Alignment();
       data.initByName("sequence", A, "sequence", B, "sequence", C, "sequence", D,
               "dataType", "nucleotide"
       );
       String sourceTree = "((A:2.0,B:2.0):1.0,(C:1.0,D:1.0):2.0):0.0"; // ((A,B),(C,D))
       String targetTree = "((A:2.0,(C:1.0,D:1.0):1.0):1.0,B:3.0):0.0"; // ((A,(C,D)),B)
       testNarrowExchange(sourceTree, targetTree, runs, data);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:22,代码来源:ExchangeOperatorTest.java


示例15: testNarrowExchange6Taxa

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
@Test
public void testNarrowExchange6Taxa() throws Exception {
   	int runs = 10000;
    Randomizer.setSeed(666);
       Sequence A = new Sequence("A", "A");
       Sequence B = new Sequence("B", "A");
       Sequence C = new Sequence("C", "A");
       Sequence D = new Sequence("D", "A");
       Sequence E = new Sequence("E", "A");
       Sequence F = new Sequence("F", "A");

       Alignment data = new Alignment();
       data.initByName("sequence", A, "sequence", B, "sequence", C, "sequence", D, "sequence", E, "sequence", F,
               "dataType", "nucleotide"
       );
       //String sourceTree = "((((A:2.0,B:2.0):1.0,(C:1.0,D:1.0):2.0):1.0,E:4.0):1.0,F:5.0):0.0"; // ((((A,B),(C,D)),E),F)
       //String targetTree = "((((A:2.0,(C:1.0,D:1.0):1.0):1.0,B:3.0):1.0,E:4.0):1.0,F:5.0):0.0"; // ((((A,(C,D)),B),E),F)

       String sourceTree = "(((A:5.0,B:5.0):2.0,((C:5.0,D:5.0):1.0,E:6.0):1.0):1.0,F:8.0):0.0"; 
       String targetTree = "(((A:5.0,B:5.0):2.0,F:7.0):1.0,((C:5.0,D:5.0):1.0,E:6.0):2.0):0.0"; 

       testNarrowExchange(sourceTree, targetTree, runs, data);
   }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:24,代码来源:ExchangeOperatorTest.java


示例16: testJC69Likelihood

import beast.evolution.alignment.Alignment; //导入依赖的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


示例17: testAscertainedJC69Likelihood

import beast.evolution.alignment.Alignment; //导入依赖的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


示例18: testBinaryCovarionLikelihood

import beast.evolution.alignment.Alignment; //导入依赖的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


示例19: testWeightedSitesReordered

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
public void testWeightedSitesReordered() throws Exception {

        // reorder taxa
        Alignment data = getAlignmentNoTInHuman();
        data.setID("data");

        List<Taxon> taxa = new ArrayList<>();
        taxa.add(new Taxon("1chimp"));
        taxa.add(new Taxon("0human"));
        TaxonSet set = new TaxonSet(taxa);

        data.taxonSetInput.setValue(set, data);
        data.siteWeightsInput.setValue("11232, 2, 3, 4 ,1123,2,3,4,112,2,3,4,11,2,3,	4 ", data);
        data.initAndValidate();

        String weights = Arrays.toString(data.getWeights());

        System.out.println(weights + "\n0human\t" + alignmentToString(data, data.getTaxonIndex("0human")) + "\n1chimp\t"
                + alignmentToString(data, data.getTaxonIndex("1chimp")));
        assertEquals("[11243, 1123, 112, 4, 2, 2, 6, 3, 3, 8, 4, 4]", weights);

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


示例20: testFilteredFileredAlignment

import beast.evolution.alignment.Alignment; //导入依赖的package包/类
@Test
public void testFilteredFileredAlignment() throws Exception {
    Alignment data1 = getAlignment();
    FilteredAlignment data2 = new FilteredAlignment();
    data2.initByName("data", data1, "filter", "2:16:2");

    
    FilteredAlignment data3 = new FilteredAlignment();
    data3.initByName("data", data2, "filter", "-");//, "ascertained", true, "excludeto", 1);
    
    assertEquals(alignmentToString(data2,0), alignmentToString(data3, 0));
    assertEquals(alignmentToString(data2,1), alignmentToString(data3, 1));

    FilteredAlignment data4 = new FilteredAlignment();
    data4.initByName("data", data3, "filter", "-", "ascertained", true, "excludeto", 1);

    assertEquals(alignmentToString(data2,0), alignmentToString(data4, 0));
    assertEquals(alignmentToString(data2,1), alignmentToString(data4, 1));
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:20,代码来源:FilteredAlignmentTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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