| 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 |
package dr.evomodelxml.treelikelihood; |
| 27 |
|
| 28 |
import java.util.ArrayList; |
| 29 |
import java.util.List; |
| 30 |
import java.util.Map; |
| 31 |
import java.util.Set; |
| 32 |
|
| 33 |
import dr.evomodel.branchmodel.BranchModel; |
| 34 |
import dr.evomodel.siteratemodel.GammaSiteRateModel; |
| 35 |
import dr.evomodel.treelikelihood.BeagleTreeLikelihood; |
| 36 |
import dr.evomodel.treelikelihood.PartialsRescalingScheme; |
| 37 |
import dr.evolution.alignment.PatternList; |
| 38 |
import dr.evolution.alignment.Patterns; |
| 39 |
import dr.evolution.alignment.SitePatterns; |
| 40 |
import dr.evomodel.branchratemodel.BranchRateModel; |
| 41 |
import dr.evomodel.tree.TreeModel; |
| 42 |
import dr.evomodel.tipstatesmodel.TipStatesModel; |
| 43 |
import dr.inference.model.*; |
| 44 |
import dr.xml.AbstractXMLObjectParser; |
| 45 |
import dr.xml.AttributeRule; |
| 46 |
import dr.xml.ElementRule; |
| 47 |
import dr.xml.XMLObject; |
| 48 |
import dr.xml.XMLParseException; |
| 49 |
import dr.xml.XMLSyntaxRule; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
public class OptimizedBeagleTreeLikelihoodParser extends AbstractXMLObjectParser { |
| 55 |
|
| 56 |
public static final String OPTIMIZED_BEAGLE_TREE_LIKELIHOOD = "optimizedBeagleTreeLikelihood"; |
| 57 |
|
| 58 |
public static final String CALIBRATE = "calibrate"; |
| 59 |
public static final String RETRY = "retry"; |
| 60 |
|
| 61 |
public static final boolean DEBUG = false; |
| 62 |
|
| 63 |
public String getParserName() { |
| 64 |
return OPTIMIZED_BEAGLE_TREE_LIKELIHOOD; |
| 65 |
} |
| 66 |
|
| 67 |
protected BeagleTreeLikelihood createTreeLikelihood(PatternList patternList, TreeModel treeModel, |
| 68 |
BranchModel branchModel, |
| 69 |
GammaSiteRateModel siteRateModel, |
| 70 |
BranchRateModel branchRateModel, |
| 71 |
TipStatesModel tipStatesModel, |
| 72 |
boolean useAmbiguities, PartialsRescalingScheme scalingScheme, |
| 73 |
boolean delayRescalingUntilUnderflow, |
| 74 |
Map<Set<String>, Parameter> partialsRestrictions, |
| 75 |
XMLObject xo) throws XMLParseException { |
| 76 |
return new BeagleTreeLikelihood( |
| 77 |
patternList, |
| 78 |
treeModel, |
| 79 |
branchModel, |
| 80 |
siteRateModel, |
| 81 |
branchRateModel, |
| 82 |
tipStatesModel, |
| 83 |
useAmbiguities, |
| 84 |
scalingScheme, |
| 85 |
delayRescalingUntilUnderflow, |
| 86 |
partialsRestrictions |
| 87 |
); |
| 88 |
} |
| 89 |
|
| 90 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 91 |
|
| 92 |
|
| 93 |
int calibrate = 100; |
| 94 |
if (xo.hasAttribute(CALIBRATE)) { |
| 95 |
calibrate = xo.getIntegerAttribute(CALIBRATE); |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
int retry = 0; |
| 100 |
if (xo.hasAttribute(RETRY)) { |
| 101 |
retry = xo.getIntegerAttribute(RETRY); |
| 102 |
} |
| 103 |
|
| 104 |
int childCount = xo.getChildCount(); |
| 105 |
List<Likelihood> likelihoods = new ArrayList<Likelihood>(); |
| 106 |
|
| 107 |
|
| 108 |
List<Likelihood> originalLikelihoods = new ArrayList<Likelihood>(); |
| 109 |
|
| 110 |
for (int i = 0; i < childCount; i++) { |
| 111 |
likelihoods.add((Likelihood)xo.getChild(i)); |
| 112 |
originalLikelihoods.add((Likelihood)xo.getChild(i)); |
| 113 |
} |
| 114 |
|
| 115 |
if (DEBUG) { |
| 116 |
System.err.println("-----"); |
| 117 |
System.err.println(childCount + " BeagleTreeLikelihoods added."); |
| 118 |
} |
| 119 |
|
| 120 |
int[] instanceCounts = new int[childCount]; |
| 121 |
for (int i = 0; i < childCount; i++) { |
| 122 |
instanceCounts[i] = 1; |
| 123 |
} |
| 124 |
int[] currentLocation = new int[childCount]; |
| 125 |
for (int i = 0; i < childCount; i++) { |
| 126 |
currentLocation[i] = i; |
| 127 |
} |
| 128 |
|
| 129 |
int[] siteCounts = new int[childCount]; |
| 130 |
|
| 131 |
SitePatterns[] patterns = new SitePatterns[childCount]; |
| 132 |
TreeModel[] treeModels = new TreeModel[childCount]; |
| 133 |
BranchModel[] branchModels = new BranchModel[childCount]; |
| 134 |
GammaSiteRateModel[] siteRateModels = new GammaSiteRateModel[childCount]; |
| 135 |
BranchRateModel[] branchRateModels = new BranchRateModel[childCount]; |
| 136 |
boolean[] ambiguities = new boolean[childCount]; |
| 137 |
PartialsRescalingScheme[] rescalingSchemes = new PartialsRescalingScheme[childCount]; |
| 138 |
boolean[] isDelayRescalingUntilUnderflow = new boolean[childCount]; |
| 139 |
List<Map<Set<String>, Parameter>> partialsRestrictions = new ArrayList<Map<Set<String>, Parameter>>(); |
| 140 |
for (int i = 0; i < likelihoods.size(); i++) { |
| 141 |
patterns[i] = (SitePatterns) ((BeagleTreeLikelihood) likelihoods.get(i)).getPatternsList(); |
| 142 |
siteCounts[i] = patterns[i].getPatternCount(); |
| 143 |
treeModels[i] = ((BeagleTreeLikelihood) likelihoods.get(i)).getTreeModel(); |
| 144 |
branchModels[i] = ((BeagleTreeLikelihood) likelihoods.get(i)).getBranchModel(); |
| 145 |
siteRateModels[i] = (GammaSiteRateModel) ((BeagleTreeLikelihood) likelihoods.get(i)).getSiteRateModel(); |
| 146 |
branchRateModels[i] = ((BeagleTreeLikelihood) likelihoods.get(i)).getBranchRateModel(); |
| 147 |
ambiguities[i] = ((BeagleTreeLikelihood) likelihoods.get(i)).useAmbiguities(); |
| 148 |
rescalingSchemes[i] = ((BeagleTreeLikelihood) likelihoods.get(i)).getRescalingScheme(); |
| 149 |
isDelayRescalingUntilUnderflow[i] = ((BeagleTreeLikelihood) likelihoods.get(i)).isDelayRescalingUntilUnderflow(); |
| 150 |
partialsRestrictions.add(i, ((BeagleTreeLikelihood) likelihoods.get(i)).getPartialsRestrictions()); |
| 151 |
} |
| 152 |
|
| 153 |
if (DEBUG) { |
| 154 |
System.err.println("Pattern counts: "); |
| 155 |
for (int i = 0;i < siteCounts.length; i++) { |
| 156 |
System.err.println(siteCounts[i] + " vs. " + patterns[i].getPatternCount()); |
| 157 |
} |
| 158 |
System.err.println(); |
| 159 |
System.err.println("Instance counts: "); |
| 160 |
for (int i = 0;i < instanceCounts.length; i++) { |
| 161 |
System.err.print(instanceCounts[i] + " "); |
| 162 |
} |
| 163 |
System.err.println(); |
| 164 |
System.err.println("Current locations: "); |
| 165 |
for (int i = 0;i < currentLocation.length; i++) { |
| 166 |
System.err.print(currentLocation[i] + " "); |
| 167 |
} |
| 168 |
System.err.println(); |
| 169 |
} |
| 170 |
|
| 171 |
TestThreadedCompoundLikelihood compound = new TestThreadedCompoundLikelihood(likelihoods); |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
if (DEBUG) { |
| 176 |
System.err.println("Timing estimates for each of the " + calibrate + " likelihood calculations:"); |
| 177 |
} |
| 178 |
double start = System.nanoTime(); |
| 179 |
for (int i = 0; i < calibrate; i++) { |
| 180 |
if (DEBUG) { |
| 181 |
|
| 182 |
compound.makeDirty(); |
| 183 |
compound.getLogLikelihood(); |
| 184 |
|
| 185 |
|
| 186 |
} else { |
| 187 |
compound.makeDirty(); |
| 188 |
compound.getLogLikelihood(); |
| 189 |
} |
| 190 |
} |
| 191 |
double end = System.nanoTime(); |
| 192 |
double baseResult = end - start; |
| 193 |
|
| 194 |
if (DEBUG) { |
| 195 |
System.err.println("Starting evaluation took: " + baseResult); |
| 196 |
} |
| 197 |
|
| 198 |
int longestIndex = 0; |
| 199 |
int longestSize = siteCounts[0]; |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
boolean notFinished = true; |
| 351 |
|
| 352 |
|
| 353 |
List<Integer> splitList = new ArrayList<Integer>(); |
| 354 |
for (int i = 0; i < siteCounts.length; i++) { |
| 355 |
int top = 0; |
| 356 |
for (int j = 0; j < siteCounts.length; j++) { |
| 357 |
if (siteCounts[j] > siteCounts[top]) { |
| 358 |
top = j; |
| 359 |
} |
| 360 |
} |
| 361 |
siteCounts[top] = 0; |
| 362 |
splitList.add(top); |
| 363 |
} |
| 364 |
for (int i = 0; i < likelihoods.size(); i++) { |
| 365 |
siteCounts[i] = patterns[i].getPatternCount(); |
| 366 |
if (DEBUG) { |
| 367 |
System.err.println("Site count " + i + " = " + siteCounts[i]); |
| 368 |
} |
| 369 |
} |
| 370 |
|
| 371 |
if (DEBUG) { |
| 372 |
|
| 373 |
System.err.print("Ordered list of likelihoods to be evaluated: "); |
| 374 |
for (int i = 0; i < splitList.size(); i++) { |
| 375 |
System.err.print(splitList.get(i) + " "); |
| 376 |
} |
| 377 |
System.err.println(); |
| 378 |
} |
| 379 |
|
| 380 |
int timesRetried = 0; |
| 381 |
|
| 382 |
while (notFinished) { |
| 383 |
|
| 384 |
|
| 385 |
longestIndex = splitList.get(0); |
| 386 |
int instanceCount = ++instanceCounts[longestIndex]; |
| 387 |
|
| 388 |
List<Likelihood> newList = new ArrayList<Likelihood>(); |
| 389 |
for (int i = 0; i < instanceCount; i++) { |
| 390 |
Patterns subPatterns = new Patterns(patterns[longestIndex], 0, 0, 1, i, instanceCount); |
| 391 |
|
| 392 |
BeagleTreeLikelihood treeLikelihood = createTreeLikelihood( |
| 393 |
subPatterns, treeModels[longestIndex], branchModels[longestIndex], siteRateModels[longestIndex], branchRateModels[longestIndex], |
| 394 |
null, |
| 395 |
ambiguities[longestIndex], rescalingSchemes[longestIndex], isDelayRescalingUntilUnderflow[longestIndex], |
| 396 |
partialsRestrictions.get(longestIndex), |
| 397 |
xo); |
| 398 |
|
| 399 |
treeLikelihood.setId(xo.getId() + "_" + longestIndex + "_" + i); |
| 400 |
System.err.println(treeLikelihood.getId() + " created."); |
| 401 |
newList.add(treeLikelihood); |
| 402 |
} |
| 403 |
for (int i = 0; i < newList.size()-1; i++) { |
| 404 |
likelihoods.remove(currentLocation[longestIndex]); |
| 405 |
} |
| 406 |
|
| 407 |
|
| 408 |
for (int i = 0; i < newList.size(); i++) { |
| 409 |
likelihoods.add(currentLocation[longestIndex], newList.get(i)); |
| 410 |
} |
| 411 |
for (int i = longestIndex+1; i < currentLocation.length; i++) { |
| 412 |
currentLocation[i]++; |
| 413 |
} |
| 414 |
compound = new TestThreadedCompoundLikelihood(likelihoods); |
| 415 |
|
| 416 |
|
| 417 |
siteCounts[longestIndex] = (instanceCount-1)*siteCounts[longestIndex]/instanceCount; |
| 418 |
longestSize = (instanceCount-1)*longestSize/instanceCount; |
| 419 |
|
| 420 |
if (DEBUG) { |
| 421 |
|
| 422 |
System.err.println("Number of BeagleTreeLikelihoods: " + compound.getLikelihoodCount()); |
| 423 |
System.err.println("Pattern counts: "); |
| 424 |
for (int i = 0;i < siteCounts.length; i++) { |
| 425 |
System.err.print(siteCounts[i] + " "); |
| 426 |
} |
| 427 |
System.err.println(); |
| 428 |
System.err.println("Instance counts: "); |
| 429 |
for (int i = 0;i < instanceCounts.length; i++) { |
| 430 |
System.err.print(instanceCounts[i] + " "); |
| 431 |
} |
| 432 |
System.err.println(); |
| 433 |
System.err.println("Current locations: "); |
| 434 |
for (int i = 0;i < currentLocation.length; i++) { |
| 435 |
System.err.print(currentLocation[i] + " "); |
| 436 |
} |
| 437 |
System.err.println(); |
| 438 |
} |
| 439 |
|
| 440 |
|
| 441 |
if (DEBUG) { |
| 442 |
System.err.println("Timing estimates for each of the " + calibrate + " likelihood calculations:"); |
| 443 |
} |
| 444 |
start = System.nanoTime(); |
| 445 |
for (int i = 0; i < calibrate; i++) { |
| 446 |
if (DEBUG) { |
| 447 |
|
| 448 |
compound.makeDirty(); |
| 449 |
compound.getLogLikelihood(); |
| 450 |
|
| 451 |
|
| 452 |
} else { |
| 453 |
compound.makeDirty(); |
| 454 |
compound.getLogLikelihood(); |
| 455 |
} |
| 456 |
} |
| 457 |
end = System.nanoTime(); |
| 458 |
double newResult = end - start; |
| 459 |
|
| 460 |
if (DEBUG) { |
| 461 |
System.err.println("New evaluation took: " + newResult + " vs. old evaluation: " + baseResult); |
| 462 |
} |
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
if (newResult < baseResult) { |
| 477 |
|
| 478 |
baseResult = newResult; |
| 479 |
|
| 480 |
if (DEBUG) { |
| 481 |
System.err.print("Current split list: "); |
| 482 |
for (int i = 0; i < splitList.size(); i++) { |
| 483 |
System.err.print(splitList.get(i) + " "); |
| 484 |
} |
| 485 |
System.err.println(); |
| 486 |
System.err.print("Current pattern counts: "); |
| 487 |
for (int i = 0; i < splitList.size(); i++) { |
| 488 |
System.err.print(siteCounts[splitList.get(i)] + " "); |
| 489 |
} |
| 490 |
System.err.println(); |
| 491 |
} |
| 492 |
int currentPatternCount = siteCounts[longestIndex]; |
| 493 |
int findIndex = 0; |
| 494 |
for (int i = 0; i < splitList.size(); i++) { |
| 495 |
if (siteCounts[splitList.get(i)] > currentPatternCount) { |
| 496 |
findIndex = i; |
| 497 |
} |
| 498 |
} |
| 499 |
if (DEBUG) { |
| 500 |
System.err.println("Current pattern count: " + currentPatternCount); |
| 501 |
System.err.println("Index found: " + findIndex + " with pattern count: " + siteCounts[findIndex]); |
| 502 |
System.err.println("Moving 0 to " + findIndex); |
| 503 |
} |
| 504 |
for (int i = 0; i < findIndex; i++) { |
| 505 |
int temp = splitList.get(i); |
| 506 |
splitList.set(i, splitList.get(i+1)); |
| 507 |
splitList.set(i+1, temp); |
| 508 |
} |
| 509 |
if (DEBUG) { |
| 510 |
System.err.print("New split list: "); |
| 511 |
for (int i = 0; i < splitList.size(); i++) { |
| 512 |
System.err.print(splitList.get(i) + " "); |
| 513 |
} |
| 514 |
System.err.println(); |
| 515 |
System.err.print("New pattern counts: "); |
| 516 |
for (int i = 0; i < splitList.size(); i++) { |
| 517 |
System.err.print(siteCounts[splitList.get(i)] + " "); |
| 518 |
} |
| 519 |
System.err.println(); |
| 520 |
} |
| 521 |
timesRetried = 0; |
| 522 |
} else { |
| 523 |
if (DEBUG) { |
| 524 |
System.err.println("timesRetried = " + timesRetried + " vs. retry = " + retry); |
| 525 |
} |
| 526 |
|
| 527 |
if (timesRetried < retry) { |
| 528 |
|
| 529 |
|
| 530 |
timesRetried++; |
| 531 |
if (DEBUG) { |
| 532 |
System.err.println("RETRY number " + timesRetried); |
| 533 |
} |
| 534 |
} else { |
| 535 |
|
| 536 |
splitList.remove(0); |
| 537 |
if (splitList.size() == 0) { |
| 538 |
notFinished = false; |
| 539 |
} |
| 540 |
|
| 541 |
|
| 542 |
if (DEBUG) { |
| 543 |
System.err.print("Removing " + (timesRetried+1) + " instance count(s): " + instanceCount); |
| 544 |
} |
| 545 |
|
| 546 |
instanceCounts[longestIndex] = instanceCounts[longestIndex] - (timesRetried+1); |
| 547 |
instanceCount = instanceCounts[longestIndex]; |
| 548 |
if (DEBUG) { |
| 549 |
System.err.println(" -> " + instanceCount + " for likelihood " + longestIndex); |
| 550 |
} |
| 551 |
newList = new ArrayList<Likelihood>(); |
| 552 |
for (int i = 0; i < instanceCount; i++) { |
| 553 |
Patterns subPatterns = new Patterns(patterns[longestIndex], 0, 0, 1, i, instanceCount); |
| 554 |
|
| 555 |
BeagleTreeLikelihood treeLikelihood = createTreeLikelihood( |
| 556 |
subPatterns, treeModels[longestIndex], branchModels[longestIndex], siteRateModels[longestIndex], branchRateModels[longestIndex], |
| 557 |
null, |
| 558 |
ambiguities[longestIndex], rescalingSchemes[longestIndex], isDelayRescalingUntilUnderflow[longestIndex], |
| 559 |
partialsRestrictions.get(longestIndex), |
| 560 |
xo); |
| 561 |
|
| 562 |
treeLikelihood.setId(xo.getId() + "_" + longestIndex + "_" + i); |
| 563 |
System.err.println(treeLikelihood.getId() + " created."); |
| 564 |
newList.add(treeLikelihood); |
| 565 |
} |
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
for (int i = 0; i < newList.size()+timesRetried+1; i++) { |
| 570 |
|
| 571 |
unregisterAllModels((BeagleTreeLikelihood)likelihoods.get(currentLocation[longestIndex])); |
| 572 |
|
| 573 |
likelihoods.remove(currentLocation[longestIndex]); |
| 574 |
} |
| 575 |
for (int i = 0; i < newList.size(); i++) { |
| 576 |
likelihoods.add(currentLocation[longestIndex], newList.get(i)); |
| 577 |
} |
| 578 |
for (int i = longestIndex+1; i < currentLocation.length; i++) { |
| 579 |
currentLocation[i] -= (timesRetried+1); |
| 580 |
} |
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
compound = new TestThreadedCompoundLikelihood(likelihoods); |
| 585 |
|
| 586 |
|
| 587 |
siteCounts[longestIndex] = (instanceCount+timesRetried+1)*siteCounts[longestIndex]/instanceCount; |
| 588 |
longestSize = (instanceCount+timesRetried+1)*longestSize/instanceCount; |
| 589 |
|
| 590 |
if (DEBUG) { |
| 591 |
System.err.println("Pattern counts: "); |
| 592 |
for (int i = 0;i < siteCounts.length; i++) { |
| 593 |
System.err.print(siteCounts[i] + " "); |
| 594 |
} |
| 595 |
System.err.println(); |
| 596 |
System.err.println("Instance counts: "); |
| 597 |
for (int i = 0;i < instanceCounts.length; i++) { |
| 598 |
System.err.print(instanceCounts[i] + " "); |
| 599 |
} |
| 600 |
System.err.println(); |
| 601 |
System.err.println("Current locations: "); |
| 602 |
for (int i = 0;i < currentLocation.length; i++) { |
| 603 |
System.err.print(currentLocation[i] + " "); |
| 604 |
} |
| 605 |
System.err.println(); |
| 606 |
} |
| 607 |
|
| 608 |
timesRetried = 0; |
| 609 |
|
| 610 |
} |
| 611 |
|
| 612 |
} |
| 613 |
|
| 614 |
} |
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
for (int i = 0; i < originalLikelihoods.size(); i++) { |
| 828 |
unregisterAllModels((BeagleTreeLikelihood)originalLikelihoods.get(i)); |
| 829 |
} |
| 830 |
|
| 831 |
return compound; |
| 832 |
|
| 833 |
} |
| 834 |
|
| 835 |
private void unregisterAllModels(BeagleTreeLikelihood btl) { |
| 836 |
btl.removeModel(btl.getTreeModel()); |
| 837 |
btl.removeModel(btl.getBranchRateModel()); |
| 838 |
btl.removeModel(btl.getBranchModel()); |
| 839 |
btl.removeModel(btl.getSiteRateModel()); |
| 840 |
if (btl.getTipStatesModel() != null) { |
| 841 |
btl.removeModel(btl.getTipStatesModel()); |
| 842 |
} |
| 843 |
} |
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
public String getParserDescription() { |
| 850 |
return "Parses a collection of BeagleTreeLikelihoods and determines the number of partitions."; |
| 851 |
} |
| 852 |
|
| 853 |
public Class getReturnType() { |
| 854 |
return Likelihood.class; |
| 855 |
} |
| 856 |
|
| 857 |
public static final XMLSyntaxRule[] rules = { |
| 858 |
new ElementRule(BeagleTreeLikelihood.class, 1, Integer.MAX_VALUE), |
| 859 |
AttributeRule.newIntegerRule(CALIBRATE, true), |
| 860 |
AttributeRule.newIntegerRule(RETRY, true) |
| 861 |
}; |
| 862 |
|
| 863 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 864 |
return rules; |
| 865 |
} |
| 866 |
} |