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


Java TreeImporter类代码示例

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


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

示例1: EmpiricalTreeDistributionModel

import dr.evolution.io.TreeImporter; //导入依赖的package包/类
private EmpiricalTreeDistributionModel(final Tree[] trees, final TreeImporter importer, int startingTree) {
    super(EMPIRICAL_TREE_DISTRIBUTION_MODEL);

    this.trees = trees;
    this.importer = importer;
    drawTreeIndex(startingTree);

    addStatistic(new Statistic.Abstract("Current Tree")  {

        public int getDimension() {
            return 1;
        }

        public double getStatisticValue(int dim) {
            return currentTreeIndex;
        }
    });
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:19,代码来源:EmpiricalTreeDistributionModel.java

示例2: summarizeTrees

import dr.evolution.io.TreeImporter; //导入依赖的package包/类
private Tree summarizeTrees(int burnin, Tree consensusTree, CladeSystem cladeSystem, String inputFileName)
        throws IOException {

    progressStream.println("Analyzing " + totalTreesUsed + " trees...");
    progressStream.println("0              25             50             75            100");
    progressStream.println("|--------------|--------------|--------------|--------------|");

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

    int counter = 0;
    int bestTreeNumber = 0;
    TreeImporter importer = new NexusImporter(new FileReader(inputFileName));

    try {
        while (importer.hasTree()) {
            Tree tree = importer.importNextTree();

            if (counter >= burnin) {
                cladeSystem.addSubTrees(tree);
            }
            if (counter > 0 && counter % stepSize == 0) {
                progressStream.print("*");
                progressStream.flush();
            }
            counter++;
        }
    } catch (Importer.ImportException e) {
        System.err.println("Error Parsing Input Tree: " + e.getMessage());
        return null;
    }

    Tree bestTree = cladeSystem.getBestTree(consensusTree);

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

示例3: summarizeTrees

import dr.evolution.io.TreeImporter; //导入依赖的package包/类
private Tree summarizeTrees(int burnin, CladeSystem cladeSystem, String inputFileName /*, boolean useSumCladeCredibility */)
            throws IOException {

        Tree bestTree = null;
        double bestScore = Double.NEGATIVE_INFINITY;

        progressStream.println("Analyzing " + totalTreesUsed + " trees...");
        progressStream.println("0              25             50             75            100");
        progressStream.println("|--------------|--------------|--------------|--------------|");

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

        int counter = 0;
        int bestTreeNumber = 0;
        TreeImporter importer = new NexusImporter(new FileReader(inputFileName), true);
        try {
            while (importer.hasTree()) {
                Tree tree = importer.importNextTree();

                if (counter >= burnin) {
                    double score = scoreTree(tree, cladeSystem /*, useSumCladeCredibility*/);
//                    progressStream.println(score);
                    if (score > bestScore) {
                        bestTree = tree;
                        bestScore = score;
                        bestTreeNumber = counter + 1;
                    }
                }
                if (counter > 0 && counter % stepSize == 0) {
                    progressStream.print("*");
                    progressStream.flush();
                }
                counter++;
            }
        } catch (Importer.ImportException e) {
            System.err.println("Error Parsing Input Tree: " + e.getMessage());
            return null;
        }
        progressStream.println();
        progressStream.println();
        progressStream.println("Best tree: " + bestTree.getId() + " (tree number " + bestTreeNumber + ")");
//        if (useSumCladeCredibility) {
//            progressStream.println("Highest Sum Clade Credibility: " + bestScore);
//        } else {
            progressStream.println("Highest Log Clade Credibility: " + bestScore);
//        }

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

示例4: NormaliseMeanTreeRate

import dr.evolution.io.TreeImporter; //导入依赖的package包/类
public NormaliseMeanTreeRate(String inputFileName, String outputFileName, double normaliseMeanRateTo) throws java.io.IOException {

        File parentFile = new File(inputFileName);

        if (parentFile.isFile()) {
            System.out.println("Analysing tree file: " + inputFileName);
        } else {
            System.err.println("File " + inputFileName + " does not exist!");
            System.exit(0);
        }

        File outFile = new File(outputFileName);
        if (outputFileName != null) {
            FileOutputStream outputStream = new FileOutputStream(outFile);
            System.setOut(new PrintStream(outputStream));
        }

        if(!outFile.canWrite()) {
            System.err.println("Cannot write to file" + outFile.getAbsolutePath());
            System.exit(0);
        }

        FileReader fileReader = new FileReader(parentFile);
        TreeImporter importer = new NexusImporter(fileReader);
        ArrayList<Tree> treeList = new ArrayList<Tree>();
        ArrayList<String> treeNames = new ArrayList<String>();
        try {
            while (importer.hasTree()) {
                Tree tree = importer.importNextTree();
                analyze(tree, normaliseMeanRateTo);
                treeList.add(tree);
                treeNames.add(tree.getId());
            }

            NexusExporter exporter = new NexusExporter(System.out);
            exporter.setSortedTranslationTable(true);
            exporter.exportTrees(treeList.toArray(new Tree[treeList.size()]),
                true, treeNames.toArray(new String[treeNames.size()]));

        } catch (Importer.ImportException e) {
            System.err.println("Error Parsing Input Tree: " + e.getMessage());
            return;
        }
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:45,代码来源:NormaliseMeanTreeRate.java

示例5: PreAnnotator

import dr.evolution.io.TreeImporter; //导入依赖的package包/类
/**
 * @throws IOException 
 * @throws ImportException 
 * 
 */
public PreAnnotator(final String hostTreesFile, final String symbiontTreesFile, final String hostTreesOutputFile, final String symbiontTreesOutputFile) throws IOException, ImportException {
	
	final FileReader hostFileReader = new FileReader(hostTreesFile);
	final FileReader symbiontFileReader = new FileReader(symbiontTreesFile);
	
	final TreeImporter hostTreeImporter = new NexusImporter(hostFileReader);
	final TreeImporter symbiontTreeImporter = new NexusImporter(symbiontFileReader);
	
	final PrintStream hostTreesStream = new PrintStream(new FileOutputStream(hostTreesOutputFile));
	final PrintStream symbiontTreesStream = new PrintStream(new FileOutputStream(symbiontTreesOutputFile));
	
	final NexusExporter hostNexusExporter = new NexusExporter(hostTreesStream);
	final NexusExporter symbiontNexusExporter = new NexusExporter(symbiontTreesStream);
	
	Map<String,Integer> hostNexusHeader = null;
	Map<String,Integer> symbiontNexusHeader = null;
	
	int totalTrees = 10000;
       final int stepSize = totalTrees / 60;
       
       PrintStream progressStream = System.out;
       progressStream.println("Reading trees (bar assumes 10,000 trees)...");
       progressStream.println("0              25             50             75            100");
       progressStream.println("|--------------|--------------|--------------|--------------|");
	totalTrees = 0;
	while (hostTreeImporter.hasTree() && symbiontTreeImporter.hasTree()) {
		MutableTree hostTree = (MutableTree) hostTreeImporter.importNextTree();
		MutableTree symbiontTree = (MutableTree) symbiontTreeImporter.importNextTree();
		if (hostTaxonList == null) hostTaxonList = hostTree;
		ids = new int[hostTree.getNodeCount()];
		addNewClades(hostTree, hostTree.getRoot());
		
		for (int i = 0; i < symbiontTree.getNodeCount(); ++i) {
			NodeRef n = symbiontTree.getNode(i);
			symbiontTree.setNodeAttribute(n, HOST_NODE_REF, ids[(Integer) symbiontTree.getNodeAttribute(n, HOST_NODE_REF)]);
		}
		if (hostNexusHeader == null) {
			hostNexusHeader = hostNexusExporter.writeNexusHeader(hostTree);
			hostTreesStream.println("\t\t;");
			symbiontNexusHeader = symbiontNexusExporter.writeNexusHeader(symbiontTree);
			symbiontTreesStream.println("\t\t;");
		}
		hostNexusExporter.writeNexusTree(hostTree, hostTree.getId(), true, hostNexusHeader);
		symbiontNexusExporter.writeNexusTree(symbiontTree, symbiontTree.getId(), true, symbiontNexusHeader);
		if (totalTrees++ % stepSize == 0) {
               progressStream.print("*");
               progressStream.flush();
           }
	}
	progressStream.println();
	progressStream.println("Read " + totalTrees + " trees.");
	hostTreesStream.println("End;");
	symbiontTreesStream.println("End;");
	progressStream.println("Done.");
	
	hostFileReader.close();
	symbiontFileReader.close();
	hostTreesStream.close();
	symbiontTreesStream.close();
	
}
 
开发者ID:armanbilge,项目名称:BECKY,代码行数:67,代码来源:PreAnnotator.java

示例6: summarizeTrees

import dr.evolution.io.TreeImporter; //导入依赖的package包/类
private Tree summarizeTrees(int burnin, CladeSystem cladeSystem, String inputFileName,
                                boolean useSumCladeCredibility) throws IOException {

        Tree bestTree = null;
        double bestScore = Double.NEGATIVE_INFINITY;

        progressStream.println("Analyzing " + totalTreesUsed + " trees...");
        progressStream.println("0              25             50             75            100");
        progressStream.println("|--------------|--------------|--------------|--------------|");

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

        int counter = 0;
        TreeImporter importer = new NexusImporter(new FileReader(inputFileName));
        try {
            while (importer.hasTree()) {
                Tree tree = importer.importNextTree();

                if (counter >= burnin) {
                    double score = scoreTree(tree, cladeSystem, useSumCladeCredibility);
//                    progressStream.println(score);
                    if (score > bestScore) {
                        bestTree = tree;
                        bestScore = score;
                    }
                }
                if (counter > 0 && counter % stepSize == 0) {
                    progressStream.print("*");
                    progressStream.flush();
                }
                counter++;
            }
        } catch (Importer.ImportException e) {
            System.err.println("Error Parsing Input Tree: " + e.getMessage());
            return null;
        }
        progressStream.println();
        progressStream.println();
        if (useSumCladeCredibility) {
            progressStream.println("Highest Sum Clade Credibility: " + bestScore);
        } else {
            progressStream.println("Highest Log Clade Credibility: " + bestScore);
        }

        return bestTree;
    }
 
开发者ID:whdc,项目名称:ieo-beast,代码行数:48,代码来源:TreeAnnotator.java


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