| 1 |
package test.dr.evomodel.treelikelihood; |
| 2 |
|
| 3 |
import dr.evolution.datatype.Nucleotides; |
| 4 |
import dr.evolution.alignment.SitePatterns; |
| 5 |
import dr.evolution.alignment.AscertainedSitePatterns; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
public class AscertainmentCorrectedLikelihoodTest extends SequenceLikelihoodTest { |
| 12 |
|
| 13 |
public AscertainmentCorrectedLikelihoodTest(String name) { |
| 14 |
super(name); |
| 15 |
} |
| 16 |
|
| 17 |
public void setUp() throws Exception { |
| 18 |
super.setUp(); |
| 19 |
|
| 20 |
format.setMaximumFractionDigits(5); |
| 21 |
|
| 22 |
int numTaxa = PRIMATES_TAXON_SEQUENCE[0].length; |
| 23 |
System.err.println("nTaxa = " + numTaxa); |
| 24 |
|
| 25 |
createAlignmentWithAllUniquePatterns(PRIMATES_TAXON_SEQUENCE, Nucleotides.INSTANCE); |
| 26 |
|
| 27 |
treeModel = createPrimateTreeModel(); |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
public void testAllPatterns() { |
| 32 |
SitePatterns patterns = new SitePatterns(alignment, null, 0, -1, 1, true); |
| 33 |
System.out.println("Using " + patterns.getPatternCount() + " patterns"); |
| 34 |
double total = computeSumOfPatterns(patterns); |
| 35 |
System.out.println("Total of all (uncorrected) probabilities = " + total); |
| 36 |
assertEquals("uncorrected", 1.0, total, tolerance); |
| 37 |
} |
| 38 |
|
| 39 |
public void testMissingPatterns() { |
| 40 |
SitePatterns patterns = new SitePatterns(alignment, null, 10, -1, 1, true); |
| 41 |
System.out.println("Using " + patterns.getPatternCount() + " patterns"); |
| 42 |
double total = computeSumOfPatterns(patterns); |
| 43 |
System.out.println("Total of 10 missing (uncorrected) probabilities = " + total); |
| 44 |
assertEquals("uncorrected", 0.78287044, total, tolerance); |
| 45 |
} |
| 46 |
|
| 47 |
public void testCorrectedPatterns() { |
| 48 |
AscertainedSitePatterns patterns = new AscertainedSitePatterns(alignment, null, 0, -1, 1, |
| 49 |
-1, -1, |
| 50 |
0, 9 |
| 51 |
); |
| 52 |
System.out.println("Using " + patterns.getPatternCount() + " patterns, with " |
| 53 |
+ patterns.getExcludePatternCount() + " excluded"); |
| 54 |
double total = computeSumOfPatterns(patterns); |
| 55 |
System.out.println("Total of 10 missing (corrected) probabilities = " + total); |
| 56 |
assertEquals("uncorrected", 1.0, total, tolerance); |
| 57 |
} |
| 58 |
} |