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