| 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 |
|
import static org.testng.Assert.assertTrue; |
| 25 |
|
|
| 26 |
|
import jalview.api.analysis.ScoreModelI; |
| 27 |
|
import jalview.api.analysis.SimilarityParamsI; |
| 28 |
|
import jalview.datamodel.Alignment; |
| 29 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 30 |
|
import jalview.datamodel.AlignmentI; |
| 31 |
|
import jalview.datamodel.AlignmentView; |
| 32 |
|
import jalview.datamodel.Annotation; |
| 33 |
|
import jalview.datamodel.Sequence; |
| 34 |
|
import jalview.datamodel.SequenceFeature; |
| 35 |
|
import jalview.datamodel.SequenceI; |
| 36 |
|
import jalview.gui.AlignFrame; |
| 37 |
|
import jalview.gui.AlignViewport; |
| 38 |
|
import jalview.gui.JvOptionPane; |
| 39 |
|
import jalview.io.DataSourceType; |
| 40 |
|
import jalview.io.FileLoader; |
| 41 |
|
import jalview.math.MatrixI; |
| 42 |
|
|
| 43 |
|
import org.testng.Assert; |
| 44 |
|
import org.testng.annotations.BeforeClass; |
| 45 |
|
import org.testng.annotations.DataProvider; |
| 46 |
|
import org.testng.annotations.Test; |
| 47 |
|
|
| 48 |
|
|
| |
|
| 65.2% |
Uncovered Elements: 54 (155) |
Complexity: 12 |
Complexity Density: 0.09 |
|
| 49 |
|
public class SecondaryStructureDistanceModelTest |
| 50 |
|
{ |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
| 55 |
1 |
@Test(groups = "Functional")... |
| 56 |
|
public void testFindDistances_withGap() |
| 57 |
|
{ |
| 58 |
1 |
AlignFrame af = setupAlignmentViewWithGap(); |
| 59 |
1 |
AlignViewport viewport = af.getViewport(); |
| 60 |
1 |
AlignmentView view = viewport.getAlignmentView(false); |
| 61 |
|
|
| 62 |
1 |
ScoreModelI sm = new SecondaryStructureDistanceModel(); |
| 63 |
1 |
sm = ScoreModels.getInstance().getScoreModel(sm.getName(), |
| 64 |
|
af.alignPanel); |
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
1 |
SimilarityParamsI params = new SimilarityParams(false, true, true, |
| 77 |
|
true); |
| 78 |
1 |
params.setSecondaryStructureSource("3D Structures"); |
| 79 |
1 |
MatrixI distances = sm.findDistances(view, params); |
| 80 |
1 |
assertEquals(distances.getValue(0, 0), 1d); |
| 81 |
1 |
assertEquals(distances.getValue(1, 1), 1d); |
| 82 |
1 |
assertEquals(distances.getValue(0, 1), 0d); |
| 83 |
1 |
assertEquals(distances.getValue(1, 0), 0d); |
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
1 |
SimilarityParamsI params2 = new SimilarityParams(false, true, false, |
| 91 |
|
true); |
| 92 |
1 |
params2.setSecondaryStructureSource("3D Structures"); |
| 93 |
1 |
MatrixI distances2 = sm.findDistances(view, params2); |
| 94 |
1 |
assertEquals(distances2.getValue(0, 1), 0d); |
| 95 |
1 |
assertEquals(distances2.getValue(1, 0), 0d); |
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
| 101 |
1 |
@Test(groups = "Functional")... |
| 102 |
|
public void testFindDistances_withSSUndefinedInEitherOneSeq() |
| 103 |
|
{ |
| 104 |
1 |
AlignFrame af = setupAlignmentViewWithoutSS("either"); |
| 105 |
1 |
AlignViewport viewport = af.getViewport(); |
| 106 |
1 |
AlignmentView view = viewport.getAlignmentView(false); |
| 107 |
|
|
| 108 |
1 |
ScoreModelI sm = new SecondaryStructureDistanceModel(); |
| 109 |
1 |
sm = ScoreModels.getInstance().getScoreModel(sm.getName(), |
| 110 |
|
af.alignPanel); |
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
1 |
SimilarityParamsI params = new SimilarityParams(false, true, true, |
| 123 |
|
true); |
| 124 |
1 |
params.setSecondaryStructureSource("3D Structures"); |
| 125 |
1 |
MatrixI distances = sm.findDistances(view, params); |
| 126 |
1 |
assertEquals(distances.getValue(0, 0), 1d); |
| 127 |
1 |
assertEquals(distances.getValue(1, 1), 1d); |
| 128 |
1 |
assertEquals(distances.getValue(0, 1), 0d); |
| 129 |
1 |
assertEquals(distances.getValue(1, 0), 0d); |
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
1 |
SimilarityParamsI params2 = new SimilarityParams(false, true, false, |
| 137 |
|
true); |
| 138 |
1 |
params2.setSecondaryStructureSource("3D Structures"); |
| 139 |
1 |
MatrixI distances2 = sm.findDistances(view, params2); |
| 140 |
1 |
assertEquals(distances2.getValue(0, 1), 0d); |
| 141 |
1 |
assertEquals(distances2.getValue(1, 0), 0d); |
| 142 |
|
} |
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
| 147 |
1 |
@Test(groups = "Functional")... |
| 148 |
|
public void testFindDistances_withSSUndefinedInBothSeqs() |
| 149 |
|
{ |
| 150 |
1 |
AlignFrame af = setupAlignmentViewWithoutSS("both"); |
| 151 |
1 |
AlignViewport viewport = af.getViewport(); |
| 152 |
1 |
AlignmentView view = viewport.getAlignmentView(false); |
| 153 |
|
|
| 154 |
1 |
ScoreModelI sm = new SecondaryStructureDistanceModel(); |
| 155 |
1 |
sm = ScoreModels.getInstance().getScoreModel(sm.getName(), |
| 156 |
|
af.alignPanel); |
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
1 |
SimilarityParamsI params = new SimilarityParams(false, true, true, |
| 169 |
|
true); |
| 170 |
1 |
params.setSecondaryStructureSource("3D Structures"); |
| 171 |
1 |
MatrixI distances = sm.findDistances(view, params); |
| 172 |
1 |
assertEquals(distances.getValue(0, 0), 1d); |
| 173 |
1 |
assertEquals(distances.getValue(1, 1), 1d); |
| 174 |
1 |
assertEquals(distances.getValue(0, 1), 0d); |
| 175 |
1 |
assertEquals(distances.getValue(1, 0), 0d); |
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
1 |
SimilarityParamsI params2 = new SimilarityParams(false, true, false, |
| 183 |
|
true); |
| 184 |
1 |
params2.setSecondaryStructureSource("3D Structures"); |
| 185 |
1 |
MatrixI distances2 = sm.findDistances(view, params2); |
| 186 |
1 |
assertEquals(distances2.getValue(0, 1), 0d); |
| 187 |
1 |
assertEquals(distances2.getValue(1, 0), 0d); |
| 188 |
|
} |
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
@return |
| 200 |
|
|
| |
|
| 0% |
Uncovered Elements: 38 (38) |
Complexity: 4 |
Complexity Density: 0.12 |
|
| 201 |
0 |
protected AlignFrame setupAlignmentView(String similar)... |
| 202 |
|
{ |
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
0 |
SequenceI s1 = new Sequence("s1", "FRKS"); |
| 207 |
0 |
SequenceI s2 = new Sequence("s2", "FSJL"); |
| 208 |
|
|
| 209 |
0 |
s1.addSequenceFeature( |
| 210 |
|
new SequenceFeature("chain", null, 1, 4, 0f, null)); |
| 211 |
0 |
s1.addSequenceFeature( |
| 212 |
|
new SequenceFeature("domain", null, 1, 4, 0f, null)); |
| 213 |
0 |
s2.addSequenceFeature( |
| 214 |
|
new SequenceFeature("chain", null, 1, 4, 0f, null)); |
| 215 |
0 |
s2.addSequenceFeature( |
| 216 |
|
new SequenceFeature("metal", null, 1, 4, 0f, null)); |
| 217 |
0 |
s2.addSequenceFeature( |
| 218 |
|
new SequenceFeature("Pfam", null, 1, 4, 0f, null)); |
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
|
|
| 223 |
0 |
Annotation ssE = new Annotation("", "", 'E', 0); |
| 224 |
0 |
Annotation ssH = new Annotation("", "", 'H', 0); |
| 225 |
0 |
Annotation ssC = new Annotation(".", "", ' ', 0); |
| 226 |
|
|
| 227 |
0 |
Annotation[] anns1; |
| 228 |
0 |
Annotation[] anns2; |
| 229 |
|
|
| 230 |
|
|
| 231 |
|
|
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| 238 |
|
|
| 239 |
0 |
if (similar == "All Similar") |
| 240 |
|
{ |
| 241 |
|
|
| 242 |
0 |
anns1 = new Annotation[] { ssE, ssH, ssC, ssE }; |
| 243 |
0 |
anns2 = new Annotation[] { ssE, ssH, ssC, ssE }; |
| 244 |
|
|
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
|
| 248 |
|
|
| 249 |
|
|
| 250 |
|
|
| 251 |
|
|
| 252 |
|
|
| 253 |
|
|
| 254 |
|
|
| 255 |
|
|
| 256 |
0 |
else if (similar == "Not Similar") |
| 257 |
|
{ |
| 258 |
|
|
| 259 |
0 |
anns1 = new Annotation[] { ssE, ssE, ssC, ssE }; |
| 260 |
0 |
anns2 = new Annotation[] { ssH, ssH, ssE, ssC }; |
| 261 |
|
|
| 262 |
|
} |
| 263 |
|
|
| 264 |
|
|
| 265 |
|
|
| 266 |
|
|
| 267 |
|
|
| 268 |
|
|
| 269 |
|
|
| 270 |
|
|
| 271 |
|
|
| 272 |
|
|
| 273 |
0 |
else if (similar == "With Coil") |
| 274 |
|
{ |
| 275 |
|
|
| 276 |
0 |
anns1 = new Annotation[] { ssE, ssE, null, ssE }; |
| 277 |
0 |
anns2 = new Annotation[] { ssH, ssH, ssE, null }; |
| 278 |
|
|
| 279 |
|
} |
| 280 |
|
|
| 281 |
|
|
| 282 |
|
|
| 283 |
|
|
| 284 |
|
|
| 285 |
|
|
| 286 |
|
|
| 287 |
|
|
| 288 |
|
|
| 289 |
|
else |
| 290 |
|
{ |
| 291 |
|
|
| 292 |
0 |
anns1 = new Annotation[] { ssH, ssE, ssC, ssE }; |
| 293 |
0 |
anns2 = new Annotation[] { ssH, ssE, ssE, ssC }; |
| 294 |
|
} |
| 295 |
|
|
| 296 |
0 |
AlignmentAnnotation ann1 = new AlignmentAnnotation( |
| 297 |
|
"Secondary Structure", "Secondary Structure", anns1); |
| 298 |
0 |
AlignmentAnnotation ann2 = new AlignmentAnnotation( |
| 299 |
|
"Secondary Structure", "Secondary Structure", anns2); |
| 300 |
|
|
| 301 |
0 |
s1.addAlignmentAnnotation(ann1); |
| 302 |
0 |
s2.addAlignmentAnnotation(ann2); |
| 303 |
|
|
| 304 |
0 |
AlignmentI al = new Alignment(new SequenceI[] { s1, s2 }); |
| 305 |
0 |
AlignFrame af = new AlignFrame(al, 300, 300); |
| 306 |
0 |
af.setShowSeqFeatures(true); |
| 307 |
0 |
af.getFeatureRenderer().findAllFeatures(true); |
| 308 |
0 |
return af; |
| 309 |
|
} |
| 310 |
|
|
| 311 |
|
|
| 312 |
|
|
| 313 |
|
|
| 314 |
|
|
| 315 |
|
|
| 316 |
|
|
| 317 |
|
|
| 318 |
|
|
| 319 |
|
|
| 320 |
|
|
| 321 |
|
|
| 322 |
|
@return |
| 323 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 1 |
Complexity Density: 0.04 |
|
| 324 |
1 |
protected AlignFrame setupAlignmentViewWithGap()... |
| 325 |
|
{ |
| 326 |
|
|
| 327 |
1 |
SequenceI s1 = new Sequence("s1", "FR S"); |
| 328 |
1 |
SequenceI s2 = new Sequence("s2", "FSJL"); |
| 329 |
|
|
| 330 |
1 |
s1.addSequenceFeature( |
| 331 |
|
new SequenceFeature("chain", null, 1, 3, 0f, null)); |
| 332 |
1 |
s1.addSequenceFeature( |
| 333 |
|
new SequenceFeature("domain", null, 1, 3, 0f, null)); |
| 334 |
1 |
s2.addSequenceFeature( |
| 335 |
|
new SequenceFeature("chain", null, 1, 4, 0f, null)); |
| 336 |
1 |
s2.addSequenceFeature( |
| 337 |
|
new SequenceFeature("metal", null, 1, 4, 0f, null)); |
| 338 |
1 |
s2.addSequenceFeature( |
| 339 |
|
new SequenceFeature("Pfam", null, 1, 4, 0f, null)); |
| 340 |
|
|
| 341 |
1 |
Annotation ssE = new Annotation("", "", 'E', 0); |
| 342 |
1 |
Annotation ssH = new Annotation("", "", 'H', 0); |
| 343 |
1 |
Annotation ssC = new Annotation(".", "", ' ', 0); |
| 344 |
|
|
| 345 |
1 |
Annotation[] anns1; |
| 346 |
1 |
Annotation[] anns2; |
| 347 |
|
|
| 348 |
1 |
anns1 = new Annotation[] { ssH, ssE, ssC }; |
| 349 |
1 |
anns2 = new Annotation[] { ssH, ssE, ssE, ssC }; |
| 350 |
|
|
| 351 |
1 |
AlignmentAnnotation ann1 = new AlignmentAnnotation( |
| 352 |
|
"Secondary Structure", "Secondary Structure", anns1); |
| 353 |
1 |
AlignmentAnnotation ann2 = new AlignmentAnnotation( |
| 354 |
|
"Secondary Structure", "Secondary Structure", anns2); |
| 355 |
|
|
| 356 |
1 |
s1.addAlignmentAnnotation(ann1); |
| 357 |
1 |
s2.addAlignmentAnnotation(ann2); |
| 358 |
|
|
| 359 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { s1, s2 }); |
| 360 |
1 |
AlignFrame af = new AlignFrame(al, 300, 300); |
| 361 |
1 |
af.setShowSeqFeatures(true); |
| 362 |
1 |
af.getFeatureRenderer().findAllFeatures(true); |
| 363 |
|
|
| 364 |
1 |
return af; |
| 365 |
|
} |
| 366 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 2 |
Complexity Density: 0.1 |
|
| 367 |
2 |
protected AlignFrame setupAlignmentViewWithoutSS(String type)... |
| 368 |
|
{ |
| 369 |
|
|
| 370 |
2 |
SequenceI s1 = new Sequence("s1", "FR S"); |
| 371 |
2 |
SequenceI s2 = new Sequence("s2", "FSJL"); |
| 372 |
|
|
| 373 |
2 |
s1.addSequenceFeature( |
| 374 |
|
new SequenceFeature("chain", null, 1, 3, 0f, null)); |
| 375 |
2 |
s1.addSequenceFeature( |
| 376 |
|
new SequenceFeature("domain", null, 1, 3, 0f, null)); |
| 377 |
2 |
s2.addSequenceFeature( |
| 378 |
|
new SequenceFeature("chain", null, 1, 4, 0f, null)); |
| 379 |
2 |
s2.addSequenceFeature( |
| 380 |
|
new SequenceFeature("metal", null, 1, 4, 0f, null)); |
| 381 |
2 |
s2.addSequenceFeature( |
| 382 |
|
new SequenceFeature("Pfam", null, 1, 4, 0f, null)); |
| 383 |
|
|
| 384 |
2 |
if (!type.equals("both")) |
| 385 |
|
{ |
| 386 |
1 |
Annotation ssE = new Annotation("", "", 'E', 0); |
| 387 |
1 |
Annotation ssH = new Annotation("", "", 'H', 0); |
| 388 |
1 |
Annotation ssC = new Annotation(".", "", ' ', 0); |
| 389 |
|
|
| 390 |
1 |
Annotation[] anns1; |
| 391 |
|
|
| 392 |
1 |
anns1 = new Annotation[] { ssH, ssE, ssC }; |
| 393 |
|
|
| 394 |
1 |
AlignmentAnnotation ann1 = new AlignmentAnnotation( |
| 395 |
|
"Secondary Structure", "Secondary Structure", anns1); |
| 396 |
|
|
| 397 |
1 |
s1.addAlignmentAnnotation(ann1); |
| 398 |
|
} |
| 399 |
|
|
| 400 |
2 |
AlignmentI al = new Alignment(new SequenceI[] { s1, s2 }); |
| 401 |
2 |
AlignFrame af = new AlignFrame(al, 300, 300); |
| 402 |
2 |
af.setShowSeqFeatures(true); |
| 403 |
2 |
af.getFeatureRenderer().findAllFeatures(true); |
| 404 |
2 |
return af; |
| 405 |
|
} |
| 406 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
| 407 |
0 |
@DataProvider(name = "testData")... |
| 408 |
|
public Object[][] testData() |
| 409 |
|
{ |
| 410 |
0 |
return new Object[][] { { "All Similar", 1d, 1d, 0d, 0d / 4 }, |
| 411 |
|
{ "Partially Similar", 1d, 1d, 0d, 0d }, |
| 412 |
|
{ "Not Similar", 1d, 1d, 0d, 0d }, |
| 413 |
|
{ "With Coil", 1d, 1d, 0d, 0d }, }; |
| 414 |
|
} |
| 415 |
|
|
| |
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
| 416 |
0 |
@Test(dataProvider = "testData")... |
| 417 |
|
public void testFindDistances(String scenario, double expectedValue00, |
| 418 |
|
double expectedValue11, double expectedValue01, |
| 419 |
|
double expectedValue10) |
| 420 |
|
{ |
| 421 |
0 |
AlignFrame af = setupAlignmentView(scenario); |
| 422 |
0 |
AlignViewport viewport = af.getViewport(); |
| 423 |
0 |
AlignmentView view = viewport.getAlignmentView(false); |
| 424 |
|
|
| 425 |
0 |
ScoreModelI sm = new SecondaryStructureDistanceModel(); |
| 426 |
0 |
sm = ScoreModels.getInstance().getScoreModel(sm.getName(), |
| 427 |
|
af.alignPanel); |
| 428 |
|
|
| 429 |
0 |
SimilarityParamsI params = new SimilarityParams(false, true, true, |
| 430 |
|
true); |
| 431 |
0 |
params.setSecondaryStructureSource("3D Structures"); |
| 432 |
0 |
MatrixI distances = sm.findDistances(view, params); |
| 433 |
|
|
| 434 |
0 |
assertEquals(distances.getValue(0, 0), expectedValue00); |
| 435 |
0 |
assertEquals(distances.getValue(1, 1), expectedValue11); |
| 436 |
0 |
assertEquals(distances.getValue(0, 1), expectedValue01); |
| 437 |
0 |
assertEquals(distances.getValue(1, 0), expectedValue10); |
| 438 |
|
} |
| 439 |
|
|
| 440 |
|
} |