Search in sources :

Example 1 with NexusExporter

use of dr.app.tools.NexusExporter in project beast-mcmc by beast-dev.

the class PathogenFrame method writeTimeTreeFile.

protected void writeTimeTreeFile(PrintStream ps) throws IOException {
    FlexibleTree tree = new FlexibleTree(pathogenPanel.getTreeAsViewed());
    Regression r = pathogenPanel.getTemporalRooting().getRootToTipRegression(pathogenPanel.getTreeAsViewed());
    for (int i = 0; i < tree.getInternalNodeCount(); i++) {
        NodeRef node = tree.getInternalNode(i);
        double height = tree.getNodeHeight(node);
        tree.setNodeHeight(node, height / r.getGradient());
    }
    TreeUtils.setHeightsFromDates(tree);
    NexusExporter nexusExporter = new NexusExporter(new PrintStream(ps));
    nexusExporter.exportTree(tree);
}
Also used : NodeRef(dr.evolution.tree.NodeRef) NexusExporter(dr.app.tools.NexusExporter) FlexibleTree(dr.evolution.tree.FlexibleTree) Regression(dr.stats.Regression)

Example 2 with NexusExporter

use of dr.app.tools.NexusExporter in project beast-mcmc by beast-dev.

the class PathogenFrame method writeTreeFile.

protected void writeTreeFile(PrintStream ps, boolean newickFormat) throws IOException {
    Tree tree = pathogenPanel.getTreeAsViewed();
    //        if (newickFormat) {
    //            NewickExporter newickExporter = new NewickExporter(ps);
    //            newickExporter.exportTree(tree);
    //        } else {
    NexusExporter nexusExporter = new NexusExporter(new PrintStream(ps));
    nexusExporter.exportTree(tree);
//        }
}
Also used : NexusExporter(dr.app.tools.NexusExporter) FlexibleTree(dr.evolution.tree.FlexibleTree) Tree(dr.evolution.tree.Tree)

Example 3 with NexusExporter

use of dr.app.tools.NexusExporter in project beast-mcmc by beast-dev.

the class TempestFrame method writeTreeFile.

protected void writeTreeFile(PrintStream ps, boolean newickFormat) throws IOException {
    Tree tree = tempestPanel.getTreeAsViewed();
    //        if (newickFormat) {
    //            NewickExporter newickExporter = new NewickExporter(ps);
    //            newickExporter.exportTree(tree);
    //        } else {
    NexusExporter nexusExporter = new NexusExporter(new PrintStream(ps));
    nexusExporter.exportTree(tree);
//        }
}
Also used : NexusExporter(dr.app.tools.NexusExporter) FlexibleTree(dr.evolution.tree.FlexibleTree) Tree(dr.evolution.tree.Tree)

Example 4 with NexusExporter

use of dr.app.tools.NexusExporter in project beast-mcmc by beast-dev.

the class TempestFrame method writeTimeTreeFile.

protected void writeTimeTreeFile(PrintStream ps) throws IOException {
    FlexibleTree tree = new FlexibleTree(tempestPanel.getTreeAsViewed());
    Regression r = tempestPanel.getTemporalRooting().getRootToTipRegression(tempestPanel.getTreeAsViewed());
    for (int i = 0; i < tree.getInternalNodeCount(); i++) {
        NodeRef node = tree.getInternalNode(i);
        double height = tree.getNodeHeight(node);
        tree.setNodeHeight(node, height / r.getGradient());
    }
    TreeUtils.setHeightsFromDates(tree);
    NexusExporter nexusExporter = new NexusExporter(new PrintStream(ps));
    nexusExporter.exportTree(tree);
}
Also used : NodeRef(dr.evolution.tree.NodeRef) NexusExporter(dr.app.tools.NexusExporter) FlexibleTree(dr.evolution.tree.FlexibleTree) Regression(dr.stats.Regression)

Example 5 with NexusExporter

use of dr.app.tools.NexusExporter in project beast-mcmc by beast-dev.

the class CoalescentSimulator method main.

public static void main(String[] args) {
    int N = 100000000;
    double[] samplingTimes = { 0.0, 0.0, 0.0, 0.0, 0.0 };
    ConstantPopulation constantPopulation = new ConstantPopulation(Units.Type.YEARS);
    constantPopulation.setN0(1);
    Taxa taxa = new Taxa();
    int i = 1;
    for (double time : samplingTimes) {
        Taxon taxon = new Taxon("tip" + i);
        taxon.setAttribute("date", new Date(time, Units.Type.YEARS, true));
        i++;
        taxa.addTaxon(taxon);
    }
    CoalescentSimulator simulator = new CoalescentSimulator();
    PrintStream out = System.out;
    //        try {
    //             out = new PrintStream(new File("out.nex"));
    //        } catch (FileNotFoundException e) {
    //            e.printStackTrace();
    //        }
    NexusExporter exporter = new NexusExporter(out);
    Tree tree = simulator.simulateTree(taxa, constantPopulation);
    Map<String, Integer> idMap = exporter.writeNexusHeader(tree);
    out.println("\t\t;");
    exporter.writeNexusTree(tree, "TREE_" + 0, true, idMap);
    for (i = 1; i < N; i++) {
        tree = simulator.simulateTree(taxa, constantPopulation);
        exporter.writeNexusTree(tree, "TREE_" + i, true, idMap);
    }
    out.println("End;");
}
Also used : PrintStream(java.io.PrintStream) Date(dr.evolution.util.Date) NexusExporter(dr.app.tools.NexusExporter)

Aggregations

NexusExporter (dr.app.tools.NexusExporter)9 FlexibleTree (dr.evolution.tree.FlexibleTree)7 PrintStream (java.io.PrintStream)4 FlexibleNode (dr.evolution.tree.FlexibleNode)3 NodeRef (dr.evolution.tree.NodeRef)3 IOException (java.io.IOException)3 Tree (dr.evolution.tree.Tree)2 Regression (dr.stats.Regression)2 Date (dr.evolution.util.Date)1 ArrayList (java.util.ArrayList)1