本文整理汇总了Java中beast.evolution.alignment.Sequence.initByName方法的典型用法代码示例。如果您正苦于以下问题:Java Sequence.initByName方法的具体用法?Java Sequence.initByName怎么用?Java Sequence.initByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beast.evolution.alignment.Sequence
的用法示例。
在下文中一共展示了Sequence.initByName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUncertainAlignment
import beast.evolution.alignment.Sequence; //导入方法依赖的package包/类
static public Alignment getUncertainAlignment(boolean duplicate) throws Exception {
String seq1Probs = new String("0.7,0.0,0.3,0.0; 0.0,0.3,0.0,0.7; 0.0,0.0,0.0,1.0;");
String seq2Probs = new String("0.7,0.0,0.3,0.0; 0.0,0.3,0.0,0.7; 0.0,1.0,0.0,0.0;");
String seq3Probs = new String("0.4,0.0,0.6,0.0; 0.0,0.6,0.0,0.4; 0.0,1.0,0.0,0.0;");
if (duplicate) {
seq1Probs += seq1Probs;
seq2Probs += seq2Probs;
seq3Probs += seq3Probs;
}
Sequence seq1 = new Sequence();
seq1.initByName("taxon","seq1","value",seq1Probs,"uncertain",true);
Sequence seq2 = new Sequence();
seq2.initByName("taxon","seq2","value",seq2Probs,"uncertain",true);
Sequence seq3 = new Sequence();
seq3.initByName("taxon","seq3","value",seq3Probs,"uncertain",true);
Alignment data = new Alignment();
data.initByName("sequence", seq1, "sequence", seq2, "sequence", seq3,
"dataType", "nucleotide"
);
DataType dataType = data.getDataType();
System.out.println("Most probable sequences:");
for (List<Integer> seq : data.getCounts()) {
System.out.println(dataType.state2string(seq));
}
return data;
}
示例2: testMascotStructured
import beast.evolution.alignment.Sequence; //导入方法依赖的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);
}
示例3: testMascotUnstructured
import beast.evolution.alignment.Sequence; //导入方法依赖的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);
}
示例4: parseBeast1XML
import beast.evolution.alignment.Sequence; //导入方法依赖的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;
}