Search in sources :

Example 36 with TreeParser

use of beast.util.TreeParser in project beast2 by CompEvol.

the class TreeParserTest method testOnlyLeafLabels2.

@Test
public void testOnlyLeafLabels2() throws Exception {
    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 newick2 = treeParser.getRoot().toNewick();
    Assert.assertEquals(newick.replaceAll(";", ""), newick2);
}
Also used : TreeParser(beast.util.TreeParser) Test(org.junit.Test)

Example 37 with TreeParser

use of beast.util.TreeParser in project beast2 by CompEvol.

the class TreeParserTest method testNodeLengthMetadata.

@Test
public void testNodeLengthMetadata() throws Exception {
    String newick = "((A:1.0,B[&key=42]:[&key=2.5]1.0):1.0,(C:1.0,D:1.0):1.0):0.0;";
    boolean isLabeled = true;
    TreeParser treeParser = new TreeParser(newick, false, false, isLabeled, 1);
    Assert.assertTrue(treeParser.getNode(1).getLengthMetaData("key").equals(2.5));
    Assert.assertTrue(treeParser.getNode(1).getMetaData("key").equals(42.0));
}
Also used : TreeParser(beast.util.TreeParser) Test(org.junit.Test)

Aggregations

TreeParser (beast.util.TreeParser)37 Test (org.junit.Test)23 Alignment (beast.evolution.alignment.Alignment)6 Sequence (beast.evolution.alignment.Sequence)3 Node (beast.evolution.tree.Node)3 Taxon (beast.evolution.alignment.Taxon)2 TaxonSet (beast.evolution.alignment.TaxonSet)2 Tree (beast.evolution.tree.Tree)2 MRCAPrior (beast.math.distributions.MRCAPrior)2 PrintStream (java.io.PrintStream)2 ArrayList (java.util.ArrayList)2 CladeSystem (beast.app.treeannotator.CladeSystem)1 TreeAnnotator (beast.app.treeannotator.TreeAnnotator)1 State (beast.core.State)1 StateNode (beast.core.StateNode)1 RealParameter (beast.core.parameter.RealParameter)1 BeagleTreeLikelihood (beast.evolution.likelihood.BeagleTreeLikelihood)1 Exchange (beast.evolution.operators.Exchange)1 ScaleOperator (beast.evolution.operators.ScaleOperator)1 SiteModel (beast.evolution.sitemodel.SiteModel)1