當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeImporter類代碼示例

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

    }
 
開發者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類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。