Search in sources :

Example 31 with TreeParser

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

the class BEASTTestCase method getTree.

public static Tree getTree(Alignment data) throws Exception {
    TreeParser tree = new TreeParser();
    tree.initByName("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);
    return tree;
}
Also used : TreeParser(beast.util.TreeParser)

Example 32 with TreeParser

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

the class UncertainAlignmentTest method getTreeB.

public static 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;
}
Also used : TreeParser(beast.util.TreeParser)

Example 33 with TreeParser

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

the class TreeParserTest method testFullyLabelledWithIntegers.

@Test
public void testFullyLabelledWithIntegers() {
    String newick = "((0:1.0,1:1.0)4:1.0,(2:1.0,3:1.0)5:1.0)6:0.0;";
    try {
        boolean isLabeled = false;
        TreeParser treeParser = new TreeParser(newick, false, false, isLabeled, 0);
        treeParser.offsetInput.setValue(0, treeParser);
        Assert.assertEquals(newick.split(";")[0], treeParser.getRoot().toShortNewick(true));
    } catch (Exception e) {
        // To change body of catch statement use File | Settings | File Templates.  \
        e.printStackTrace();
        Assert.assertTrue("Exception!", false);
    }
}
Also used : TreeParser(beast.util.TreeParser) Test(org.junit.Test)

Example 34 with TreeParser

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

the class TreeParserTest method testInternalNodeLabels.

@Test
public void testInternalNodeLabels() throws Exception {
    String newick = "((xmr),((knw)ctm));";
    boolean isLabeled = true;
    TreeParser treeParser = new TreeParser(newick, false, true, isLabeled, 0, false);
    Assert.assertTrue(treeParser.getNode(0).getID().equals("knw"));
    Assert.assertTrue(treeParser.getNode(1).getID().equals("xmr"));
    Assert.assertTrue(treeParser.getNode(0).getParent().getID().equals("ctm"));
    Assert.assertTrue(treeParser.getNode(1).getParent().getID() == null);
}
Also used : TreeParser(beast.util.TreeParser) Test(org.junit.Test)

Example 35 with TreeParser

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

the class TreeParserTest method testVectorMetadata.

@Test
public void testVectorMetadata() throws Exception {
    String newick = "((A:1.0,B[&key={1,2,3}]: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).getMetaData("key") instanceof Double[]) && ((Double[]) (treeParser.getNode(1).getMetaData("key"))).length == 3);
}
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