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


Java NexusImporter类代码示例

本文整理汇总了Java中jebl.evolution.io.NexusImporter的典型用法代码示例。如果您正苦于以下问题:Java NexusImporter类的具体用法?Java NexusImporter怎么用?Java NexusImporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NexusImporter类属于jebl.evolution.io包,在下文中一共展示了NexusImporter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: simulate

import jebl.evolution.io.NexusImporter; //导入依赖的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: TimeSlicerParser

import jebl.evolution.io.NexusImporter; //导入依赖的package包/类
public TimeSlicerParser(String traitName, //
			NexusImporter treesImporter, //
			TimeParser timeParser, //
			int burnIn, //
			int assumedTrees, //
			
//			boolean hasRRWrate, //
			String rrwRateName, //
			
			double hpdLevel, //
			int gridSize, //
			double timescaleMultiplier, //
			Double[] sliceHeights //

	) {

		this.sliceHeights = sliceHeights;
		this.treesImporter = treesImporter;
		this.timeParser = timeParser;
		this.burnIn = burnIn;
		this.assumedTrees = assumedTrees;
		this.traitName = traitName;
		
//		this.hasRRWrate = hasRRWrate;
		this.rrwRateName = rrwRateName;
		this.hpdLevel = hpdLevel;

		this.gridSize = gridSize;
		this.timescaleMultiplier = timescaleMultiplier;

		this.uniqueAreaAttributes = new LinkedList<Attribute>();
		this.areasList = new LinkedList<Area>();
		
	}
 
开发者ID:phylogeography,项目名称:SpreaD3,代码行数:35,代码来源:TimeSlicerParser.java

示例3: doImport

import jebl.evolution.io.NexusImporter; //导入依赖的package包/类
public final void doImport() {
        int returnVal = importChooser.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File[] files = importChooser.getSelectedFiles();
            for (File file : files) {
                if (file == null || file.getName().equals("")) {
                    JOptionPane.showMessageDialog(this, "Invalid file name",
                            "Invalid file name", JOptionPane.ERROR_MESSAGE);
                } else {
                    try {
                        importDataFile(file);

                        setDirty();
//                    } catch (FileNotFoundException fnfe) {
//                        JOptionPane.showMessageDialog(this, "Unable to open file: File not found",
//                                "Unable to open file", JOptionPane.ERROR_MESSAGE);
                    } catch (IOException ioe) {
                        JOptionPane.showMessageDialog(this, "File I/O Error unable to read file: " + ioe.getMessage(),
                                "Unable to read file", JOptionPane.ERROR_MESSAGE);
                        return;

                    } catch (NexusImporter.MissingBlockException ex) {
                        JOptionPane.showMessageDialog(this, "TAXON, DATA or CHARACTERS block is missing in Nexus file: " + ex,
                                "Missing Block in Nexus File",
                                JOptionPane.ERROR_MESSAGE);

                    } catch (ImportException ime) {
                        JOptionPane.showMessageDialog(this, "Error parsing imported file: " + ime,
                                "Error reading file",
                                JOptionPane.ERROR_MESSAGE);
                        return;

//                    } catch (Exception ex) {
//                        JOptionPane.showMessageDialog(this, "Fatal exception: " + ex,
//                                "Error reading file",
//                                JOptionPane.ERROR_MESSAGE);
//                        return;
                    }
                }
            }

//            setAllOptions();
        }
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:45,代码来源:TreeSpaceFrame.java

示例4: loadTrees

import jebl.evolution.io.NexusImporter; //导入依赖的package包/类
private TreeLineages loadTrees(InputFile inputFile) throws IOException {

        PrintStream progressStream = System.out;

        int totalTrees = 10000;
        int totalTreesUsed = 0;

        progressStream.println("Reading trees (bar assumes 10,000 trees)...");
        progressStream.println("0              25             50             75            100");
        progressStream.println("|--------------|--------------|--------------|--------------|");

        int stepSize = totalTrees / 60;
        if (stepSize < 1) stepSize = 1;

        TreeLineages treeLineages = new TreeLineages();

        FileReader fileReader = new FileReader(inputFile.getFile());
        jebl.evolution.io.NexusImporter importer = new NexusImporter(fileReader);
        try {
            totalTrees = 0;
            while (importer.hasTree()) {
                RootedTree tree = (RootedTree)importer.importNextTree();

                if (totalTrees >= inputFile.getBurnin()) {
                    treeLineages.addTree(tree);
                    totalTreesUsed += 1;
                }

                if (totalTrees > 0 && totalTrees % stepSize == 0) {
                    progressStream.print("*");
                    progressStream.flush();
                }
                totalTrees++;
            }

        } catch (ImportException e) {
            System.err.println("Error Parsing Input Tree: " + e.getMessage());
            return null;
        }
        fileReader.close();
        progressStream.println();
        progressStream.println();

        if (totalTrees < 1) {
            System.err.println("No trees");
            return null;
        }
        if (totalTreesUsed <= 1) {
            if (inputFile.getBurnin() > 0) {
                System.err.println("No trees to use: burnin too high");
                return null;
            }
        }

        progressStream.println("Total trees read: " + totalTrees);
        if (inputFile.getBurnin() > 0) {
            progressStream.println("Ignoring first " + inputFile.getBurnin() + " trees.");
        }

        treeLineages.setupTrees();

        return treeLineages;
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:64,代码来源:TreeSpaceFrame.java

示例5: importRootedTree

import jebl.evolution.io.NexusImporter; //导入依赖的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

示例6: simulate

import jebl.evolution.io.NexusImporter; //导入依赖的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

示例7: importTree

import jebl.evolution.io.NexusImporter; //导入依赖的package包/类
public static RootedTree importTree(String treeFilename) throws IOException, ImportException {
	
	NexusImporter importer = new NexusImporter(new FileReader(
			treeFilename));

	RootedTree rootedTree = (RootedTree) importer
			.importNextTree();
	
	return rootedTree;
}
 
开发者ID:phylogeography,项目名称:SpreaD3,代码行数:11,代码来源:Utils.java


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