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 |
|
|
|
|
| 89.7% |
Uncovered Elements: 6 (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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
48 |
10674 |
public static int encodeCodon(char[] codon)... |
49 |
|
{ |
50 |
10674 |
if (codon == null) |
51 |
|
{ |
52 |
1 |
return -1; |
53 |
|
} |
54 |
10673 |
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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 11 |
Complexity Density: 0.52 |
|
66 |
32030 |
public static int encodeCodon(char c)... |
67 |
|
{ |
68 |
32030 |
int result = Integer.MIN_VALUE; |
69 |
32030 |
switch (c) |
70 |
|
{ |
71 |
9171 |
case 'A': |
72 |
4 |
case 'a': |
73 |
9175 |
result = 0; |
74 |
9175 |
break; |
75 |
7472 |
case 'C': |
76 |
5 |
case 'c': |
77 |
7477 |
result = 1; |
78 |
7477 |
break; |
79 |
7389 |
case 'G': |
80 |
5 |
case 'g': |
81 |
7394 |
result = 2; |
82 |
7394 |
break; |
83 |
7974 |
case 'T': |
84 |
7 |
case 't': |
85 |
1 |
case 'U': |
86 |
1 |
case 'u': |
87 |
7983 |
result = 3; |
88 |
7983 |
break; |
89 |
|
} |
90 |
32030 |
return result; |
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
@param |
99 |
|
@return |
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
101 |
3831 |
public static char[] decodeCodon(int encoded)... |
102 |
|
{ |
103 |
3831 |
char[] result = new char[3]; |
104 |
3831 |
result[2] = decodeNucleotide(encoded & 3); |
105 |
3831 |
encoded = encoded >>> CODON_ENCODING_BITSHIFT; |
106 |
3831 |
result[1] = decodeNucleotide(encoded & 3); |
107 |
3831 |
encoded = encoded >>> CODON_ENCODING_BITSHIFT; |
108 |
3831 |
result[0] = decodeNucleotide(encoded & 3); |
109 |
3831 |
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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 5 |
Complexity Density: 0.33 |
|
127 |
11498 |
public static char decodeNucleotide(int i)... |
128 |
|
{ |
129 |
11498 |
char result = '0'; |
130 |
11498 |
switch (i) |
131 |
|
{ |
132 |
3274 |
case 0: |
133 |
3274 |
result = 'A'; |
134 |
3274 |
break; |
135 |
2624 |
case 1: |
136 |
2624 |
result = 'C'; |
137 |
2624 |
break; |
138 |
2601 |
case 2: |
139 |
2601 |
result = 'G'; |
140 |
2601 |
break; |
141 |
2998 |
case 3: |
142 |
2998 |
result = 'T'; |
143 |
2998 |
break; |
144 |
|
} |
145 |
11498 |
return result; |
146 |
|
} |
147 |
|
|
148 |
|
} |