| 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.datatype; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public class SimpleCodons extends DataType { |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
public static final String DESCRIPTION = "simpleCodon"; |
| 48 |
public static final int TYPE = CODONS; |
| 49 |
|
| 50 |
public static final SimpleCodons UNIVERSAL = new SimpleCodons(GeneticCode.UNIVERSAL); |
| 51 |
public static final SimpleCodons VERTEBRATE_MT = new SimpleCodons(GeneticCode.VERTEBRATE_MT); |
| 52 |
public static final SimpleCodons YEAST = new SimpleCodons(GeneticCode.YEAST); |
| 53 |
public static final SimpleCodons MOLD_PROTOZOAN_MT = new SimpleCodons(GeneticCode.MOLD_PROTOZOAN_MT); |
| 54 |
public static final SimpleCodons MYCOPLASMA = new SimpleCodons(GeneticCode.MYCOPLASMA); |
| 55 |
public static final SimpleCodons INVERTEBRATE_MT = new SimpleCodons(GeneticCode.INVERTEBRATE_MT); |
| 56 |
public static final SimpleCodons CILIATE = new SimpleCodons(GeneticCode.CILIATE); |
| 57 |
public static final SimpleCodons ECHINODERM_MT = new SimpleCodons(GeneticCode.ECHINODERM_MT); |
| 58 |
public static final SimpleCodons EUPLOTID_NUC = new SimpleCodons(GeneticCode.EUPLOTID_NUC); |
| 59 |
public static final SimpleCodons BACTERIAL = new SimpleCodons(GeneticCode.BACTERIAL); |
| 60 |
public static final SimpleCodons ALT_YEAST = new SimpleCodons(GeneticCode.ALT_YEAST); |
| 61 |
public static final SimpleCodons ASCIDIAN_MT = new SimpleCodons(GeneticCode.ASCIDIAN_MT); |
| 62 |
public static final SimpleCodons FLATWORM_MT = new SimpleCodons(GeneticCode.FLATWORM_MT); |
| 63 |
public static final SimpleCodons BLEPHARISMA_NUC = new SimpleCodons(GeneticCode.BLEPHARISMA_NUC); |
| 64 |
|
| 65 |
public static final int UNKNOWN_STATE = 64; |
| 66 |
public static final int GAP_STATE = 65; |
| 67 |
|
| 68 |
public static final String[] CODON_TRIPLETS = { |
| 69 |
"AAA", "AAC", "AAG", "AAT", "ACA", "ACC", "ACG","ACT", |
| 70 |
"AGA", "AGC", "AGG", "AGT", "ATA", "ATC", "ATG","ATT", |
| 71 |
"CAA", "CAC", "CAG", "CAT", "CCA", "CCC", "CCG","CCT", |
| 72 |
"CGA", "CGC", "CGG", "CGT", "CTA", "CTC", "CTG","CTT", |
| 73 |
"GAA", "GAC", "GAG", "GAT", "GCA", "GCC", "GCG","GCT", |
| 74 |
"GGA", "GGC", "GGG", "GGT", "GTA", "GTC", "GTG","GTT", |
| 75 |
"TAA", "TAC", "TAG", "TAT", "TCA", "TCC", "TCG","TCT", |
| 76 |
"TGA", "TGC", "TGG", "TGT", "TTA", "TTC", "TTG","TTT", |
| 77 |
"???", "---" |
| 78 |
}; |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
private SimpleCodons(GeneticCode geneticCode) { |
| 84 |
this.geneticCode = geneticCode; |
| 85 |
|
| 86 |
stateCount = 64; |
| 87 |
ambiguousStateCount = 66; |
| 88 |
} |
| 89 |
|
| 90 |
@Override |
| 91 |
public char[] getValidChars() { |
| 92 |
return null; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
public final int getState(char c) |
| 103 |
{ |
| 104 |
throw new IllegalArgumentException("Codons datatype cannot be expressed as char"); |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
public int getUnknownState() { |
| 113 |
return UNKNOWN_STATE; |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
public int getGapState() { |
| 122 |
return GAP_STATE; |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
public final int getState(char nuc1, char nuc2, char nuc3) |
| 135 |
{ |
| 136 |
return getState(Nucleotides.INSTANCE.getState(nuc1), |
| 137 |
Nucleotides.INSTANCE.getState(nuc2), |
| 138 |
Nucleotides.INSTANCE.getState(nuc3)); |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
public final int getState(int nuc1, int nuc2, int nuc3) |
| 151 |
{ |
| 152 |
if (Nucleotides.INSTANCE.isGapState(nuc1) || |
| 153 |
Nucleotides.INSTANCE.isGapState(nuc2) || |
| 154 |
Nucleotides.INSTANCE.isGapState(nuc3)) { |
| 155 |
return GAP_STATE; |
| 156 |
} |
| 157 |
|
| 158 |
if (Nucleotides.INSTANCE.isAmbiguousState(nuc1) || |
| 159 |
Nucleotides.INSTANCE.isAmbiguousState(nuc2) || |
| 160 |
Nucleotides.INSTANCE.isAmbiguousState(nuc3)) { |
| 161 |
return UNKNOWN_STATE; |
| 162 |
} |
| 163 |
|
| 164 |
return (nuc1 * 16) + (nuc2 * 4) + nuc3; |
| 165 |
} |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
public final char getChar(int state) |
| 175 |
{ |
| 176 |
throw new IllegalArgumentException("Codons datatype cannot be expressed as char"); |
| 177 |
} |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
public final String getTriplet(int state) |
| 187 |
{ |
| 188 |
return CODON_TRIPLETS[state]; |
| 189 |
} |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
public final int[] getTripletStates(int state) |
| 199 |
{ |
| 200 |
int[] triplet = new int[3]; |
| 201 |
|
| 202 |
triplet[0] = Nucleotides.INSTANCE.getState(CODON_TRIPLETS[state].charAt(0)); |
| 203 |
triplet[1] = Nucleotides.INSTANCE.getState(CODON_TRIPLETS[state].charAt(1)); |
| 204 |
triplet[2] = Nucleotides.INSTANCE.getState(CODON_TRIPLETS[state].charAt(2)); |
| 205 |
|
| 206 |
return triplet; |
| 207 |
} |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
public String getDescription() { |
| 215 |
return DESCRIPTION; |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
public int getType() { |
| 224 |
return TYPE; |
| 225 |
} |
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
public GeneticCode getGeneticCode() { |
| 231 |
return geneticCode; |
| 232 |
} |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
public final boolean isStopCodon(int state) { |
| 240 |
return geneticCode.isStopCodon(state); |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
private GeneticCode geneticCode; |
| 246 |
|
| 247 |
} |