| 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.evolution.alignment; |
| 27 |
|
| 28 |
import dr.math.MathUtils; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public class ShuffledSiteList extends ResamplePatterns implements SiteList |
| 38 |
{ |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public ShuffledSiteList() { |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public ShuffledSiteList(SiteList patterns) { |
| 50 |
setPatterns(patterns); |
| 51 |
} |
| 52 |
|
| 53 |
public void setPatterns(SiteList patterns) { |
| 54 |
this.patterns = patterns; |
| 55 |
resamplePatterns(); |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public void resamplePatterns() { |
| 61 |
|
| 62 |
int siteCount = patterns.getSiteCount(); |
| 63 |
siteIndices = MathUtils.shuffled(siteCount); |
| 64 |
} |
| 65 |
|
| 66 |
public int getSiteCount() { |
| 67 |
return siteIndices.length; |
| 68 |
} |
| 69 |
|
| 70 |
public int[] getSitePattern(int siteIndex) { |
| 71 |
return patterns.getSitePattern(siteIndices[siteIndex]); |
| 72 |
} |
| 73 |
|
| 74 |
@Override |
| 75 |
public double[][] getUncertainSitePattern(int siteIndex) { |
| 76 |
return patterns.getUncertainSitePattern(siteIndices[siteIndex]); |
| 77 |
} |
| 78 |
|
| 79 |
public int getPatternIndex(int siteIndex) { |
| 80 |
return patterns.getPatternIndex(siteIndices[siteIndex]); |
| 81 |
} |
| 82 |
|
| 83 |
public int getState(int taxonIndex, int siteIndex) { |
| 84 |
return patterns.getState(taxonIndex, siteIndices[siteIndex]); |
| 85 |
} |
| 86 |
|
| 87 |
@Override |
| 88 |
public double[] getUncertainState(int taxonIndex, int siteIndex) { |
| 89 |
return patterns.getUncertainState(taxonIndex, siteIndices[siteIndex]); |
| 90 |
} |
| 91 |
|
| 92 |
int siteIndices[] = null; |
| 93 |
|
| 94 |
@Override |
| 95 |
public boolean areUncertain() { |
| 96 |
return false; |
| 97 |
} |
| 98 |
} |