use of beast.util.TreeParser in project beast2 by CompEvol.
the class YuleModelTest method testYule.
@Test
public void testYule() throws Exception {
YuleModel bdssm = new YuleModel();
Tree tree1 = new TreeParser("((A:1.0,B:1.0):1.0,C:2.0);", false);
bdssm.setInputValue("tree", tree1);
bdssm.setInputValue("birthDiffRate", new RealParameter("10."));
bdssm.setInputValue("originHeight", new RealParameter("10."));
bdssm.initAndValidate();
double logP1 = bdssm.calculateTreeLogLikelihood(tree1);
Tree tree = new TreeParser("((A:1.0,B:1.0):2.0,C:3.0);", false);
bdssm.setInputValue("tree", tree);
bdssm.setInputValue("birthDiffRate", new RealParameter("10."));
bdssm.setInputValue("originHeight", new RealParameter("10."));
bdssm.initAndValidate();
double logP2 = bdssm.calculateTreeLogLikelihood(tree);
assertEquals(logP1 - logP2, 10.0);
}
use of beast.util.TreeParser in project beast2 by CompEvol.
the class Tree method fromXML.
/**
* reconstruct tree from XML fragment in the form of a DOM node *
*/
@Override
public void fromXML(final org.w3c.dom.Node node) {
final String newick = node.getTextContent();
final TreeParser parser = new TreeParser();
try {
parser.thresholdInput.setValue(1e-10, parser);
} catch (Exception e1) {
e1.printStackTrace();
}
try {
parser.offsetInput.setValue(0, parser);
setRoot(parser.parseNewick(newick));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
initArrays();
}
use of beast.util.TreeParser in project beast2 by CompEvol.
the class StateNodeInitialiserTest method testClusterTree.
@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());
}
use of beast.util.TreeParser in project beast2 by CompEvol.
the class NodeTest method testBinarySortedNewickTest.
@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);
}
use of beast.util.TreeParser in project beast2 by CompEvol.
the class UncertainAlignmentTest method getTreeA.
public static 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;
}
Aggregations