本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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");
}