Search in sources :

Example 6 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 7 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 8 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)

Example 9 with NexusExporter

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

the class WithinCaseCoalescent method debugTreelet.

public void debugTreelet(Tree treelet, String fileName) {
    try {
        FlexibleTree treeCopy = new FlexibleTree(treelet);
        for (int j = 0; j < treeCopy.getNodeCount(); j++) {
            FlexibleNode node = (FlexibleNode) treeCopy.getNode(j);
            node.setAttribute("Number", node.getNumber());
        }
        NexusExporter testTreesOut = new NexusExporter(new PrintStream(fileName));
        testTreesOut.exportTree(treeCopy);
    } catch (IOException ignored) {
        System.out.println("IOException");
    }
}
Also used : NexusExporter(dr.app.tools.NexusExporter) PrintStream(java.io.PrintStream) FlexibleTree(dr.evolution.tree.FlexibleTree) FlexibleNode(dr.evolution.tree.FlexibleNode) IOException(java.io.IOException)

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