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);
// }
}
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);
}
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;");
}
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");
}
}
Aggregations