1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.analysis; |
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
@author |
27 |
|
|
28 |
|
|
|
|
| 0% |
Uncovered Elements: 58 (58) |
Complexity: 20 |
Complexity Density: 0.39 |
|
29 |
|
public class CodingUtils |
30 |
|
{ |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
private static final int CODON_ENCODING_BITSHIFT = 2; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@param |
45 |
|
@return |
46 |
|
|
47 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
48 |
0 |
public static int encodeCodon(char[] codon)... |
49 |
|
{ |
50 |
0 |
if (codon == null) |
51 |
|
{ |
52 |
0 |
return -1; |
53 |
|
} |
54 |
0 |
return encodeCodon(codon[2]) |
55 |
|
+ (encodeCodon(codon[1]) << CODON_ENCODING_BITSHIFT) |
56 |
|
+ (encodeCodon(codon[0]) << (2 * CODON_ENCODING_BITSHIFT)); |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
@param |
64 |
|
@return |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 11 |
Complexity Density: 0.52 |
|
66 |
0 |
public static int encodeCodon(char c)... |
67 |
|
{ |
68 |
0 |
int result = Integer.MIN_VALUE; |
69 |
0 |
switch (c) |
70 |
|
{ |
71 |
0 |
case 'A': |
72 |
0 |
case 'a': |
73 |
0 |
result = 0; |
74 |
0 |
break; |
75 |
0 |
case 'C': |
76 |
0 |
case 'c': |
77 |
0 |
result = 1; |
78 |
0 |
break; |
79 |
0 |
case 'G': |
80 |
0 |
case 'g': |
81 |
0 |
result = 2; |
82 |
0 |
break; |
83 |
0 |
case 'T': |
84 |
0 |
case 't': |
85 |
0 |
case 'U': |
86 |
0 |
case 'u': |
87 |
0 |
result = 3; |
88 |
0 |
break; |
89 |
|
} |
90 |
0 |
return result; |
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
@param |
99 |
|
@return |
100 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
101 |
0 |
public static char[] decodeCodon(int encoded)... |
102 |
|
{ |
103 |
0 |
char[] result = new char[3]; |
104 |
0 |
result[2] = decodeNucleotide(encoded & 3); |
105 |
0 |
encoded = encoded >>> CODON_ENCODING_BITSHIFT; |
106 |
0 |
result[1] = decodeNucleotide(encoded & 3); |
107 |
0 |
encoded = encoded >>> CODON_ENCODING_BITSHIFT; |
108 |
0 |
result[0] = decodeNucleotide(encoded & 3); |
109 |
0 |
return result; |
110 |
|
} |
111 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
112 |
0 |
public static void decodeCodon2(int encoded, char[] result)... |
113 |
|
{ |
114 |
0 |
result[2] = decodeNucleotide(encoded & 3); |
115 |
0 |
encoded = encoded >>> CODON_ENCODING_BITSHIFT; |
116 |
0 |
result[1] = decodeNucleotide(encoded & 3); |
117 |
0 |
encoded = encoded >>> CODON_ENCODING_BITSHIFT; |
118 |
0 |
result[0] = decodeNucleotide(encoded & 3); |
119 |
|
} |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
@param |
125 |
|
@return |
126 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 5 |
Complexity Density: 0.33 |
|
127 |
0 |
public static char decodeNucleotide(int i)... |
128 |
|
{ |
129 |
0 |
char result = '0'; |
130 |
0 |
switch (i) |
131 |
|
{ |
132 |
0 |
case 0: |
133 |
0 |
result = 'A'; |
134 |
0 |
break; |
135 |
0 |
case 1: |
136 |
0 |
result = 'C'; |
137 |
0 |
break; |
138 |
0 |
case 2: |
139 |
0 |
result = 'G'; |
140 |
0 |
break; |
141 |
0 |
case 3: |
142 |
0 |
result = 'T'; |
143 |
0 |
break; |
144 |
|
} |
145 |
0 |
return result; |
146 |
|
} |
147 |
|
|
148 |
|
} |