本文整理汇总了Java中beast.util.TreeParser.initByName方法的典型用法代码示例。如果您正苦于以下问题:Java TreeParser.initByName方法的具体用法?Java TreeParser.initByName怎么用?Java TreeParser.initByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beast.util.TreeParser
的用法示例。
在下文中一共展示了TreeParser.initByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import beast.util.TreeParser; //导入方法依赖的package包/类
private void initialize(TaxonSet speciesSuperset) throws Exception {
speciesTree = new SpeciesTreeParser();
speciesTree.initByName("newick", newickSpeciesTree, "IsLabelledNewick", true, "taxonset", speciesSuperset);
for (String geneTreeNewick: newickGeneTrees) {
TreeParser geneTree = new TreeParser();
geneTree.initByName("newick", geneTreeNewick, "IsLabelledNewick", true);
geneTrees.add(geneTree);
GeneTree geneTreeWrapper = new GeneTree();
geneTreeWrapper.initByName("tree", geneTree, "ploidy", ploidy, "speciesTree", speciesTree);
geneTreeWrappers.add(geneTreeWrapper);
}
state.initByName("stateNode", alphaParameter);
state.initByName("stateNode", meanParameter);
msc = new MultispeciesCoalescent();
msc.initByName("populationShape", alphaParameter, "populationMean", meanParameter, "distribution", geneTreeWrappers);
for (GeneTree gt: geneTreeWrappers) gt.calculateLogP();
}
示例2: testLogP
import beast.util.TreeParser; //导入方法依赖的package包/类
@Test
public void testLogP() throws Exception {
TaxonSet speciesSuperset = generateSuperset();
speciesTree = new SpeciesTreeParser();
speciesTree.initByName("newick", newickSpeciesTree, "IsLabelledNewick", true, "taxonset", speciesSuperset);
final int nBranches = nSpecies * 2 - 1;
popsizeParameter.initByName("value", String.valueOf(popSize), "dimension", String.valueOf(nBranches));
state.initByName("stateNode", popsizeParameter);
popModel = new ConstantPopulations();
popModel.initByName("populationSizes", popsizeParameter, "speciesTree", speciesTree);
double calculatedLogP = 0.0;
for (String geneTreeNewick: newickGeneTrees) {
TreeParser geneTree = new TreeParser();
geneTree.initByName("newick", geneTreeNewick, "IsLabelledNewick", true);
GeneTree geneTreeWrapper = new GeneTree();
geneTreeWrapper.initByName("tree", geneTree, "ploidy", ploidy, "speciesTree", speciesTree, "populationModel", popModel);
calculatedLogP += geneTreeWrapper.calculateLogP();
}
// System.out.println(String.format("expected %f, calculated %f", expectedLogP, calculatedLogP));
assertEquals(expectedLogP, calculatedLogP, allowedError);
}
示例3: initialize
import beast.util.TreeParser; //导入方法依赖的package包/类
private void initialize(TaxonSet speciesSuperset) throws Exception {
speciesTree = new SpeciesTreeParser();
speciesTree.initByName("newick", newickSpeciesTree, "IsLabelledNewick", true, "taxonset", speciesSuperset);
for (String geneTreeNewick: newickGeneTrees) {
TreeParser geneTree = new TreeParser();
geneTree.initByName("newick", geneTreeNewick, "IsLabelledNewick", true);
geneTrees.add(geneTree);
GeneTree geneTreeWrapper = new GeneTree();
geneTreeWrapper.initByName("tree", geneTree, "ploidy", ploidy, "speciesTree", speciesTree);
geneTreeWrappers.add(geneTreeWrapper);
}
state.initByName("stateNode", alphaParameter);
state.initByName("stateNode", meanParameter);
msc = new MultispeciesCoalescent();
msc.initByName("populationShape", alphaParameter, "populationMean", meanParameter, "distribution", geneTreeWrappers);
}
示例4: testNonBinarySortedNewickTest
import beast.util.TreeParser; //导入方法依赖的package包/类
@Test
public void testNonBinarySortedNewickTest() {
String newick = "((A:1.0,B:1.0,C:1.0):1.0,(D:1.0,E:1.0,F:1.0,G:1.0):1.0):0.0;";
TreeParser treeParser = new TreeParser();
treeParser.initByName("IsLabelledNewick", true,
"newick", newick,
"adjustTipHeights", false,
"binarizeMultifurcations", false);
String sortedNewick = treeParser.getRoot().toSortedNewick(new int[1], false);
String goal = "((1:1.0,2:1.0,3:1.0):1.0,(4:1.0,5:1.0,6:1.0,7:1.0):1.0):0.0";
assertEquals(goal.split(";")[0], sortedNewick);
}
示例5: testClusterTree
import beast.util.TreeParser; //导入方法依赖的package包/类
@Test
public void testClusterTree() throws Exception {
Alignment data = BEASTTestCase.getAlignment();
Tree tree = new Tree();
tree.initAndValidate();
assertEquals(true, tree.getNodeCount() == 1);
TreeParser tree2 = new TreeParser();
tree2.initByName(
"initial", tree,
"taxa", data,
"newick", "((((human:0.024003,(chimp:0.010772,bonobo:0.010772):0.013231):0.012035,gorilla:0.036038):0.033087000000000005,orangutan:0.069125):0.030456999999999998,siamang:0.099582);",
"IsLabelledNewick", true);
assertEquals(true, tree.getNodeCount() > 1);
assertEquals(11, tree.getNodeCount());
}
示例6: initializeGeneTrees
import beast.util.TreeParser; //导入方法依赖的package包/类
public void initializeGeneTrees() throws Exception {
for (String geneTreeNewick: newickGeneTrees) {
TreeParser geneTree = new TreeParser();
geneTree.initByName("newick", geneTreeNewick, "IsLabelledNewick", true);
geneTrees.add(geneTree);
GeneTree geneTreeWrapper = new GeneTree();
geneTreeWrapper.initByName("tree", geneTree, "ploidy", ploidy, "speciesTree", speciesTreeWrapper);
geneTreeWrappers.add(geneTreeWrapper);
}
}
示例7: testRates
import beast.util.TreeParser; //导入方法依赖的package包/类
@Test
public void testRates() throws Exception {
testTree = new TreeParser();
testTree.initByName("newick", newickTree, "IsLabelledNewick", true);
// Create dummy state to allow statenode editing
State state = new State();
state.initialise();
treeLengthLogger = new TreeLengthLogger();
treeLengthLogger.initByName("tree", testTree);
final double computedLength = treeLengthLogger.getArrayValue();
assertEquals(expectedLength, computedLength, allowedError);
}
示例8: initializeTrees
import beast.util.TreeParser; //导入方法依赖的package包/类
public void initializeTrees(TaxonSet speciesSuperSet) throws Exception {
speciesTree = new SpeciesTreeParser();
speciesTree.initByName("newick", newickSpeciesTree, "IsLabelledNewick", true, "taxonset", speciesSuperSet);
geneTree = new TreeParser();
geneTree.initByName("newick", newickGeneTree, "IsLabelledNewick", true);
geneTreeWrapper = new GeneTree();
geneTreeWrapper.initByName("tree", geneTree, "ploidy", ploidy, "speciesTree", speciesTree);
}
示例9: testLogP
import beast.util.TreeParser; //导入方法依赖的package包/类
@Test
public void testLogP() throws Exception {
TaxonSet speciesSuperset = generateSuperset();
speciesTree = new SpeciesTreeParser();
speciesTree.initByName("newick", newickSpeciesTree, "IsLabelledNewick", true, "taxonset", speciesSuperset);
state.initByName("stateNode", speciesTree);
tipPopSizesParameter.initByName("dimension", String.valueOf(nSpecies), "value", 1.0);
topPopSizesParameter.initByName("dimension", String.valueOf(nSpecies * 2 - 2), "value", 1.0);
state.initByName("stateNode", tipPopSizesParameter);
state.initByName("stateNode", topPopSizesParameter);
state.initialise();
popModel = new LinearWithConstantRoot();
popModel.initByName("tipPopulationSizes", tipPopSizesParameter, "topPopulationSizes", topPopSizesParameter, "speciesTree", speciesTree);
popModel.initPopSizes(popSize);
double calculatedLogP = 0.0;
for (String geneTreeNewick: newickGeneTrees) {
TreeParser geneTree = new TreeParser();
geneTree.initByName("newick", geneTreeNewick, "IsLabelledNewick", true);
GeneTree geneTreeWrapper = new GeneTree();
geneTreeWrapper.initByName("tree", geneTree, "ploidy", ploidy, "speciesTree", speciesTree, "populationModel", popModel);
calculatedLogP += geneTreeWrapper.calculateLogP();
}
// System.out.println(String.format("expected %f, calculated %f", expectedLogP, calculatedLogP));
assertEquals(expectedLogP, calculatedLogP, allowedError);
}
示例10: testLogP
import beast.util.TreeParser; //导入方法依赖的package包/类
@Test
public void testLogP() throws Exception {
TaxonSet speciesSuperset = generateSuperset();
speciesTree = new SpeciesTreeParser();
speciesTree.initByName("newick", newickSpeciesTree, "IsLabelledNewick", true, "taxonset", speciesSuperset);
state.initByName("stateNode", speciesTree);
final int nBranches = nSpecies * 2 - 1;
popsizeParameter.initByName("value", String.valueOf(popSize), "dimension", String.valueOf(nBranches));
state.initByName("stateNode", popsizeParameter);
state.initialise();
popModel = new ConstantPopulations();
popModel.initByName("populationSizes", popsizeParameter, "speciesTree", speciesTree);
double calculatedLogP = 0.0;
for (String geneTreeNewick: newickGeneTrees) {
TreeParser geneTree = new TreeParser();
geneTree.initByName("newick", geneTreeNewick, "IsLabelledNewick", true);
GeneTree geneTreeWrapper = new GeneTree();
geneTreeWrapper.initByName("tree", geneTree, "ploidy", ploidy, "speciesTree", speciesTree, "populationModel", popModel);
calculatedLogP += geneTreeWrapper.calculateLogP();
}
// System.out.println(String.format("expected %f, calculated %f", expectedLogP, calculatedLogP));
assertEquals(expectedLogP, calculatedLogP, allowedError);
}
示例11: main
import beast.util.TreeParser; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
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");
TreeParser tree = new TreeParser();
tree.initByName("taxa", data,
"newick", "(((A:1,B:1):1,C:2):1,D:3)",
"IsLabelledNewick", true);
JukesCantor JC = new JukesCantor();
JC.initAndValidate();
SiteModel siteModel = new SiteModel();
siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "substModel", JC);
BeagleTreeLikelihood likelihood = new BeagleTreeLikelihood();
likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Success");
// if we got this far, exit with status 0
System.exit(0);
}
示例12: testBinarySortedNewickTest
import beast.util.TreeParser; //导入方法依赖的package包/类
@Test
public void testBinarySortedNewickTest() {
String newick = "((D:5.0,C:4.0):6.0,(A:1.0,B:2.0):3.0):0.0;";
TreeParser treeParser = new TreeParser();
treeParser.initByName("IsLabelledNewick", true,
"newick", newick,
"adjustTipHeights", false);
String sortedNewick = treeParser.getRoot().toSortedNewick(new int[1], false);
String goal = "((1:1.0,2:2.0):3.0,(3:4.0,4:5.0):6.0):0.0";
assertEquals(goal.split(";")[0], sortedNewick);
}
示例13: getTreeB
import beast.util.TreeParser; //导入方法依赖的package包/类
static public Tree getTreeB(Alignment data) throws Exception {
TreeParser tree = new TreeParser();
tree.initByName("taxa", data,
"newick", "(seq1:2,(seq2:1,seq3:1):1);",
"IsLabelledNewick", true);
return tree;
}
示例14: getTreeA
import beast.util.TreeParser; //导入方法依赖的package包/类
static public Tree getTreeA(Alignment data) throws Exception {
TreeParser tree = new TreeParser();
tree.initByName("taxa", data,
"newick", "((seq1:1,seq2:1):1,seq3:2);",
"IsLabelledNewick", true);
return tree;
}
示例15: getTree
import beast.util.TreeParser; //导入方法依赖的package包/类
static public Tree getTree(Alignment data, String tree) throws Exception {
TreeParser t = new TreeParser();
t.initByName("taxa", data,
"newick", tree,
"IsLabelledNewick", true);
return t;
}