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


Java Alignment.setID方法代码示例

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


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

示例1: 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

示例2: simulate

import beast.evolution.alignment.Alignment; //导入方法依赖的package包/类
/**
 * perform the actual sequence generation
 *
 * @return alignment containing randomly generated sequences for the nodes in the
 *         leaves of the tree
 * @
 */
public Alignment simulate()  {
    Node root = m_tree.getRoot();


    double[] categoryProbs = m_siteModel.getCategoryProportions(root);
    int[] category = new int[m_sequenceLength];
    for (int i = 0; i < m_sequenceLength; i++) {
        category[i] = Randomizer.randomChoicePDF(categoryProbs);
    }

    double[] frequencies = m_siteModel.getSubstitutionModel().getFrequencies();
    int[] seq = new int[m_sequenceLength];
    for (int i = 0; i < m_sequenceLength; i++) {
        seq[i] = Randomizer.randomChoicePDF(frequencies);
    }


    Alignment alignment = new Alignment();
    alignment.userDataTypeInput.setValue(m_data.get().getDataType(), alignment);
    alignment.setID("SequenceSimulator");

    traverse(root, seq, category, alignment);


    return alignment;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:34,代码来源:SequenceSimulator.java

示例3: parseBeast1XML

import beast.evolution.alignment.Alignment; //导入方法依赖的package包/类
private static BEASTInterface parseBeast1XML(String ID, String xml) throws SAXException, IOException, ParserConfigurationException  {
	DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
	Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(xml)));
	doc.normalize();

	NodeList alignments = doc.getElementsByTagName("alignment");
	Alignment alignment = new Alignment();
	alignment.dataTypeInput.setValue("nucleotide", alignment);

	// parse first alignment
	org.w3c.dom.Node node = alignments.item(0);

	String dataTypeName = node.getAttributes().getNamedItem("dataType").getNodeValue();
	int totalCount = 4;
	if (dataTypeName == null) {
		alignment.dataTypeInput.setValue("integer", alignment);
	} else if (dataTypeName.toLowerCase().equals("dna") || dataTypeName.toLowerCase().equals("nucleotide")) {
		alignment.dataTypeInput.setValue("nucleotide", alignment);
		totalCount = 4;
	} else if (dataTypeName.toLowerCase().equals("aminoacid") || dataTypeName.toLowerCase().equals("protein")) {
		alignment.dataTypeInput.setValue("aminoacid", alignment);
		totalCount = 20;
	} else {
		alignment.dataTypeInput.setValue("integer", alignment);
	}

	NodeList children = node.getChildNodes();
	for (int i = 0; i < children.getLength(); i++) {
		org.w3c.dom.Node child = children.item(i);
		if (child.getNodeName().equals("sequence")) {
			Sequence sequence = new Sequence();
			// find the taxon
			String taxon = "";
			NodeList sequenceChildren = child.getChildNodes();
			for (int j = 0; j < sequenceChildren.getLength(); j++) {
				org.w3c.dom.Node child2 = sequenceChildren.item(j);
				if (child2.getNodeName().equals("taxon")) {
					taxon = child2.getAttributes().getNamedItem("idref").getNodeValue();
				}
			}
			String data = child.getTextContent();
			sequence.initByName("totalcount", totalCount, "taxon", taxon, "value", data);
			sequence.setID("seq_" + taxon);
			alignment.sequenceInput.setValue(sequence, alignment);

		}
	}
	alignment.setID(ID);
	alignment.initAndValidate();
	return alignment;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:52,代码来源:BeautiAlignmentProvider.java

示例4: testReordered

import beast.evolution.alignment.Alignment; //导入方法依赖的package包/类
@Test
public void testReordered() throws Exception {
	// make sure the order of sites is not affected by filtering
    Alignment data = getAlignmentNoTInHuman();
    data.setID("data");

    // second sequence not in alphabetical order
    FilteredAlignment data2 = new FilteredAlignment();
    data2.initByName("data", data, "filter", "3:6:1");

    System.out.println("human\t" + alignmentToString(data2, 0) + "\n1chimp\t"
            + alignmentToString(data2, 1));

    assertEquals(alignmentToString(data2,0), "AACC");
    assertEquals(alignmentToString(data2,1), "GTAC");

    // first sequence not in alphabetical order
    FilteredAlignment data3 = new FilteredAlignment();
    data3.initByName("data", data, "filter", "11:14:1");

    System.out.println("human\t" + alignmentToString(data3, 0) + "\n1chimp\t"
            + alignmentToString(data3, 1));

    assertEquals(alignmentToString(data3,0), "GGAA");
    assertEquals(alignmentToString(data3,1), "GTAC");

    // first sequence not in alphabetical order, repeat site
    FilteredAlignment data4 = new FilteredAlignment();
    data4.initByName("data", data, "filter", "3:16:4");

    System.out.println("human\t" + alignmentToString(data4, 0) + "\n1chimp\t"
            + alignmentToString(data4, 1));

    assertEquals(alignmentToString(data4,0), "ACGA");
    assertEquals(alignmentToString(data4,1), "GGGG");

    // first and second sequence not in alphabetical order
    FilteredAlignment data5 = new FilteredAlignment();
    data5.initByName("data", data, "filter", "4:14:3");

    System.out.println("human\t" + alignmentToString(data5, 0) + "\n1chimp\t"
            + alignmentToString(data5, 1));

    assertEquals(alignmentToString(data5,0), "ACGA");
    assertEquals(alignmentToString(data5,1), "TGCA");
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:47,代码来源:FilteredAlignmentTest.java


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