1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.analysis.scoremodels; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
|
25 |
|
import jalview.api.analysis.SimilarityParamsI; |
26 |
|
import jalview.util.Comparison; |
27 |
|
|
28 |
|
import org.testng.annotations.Test; |
29 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (77) |
Complexity: 4 |
Complexity Density: 0.05 |
|
30 |
|
public class PIDModelTest |
31 |
|
{ |
32 |
|
private static final double DELTA = 0.00001D; |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
34 |
1 |
@Test(groups = "Functional")... |
35 |
|
public void testGetPairwiseScore() |
36 |
|
{ |
37 |
1 |
PIDModel sm = new PIDModel(); |
38 |
1 |
assertEquals(sm.getPairwiseScore('A', 'A'), 1f); |
39 |
1 |
assertEquals(sm.getPairwiseScore('A', 'a'), 1f); |
40 |
1 |
assertEquals(sm.getPairwiseScore('a', 'A'), 1f); |
41 |
1 |
assertEquals(sm.getPairwiseScore('A', 'B'), 0f); |
42 |
1 |
assertEquals(sm.getPairwiseScore('A', ' '), 0f); |
43 |
1 |
assertEquals(sm.getPairwiseScore(' ', ' '), 0f); |
44 |
1 |
assertEquals(sm.getPairwiseScore('.', '.'), 0f); |
45 |
1 |
assertEquals(sm.getPairwiseScore('-', '-'), 0f); |
46 |
|
} |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (36) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
52 |
1 |
@Test(groups = "Functional")... |
53 |
|
public void testComputePID_matchesComparisonPID() |
54 |
|
{ |
55 |
1 |
SimilarityParamsI params = new SimilarityParams(true, true, true, true); |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
1 |
String s1 = "ARFNQDWSGI"; |
61 |
1 |
String s2 = "ARKNQDQSGI"; |
62 |
|
|
63 |
1 |
new PIDModel(); |
64 |
1 |
double newScore = PIDModel.computePID(s1, s2, params); |
65 |
1 |
double oldScore = Comparison.PID(s1, s2); |
66 |
1 |
assertEquals(newScore, oldScore, DELTA); |
67 |
|
|
68 |
1 |
assertEquals(newScore, PIDModel.computePID(s2, s1, params)); |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
1 |
s1 = "-RFNQDWSGI"; |
74 |
1 |
s2 = "ARKNQ-QSGI"; |
75 |
1 |
new PIDModel(); |
76 |
1 |
newScore = PIDModel.computePID(s1, s2, params); |
77 |
1 |
oldScore = Comparison.PID(s1, s2); |
78 |
1 |
assertEquals(newScore, oldScore, DELTA); |
79 |
1 |
assertEquals(newScore, PIDModel.computePID(s2, s1, params)); |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
1 |
s1 = "ARK-"; |
85 |
1 |
s2 = "-RFNQ"; |
86 |
1 |
new PIDModel(); |
87 |
1 |
newScore = PIDModel.computePID(s1, s2, params); |
88 |
1 |
oldScore = Comparison.PID(s1, s2); |
89 |
1 |
assertEquals(newScore, oldScore, DELTA); |
90 |
1 |
assertEquals(newScore, PIDModel.computePID(s2, s1, params)); |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
1 |
s1 = "-RFNQ"; |
96 |
1 |
s2 = "ARK-"; |
97 |
1 |
new PIDModel(); |
98 |
1 |
newScore = PIDModel.computePID(s1, s2, params); |
99 |
1 |
oldScore = Comparison.PID(s1, s2); |
100 |
1 |
assertEquals(newScore, oldScore, DELTA); |
101 |
1 |
assertEquals(newScore, PIDModel.computePID(s2, s1, params)); |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
1 |
s1 = "-R-F-NQ"; |
107 |
1 |
s2 = "AR-K--"; |
108 |
1 |
new PIDModel(); |
109 |
1 |
newScore = PIDModel.computePID(s1, s2, params); |
110 |
1 |
oldScore = Comparison.PID(s1, s2); |
111 |
1 |
assertEquals(newScore, oldScore, DELTA); |
112 |
1 |
assertEquals(newScore, PIDModel.computePID(s2, s1, params)); |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
119 |
1 |
@Test(groups = "Functional")... |
120 |
|
public void testComputePID_matchShortestSequence() |
121 |
|
{ |
122 |
1 |
String s1 = "FR-K-S"; |
123 |
1 |
String s2 = "FS--L"; |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
1 |
SimilarityParamsI params = new SimilarityParams(true, true, true, true); |
130 |
1 |
assertEquals(PIDModel.computePID(s1, s2, params), 80d); |
131 |
1 |
assertEquals(PIDModel.computePID(s2, s1, params), 80d); |
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
1 |
params = new SimilarityParams(false, true, true, true); |
138 |
1 |
assertEquals(PIDModel.computePID(s1, s2, params), 75d); |
139 |
1 |
assertEquals(PIDModel.computePID(s2, s1, params), 75d); |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
1 |
params = new SimilarityParams(true, false, true, true); |
147 |
1 |
assertEquals(PIDModel.computePID(s1, s2, params), 40d); |
148 |
1 |
assertEquals(PIDModel.computePID(s2, s1, params), 40d); |
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
1 |
params = new SimilarityParams(false, false, true, true); |
156 |
1 |
assertEquals(PIDModel.computePID(s1, s2, params), 25d); |
157 |
1 |
assertEquals(PIDModel.computePID(s2, s1, params), 25d); |
158 |
|
} |
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
164 |
1 |
@Test(groups = "Functional")... |
165 |
|
public void testComputePID_matchLongestSequence() |
166 |
|
{ |
167 |
1 |
String s1 = "FR-K-S"; |
168 |
1 |
String s2 = "FS--L"; |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
1 |
SimilarityParamsI params = new SimilarityParams(true, true, true, |
176 |
|
false); |
177 |
1 |
assertEquals(PIDModel.computePID(s1, s2, params), 500d / 6); |
178 |
1 |
assertEquals(PIDModel.computePID(s2, s1, params), 500d / 6); |
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
1 |
params = new SimilarityParams(false, true, true, false); |
185 |
1 |
assertEquals(PIDModel.computePID(s1, s2, params), 80d); |
186 |
1 |
assertEquals(PIDModel.computePID(s2, s1, params), 80d); |
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
1 |
params = new SimilarityParams(true, false, true, false); |
194 |
1 |
assertEquals(PIDModel.computePID(s1, s2, params), 100d / 3); |
195 |
1 |
assertEquals(PIDModel.computePID(s2, s1, params), 100d / 3); |
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
1 |
params = new SimilarityParams(false, false, true, false); |
203 |
1 |
assertEquals(PIDModel.computePID(s1, s2, params), 20d); |
204 |
1 |
assertEquals(PIDModel.computePID(s2, s1, params), 20d); |
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
} |
211 |
|
} |