| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
package dr.evomodel.tree; |
| 30 |
|
| 31 |
import dr.evolution.io.Importer; |
| 32 |
import dr.evolution.io.NewickImporter; |
| 33 |
import dr.evolution.io.NexusImporter; |
| 34 |
import dr.evolution.io.TreeTrace; |
| 35 |
import dr.evolution.tree.Clade; |
| 36 |
import dr.evolution.tree.NodeRef; |
| 37 |
import dr.evolution.tree.SimpleTree; |
| 38 |
import dr.evolution.tree.Tree; |
| 39 |
import dr.inference.model.Likelihood; |
| 40 |
import dr.math.MathUtils; |
| 41 |
|
| 42 |
import java.io.BufferedReader; |
| 43 |
import java.io.IOException; |
| 44 |
import java.io.Reader; |
| 45 |
import java.util.*; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
public class ConditionalCladeFrequency extends |
| 54 |
AbstractCladeImportanceDistribution { |
| 55 |
|
| 56 |
private double EPSILON; |
| 57 |
|
| 58 |
private long samples = 0; |
| 59 |
|
| 60 |
private HashMap<BitSet, Clade> cladeProbabilities; |
| 61 |
|
| 62 |
private HashMap<BitSet, HashMap<BitSet, Clade>> cladeCoProbabilities; |
| 63 |
|
| 64 |
private TreeTrace[] traces; |
| 65 |
|
| 66 |
private int burnin; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
public ConditionalCladeFrequency(Tree tree, double epsilon) { |
| 73 |
|
| 74 |
|
| 75 |
cladeProbabilities = new HashMap<BitSet, Clade>(); |
| 76 |
cladeCoProbabilities = new HashMap<BitSet, HashMap<BitSet, Clade>>(); |
| 77 |
|
| 78 |
|
| 79 |
EPSILON = epsilon; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
public ConditionalCladeFrequency(TreeTrace[] traces, double epsilon, |
| 90 |
int burnIn, boolean verbose) { |
| 91 |
|
| 92 |
|
| 93 |
cladeProbabilities = new HashMap<BitSet, Clade>(); |
| 94 |
cladeCoProbabilities = new HashMap<BitSet, HashMap<BitSet, Clade>>(); |
| 95 |
|
| 96 |
|
| 97 |
EPSILON = epsilon; |
| 98 |
this.traces = traces; |
| 99 |
|
| 100 |
|
| 101 |
int minMaxState = Integer.MAX_VALUE; |
| 102 |
for (TreeTrace trace : traces) { |
| 103 |
if (trace.getMaximumState() < minMaxState) { |
| 104 |
minMaxState = trace.getMaximumState(); |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
if (burnIn < 0 || burnIn >= minMaxState) { |
| 109 |
this.burnin = minMaxState / (10 * traces[0].getStepSize()); |
| 110 |
if (verbose) |
| 111 |
System.out |
| 112 |
.println("WARNING: Burn-in larger than total number of states - using 10% of smallest trace"); |
| 113 |
} else { |
| 114 |
this.burnin = burnIn; |
| 115 |
} |
| 116 |
|
| 117 |
|
| 118 |
analyzeTrace(verbose); |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
public void analyzeTrace(boolean verbose) { |
| 128 |
|
| 129 |
if (verbose) { |
| 130 |
if (traces.length > 1) |
| 131 |
System.out.println("Combining " + traces.length + " traces."); |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
Tree tree = getTree(0); |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
for (TreeTrace trace : traces) { |
| 140 |
|
| 141 |
int treeCount = trace.getTreeCount(burnin * trace.getStepSize()); |
| 142 |
double stepSize = treeCount / 60.0; |
| 143 |
int counter = 1; |
| 144 |
|
| 145 |
if (verbose) { |
| 146 |
System.out.println("Analyzing " + treeCount + " trees..."); |
| 147 |
System.out |
| 148 |
.println("0 25 50 75 100"); |
| 149 |
System.out |
| 150 |
.println("|--------------|--------------|--------------|--------------|"); |
| 151 |
System.out.print("*"); |
| 152 |
} |
| 153 |
for (int i = 1; i < treeCount; i++) { |
| 154 |
|
| 155 |
tree = trace.getTree(i, burnin * trace.getStepSize()); |
| 156 |
|
| 157 |
|
| 158 |
addTree(tree); |
| 159 |
|
| 160 |
|
| 161 |
if (i >= (int) Math.round(counter * stepSize) && counter <= 60) { |
| 162 |
if (verbose) { |
| 163 |
System.out.print("*"); |
| 164 |
System.out.flush(); |
| 165 |
} |
| 166 |
counter += 1; |
| 167 |
} |
| 168 |
} |
| 169 |
if (verbose) { |
| 170 |
System.out.println("*"); |
| 171 |
} |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
public void report(Reader r) throws IOException, Importer.ImportException { |
| 181 |
|
| 182 |
System.err.println("making report"); |
| 183 |
|
| 184 |
ArrayList<Tree> referenceTrees = new ArrayList<Tree>(); |
| 185 |
|
| 186 |
BufferedReader reader = new BufferedReader(r); |
| 187 |
String line = reader.readLine(); |
| 188 |
|
| 189 |
if (line.toUpperCase().startsWith("#NEXUS")) { |
| 190 |
NexusImporter importer = new NexusImporter(reader); |
| 191 |
Tree[] trees = importer.importTrees(null); |
| 192 |
|
| 193 |
for (Tree tree : trees) { |
| 194 |
referenceTrees.add(tree); |
| 195 |
|
| 196 |
SimpleTree sTree = new SimpleTree(tree); |
| 197 |
System.out.println("Estimated marginal posterior by condiational clade frequencies:"); |
| 198 |
System.out.println(getTreeProbability(sTree) + "\t\t" + sTree); |
| 199 |
} |
| 200 |
} else { |
| 201 |
throw new RuntimeException("Could not read reference tree. Only Nexus format is supported."); |
| 202 |
} |
| 203 |
|
| 204 |
System.out.flush(); |
| 205 |
} |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
public double getTreeProbability(Tree tree) { |
| 214 |
|
| 215 |
double prob = 0.0; |
| 216 |
|
| 217 |
List<Clade> clades = new ArrayList<Clade>(); |
| 218 |
List<Clade> parentClades = new ArrayList<Clade>(); |
| 219 |
|
| 220 |
getNonComplementaryClades(tree, tree.getRoot(), parentClades, clades); |
| 221 |
|
| 222 |
int size = clades.size(); |
| 223 |
|
| 224 |
for (int i = 0; i < size; i++) { |
| 225 |
Clade c = clades.get(i); |
| 226 |
|
| 227 |
|
| 228 |
Clade parent = parentClades.get(i); |
| 229 |
|
| 230 |
|
| 231 |
double tmp = EPSILON; |
| 232 |
double parentOccurrences = 0.0; |
| 233 |
BitSet parentBits = parent.getBits(); |
| 234 |
if (cladeProbabilities.containsKey(parentBits)) { |
| 235 |
|
| 236 |
parentOccurrences += cladeProbabilities.get(parentBits) |
| 237 |
.getSampleCount(); |
| 238 |
} |
| 239 |
|
| 240 |
if (cladeCoProbabilities.containsKey(parentBits)) { |
| 241 |
|
| 242 |
HashMap<BitSet, Clade> conditionalProbs = cladeCoProbabilities |
| 243 |
.get(parentBits); |
| 244 |
|
| 245 |
BitSet bits = c.getBits(); |
| 246 |
if (conditionalProbs.containsKey(bits)) { |
| 247 |
|
| 248 |
tmp += conditionalProbs.get(bits).getSampleCount(); |
| 249 |
} |
| 250 |
} |
| 251 |
|
| 252 |
final double splits = Math.pow(2, parent.getSize() - 1) - 1; |
| 253 |
parentOccurrences += EPSILON * splits; |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
prob += Math.log(tmp / parentOccurrences); |
| 258 |
|
| 259 |
} |
| 260 |
|
| 261 |
return prob; |
| 262 |
} |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
public double getTreeProbability(Tree tree, |
| 271 |
HashMap<String, Integer> taxonMap) { |
| 272 |
double prob = 0.0; |
| 273 |
|
| 274 |
List<Clade> clades = new ArrayList<Clade>(); |
| 275 |
List<Clade> parentClades = new ArrayList<Clade>(); |
| 276 |
|
| 277 |
getNonComplementaryClades(tree, tree.getRoot(), parentClades, clades, |
| 278 |
taxonMap); |
| 279 |
|
| 280 |
int size = clades.size(); |
| 281 |
|
| 282 |
|
| 283 |
for (int i = 0; i < size; i++) { |
| 284 |
Clade c = clades.get(i); |
| 285 |
|
| 286 |
|
| 287 |
Clade parent = parentClades.get(i); |
| 288 |
|
| 289 |
|
| 290 |
double tmp = EPSILON; |
| 291 |
double parentOccurrences = 0.0; |
| 292 |
BitSet parentBits = parent.getBits(); |
| 293 |
if (cladeProbabilities.containsKey(parentBits)) { |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
parentOccurrences += cladeProbabilities.get(parentBits) |
| 298 |
.getSampleCount(); |
| 299 |
} |
| 300 |
|
| 301 |
if (cladeCoProbabilities.containsKey(parentBits)) { |
| 302 |
|
| 303 |
HashMap<BitSet, Clade> conditionalProbs = cladeCoProbabilities |
| 304 |
.get(parentBits); |
| 305 |
|
| 306 |
BitSet bits = c.getBits(); |
| 307 |
if (conditionalProbs.containsKey(bits)) { |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
tmp += conditionalProbs.get(bits).getSampleCount(); |
| 312 |
} |
| 313 |
} |
| 314 |
|
| 315 |
final double splits = Math.pow(2, parent.getSize() - 1) - 1; |
| 316 |
parentOccurrences += EPSILON * splits; |
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
prob += Math.log(tmp / parentOccurrences); |
| 321 |
|
| 322 |
} |
| 323 |
|
| 324 |
return prob; |
| 325 |
} |
| 326 |
|
| 327 |
public double splitClade(Clade parent, Clade[] children) { |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
final double splits = Math.pow(2, parent.getSize() - 1) - 1; |
| 335 |
|
| 336 |
double prob = 0; |
| 337 |
|
| 338 |
if (cladeCoProbabilities.containsKey(parent.getBits())) { |
| 339 |
HashMap<BitSet, Clade> childClades = cladeCoProbabilities |
| 340 |
.get(parent.getBits()); |
| 341 |
double noChildClades = 0.0; |
| 342 |
|
| 343 |
double sum = 0.0; |
| 344 |
Set<BitSet> keys = childClades.keySet(); |
| 345 |
for (BitSet child : keys) { |
| 346 |
Clade tmp = childClades.get(child); |
| 347 |
if (parent.getSize() > tmp.getSize() + 1) { |
| 348 |
sum += (tmp.getSampleCount() + EPSILON) / 2.0; |
| 349 |
noChildClades += 0.5; |
| 350 |
} else { |
| 351 |
sum += (tmp.getSampleCount() + EPSILON); |
| 352 |
noChildClades += 1.0; |
| 353 |
} |
| 354 |
} |
| 355 |
|
| 356 |
|
| 357 |
sum += EPSILON * (splits - noChildClades); |
| 358 |
|
| 359 |
|
| 360 |
double randomNumber = MathUtils.nextDouble() * sum; |
| 361 |
for (BitSet child : keys) { |
| 362 |
Clade tmp = childClades.get(child); |
| 363 |
if (parent.getSize() > tmp.getSize() + 1) { |
| 364 |
randomNumber -= (tmp.getSampleCount() + EPSILON) / 2.0; |
| 365 |
} else { |
| 366 |
randomNumber -= (tmp.getSampleCount() + EPSILON); |
| 367 |
} |
| 368 |
if (randomNumber < 0) { |
| 369 |
children[0] = tmp; |
| 370 |
prob = (tmp.getSampleCount() + EPSILON) / sum; |
| 371 |
break; |
| 372 |
} |
| 373 |
} |
| 374 |
|
| 375 |
if (randomNumber >= 0) { |
| 376 |
|
| 377 |
prob = EPSILON / sum; |
| 378 |
BitSet newChild; |
| 379 |
BitSet inverseBits; |
| 380 |
do { |
| 381 |
do { |
| 382 |
newChild = (BitSet) parent.getBits().clone(); |
| 383 |
int index = -1; |
| 384 |
do { |
| 385 |
index = newChild.nextSetBit(index + 1); |
| 386 |
if (index > -1 && MathUtils.nextBoolean()) { |
| 387 |
newChild.clear(index); |
| 388 |
} |
| 389 |
} while (index > -1); |
| 390 |
} while (newChild.cardinality() == 0 |
| 391 |
|| newChild.cardinality() == parent.getSize()); |
| 392 |
inverseBits = (BitSet) newChild.clone(); |
| 393 |
inverseBits.xor(parent.getBits()); |
| 394 |
} while (childClades.containsKey(newChild) |
| 395 |
|| childClades.containsKey(inverseBits)); |
| 396 |
|
| 397 |
Clade randomClade = new Clade(newChild, 0.9999 * parent |
| 398 |
.getHeight()); |
| 399 |
children[0] = randomClade; |
| 400 |
|
| 401 |
BitSet secondChild = (BitSet) children[0].getBits().clone(); |
| 402 |
secondChild.xor(parent.getBits()); |
| 403 |
children[1] = new Clade(secondChild, 0.9999 * parent |
| 404 |
.getHeight()); |
| 405 |
} else { |
| 406 |
BitSet secondChild = (BitSet) children[0].getBits().clone(); |
| 407 |
secondChild.xor(parent.getBits()); |
| 408 |
children[1] = childClades.get(secondChild); |
| 409 |
if (children[1] == null) { |
| 410 |
children[1] = new Clade(secondChild, 0.9999 * parent |
| 411 |
.getHeight()); |
| 412 |
} |
| 413 |
} |
| 414 |
|
| 415 |
} else { |
| 416 |
prob = 1.0 / splits; |
| 417 |
|
| 418 |
BitSet newChild; |
| 419 |
do { |
| 420 |
newChild = (BitSet) parent.getBits().clone(); |
| 421 |
int index = -1; |
| 422 |
do { |
| 423 |
index = newChild.nextSetBit(index + 1); |
| 424 |
if (index > -1 && MathUtils.nextBoolean()) { |
| 425 |
newChild.clear(index); |
| 426 |
} |
| 427 |
} while (index > -1); |
| 428 |
} while (newChild.cardinality() == 0 |
| 429 |
|| newChild.cardinality() == parent.getSize()); |
| 430 |
Clade randomClade = new Clade(newChild, 0.9999 * parent.getHeight()); |
| 431 |
|
| 432 |
randomClade.addHeight(0.9999 * parent.getHeight()); |
| 433 |
children[0] = randomClade; |
| 434 |
BitSet secondChild = (BitSet) children[0].getBits().clone(); |
| 435 |
secondChild.xor(parent.getBits()); |
| 436 |
children[1] = new Clade(secondChild, 0.9999 * parent.getHeight()); |
| 437 |
|
| 438 |
randomClade.addHeight(0.9999 * parent.getHeight()); |
| 439 |
} |
| 440 |
|
| 441 |
return Math.log(prob); |
| 442 |
|
| 443 |
} |
| 444 |
|
| 445 |
public double getChanceForNodeHeights(TreeModel tree, Likelihood likelihood) { |
| 446 |
double prob = 0.0; |
| 447 |
NodeRef node = tree.getRoot(); |
| 448 |
Clade currentClade = getClade(tree, node); |
| 449 |
|
| 450 |
int childcount = tree.getChildCount(node); |
| 451 |
for (int i = 0; i < childcount; i++) { |
| 452 |
NodeRef child = tree.getChild(node, i); |
| 453 |
if (!tree.isExternal(child)) { |
| 454 |
|
| 455 |
|
| 456 |
} |
| 457 |
} |
| 458 |
|
| 459 |
return prob; |
| 460 |
} |
| 461 |
|
| 462 |
public double setNodeHeights(TreeModel tree, Likelihood likelihood) { |
| 463 |
double prob = 0.0; |
| 464 |
NodeRef node = tree.getRoot(); |
| 465 |
Clade currentClade = getClade(tree, node); |
| 466 |
|
| 467 |
int childcount = tree.getChildCount(node); |
| 468 |
for (int i = 0; i < childcount; i++) { |
| 469 |
NodeRef child = tree.getChild(node, i); |
| 470 |
if (!tree.isExternal(child)) { |
| 471 |
|
| 472 |
|
| 473 |
} |
| 474 |
} |
| 475 |
|
| 476 |
return prob; |
| 477 |
} |
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
public final Tree getTree(int index) { |
| 486 |
|
| 487 |
int oldTreeCount = 0; |
| 488 |
int newTreeCount = 0; |
| 489 |
for (TreeTrace trace : traces) { |
| 490 |
newTreeCount += trace.getTreeCount(burnin * trace.getStepSize()); |
| 491 |
|
| 492 |
if (index < newTreeCount) { |
| 493 |
return trace.getTree(index - oldTreeCount, burnin |
| 494 |
* trace.getStepSize()); |
| 495 |
} |
| 496 |
oldTreeCount = newTreeCount; |
| 497 |
} |
| 498 |
throw new RuntimeException("Couldn't find tree " + index); |
| 499 |
} |
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
public void addTree(Tree tree) { |
| 507 |
|
| 508 |
samples++; |
| 509 |
|
| 510 |
List<Clade> clades = new ArrayList<Clade>(); |
| 511 |
List<Clade> parentClades = new ArrayList<Clade>(); |
| 512 |
|
| 513 |
getClades(tree, tree.getRoot(), parentClades, clades); |
| 514 |
|
| 515 |
clades.add(parentClades.get(parentClades.size() - 1)); |
| 516 |
parentClades.add(clades.get(clades.size() - 1)); |
| 517 |
|
| 518 |
int size = clades.size(); |
| 519 |
|
| 520 |
|
| 521 |
for (int i = 0; i < size; i++) { |
| 522 |
Clade c = clades.get(i); |
| 523 |
|
| 524 |
|
| 525 |
Clade parent = parentClades.get(i); |
| 526 |
|
| 527 |
HashMap<BitSet, Clade> coFreqs; |
| 528 |
|
| 529 |
if (cladeProbabilities.containsKey(c.getBits())) { |
| 530 |
Clade tmp = cladeProbabilities.get(c.getBits()); |
| 531 |
|
| 532 |
tmp.addHeight(c.getHeight()); |
| 533 |
|
| 534 |
|
| 535 |
} else { |
| 536 |
|
| 537 |
|
| 538 |
c.addHeight(c.getHeight()); |
| 539 |
cladeProbabilities.put(c.getBits(), c); |
| 540 |
} |
| 541 |
|
| 542 |
|
| 543 |
if (!parent.equals(c)) { |
| 544 |
if (cladeCoProbabilities.containsKey(parent.getBits())) { |
| 545 |
coFreqs = cladeCoProbabilities.get(parent.getBits()); |
| 546 |
} else { |
| 547 |
|
| 548 |
|
| 549 |
coFreqs = new HashMap<BitSet, Clade>(); |
| 550 |
cladeCoProbabilities.put(parent.getBits(), coFreqs); |
| 551 |
} |
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
if (coFreqs.containsKey(c.getBits())) { |
| 556 |
Clade tmp = coFreqs.get(c.getBits()); |
| 557 |
tmp.addHeight(c.getHeight()); |
| 558 |
|
| 559 |
} else { |
| 560 |
|
| 561 |
|
| 562 |
Clade tmp = new Clade((BitSet) c.getBits().clone(), c.getHeight()); |
| 563 |
tmp.addHeight(c.getHeight()); |
| 564 |
coFreqs.put(c.getBits(), tmp); |
| 565 |
} |
| 566 |
} |
| 567 |
} |
| 568 |
} |
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
public void addTree(Tree tree, HashMap<String, Integer> taxonMap) { |
| 576 |
|
| 577 |
samples++; |
| 578 |
|
| 579 |
List<Clade> clades = new ArrayList<Clade>(); |
| 580 |
List<Clade> parentClades = new ArrayList<Clade>(); |
| 581 |
|
| 582 |
getClades(tree, tree.getRoot(), parentClades, clades, taxonMap); |
| 583 |
|
| 584 |
clades.add(parentClades.get(parentClades.size() - 1)); |
| 585 |
parentClades.add(clades.get(clades.size() - 1)); |
| 586 |
|
| 587 |
int size = clades.size(); |
| 588 |
|
| 589 |
|
| 590 |
for (int i = 0; i < size; i++) { |
| 591 |
Clade c = clades.get(i); |
| 592 |
|
| 593 |
|
| 594 |
Clade parent = parentClades.get(i); |
| 595 |
|
| 596 |
HashMap<BitSet, Clade> coFreqs; |
| 597 |
|
| 598 |
if (cladeProbabilities.containsKey(c.getBits())) { |
| 599 |
Clade tmp = cladeProbabilities.get(c.getBits()); |
| 600 |
|
| 601 |
tmp.addHeight(c.getHeight()); |
| 602 |
|
| 603 |
|
| 604 |
} else { |
| 605 |
|
| 606 |
|
| 607 |
c.addHeight(c.getHeight()); |
| 608 |
cladeProbabilities.put(c.getBits(), c); |
| 609 |
} |
| 610 |
|
| 611 |
|
| 612 |
if (!parent.equals(c)) { |
| 613 |
if (cladeCoProbabilities.containsKey(parent.getBits())) { |
| 614 |
coFreqs = cladeCoProbabilities.get(parent.getBits()); |
| 615 |
} else { |
| 616 |
|
| 617 |
|
| 618 |
coFreqs = new HashMap<BitSet, Clade>(); |
| 619 |
cladeCoProbabilities.put(parent.getBits(), coFreqs); |
| 620 |
} |
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
if (coFreqs.containsKey(c.getBits())) { |
| 625 |
Clade tmp = coFreqs.get(c.getBits()); |
| 626 |
tmp.addHeight(c.getHeight()); |
| 627 |
|
| 628 |
} else { |
| 629 |
|
| 630 |
|
| 631 |
Clade tmp = new Clade((BitSet) c.getBits().clone(), c |
| 632 |
.getHeight()); |
| 633 |
tmp.addHeight(c.getHeight()); |
| 634 |
coFreqs.put(c.getBits(), tmp); |
| 635 |
} |
| 636 |
} |
| 637 |
} |
| 638 |
} |
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
public static ConditionalCladeFrequency analyzeLogFile(Reader[] reader, |
| 648 |
double e, int burnin, boolean verbose) throws IOException { |
| 649 |
|
| 650 |
TreeTrace[] trace = new TreeTrace[reader.length]; |
| 651 |
for (int i = 0; i < reader.length; i++) { |
| 652 |
try { |
| 653 |
trace[i] = TreeTrace.loadTreeTrace(reader[i]); |
| 654 |
} catch (Importer.ImportException ie) { |
| 655 |
throw new RuntimeException(ie.toString()); |
| 656 |
} |
| 657 |
reader[i].close(); |
| 658 |
|
| 659 |
} |
| 660 |
|
| 661 |
return new ConditionalCladeFrequency(trace, e, burnin, verbose); |
| 662 |
} |
| 663 |
} |