本文整理汇总了Java中jebl.evolution.io.TreeImporter.importNextTree方法的典型用法代码示例。如果您正苦于以下问题:Java TreeImporter.importNextTree方法的具体用法?Java TreeImporter.importNextTree怎么用?Java TreeImporter.importNextTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jebl.evolution.io.TreeImporter
的用法示例。
在下文中一共展示了TreeImporter.importNextTree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: simulate
import jebl.evolution.io.TreeImporter; //导入方法依赖的package包/类
public static void simulate(String inputFileName, String treesFileName, String outputFileName) throws IOException, TraceException, Importer.ImportException {
File logFile = new File(inputFileName);
System.out.println("Loading trace file: " + inputFileName);
LogFileTraces traces = new LogFileTraces(inputFileName, logFile);
traces.loadTraces();
traces.setBurnIn(0);
System.out.println(traces.getStateCount() + " states loaded");
System.out.println();
System.out.println("Opening trees file: " + treesFileName);
// BufferedReader reader = new BufferedReader(new FileReader(treesFileName));
System.out.println("Simulating...");
System.out.println("0 25 50 75 100");
System.out.println("|--------------|--------------|--------------|--------------|");
int stepSize = traces.getStateCount() / 60;
if (stepSize < 1) stepSize = 1;
PrintWriter writer = new PrintWriter(new FileWriter(outputFileName));
FileReader fileReader = new FileReader(treesFileName);
TreeImporter importer = new NexusImporter(fileReader);
EmpiricalDemographicFunction demo = null;
IntervalGenerator intervals = null;
TreeSimulator sim = null;
CoalGenData data = new CoalGenData();
data.traces = traces;
data.setDemographicModel(7); // const stepwise bsp
data.setupSkyline();
double[] popSizes = new double[data.popSizeCount];
double[] groupSizes = new double[data.groupSizeCount];
NewickExporter exporter = new NewickExporter(writer);
int count = 0;
try {
while (importer.hasTree()) {
RootedTree inTree = (RootedTree)importer.importNextTree();
if (sim == null) {
setSamplingTimes(inTree);
sim = new TreeSimulator(inTree.getTaxa(), "date");
}
data.getNextSkyline(popSizes, groupSizes);
double[] times = getTimes(inTree, groupSizes);
demo = new EmpiricalDemographicFunction(popSizes, times, true);
intervals = new CoalescentIntervalGenerator(demo);
RootedTree outTree = sim.simulate(intervals);
exporter.exportTree(outTree);
writer.println();
writer.flush();
if (count > 0 && count % stepSize == 0) {
System.out.print("*");
System.out.flush();
}
count++;
}
} catch (ImportException e) {
e.printStackTrace();
}
fileReader.close();
writer.close();
}
示例2: importRootedTree
import jebl.evolution.io.TreeImporter; //导入方法依赖的package包/类
public static RootedTree importRootedTree(String tree) throws IOException, ImportException {
TreeImporter importer = new NexusImporter(new FileReader(tree));
RootedTree rootedTree = (RootedTree) importer.importNextTree();
return rootedTree;
}
示例3: simulate
import jebl.evolution.io.TreeImporter; //导入方法依赖的package包/类
public static void simulate(String inputFileName, String treesFileName, String outputFileName) throws IOException, TraceException, Importer.ImportException {
File logFile = new File(inputFileName);
BufferedReader reader = new BufferedReader(new FileReader(logFile));
System.out.println("Loading trace file: " + inputFileName);
LogFileTraces traces = new LogFileTraces(inputFileName, logFile);
traces.loadTraces(reader);
traces.setBurnIn(0);
System.out.println(traces.getStateCount() + " states loaded");
System.out.println();
System.out.println("Opening trees file: " + treesFileName);
reader = new BufferedReader(new FileReader(treesFileName));
System.out.println("Simulating...");
System.out.println("0 25 50 75 100");
System.out.println("|--------------|--------------|--------------|--------------|");
int stepSize = traces.getStateCount() / 60;
if (stepSize < 1) stepSize = 1;
PrintWriter writer = new PrintWriter(new FileWriter(outputFileName));
FileReader fileReader = new FileReader(treesFileName);
TreeImporter importer = new NexusImporter(fileReader);
EmpiricalDemographicFunction demo = null;
IntervalGenerator intervals = null;
TreeSimulator sim = null;
CoalGenData data = new CoalGenData();
data.traces = traces;
data.setDemographicModel(7); // const stepwise bsp
data.setupSkyline();
double[] popSizes = new double[data.popSizeCount];
double[] groupSizes = new double[data.groupSizeCount];
NewickExporter exporter = new NewickExporter(writer);
int count = 0;
try {
while (importer.hasTree()) {
RootedTree inTree = (RootedTree)importer.importNextTree();
if (sim == null) {
setSamplingTimes(inTree);
sim = new TreeSimulator(inTree.getTaxa(), "date");
}
data.getNextSkyline(popSizes, groupSizes);
double[] times = getTimes(inTree, groupSizes);
demo = new EmpiricalDemographicFunction(popSizes, times, true);
intervals = new CoalescentIntervalGenerator(demo);
RootedTree outTree = sim.simulate(intervals);
exporter.exportTree(outTree);
writer.println();
writer.flush();
if (count > 0 && count % stepSize == 0) {
System.out.print("*");
System.out.flush();
}
count++;
}
} catch (ImportException e) {
e.printStackTrace();
}
fileReader.close();
writer.close();
}