当前位置: 首页>>代码示例>>Java>>正文


Java TreeImporter.importNextTree方法代码示例

本文整理汇总了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();

    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:78,代码来源:CoalGenApp.java

示例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;
}
 
开发者ID:phylogeography,项目名称:SpreaD3,代码行数:7,代码来源:Utils.java

示例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();

}
 
开发者ID:whdc,项目名称:ieo-beast,代码行数:80,代码来源:CoalGenApp.java


注:本文中的jebl.evolution.io.TreeImporter.importNextTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。