| 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.tree; |
| 27 |
|
| 28 |
import dr.evolution.util.TaxonList; |
| 29 |
|
| 30 |
import java.io.PrintWriter; |
| 31 |
import java.io.StringWriter; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public class SplitSystem |
| 41 |
{ |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
public SplitSystem(TaxonList taxonList, int size) |
| 51 |
{ |
| 52 |
this.taxonList = taxonList; |
| 53 |
|
| 54 |
labelCount = taxonList.getTaxonCount(); |
| 55 |
splitCount = size; |
| 56 |
|
| 57 |
splits = new boolean[splitCount][labelCount]; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
public int getSplitCount() |
| 62 |
{ |
| 63 |
return splitCount; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
public int getLabelCount() |
| 68 |
{ |
| 69 |
return labelCount; |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
public boolean[][] getSplitVector() |
| 74 |
{ |
| 75 |
return splits; |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
public boolean[] getSplit(int i) |
| 80 |
{ |
| 81 |
return splits[i]; |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
public TaxonList getTaxonList() { return taxonList; } |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
public boolean hasSplit(boolean[] split) |
| 95 |
{ |
| 96 |
for (int i = 0; i < splitCount; i++) |
| 97 |
{ |
| 98 |
if (SplitUtils.isSame(split, splits[i])) return true; |
| 99 |
} |
| 100 |
|
| 101 |
return false; |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
public String toString() |
| 107 |
{ |
| 108 |
StringWriter sw = new StringWriter(); |
| 109 |
PrintWriter pw = new PrintWriter(sw); |
| 110 |
|
| 111 |
for (int i = 0; i < labelCount; i++) |
| 112 |
{ |
| 113 |
pw.println(taxonList.getTaxon(i)); |
| 114 |
} |
| 115 |
pw.println(); |
| 116 |
|
| 117 |
|
| 118 |
for (int i = 0; i < splitCount; i++) |
| 119 |
{ |
| 120 |
for (int j = 0; j < labelCount; j++) |
| 121 |
{ |
| 122 |
if (splits[i][j] == true) |
| 123 |
pw.print('*'); |
| 124 |
else |
| 125 |
pw.print('.'); |
| 126 |
} |
| 127 |
|
| 128 |
pw.println(); |
| 129 |
} |
| 130 |
|
| 131 |
return sw.toString(); |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
private int labelCount, splitCount; |
| 140 |
private TaxonList taxonList; |
| 141 |
private boolean[][] splits; |
| 142 |
} |