本文整理匯總了Java中jebl.evolution.io.TreeImporter類的典型用法代碼示例。如果您正苦於以下問題:Java TreeImporter類的具體用法?Java TreeImporter怎麽用?Java TreeImporter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TreeImporter類屬於jebl.evolution.io包,在下文中一共展示了TreeImporter類的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();
}