| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.datamodel; |
| 22 |
|
|
| 23 |
|
import static org.testng.AssertJUnit.assertEquals; |
| 24 |
|
import static org.testng.AssertJUnit.assertFalse; |
| 25 |
|
import static org.testng.AssertJUnit.assertNotNull; |
| 26 |
|
import static org.testng.AssertJUnit.assertNull; |
| 27 |
|
import static org.testng.AssertJUnit.assertSame; |
| 28 |
|
import static org.testng.AssertJUnit.assertTrue; |
| 29 |
|
|
| 30 |
|
import java.io.IOException; |
| 31 |
|
import java.util.Arrays; |
| 32 |
|
import java.util.Iterator; |
| 33 |
|
import java.util.List; |
| 34 |
|
|
| 35 |
|
import org.testng.Assert; |
| 36 |
|
import org.testng.annotations.BeforeClass; |
| 37 |
|
import org.testng.annotations.BeforeMethod; |
| 38 |
|
import org.testng.annotations.Test; |
| 39 |
|
|
| 40 |
|
import jalview.analysis.AlignmentGenerator; |
| 41 |
|
import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping; |
| 42 |
|
import jalview.gui.JvOptionPane; |
| 43 |
|
import jalview.io.DataSourceType; |
| 44 |
|
import jalview.io.FileFormat; |
| 45 |
|
import jalview.io.FileFormatI; |
| 46 |
|
import jalview.io.FormatAdapter; |
| 47 |
|
import jalview.util.Comparison; |
| 48 |
|
import jalview.util.MapList; |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
@author |
| 54 |
|
|
| 55 |
|
|
| |
|
| 89.1% |
Uncovered Elements: 80 (733) |
Complexity: 94 |
Complexity Density: 0.16 |
|
| 56 |
|
public class AlignmentTest |
| 57 |
|
{ |
| 58 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 59 |
1 |
@BeforeClass(alwaysRun = true)... |
| 60 |
|
public void setUpJvOptionPane() |
| 61 |
|
{ |
| 62 |
1 |
JvOptionPane.setInteractiveMode(false); |
| 63 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
|
| 67 |
|
private static final String TEST_DATA = |
| 68 |
|
"# STOCKHOLM 1.0\n" + |
| 69 |
|
"#=GS D.melanogaster.1 AC AY119185.1/838-902\n" + |
| 70 |
|
"#=GS D.melanogaster.2 AC AC092237.1/57223-57161\n" + |
| 71 |
|
"#=GS D.melanogaster.3 AC AY060611.1/560-627\n" + |
| 72 |
|
"D.melanogaster.1 G.AGCC.CU...AUGAUCGA\n" + |
| 73 |
|
"#=GR D.melanogaster.1 SS ................((((\n" + |
| 74 |
|
"D.melanogaster.2 C.AUUCAACU.UAUGAGGAU\n" + |
| 75 |
|
"#=GR D.melanogaster.2 SS ................((((\n" + |
| 76 |
|
"D.melanogaster.3 G.UGGCGCU..UAUGACGCA\n" + |
| 77 |
|
"#=GR D.melanogaster.3 SS (.(((...(....(((((((\n" + |
| 78 |
|
"//"; |
| 79 |
|
|
| 80 |
|
private static final String AA_SEQS_1 = |
| 81 |
|
">Seq1Name/5-8\n" + |
| 82 |
|
"K-QY--L\n" + |
| 83 |
|
">Seq2Name/12-15\n" + |
| 84 |
|
"-R-FP-W-\n"; |
| 85 |
|
|
| 86 |
|
private static final String CDNA_SEQS_1 = |
| 87 |
|
">Seq1Name/100-111\n" + |
| 88 |
|
"AC-GG--CUC-CAA-CT\n" + |
| 89 |
|
">Seq2Name/200-211\n" + |
| 90 |
|
"-CG-TTA--ACG---AAGT\n"; |
| 91 |
|
|
| 92 |
|
private static final String CDNA_SEQS_2 = |
| 93 |
|
">Seq1Name/50-61\n" + |
| 94 |
|
"GCTCGUCGTACT\n" + |
| 95 |
|
">Seq2Name/60-71\n" + |
| 96 |
|
"GGGTCAGGCAGT\n"; |
| 97 |
|
|
| 98 |
|
|
| 99 |
|
private AlignmentI al; |
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
@param |
| 105 |
|
@param |
| 106 |
|
|
| 107 |
|
@return |
| 108 |
|
@throws |
| 109 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 110 |
45 |
protected AlignmentI loadAlignment(final String data, FileFormatI format)... |
| 111 |
|
throws IOException |
| 112 |
|
{ |
| 113 |
45 |
AlignmentI a = new FormatAdapter().readFile(data, DataSourceType.PASTE, |
| 114 |
|
format); |
| 115 |
45 |
a.setDataset(null); |
| 116 |
45 |
return a; |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
@param |
| 123 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 124 |
0 |
public static void assertAlignmentDatasetRefs(AlignmentI alignment)... |
| 125 |
|
{ |
| 126 |
0 |
verifyAlignmentDatasetRefs(alignment, true, null); |
| 127 |
|
} |
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
@param |
| 133 |
|
@param |
| 134 |
|
|
| 135 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 136 |
1 |
public static void assertAlignmentDatasetRefs(AlignmentI alignment,... |
| 137 |
|
String message) |
| 138 |
|
{ |
| 139 |
1 |
verifyAlignmentDatasetRefs(alignment, true, message); |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
@param |
| 147 |
|
|
| 148 |
|
@param |
| 149 |
|
|
| 150 |
|
@param |
| 151 |
|
|
| 152 |
|
|
| 153 |
|
@return |
| 154 |
|
|
| |
|
| 62.5% |
Uncovered Elements: 45 (120) |
Complexity: 29 |
Complexity Density: 0.45 |
|
| 155 |
44 |
public static boolean verifyAlignmentDatasetRefs(AlignmentI alignment,... |
| 156 |
|
boolean raiseAssert, String message) |
| 157 |
|
{ |
| 158 |
44 |
if (message == null) |
| 159 |
|
{ |
| 160 |
24 |
message = ""; |
| 161 |
|
} |
| 162 |
44 |
if (alignment == null) |
| 163 |
|
{ |
| 164 |
0 |
if (raiseAssert) |
| 165 |
|
{ |
| 166 |
0 |
Assert.fail(message + "Alignment for verification was null."); |
| 167 |
|
} |
| 168 |
0 |
return false; |
| 169 |
|
} |
| 170 |
44 |
if (alignment.getDataset() != null) |
| 171 |
|
{ |
| 172 |
19 |
AlignmentI dataset = alignment.getDataset(); |
| 173 |
|
|
| 174 |
19 |
for (SequenceI seq : alignment.getSequences()) |
| 175 |
|
{ |
| 176 |
39 |
SequenceI seqds = seq.getDatasetSequence(); |
| 177 |
39 |
if (seqds.getDatasetSequence() != null) |
| 178 |
|
{ |
| 179 |
0 |
if (raiseAssert) |
| 180 |
|
{ |
| 181 |
0 |
Assert.fail(message |
| 182 |
|
+ " Alignment contained a sequence who's dataset sequence has a second dataset reference."); |
| 183 |
|
} |
| 184 |
0 |
return false; |
| 185 |
|
} |
| 186 |
39 |
if (dataset.findIndex(seqds) == -1) |
| 187 |
|
{ |
| 188 |
0 |
if (raiseAssert) |
| 189 |
|
{ |
| 190 |
0 |
Assert.fail(message |
| 191 |
|
+ " Alignment contained a sequence who's dataset sequence was not in the dataset."); |
| 192 |
|
} |
| 193 |
0 |
return false; |
| 194 |
|
} |
| 195 |
|
} |
| 196 |
19 |
return verifyAlignmentDatasetRefs(alignment.getDataset(), raiseAssert, |
| 197 |
|
message); |
| 198 |
|
} |
| 199 |
|
else |
| 200 |
|
{ |
| 201 |
25 |
int dsp = -1; |
| 202 |
|
|
| 203 |
25 |
for (SequenceI seqds : alignment.getSequences()) |
| 204 |
|
{ |
| 205 |
80 |
dsp++; |
| 206 |
80 |
if (seqds.getDatasetSequence() != null) |
| 207 |
|
{ |
| 208 |
2 |
if (raiseAssert) |
| 209 |
|
{ |
| 210 |
1 |
Assert.fail(message |
| 211 |
|
+ " Dataset contained a sequence with non-null dataset reference (ie not a dataset sequence!)"); |
| 212 |
|
} |
| 213 |
1 |
return false; |
| 214 |
|
} |
| 215 |
78 |
int foundp = alignment.findIndex(seqds); |
| 216 |
78 |
if (foundp != dsp) |
| 217 |
|
{ |
| 218 |
2 |
if (raiseAssert) |
| 219 |
|
{ |
| 220 |
1 |
Assert.fail(message |
| 221 |
|
+ " Dataset sequence array contains a reference at " |
| 222 |
|
+ dsp + " to a sequence first seen at " + foundp + " (" |
| 223 |
|
+ seqds.toString() + ")"); |
| 224 |
|
} |
| 225 |
1 |
return false; |
| 226 |
|
} |
| 227 |
76 |
if (seqds.getDBRefs() != null) |
| 228 |
|
{ |
| 229 |
28 |
for (DBRefEntry dbr : seqds.getDBRefs()) |
| 230 |
|
{ |
| 231 |
28 |
if (dbr.getMap() != null) |
| 232 |
|
{ |
| 233 |
28 |
SequenceI seqdbrmapto = dbr.getMap().getTo(); |
| 234 |
28 |
if (seqdbrmapto != null) |
| 235 |
|
{ |
| 236 |
28 |
if (seqdbrmapto.getDatasetSequence() != null) |
| 237 |
|
{ |
| 238 |
0 |
if (raiseAssert) |
| 239 |
|
{ |
| 240 |
0 |
Assert.fail(message |
| 241 |
|
+ " DBRefEntry for sequence in alignment had map to sequence which was not a dataset sequence"); |
| 242 |
|
} |
| 243 |
0 |
return false; |
| 244 |
|
|
| 245 |
|
} |
| 246 |
28 |
if (alignment.findIndex(dbr.getMap().getTo()) == -1) |
| 247 |
|
{ |
| 248 |
2 |
if (raiseAssert) |
| 249 |
|
{ |
| 250 |
1 |
Assert.fail(message + " DBRefEntry " + dbr |
| 251 |
|
+ " for sequence " + seqds |
| 252 |
|
+ " in alignment has map to sequence not in dataset"); |
| 253 |
|
} |
| 254 |
1 |
return false; |
| 255 |
|
} |
| 256 |
|
} |
| 257 |
|
} |
| 258 |
|
} |
| 259 |
|
} |
| 260 |
|
} |
| 261 |
|
|
| 262 |
19 |
if (alignment.getCodonFrames() != null) |
| 263 |
|
{ |
| 264 |
19 |
for (AlignedCodonFrame alc : alignment.getCodonFrames()) |
| 265 |
|
{ |
| 266 |
6 |
for (SequenceToSequenceMapping ssm : alc.getMappings()) |
| 267 |
|
{ |
| 268 |
6 |
if (ssm.getFromSeq().getDatasetSequence() != null) |
| 269 |
|
{ |
| 270 |
0 |
if (raiseAssert) |
| 271 |
|
{ |
| 272 |
0 |
Assert.fail(message |
| 273 |
|
+ " CodonFrame-SSM-FromSeq is not a dataset sequence"); |
| 274 |
|
} |
| 275 |
0 |
return false; |
| 276 |
|
} |
| 277 |
6 |
if (alignment.findIndex(ssm.getFromSeq()) == -1) |
| 278 |
|
{ |
| 279 |
|
|
| 280 |
2 |
if (raiseAssert) |
| 281 |
|
{ |
| 282 |
1 |
Assert.fail(message |
| 283 |
|
+ " CodonFrame-SSM-FromSeq is not contained in dataset"); |
| 284 |
|
} |
| 285 |
1 |
return false; |
| 286 |
|
} |
| 287 |
4 |
if (ssm.getMapping().getTo().getDatasetSequence() != null) |
| 288 |
|
{ |
| 289 |
0 |
if (raiseAssert) |
| 290 |
|
{ |
| 291 |
0 |
Assert.fail(message |
| 292 |
|
+ " CodonFrame-SSM-Mapping-ToSeq is not a dataset sequence"); |
| 293 |
|
} |
| 294 |
0 |
return false; |
| 295 |
|
} |
| 296 |
4 |
if (alignment.findIndex(ssm.getMapping().getTo()) == -1) |
| 297 |
|
{ |
| 298 |
|
|
| 299 |
0 |
if (raiseAssert) |
| 300 |
|
{ |
| 301 |
0 |
Assert.fail(message |
| 302 |
|
+ " CodonFrame-SSM-Mapping-ToSeq is not contained in dataset"); |
| 303 |
|
} |
| 304 |
0 |
return false; |
| 305 |
|
} |
| 306 |
|
} |
| 307 |
|
} |
| 308 |
|
} |
| 309 |
|
} |
| 310 |
17 |
return true; |
| 311 |
|
} |
| 312 |
|
|
| 313 |
|
|
| 314 |
|
|
| 315 |
|
|
| 316 |
|
|
| 317 |
|
@param |
| 318 |
|
@param |
| 319 |
|
@param |
| 320 |
|
|
| |
|
| 76.5% |
Uncovered Elements: 4 (17) |
Complexity: 5 |
Complexity Density: 0.38 |
|
| 321 |
12 |
private void assertVerifyAlignment(AlignmentI al, boolean expected,... |
| 322 |
|
String msg) |
| 323 |
|
{ |
| 324 |
12 |
if (expected) |
| 325 |
|
{ |
| 326 |
8 |
try |
| 327 |
|
{ |
| 328 |
|
|
| 329 |
8 |
Assert.assertTrue(verifyAlignmentDatasetRefs(al, true, null), |
| 330 |
|
"Valid test alignment failed when raiseAsserts enabled:" |
| 331 |
|
+ msg); |
| 332 |
|
} catch (AssertionError ae) |
| 333 |
|
{ |
| 334 |
0 |
ae.printStackTrace(); |
| 335 |
0 |
Assert.fail( |
| 336 |
|
"Valid test alignment raised assertion errors when raiseAsserts enabled: " |
| 337 |
|
+ msg, |
| 338 |
|
ae); |
| 339 |
|
} |
| 340 |
|
|
| 341 |
8 |
Assert.assertTrue(verifyAlignmentDatasetRefs(al, false, null), |
| 342 |
|
"Valid test alignment tested false when raiseAsserts disabled:" |
| 343 |
|
+ msg); |
| 344 |
|
} |
| 345 |
|
else |
| 346 |
|
{ |
| 347 |
4 |
boolean assertRaised = false; |
| 348 |
4 |
try |
| 349 |
|
{ |
| 350 |
4 |
verifyAlignmentDatasetRefs(al, true, null); |
| 351 |
|
} catch (AssertionError ae) |
| 352 |
|
{ |
| 353 |
|
|
| 354 |
4 |
assertRaised = true; |
| 355 |
|
} |
| 356 |
4 |
if (!assertRaised) |
| 357 |
|
{ |
| 358 |
0 |
Assert.fail( |
| 359 |
|
"Invalid test alignment passed when raiseAsserts enabled:" |
| 360 |
|
+ msg); |
| 361 |
|
} |
| 362 |
|
|
| 363 |
4 |
Assert.assertFalse(verifyAlignmentDatasetRefs(al, false, null), |
| 364 |
|
"Invalid test alignment tested true when raiseAsserts disabled:" |
| 365 |
|
+ msg); |
| 366 |
|
} |
| 367 |
|
} |
| 368 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (35) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
| 369 |
1 |
@Test(groups = { "Functional" })... |
| 370 |
|
public void testVerifyAlignmentDatasetRefs() |
| 371 |
|
{ |
| 372 |
1 |
SequenceI sq1 = new Sequence("sq1", "ASFDD"), |
| 373 |
|
sq2 = new Sequence("sq2", "TTTTTT"); |
| 374 |
|
|
| 375 |
|
|
| 376 |
1 |
Alignment al = new Alignment(new SequenceI[] { sq1, sq2 }); |
| 377 |
|
|
| 378 |
1 |
assertVerifyAlignment(al, true, "Simple valid alignment didn't verify"); |
| 379 |
|
|
| 380 |
|
|
| 381 |
1 |
sq1.setDatasetSequence(sq2); |
| 382 |
1 |
assertVerifyAlignment(al, false, |
| 383 |
|
"didn't detect dataset sequence with a dataset sequence reference."); |
| 384 |
|
|
| 385 |
1 |
sq1.setDatasetSequence(null); |
| 386 |
1 |
assertVerifyAlignment(al, true, |
| 387 |
|
"didn't reinstate validity after nulling dataset sequence dataset reference"); |
| 388 |
|
|
| 389 |
|
|
| 390 |
1 |
al.createDatasetAlignment(); |
| 391 |
1 |
assertNotNull(al.getDataset()); |
| 392 |
|
|
| 393 |
1 |
assertVerifyAlignment(al, true, |
| 394 |
|
"verify failed after createDatasetAlignment"); |
| 395 |
|
|
| 396 |
|
|
| 397 |
1 |
DBRefEntry dbrs1tos2 = new DBRefEntry("UNIPROT", "1", "Q111111"); |
| 398 |
1 |
dbrs1tos2 |
| 399 |
|
.setMap(new Mapping(sq2.getDatasetSequence(), new int[] |
| 400 |
|
{ 1, 5 }, new int[] { 2, 6 }, 1, 1)); |
| 401 |
1 |
sq1.getDatasetSequence().addDBRef(dbrs1tos2); |
| 402 |
1 |
assertVerifyAlignment(al, true, |
| 403 |
|
"verify failed after addition of valid DBRefEntry/map"); |
| 404 |
|
|
| 405 |
|
|
| 406 |
1 |
SequenceI sqout = new Sequence("sqout", "ututututucagcagcag"), |
| 407 |
|
sqnew = new Sequence("sqnew", "EEERRR"); |
| 408 |
1 |
DBRefEntry sqnewsqout = new DBRefEntry("ENAFOO", "1", "R000001"); |
| 409 |
1 |
sqnewsqout |
| 410 |
|
.setMap(new Mapping(sqout, new int[] |
| 411 |
|
{ 1, 6 }, new int[] { 1, 18 }, 1, 3)); |
| 412 |
1 |
al.getDataset().addSequence(sqnew); |
| 413 |
|
|
| 414 |
1 |
assertVerifyAlignment(al, true, |
| 415 |
|
"verify failed after addition of new sequence to dataset"); |
| 416 |
|
|
| 417 |
1 |
sqnew.addDBRef(sqnewsqout); |
| 418 |
1 |
assertVerifyAlignment(al, false, |
| 419 |
|
"verify passed when a dbref with map to sequence outside of dataset was added"); |
| 420 |
|
|
| 421 |
1 |
al.getDataset().addSequence(sqout); |
| 422 |
1 |
assertVerifyAlignment(al, true, |
| 423 |
|
"verify should have passed after adding dbref->to sequence in to dataset"); |
| 424 |
|
|
| 425 |
1 |
SequenceI sqanotherout = new Sequence("sqanotherout", |
| 426 |
|
"aggtutaggcagcagcag"); |
| 427 |
|
|
| 428 |
1 |
AlignedCodonFrame alc = new AlignedCodonFrame(); |
| 429 |
1 |
alc.addMap(sqanotherout, sqnew, |
| 430 |
|
new MapList(new int[] |
| 431 |
|
{ 1, 6 }, new int[] { 1, 18 }, 3, 1)); |
| 432 |
|
|
| 433 |
1 |
al.addCodonFrame(alc); |
| 434 |
1 |
Assert.assertEquals(al.getDataset().getCodonFrames().size(), 1); |
| 435 |
|
|
| 436 |
1 |
assertVerifyAlignment(al, false, |
| 437 |
|
"verify passed when alCodonFrame mapping to sequence outside of dataset was added"); |
| 438 |
|
|
| 439 |
1 |
al.getDataset().addSequence(sqanotherout); |
| 440 |
1 |
assertVerifyAlignment(al, true, |
| 441 |
|
"verify should have passed once all sequences involved in alCodonFrame were added to dataset"); |
| 442 |
1 |
al.getDataset().addSequence(sqanotherout); |
| 443 |
1 |
assertVerifyAlignment(al, false, |
| 444 |
|
"verify should have failed when a sequence was added twice to the dataset"); |
| 445 |
1 |
al.getDataset().deleteSequence(sqanotherout); |
| 446 |
1 |
assertVerifyAlignment(al, true, |
| 447 |
|
"verify should have passed after duplicate entry for sequence was removed"); |
| 448 |
|
} |
| 449 |
|
|
| 450 |
|
|
| 451 |
|
|
| 452 |
|
|
| 453 |
|
|
| 454 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 455 |
6 |
public static void assertDatasetIsNormalised(AlignmentI al)... |
| 456 |
|
{ |
| 457 |
6 |
assertDatasetIsNormalised(al, null); |
| 458 |
|
} |
| 459 |
|
|
| 460 |
|
|
| 461 |
|
|
| 462 |
|
|
| 463 |
|
|
| 464 |
|
@param |
| 465 |
|
|
| 466 |
|
@param |
| 467 |
|
|
| 468 |
|
|
| |
|
| 90.9% |
Uncovered Elements: 3 (33) |
Complexity: 9 |
Complexity Density: 0.53 |
|
| 469 |
12 |
public static void assertDatasetIsNormalised(AlignmentI al,... |
| 470 |
|
String message) |
| 471 |
|
{ |
| 472 |
12 |
if (al.getDataset() != null) |
| 473 |
|
{ |
| 474 |
6 |
assertDatasetIsNormalised(al.getDataset(), message); |
| 475 |
5 |
return; |
| 476 |
|
} |
| 477 |
|
|
| 478 |
|
|
| 479 |
|
|
| 480 |
6 |
List<SequenceI> seqSet = al.getSequences(); |
| 481 |
18 |
for (int p = 0; p < seqSet.size(); p++) |
| 482 |
|
{ |
| 483 |
13 |
SequenceI pSeq = seqSet.get(p); |
| 484 |
27 |
for (int q = p + 1; q < seqSet.size(); q++) |
| 485 |
|
{ |
| 486 |
15 |
SequenceI qSeq = seqSet.get(q); |
| 487 |
15 |
if (pSeq.getStart() != qSeq.getStart()) |
| 488 |
|
{ |
| 489 |
4 |
continue; |
| 490 |
|
} |
| 491 |
11 |
if (pSeq.getEnd() != qSeq.getEnd()) |
| 492 |
|
{ |
| 493 |
0 |
continue; |
| 494 |
|
} |
| 495 |
11 |
if (!pSeq.getName().equals(qSeq.getName())) |
| 496 |
|
{ |
| 497 |
7 |
continue; |
| 498 |
|
} |
| 499 |
4 |
if (!Arrays.equals(pSeq.getSequence(), qSeq.getSequence())) |
| 500 |
|
{ |
| 501 |
3 |
continue; |
| 502 |
|
} |
| 503 |
1 |
Assert.fail((message == null ? "" : message + " :") |
| 504 |
|
+ "Found similar sequences at position " + p + " and " + q |
| 505 |
|
+ "\n" + pSeq.toString()); |
| 506 |
|
} |
| 507 |
|
} |
| 508 |
|
} |
| 509 |
|
|
| |
|
| 80% |
Uncovered Elements: 7 (35) |
Complexity: 8 |
Complexity Density: 0.24 |
1PASS
|
|
| 510 |
1 |
@Test(groups = { "Functional", "Asserts" })... |
| 511 |
|
public void testAssertDatasetIsNormalised() |
| 512 |
|
{ |
| 513 |
1 |
Sequence sq1 = new Sequence("s1/1-4", "asdf"); |
| 514 |
1 |
Sequence sq1shift = new Sequence("s1/2-5", "asdf"); |
| 515 |
1 |
Sequence sq1seqd = new Sequence("s1/1-4", "asdt"); |
| 516 |
1 |
Sequence sq2 = new Sequence("s2/1-4", "asdf"); |
| 517 |
1 |
Sequence sq1dup = new Sequence("s1/1-4", "asdf"); |
| 518 |
|
|
| 519 |
1 |
Alignment al = new Alignment(new SequenceI[] { sq1 }); |
| 520 |
1 |
al.setDataset(null); |
| 521 |
|
|
| 522 |
1 |
try |
| 523 |
|
{ |
| 524 |
1 |
assertDatasetIsNormalised(al); |
| 525 |
|
} catch (AssertionError ae) |
| 526 |
|
{ |
| 527 |
0 |
Assert.fail("Single sequence should be valid normalised dataset."); |
| 528 |
|
} |
| 529 |
1 |
al.addSequence(sq2); |
| 530 |
1 |
try |
| 531 |
|
{ |
| 532 |
1 |
assertDatasetIsNormalised(al); |
| 533 |
|
} catch (AssertionError ae) |
| 534 |
|
{ |
| 535 |
0 |
Assert.fail( |
| 536 |
|
"Two different sequences should be valid normalised dataset."); |
| 537 |
|
} |
| 538 |
|
|
| 539 |
|
|
| 540 |
|
|
| 541 |
1 |
al.findName(sq2.getName()).setName("sq1"); |
| 542 |
1 |
try |
| 543 |
|
{ |
| 544 |
1 |
assertDatasetIsNormalised(al); |
| 545 |
|
} catch (AssertionError ae) |
| 546 |
|
{ |
| 547 |
0 |
Assert.fail( |
| 548 |
|
"Two different sequences in dataset, but same name in alignment, should be valid normalised dataset."); |
| 549 |
|
} |
| 550 |
|
|
| 551 |
1 |
al.addSequence(sq1seqd); |
| 552 |
1 |
try |
| 553 |
|
{ |
| 554 |
1 |
assertDatasetIsNormalised(al); |
| 555 |
|
} catch (AssertionError ae) |
| 556 |
|
{ |
| 557 |
0 |
Assert.fail( |
| 558 |
|
"sq1 and sq1 with different sequence should be distinct."); |
| 559 |
|
} |
| 560 |
|
|
| 561 |
1 |
al.addSequence(sq1shift); |
| 562 |
1 |
try |
| 563 |
|
{ |
| 564 |
1 |
assertDatasetIsNormalised(al); |
| 565 |
|
} catch (AssertionError ae) |
| 566 |
|
{ |
| 567 |
0 |
Assert.fail( |
| 568 |
|
"sq1 and sq1 with different start/end should be distinct."); |
| 569 |
|
} |
| 570 |
|
|
| 571 |
|
|
| 572 |
|
|
| 573 |
1 |
al.addSequence(sq1dup); |
| 574 |
1 |
boolean ssertRaised = false; |
| 575 |
1 |
try |
| 576 |
|
{ |
| 577 |
1 |
assertDatasetIsNormalised(al); |
| 578 |
|
|
| 579 |
|
} catch (AssertionError ae) |
| 580 |
|
{ |
| 581 |
1 |
ssertRaised = true; |
| 582 |
|
} |
| 583 |
1 |
if (!ssertRaised) |
| 584 |
|
{ |
| 585 |
0 |
Assert.fail("Expected identical sequence to raise exception."); |
| 586 |
|
} |
| 587 |
|
} |
| 588 |
|
|
| 589 |
|
|
| 590 |
|
|
| 591 |
|
|
| 592 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 593 |
32 |
@BeforeMethod(alwaysRun = true)... |
| 594 |
|
public void setUp() throws IOException |
| 595 |
|
{ |
| 596 |
32 |
al = loadAlignment(TEST_DATA, FileFormat.Stockholm); |
| 597 |
32 |
int i = 0; |
| 598 |
32 |
for (AlignmentAnnotation ann : al.getAlignmentAnnotation()) |
| 599 |
|
{ |
| 600 |
96 |
ann.setCalcId("CalcIdFor" + al.getSequenceAt(i).getName()); |
| 601 |
96 |
i++; |
| 602 |
|
} |
| 603 |
|
} |
| 604 |
|
|
| 605 |
|
|
| 606 |
|
|
| 607 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
| 608 |
1 |
@Test(groups = { "Functional" })... |
| 609 |
|
public void testFindAnnotation_byCalcId() |
| 610 |
|
{ |
| 611 |
1 |
Iterable<AlignmentAnnotation> anns = al |
| 612 |
|
.findAnnotation("CalcIdForD.melanogaster.2"); |
| 613 |
1 |
Iterator<AlignmentAnnotation> iter = anns.iterator(); |
| 614 |
1 |
assertTrue(iter.hasNext()); |
| 615 |
1 |
AlignmentAnnotation ann = iter.next(); |
| 616 |
1 |
assertEquals("D.melanogaster.2", ann.sequenceRef.getName()); |
| 617 |
1 |
assertFalse(iter.hasNext()); |
| 618 |
|
|
| 619 |
|
|
| 620 |
1 |
anns = al.findAnnotation("CalcIdForD.melanogaster.?"); |
| 621 |
1 |
assertFalse(iter.hasNext()); |
| 622 |
1 |
anns = al.findAnnotation(null); |
| 623 |
1 |
assertFalse(iter.hasNext()); |
| 624 |
|
} |
| 625 |
|
|
| 626 |
|
|
| 627 |
|
|
| 628 |
|
|
| 629 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (40) |
Complexity: 2 |
Complexity Density: 0.05 |
1PASS
|
|
| 630 |
1 |
@Test(groups = { "Functional" })... |
| 631 |
|
public void testFindAnnotations_bySeqLabelandorCalcId() |
| 632 |
|
{ |
| 633 |
|
|
| 634 |
|
|
| 635 |
|
|
| 636 |
|
|
| 637 |
|
|
| 638 |
|
|
| 639 |
1 |
Iterable<AlignmentAnnotation> anns = al.findAnnotations(null, |
| 640 |
|
"CalcIdForD.melanogaster.2", null); |
| 641 |
1 |
Iterator<AlignmentAnnotation> iter = anns.iterator(); |
| 642 |
1 |
assertTrue(iter.hasNext()); |
| 643 |
1 |
AlignmentAnnotation ann = iter.next(); |
| 644 |
1 |
assertEquals("D.melanogaster.2", ann.sequenceRef.getName()); |
| 645 |
1 |
assertFalse(iter.hasNext()); |
| 646 |
|
|
| 647 |
|
|
| 648 |
1 |
SequenceI rseq = ann.sequenceRef; |
| 649 |
|
|
| 650 |
|
|
| 651 |
1 |
anns = al.findAnnotations(rseq, null, null); |
| 652 |
1 |
iter = anns.iterator(); |
| 653 |
1 |
assertTrue(iter.hasNext()); |
| 654 |
1 |
ann = iter.next(); |
| 655 |
1 |
assertEquals("D.melanogaster.2", ann.sequenceRef.getName()); |
| 656 |
1 |
assertFalse(iter.hasNext()); |
| 657 |
|
|
| 658 |
|
|
| 659 |
1 |
anns = al.findAnnotations(null, "CalcIdForD.melanogaster.?", null); |
| 660 |
1 |
iter = anns.iterator(); |
| 661 |
1 |
assertFalse(iter.hasNext()); |
| 662 |
|
|
| 663 |
|
|
| 664 |
1 |
anns = al.findAnnotations(null, null, "Secondary Structure"); |
| 665 |
1 |
iter = anns.iterator(); |
| 666 |
1 |
assertTrue(iter.hasNext()); |
| 667 |
1 |
iter.next(); |
| 668 |
1 |
assertTrue(iter.hasNext()); |
| 669 |
1 |
iter.next(); |
| 670 |
1 |
assertTrue(iter.hasNext()); |
| 671 |
1 |
iter.next(); |
| 672 |
|
|
| 673 |
1 |
assertFalse(iter.hasNext()); |
| 674 |
|
|
| 675 |
|
|
| 676 |
|
|
| 677 |
1 |
SequenceI sqfound; |
| 678 |
1 |
anns = al.findAnnotations(sqfound = al.getSequenceAt(1), null, |
| 679 |
|
"Secondary Structure"); |
| 680 |
1 |
iter = anns.iterator(); |
| 681 |
1 |
assertTrue(iter.hasNext()); |
| 682 |
|
|
| 683 |
1 |
assertTrue(sqfound == iter.next().sequenceRef); |
| 684 |
1 |
assertFalse(iter.hasNext()); |
| 685 |
|
|
| 686 |
|
|
| 687 |
1 |
anns = al.findAnnotations(null, null, null); |
| 688 |
1 |
iter = anns.iterator(); |
| 689 |
1 |
int n = al.getAlignmentAnnotation().length; |
| 690 |
4 |
while (iter.hasNext()) |
| 691 |
|
{ |
| 692 |
3 |
n--; |
| 693 |
3 |
iter.next(); |
| 694 |
|
} |
| 695 |
1 |
assertTrue("Found " + n + " fewer annotations from search.", n == 0); |
| 696 |
|
} |
| 697 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 698 |
1 |
@Test(groups = { "Functional" })... |
| 699 |
|
public void testDeleteAllAnnotations_includingAutocalculated() |
| 700 |
|
{ |
| 701 |
1 |
AlignmentAnnotation aa = new AlignmentAnnotation("Consensus", |
| 702 |
|
"Consensus", 0.5); |
| 703 |
1 |
aa.autoCalculated = true; |
| 704 |
1 |
al.addAnnotation(aa); |
| 705 |
1 |
AlignmentAnnotation[] anns = al.getAlignmentAnnotation(); |
| 706 |
1 |
assertEquals("Wrong number of annotations before deleting", 4, |
| 707 |
|
anns.length); |
| 708 |
1 |
al.deleteAllAnnotations(true); |
| 709 |
1 |
assertEquals("Not all deleted", 0, al.getAlignmentAnnotation().length); |
| 710 |
|
} |
| 711 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 712 |
1 |
@Test(groups = { "Functional" })... |
| 713 |
|
public void testDeleteAllAnnotations_excludingAutocalculated() |
| 714 |
|
{ |
| 715 |
1 |
AlignmentAnnotation aa = new AlignmentAnnotation("Consensus", |
| 716 |
|
"Consensus", 0.5); |
| 717 |
1 |
aa.autoCalculated = true; |
| 718 |
1 |
al.addAnnotation(aa); |
| 719 |
1 |
AlignmentAnnotation[] anns = al.getAlignmentAnnotation(); |
| 720 |
1 |
assertEquals("Wrong number of annotations before deleting", 4, |
| 721 |
|
anns.length); |
| 722 |
1 |
al.deleteAllAnnotations(false); |
| 723 |
1 |
assertEquals("Not just one annotation left", 1, |
| 724 |
|
al.getAlignmentAnnotation().length); |
| 725 |
|
} |
| 726 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
| 727 |
1 |
@Test(groups = { "Functional" })... |
| 728 |
|
public void testIsSecondaryStructurePresent() |
| 729 |
|
{ |
| 730 |
|
|
| 731 |
1 |
assertTrue(al.isSecondaryStructurePresent()); |
| 732 |
1 |
al.deleteAllAnnotations(true); |
| 733 |
1 |
assertFalse(al.isSecondaryStructurePresent()); |
| 734 |
|
|
| 735 |
1 |
AlignmentAnnotation aa = new AlignmentAnnotation("Secondary Structure", |
| 736 |
|
"Secondary Structure", 0.5); |
| 737 |
1 |
Annotation ae[] = new Annotation[] { new Annotation("H", "H", 'H', 0f), |
| 738 |
|
new Annotation("H", "H", 'H', 0f), |
| 739 |
|
new Annotation("H", "H", 'H', 0f), |
| 740 |
|
new Annotation("H", "H", 'H', 0f) }; |
| 741 |
1 |
aa.annotations = ae; |
| 742 |
1 |
aa.validateRangeAndDisplay(); |
| 743 |
1 |
al.addAnnotation(aa); |
| 744 |
|
|
| 745 |
|
|
| 746 |
1 |
assertFalse(al.isSecondaryStructurePresent()); |
| 747 |
1 |
aa = new AlignmentAnnotation(aa); |
| 748 |
1 |
al.getSequenceAt(0).addAlignmentAnnotation(aa); |
| 749 |
1 |
al.addAnnotation(aa); |
| 750 |
|
|
| 751 |
|
|
| 752 |
1 |
assertTrue(al.isSecondaryStructurePresent()); |
| 753 |
|
} |
| 754 |
|
|
| 755 |
|
|
| 756 |
|
|
| 757 |
|
|
| 758 |
|
|
| 759 |
|
|
| 760 |
|
|
| 761 |
|
|
| 762 |
|
@throws |
| 763 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 764 |
1 |
@Test(groups = { "Functional" })... |
| 765 |
|
public void testAlignAs_dnaAsDna() throws IOException |
| 766 |
|
{ |
| 767 |
|
|
| 768 |
1 |
AlignmentI al1 = loadAlignment(CDNA_SEQS_1, FileFormat.Fasta); |
| 769 |
|
|
| 770 |
1 |
AlignmentI al2 = loadAlignment(CDNA_SEQS_2, FileFormat.Fasta); |
| 771 |
|
|
| 772 |
|
|
| 773 |
|
|
| 774 |
|
|
| 775 |
|
|
| 776 |
1 |
makeMappings(al1, al2); |
| 777 |
|
|
| 778 |
1 |
((Alignment) al2).alignAs(al1, false, true); |
| 779 |
1 |
assertEquals("GC-TC--GUC-GTACT", |
| 780 |
|
al2.getSequenceAt(0).getSequenceAsString()); |
| 781 |
1 |
assertEquals("-GG-GTC--AGG--CAGT", |
| 782 |
|
al2.getSequenceAt(1).getSequenceAsString()); |
| 783 |
|
} |
| 784 |
|
|
| 785 |
|
|
| 786 |
|
|
| 787 |
|
|
| 788 |
|
@throws |
| 789 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 790 |
1 |
@Test(groups = { "Functional" })... |
| 791 |
|
public void testAlignAs_proteinAsCdna() throws IOException |
| 792 |
|
{ |
| 793 |
|
|
| 794 |
1 |
AlignmentI al1 = loadAlignment(CDNA_SEQS_1, FileFormat.Fasta); |
| 795 |
1 |
AlignmentI al2 = loadAlignment(AA_SEQS_1, FileFormat.Fasta); |
| 796 |
1 |
makeMappings(al1, al2); |
| 797 |
|
|
| 798 |
|
|
| 799 |
1 |
al2.getCodonFrames().addAll(al1.getCodonFrames()); |
| 800 |
|
|
| 801 |
1 |
((Alignment) al2).alignAs(al1, false, true); |
| 802 |
1 |
assertEquals("K-Q-Y-L-", al2.getSequenceAt(0).getSequenceAsString()); |
| 803 |
1 |
assertEquals("-R-F-P-W", al2.getSequenceAt(1).getSequenceAsString()); |
| 804 |
|
} |
| 805 |
|
|
| 806 |
|
|
| 807 |
|
|
| 808 |
|
|
| 809 |
|
@throws |
| 810 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 811 |
1 |
@Test(groups = { "Functional" }, enabled = true)... |
| 812 |
|
|
| 813 |
|
public void testAlignAs_cdnaAsProtein() throws IOException |
| 814 |
|
{ |
| 815 |
|
|
| 816 |
|
|
| 817 |
|
|
| 818 |
1 |
AlignmentI al1 = loadAlignment(CDNA_SEQS_1, FileFormat.Fasta); |
| 819 |
1 |
AlignmentI al2 = loadAlignment(AA_SEQS_1, FileFormat.Fasta); |
| 820 |
1 |
makeMappings(al1, al2); |
| 821 |
|
|
| 822 |
|
|
| 823 |
|
|
| 824 |
|
|
| 825 |
1 |
((Alignment) al1).alignAs(al2, false, true); |
| 826 |
1 |
assertEquals("ACG---GCUCCA------ACT---", |
| 827 |
|
al1.getSequenceAt(0).getSequenceAsString()); |
| 828 |
1 |
assertEquals("---CGT---TAACGA---AGT---", |
| 829 |
|
al1.getSequenceAt(1).getSequenceAsString()); |
| 830 |
|
} |
| 831 |
|
|
| 832 |
|
|
| 833 |
|
|
| 834 |
|
|
| 835 |
|
@throws |
| 836 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 837 |
1 |
@Test(groups = { "Functional" }, enabled = true)... |
| 838 |
|
|
| 839 |
|
public void testAlignAs_cdnaAsProtein_singleSequence() throws IOException |
| 840 |
|
{ |
| 841 |
|
|
| 842 |
|
|
| 843 |
|
|
| 844 |
1 |
verifyAlignAs(">dna\nCAAaaa\n", ">protein\nQ-K\n", "CAA---aaa"); |
| 845 |
|
|
| 846 |
|
|
| 847 |
|
|
| 848 |
|
|
| 849 |
1 |
verifyAlignAs(">dna/5-10\nCAAaaa\n", ">protein/20-21\nQ-K\n", |
| 850 |
|
"CAA---aaa"); |
| 851 |
|
|
| 852 |
|
|
| 853 |
|
|
| 854 |
|
|
| 855 |
1 |
verifyAlignAs(">dna/10-18\nCA-Aa-aa--AGA\n", ">aa/6-8\n-Q-K--R\n", |
| 856 |
|
"---CAA---aaa------AGA"); |
| 857 |
|
} |
| 858 |
|
|
| 859 |
|
|
| 860 |
|
|
| 861 |
|
|
| 862 |
|
|
| 863 |
|
@param |
| 864 |
|
@param |
| 865 |
|
@param |
| 866 |
|
@throws |
| 867 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 868 |
3 |
public void verifyAlignAs(String fromSeqs, String toSeqs, String expected)... |
| 869 |
|
throws IOException |
| 870 |
|
{ |
| 871 |
|
|
| 872 |
|
|
| 873 |
|
|
| 874 |
|
|
| 875 |
3 |
AlignmentI al1 = loadAlignment(fromSeqs, FileFormat.Fasta); |
| 876 |
3 |
AlignmentI al2 = loadAlignment(toSeqs, FileFormat.Fasta); |
| 877 |
3 |
makeMappings(al1, al2); |
| 878 |
|
|
| 879 |
|
|
| 880 |
|
|
| 881 |
|
|
| 882 |
3 |
((Alignment) al1).alignAs(al2, false, true); |
| 883 |
3 |
assertEquals(expected, al1.getSequenceAt(0).getSequenceAsString()); |
| 884 |
|
} |
| 885 |
|
|
| 886 |
|
|
| 887 |
|
|
| 888 |
|
|
| 889 |
|
|
| 890 |
|
@param |
| 891 |
|
@param |
| 892 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 893 |
6 |
public void makeMappings(AlignmentI alFrom, AlignmentI alTo)... |
| 894 |
|
{ |
| 895 |
6 |
int ratio = (alFrom.isNucleotide() == alTo.isNucleotide() ? 1 : 3); |
| 896 |
|
|
| 897 |
6 |
AlignedCodonFrame acf = new AlignedCodonFrame(); |
| 898 |
|
|
| 899 |
15 |
for (int i = 0; i < alFrom.getHeight(); i++) |
| 900 |
|
{ |
| 901 |
9 |
SequenceI seqFrom = alFrom.getSequenceAt(i); |
| 902 |
9 |
SequenceI seqTo = alTo.getSequenceAt(i); |
| 903 |
9 |
MapList ml = new MapList( |
| 904 |
|
new int[] |
| 905 |
|
{ seqFrom.getStart(), seqFrom.getEnd() }, |
| 906 |
|
new int[] |
| 907 |
|
{ seqTo.getStart(), seqTo.getEnd() }, ratio, 1); |
| 908 |
9 |
acf.addMap(seqFrom, seqTo, ml); |
| 909 |
|
} |
| 910 |
|
|
| 911 |
|
|
| 912 |
|
|
| 913 |
|
|
| 914 |
|
|
| 915 |
6 |
alFrom.addCodonFrame(acf); |
| 916 |
6 |
alTo.addCodonFrame(acf); |
| 917 |
|
} |
| 918 |
|
|
| 919 |
|
|
| 920 |
|
|
| 921 |
|
|
| 922 |
|
|
| 923 |
|
@throws |
| 924 |
|
|
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
| 925 |
0 |
@Test(groups = { "Functional" }, enabled = false)... |
| 926 |
|
|
| 927 |
|
public void testAlignAs_dnaAsProtein_withIntrons() throws IOException |
| 928 |
|
{ |
| 929 |
|
|
| 930 |
|
|
| 931 |
|
|
| 932 |
0 |
String dna1 = "A-Aa-gG-GCC-cT-TT"; |
| 933 |
0 |
String dna2 = "c--CCGgg-TT--T-AA-A"; |
| 934 |
0 |
AlignmentI al1 = loadAlignment( |
| 935 |
|
">Dna1/6-17\n" + dna1 + "\n>Dna2/20-31\n" + dna2 + "\n", |
| 936 |
|
FileFormat.Fasta); |
| 937 |
0 |
AlignmentI al2 = loadAlignment( |
| 938 |
|
">Pep1/7-9\n-P--YK\n>Pep2/11-13\nG-T--F\n", FileFormat.Fasta); |
| 939 |
0 |
AlignedCodonFrame acf = new AlignedCodonFrame(); |
| 940 |
|
|
| 941 |
|
|
| 942 |
0 |
MapList ml1 = new MapList(new int[] { 6, 7, 10, 13, 15, 17 }, |
| 943 |
|
new int[] |
| 944 |
|
{ 7, 9 }, 3, 1); |
| 945 |
0 |
acf.addMap(al1.getSequenceAt(0), al2.getSequenceAt(0), ml1); |
| 946 |
0 |
MapList ml2 = new MapList(new int[] { 21, 23, 26, 31 }, |
| 947 |
|
new int[] |
| 948 |
|
{ 11, 13 }, 3, 1); |
| 949 |
0 |
acf.addMap(al1.getSequenceAt(1), al2.getSequenceAt(1), ml2); |
| 950 |
0 |
al2.addCodonFrame(acf); |
| 951 |
|
|
| 952 |
|
|
| 953 |
|
|
| 954 |
|
|
| 955 |
0 |
((Alignment) al1).alignAs(al2, false, false); |
| 956 |
0 |
assertEquals("---AAagG------GCCcTTT", |
| 957 |
|
al1.getSequenceAt(0).getSequenceAsString()); |
| 958 |
|
|
| 959 |
0 |
assertEquals("cCCGgg-TTT------AAA", |
| 960 |
|
al1.getSequenceAt(1).getSequenceAsString()); |
| 961 |
|
|
| 962 |
|
|
| 963 |
|
|
| 964 |
|
|
| 965 |
0 |
al1.getSequenceAt(0).setSequence(dna1); |
| 966 |
0 |
al1.getSequenceAt(1).setSequence(dna2); |
| 967 |
0 |
((Alignment) al1).alignAs(al2, true, true); |
| 968 |
|
|
| 969 |
|
|
| 970 |
|
|
| 971 |
0 |
assertEquals("---A-Aa-gG------GCC-cT-TT", |
| 972 |
|
al1.getSequenceAt(0).getSequenceAsString()); |
| 973 |
0 |
assertEquals("c--CCGgg-TT--T------AA-A", |
| 974 |
|
al1.getSequenceAt(1).getSequenceAsString()); |
| 975 |
|
} |
| 976 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
| 977 |
1 |
@Test(groups = "Functional")... |
| 978 |
|
public void testCopyConstructor() throws IOException |
| 979 |
|
{ |
| 980 |
1 |
AlignmentI protein = loadAlignment(AA_SEQS_1, FileFormat.Fasta); |
| 981 |
|
|
| 982 |
1 |
protein.setDataset(null); |
| 983 |
1 |
AlignedCodonFrame acf = new AlignedCodonFrame(); |
| 984 |
1 |
List<AlignedCodonFrame> acfList = Arrays |
| 985 |
|
.asList(new AlignedCodonFrame[] |
| 986 |
|
{ acf }); |
| 987 |
1 |
protein.getDataset().setCodonFrames(acfList); |
| 988 |
1 |
AlignmentI copy = new Alignment(protein); |
| 989 |
|
|
| 990 |
|
|
| 991 |
|
|
| 992 |
|
|
| 993 |
1 |
assertFalse(copy.getSequenceAt(0) == protein.getSequenceAt(0)); |
| 994 |
1 |
assertFalse(copy.getSequenceAt(1) == protein.getSequenceAt(1)); |
| 995 |
1 |
assertSame(copy.getSequenceAt(0).getDatasetSequence(), |
| 996 |
|
protein.getSequenceAt(0).getDatasetSequence()); |
| 997 |
1 |
assertSame(copy.getSequenceAt(1).getDatasetSequence(), |
| 998 |
|
protein.getSequenceAt(1).getDatasetSequence()); |
| 999 |
|
|
| 1000 |
|
|
| 1001 |
|
|
| 1002 |
1 |
assertNull(copy.getDataset()); |
| 1003 |
|
|
| 1004 |
|
|
| 1005 |
|
|
| 1006 |
|
|
| 1007 |
|
} |
| 1008 |
|
|
| 1009 |
|
|
| 1010 |
|
|
| 1011 |
|
|
| 1012 |
|
@throws |
| 1013 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
| 1014 |
1 |
@Test(groups = "Functional")... |
| 1015 |
|
public void testCreateDatasetAlignment() throws IOException |
| 1016 |
|
{ |
| 1017 |
1 |
AlignmentI protein = new FormatAdapter().readFile(AA_SEQS_1, |
| 1018 |
|
DataSourceType.PASTE, FileFormat.Fasta); |
| 1019 |
|
|
| 1020 |
|
|
| 1021 |
|
|
| 1022 |
|
|
| 1023 |
1 |
protein.getSequenceAt(0).createDatasetSequence(); |
| 1024 |
1 |
assertNotNull(protein.getSequenceAt(0).getDatasetSequence()); |
| 1025 |
1 |
assertNull(protein.getSequenceAt(1).getDatasetSequence()); |
| 1026 |
|
|
| 1027 |
|
|
| 1028 |
|
|
| 1029 |
|
|
| 1030 |
1 |
AlignedCodonFrame acf = new AlignedCodonFrame(); |
| 1031 |
1 |
protein.addCodonFrame(acf); |
| 1032 |
1 |
assertNull(protein.getDataset()); |
| 1033 |
1 |
assertTrue(protein.getCodonFrames().contains(acf)); |
| 1034 |
|
|
| 1035 |
|
|
| 1036 |
|
|
| 1037 |
|
|
| 1038 |
|
|
| 1039 |
|
|
| 1040 |
|
|
| 1041 |
1 |
((Alignment) protein).createDatasetAlignment(); |
| 1042 |
|
|
| 1043 |
1 |
AlignmentI ds = protein.getDataset(); |
| 1044 |
|
|
| 1045 |
|
|
| 1046 |
1 |
assertNotNull(protein.getSequenceAt(1).getDatasetSequence()); |
| 1047 |
|
|
| 1048 |
1 |
assertEquals(ds.getSequenceAt(0), |
| 1049 |
|
protein.getSequenceAt(0).getDatasetSequence()); |
| 1050 |
1 |
assertEquals(ds.getSequenceAt(1), |
| 1051 |
|
protein.getSequenceAt(1).getDatasetSequence()); |
| 1052 |
|
|
| 1053 |
|
|
| 1054 |
|
|
| 1055 |
1 |
assertTrue(protein.getCodonFrames().contains(acf)); |
| 1056 |
|
|
| 1057 |
1 |
assertTrue(ds.getCodonFrames().contains(acf)); |
| 1058 |
|
} |
| 1059 |
|
|
| 1060 |
|
|
| 1061 |
|
|
| 1062 |
|
|
| 1063 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
| 1064 |
1 |
@Test(groups = "Functional")... |
| 1065 |
|
public void testCreateDatasetAlignmentWithMappedToSeqs() |
| 1066 |
|
{ |
| 1067 |
|
|
| 1068 |
1 |
SequenceI sq1 = new Sequence("sq1", "A--SDF"); |
| 1069 |
1 |
SequenceI sq2 = new Sequence("sq2", "G--TRQ"); |
| 1070 |
|
|
| 1071 |
|
|
| 1072 |
1 |
DBRefEntry dbr = new DBRefEntry("SQ1", "", "sq3"); |
| 1073 |
1 |
SequenceI sq3 = new Sequence("sq3", "VWANG"); |
| 1074 |
1 |
dbr.setMap( |
| 1075 |
|
new Mapping(sq3, new MapList(new int[] |
| 1076 |
|
{ 1, 4 }, new int[] { 2, 5 }, 1, 1))); |
| 1077 |
1 |
sq1.addDBRef(dbr); |
| 1078 |
|
|
| 1079 |
1 |
SequenceI sq4 = new Sequence("sq4", "ERKWI"); |
| 1080 |
1 |
DBRefEntry dbr2 = new DBRefEntry("SQ2", "", "sq4"); |
| 1081 |
1 |
dbr2.setMap( |
| 1082 |
|
new Mapping(sq4, new MapList(new int[] |
| 1083 |
|
{ 1, 4 }, new int[] { 2, 5 }, 1, 1))); |
| 1084 |
1 |
sq2.addDBRef(dbr2); |
| 1085 |
|
|
| 1086 |
1 |
AlignedCodonFrame alc = new AlignedCodonFrame(); |
| 1087 |
1 |
alc.addMap(sq1, sq2, |
| 1088 |
|
new MapList(new int[] |
| 1089 |
|
{ 1, 4 }, new int[] { 1, 4 }, 1, 1)); |
| 1090 |
|
|
| 1091 |
1 |
AlignmentI protein = new Alignment(new SequenceI[] { sq1, sq2 }); |
| 1092 |
|
|
| 1093 |
|
|
| 1094 |
|
|
| 1095 |
|
|
| 1096 |
|
|
| 1097 |
|
|
| 1098 |
|
|
| 1099 |
|
|
| 1100 |
1 |
((Alignment) protein).createDatasetAlignment(); |
| 1101 |
|
|
| 1102 |
1 |
AlignmentI ds = protein.getDataset(); |
| 1103 |
|
|
| 1104 |
|
|
| 1105 |
|
|
| 1106 |
1 |
assertEquals(4, ds.getHeight()); |
| 1107 |
1 |
assertTrue(ds.getSequences().contains(sq1.getDatasetSequence())); |
| 1108 |
1 |
assertTrue(ds.getSequences().contains(sq2.getDatasetSequence())); |
| 1109 |
1 |
assertTrue(ds.getSequences().contains(sq3)); |
| 1110 |
1 |
assertTrue(ds.getSequences().contains(sq4)); |
| 1111 |
|
|
| 1112 |
|
|
| 1113 |
1 |
assertEquals(ds.getCodonFrame(sq1.getDatasetSequence()), |
| 1114 |
|
ds.getCodonFrame(sq2.getDatasetSequence())); |
| 1115 |
|
} |
| 1116 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
| 1117 |
1 |
@Test(groups = "Functional")... |
| 1118 |
|
public void testAddCodonFrame() |
| 1119 |
|
{ |
| 1120 |
1 |
AlignmentI align = new Alignment(new SequenceI[] {}); |
| 1121 |
1 |
AlignedCodonFrame acf = new AlignedCodonFrame(); |
| 1122 |
1 |
align.addCodonFrame(acf); |
| 1123 |
1 |
assertEquals(1, align.getCodonFrames().size()); |
| 1124 |
1 |
assertTrue(align.getCodonFrames().contains(acf)); |
| 1125 |
|
|
| 1126 |
1 |
align.addCodonFrame(acf); |
| 1127 |
1 |
assertEquals(1, align.getCodonFrames().size()); |
| 1128 |
|
|
| 1129 |
|
|
| 1130 |
1 |
((Alignment) align).createDatasetAlignment(); |
| 1131 |
1 |
assertSame(align.getCodonFrames(), align.getDataset().getCodonFrames()); |
| 1132 |
1 |
assertEquals(1, align.getCodonFrames().size()); |
| 1133 |
|
|
| 1134 |
1 |
AlignedCodonFrame acf2 = new AlignedCodonFrame(); |
| 1135 |
1 |
align.addCodonFrame(acf2); |
| 1136 |
1 |
assertTrue(align.getDataset().getCodonFrames().contains(acf)); |
| 1137 |
|
} |
| 1138 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
| 1139 |
1 |
@Test(groups = "Functional")... |
| 1140 |
|
public void testAddSequencePreserveDatasetIntegrity() |
| 1141 |
|
{ |
| 1142 |
1 |
Sequence seq = new Sequence("testSeq", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
| 1143 |
1 |
Alignment align = new Alignment(new SequenceI[] { seq }); |
| 1144 |
1 |
align.createDatasetAlignment(); |
| 1145 |
1 |
AlignmentI ds = align.getDataset(); |
| 1146 |
1 |
SequenceI copy = new Sequence(seq); |
| 1147 |
1 |
copy.insertCharAt(3, 5, '-'); |
| 1148 |
1 |
align.addSequence(copy); |
| 1149 |
1 |
Assert.assertEquals(align.getDataset().getHeight(), 1, |
| 1150 |
|
"Dataset shouldn't have more than one sequence."); |
| 1151 |
|
|
| 1152 |
1 |
Sequence seq2 = new Sequence("newtestSeq", |
| 1153 |
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
| 1154 |
1 |
align.addSequence(seq2); |
| 1155 |
1 |
Assert.assertEquals(align.getDataset().getHeight(), 2, |
| 1156 |
|
"Dataset should now have two sequences."); |
| 1157 |
|
|
| 1158 |
1 |
assertAlignmentDatasetRefs(align, |
| 1159 |
|
"addSequence broke dataset reference integrity"); |
| 1160 |
|
} |
| 1161 |
|
|
| 1162 |
|
|
| 1163 |
|
|
| 1164 |
|
|
| 1165 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (30) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
| 1166 |
1 |
@Test(groups = "Functional")... |
| 1167 |
|
public void testCreateDataset_updateDbrefMappings() |
| 1168 |
|
{ |
| 1169 |
1 |
SequenceI pep = new Sequence("pep", "ASD"); |
| 1170 |
1 |
SequenceI dna = new Sequence("dna", "aaaGCCTCGGATggg"); |
| 1171 |
1 |
SequenceI cds = new Sequence("cds", "GCCTCGGAT"); |
| 1172 |
|
|
| 1173 |
|
|
| 1174 |
1 |
DBRefEntry dbr = new DBRefEntry("UNIPROT", "", "pep"); |
| 1175 |
1 |
dbr.setMap( |
| 1176 |
|
new Mapping(pep, new MapList(new int[] |
| 1177 |
|
{ 4, 15 }, new int[] { 1, 4 }, 3, 1))); |
| 1178 |
1 |
dna.addDBRef(dbr); |
| 1179 |
|
|
| 1180 |
|
|
| 1181 |
1 |
DBRefEntry dbr2 = new DBRefEntry("UNIPROT", "", "pep"); |
| 1182 |
1 |
dbr2.setMap( |
| 1183 |
|
new Mapping(pep, new MapList(new int[] |
| 1184 |
|
{ 1, 12 }, new int[] { 1, 4 }, 3, 1))); |
| 1185 |
1 |
cds.addDBRef(dbr2); |
| 1186 |
|
|
| 1187 |
|
|
| 1188 |
1 |
DBRefEntry dbr3 = new DBRefEntry("EMBL", "", "dna"); |
| 1189 |
1 |
dbr3.setMap( |
| 1190 |
|
new Mapping(dna, new MapList(new int[] |
| 1191 |
|
{ 1, 4 }, new int[] { 4, 15 }, 1, 3))); |
| 1192 |
1 |
pep.addDBRef(dbr3); |
| 1193 |
|
|
| 1194 |
|
|
| 1195 |
1 |
DBRefEntry dbr4 = new DBRefEntry("EMBLCDS", "", "cds"); |
| 1196 |
1 |
dbr4.setMap( |
| 1197 |
|
new Mapping(cds, new MapList(new int[] |
| 1198 |
|
{ 1, 4 }, new int[] { 1, 12 }, 1, 3))); |
| 1199 |
1 |
pep.addDBRef(dbr4); |
| 1200 |
|
|
| 1201 |
1 |
AlignmentI protein = new Alignment(new SequenceI[] { pep }); |
| 1202 |
|
|
| 1203 |
|
|
| 1204 |
|
|
| 1205 |
|
|
| 1206 |
1 |
((Alignment) protein).createDatasetAlignment(); |
| 1207 |
|
|
| 1208 |
1 |
AlignmentI ds = protein.getDataset(); |
| 1209 |
|
|
| 1210 |
|
|
| 1211 |
1 |
assertEquals(3, ds.getHeight()); |
| 1212 |
1 |
assertTrue(ds.getSequences().contains(pep.getDatasetSequence())); |
| 1213 |
1 |
assertTrue(ds.getSequences().contains(dna)); |
| 1214 |
1 |
assertTrue(ds.getSequences().contains(cds)); |
| 1215 |
|
|
| 1216 |
|
|
| 1217 |
|
|
| 1218 |
|
|
| 1219 |
1 |
List<DBRefEntry> dbRefs = pep.getDBRefs(); |
| 1220 |
1 |
assertEquals(2, dbRefs.size()); |
| 1221 |
1 |
assertSame(dna, dbRefs.get(0).map.to); |
| 1222 |
1 |
assertSame(cds, dbRefs.get(1).map.to); |
| 1223 |
1 |
assertEquals(1, dna.getDBRefs().size()); |
| 1224 |
1 |
assertSame(pep.getDatasetSequence(), dna.getDBRefs().get(0).map.to); |
| 1225 |
1 |
assertEquals(1, cds.getDBRefs().size()); |
| 1226 |
1 |
assertSame(pep.getDatasetSequence(), cds.getDBRefs().get(0).map.to); |
| 1227 |
|
} |
| 1228 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (33) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
| 1229 |
1 |
@Test(groups = { "Functional" })... |
| 1230 |
|
public void testFindGroup() |
| 1231 |
|
{ |
| 1232 |
1 |
SequenceI seq1 = new Sequence("seq1", "ABCDEF---GHI"); |
| 1233 |
1 |
SequenceI seq2 = new Sequence("seq2", "---JKLMNO---"); |
| 1234 |
1 |
AlignmentI a = new Alignment(new SequenceI[] { seq1, seq2 }); |
| 1235 |
|
|
| 1236 |
1 |
assertNull(a.findGroup(null, 0)); |
| 1237 |
1 |
assertNull(a.findGroup(seq1, 1)); |
| 1238 |
1 |
assertNull(a.findGroup(seq1, -1)); |
| 1239 |
|
|
| 1240 |
|
|
| 1241 |
|
|
| 1242 |
|
|
| 1243 |
1 |
SequenceGroup sg1 = new SequenceGroup(); |
| 1244 |
1 |
sg1.addSequence(seq1, false); |
| 1245 |
1 |
sg1.setStartRes(3); |
| 1246 |
1 |
sg1.setEndRes(5); |
| 1247 |
1 |
a.addGroup(sg1); |
| 1248 |
|
|
| 1249 |
1 |
assertNull(a.findGroup(seq1, 2)); |
| 1250 |
1 |
assertNull(a.findGroup(seq1, 6)); |
| 1251 |
1 |
assertNull(a.findGroup(seq2, 5)); |
| 1252 |
1 |
assertSame(a.findGroup(seq1, 3), sg1); |
| 1253 |
1 |
assertSame(a.findGroup(seq1, 4), sg1); |
| 1254 |
1 |
assertSame(a.findGroup(seq1, 5), sg1); |
| 1255 |
|
|
| 1256 |
|
|
| 1257 |
|
|
| 1258 |
|
|
| 1259 |
|
|
| 1260 |
|
|
| 1261 |
1 |
SequenceGroup sg2 = new SequenceGroup(); |
| 1262 |
1 |
sg2.addSequence(seq1, false); |
| 1263 |
1 |
sg2.addSequence(seq2, false); |
| 1264 |
1 |
sg2.setStartRes(4); |
| 1265 |
1 |
sg2.setEndRes(7); |
| 1266 |
1 |
a.addGroup(sg2); |
| 1267 |
|
|
| 1268 |
1 |
assertNull(a.findGroup(seq1, 2)); |
| 1269 |
1 |
assertSame(a.findGroup(seq1, 3), sg1); |
| 1270 |
|
|
| 1271 |
|
|
| 1272 |
|
|
| 1273 |
|
|
| 1274 |
1 |
assertSame(a.findGroup(seq1, 4), sg1); |
| 1275 |
1 |
assertSame(a.findGroup(seq1, 5), sg1); |
| 1276 |
|
|
| 1277 |
|
|
| 1278 |
|
|
| 1279 |
|
|
| 1280 |
1 |
assertSame(a.findGroup(seq2, 4), sg2); |
| 1281 |
1 |
assertSame(a.findGroup(seq2, 5), sg2); |
| 1282 |
1 |
assertSame(a.findGroup(seq2, 6), sg2); |
| 1283 |
1 |
assertSame(a.findGroup(seq2, 7), sg2); |
| 1284 |
1 |
assertNull(a.findGroup(seq2, 3)); |
| 1285 |
1 |
assertNull(a.findGroup(seq2, 8)); |
| 1286 |
|
} |
| 1287 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
| 1288 |
1 |
@Test(groups = { "Functional" })... |
| 1289 |
|
public void testDeleteSequenceByIndex() |
| 1290 |
|
{ |
| 1291 |
|
|
| 1292 |
1 |
AlignmentGenerator gen = new AlignmentGenerator(false); |
| 1293 |
1 |
AlignmentI a = gen.generate(20, 15, 123, 5, 5); |
| 1294 |
|
|
| 1295 |
|
|
| 1296 |
1 |
int height = a.getAbsoluteHeight(); |
| 1297 |
1 |
a.deleteSequence(10); |
| 1298 |
1 |
assertEquals(a.getAbsoluteHeight(), height - 1); |
| 1299 |
|
|
| 1300 |
|
|
| 1301 |
1 |
a.deleteSequence(-1); |
| 1302 |
1 |
assertEquals(a.getAbsoluteHeight(), height - 1); |
| 1303 |
|
|
| 1304 |
|
|
| 1305 |
1 |
a.deleteSequence(14); |
| 1306 |
1 |
assertEquals(a.getAbsoluteHeight(), height - 1); |
| 1307 |
|
} |
| 1308 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
| 1309 |
1 |
@Test(groups = { "Functional" })... |
| 1310 |
|
public void testDeleteSequenceBySeq() |
| 1311 |
|
{ |
| 1312 |
|
|
| 1313 |
1 |
AlignmentGenerator gen = new AlignmentGenerator(false); |
| 1314 |
1 |
AlignmentI a = gen.generate(20, 15, 123, 5, 5); |
| 1315 |
|
|
| 1316 |
|
|
| 1317 |
1 |
int height = a.getAbsoluteHeight(); |
| 1318 |
1 |
SequenceI seq = a.getSequenceAt(10); |
| 1319 |
1 |
a.deleteSequence(seq); |
| 1320 |
1 |
assertEquals(a.getAbsoluteHeight(), height - 1); |
| 1321 |
|
|
| 1322 |
|
|
| 1323 |
1 |
seq = new Sequence("cds", "GCCTCGGAT"); |
| 1324 |
1 |
assertEquals(a.getAbsoluteHeight(), height - 1); |
| 1325 |
|
} |
| 1326 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
| 1327 |
1 |
@Test(groups = { "Functional" })... |
| 1328 |
|
public void testDeleteHiddenSequence() |
| 1329 |
|
{ |
| 1330 |
|
|
| 1331 |
1 |
AlignmentGenerator gen = new AlignmentGenerator(false); |
| 1332 |
1 |
AlignmentI a = gen.generate(20, 15, 123, 5, 5); |
| 1333 |
|
|
| 1334 |
|
|
| 1335 |
|
|
| 1336 |
1 |
int height = a.getAbsoluteHeight(); |
| 1337 |
1 |
SequenceI seq = a.getSequenceAt(2); |
| 1338 |
1 |
a.getHiddenSequences().hideSequence(seq); |
| 1339 |
1 |
assertEquals(a.getHiddenSequences().getSize(), 1); |
| 1340 |
1 |
a.deleteSequence(2); |
| 1341 |
1 |
assertEquals(a.getAbsoluteHeight(), height - 1); |
| 1342 |
1 |
assertEquals(a.getHiddenSequences().getSize(), 1); |
| 1343 |
|
|
| 1344 |
|
|
| 1345 |
|
|
| 1346 |
1 |
a.deleteSequence(10); |
| 1347 |
1 |
assertEquals(a.getAbsoluteHeight(), height - 2); |
| 1348 |
1 |
assertEquals(a.getHiddenSequences().getSize(), 1); |
| 1349 |
|
} |
| 1350 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 1351 |
1 |
@Test(... |
| 1352 |
|
groups = "Functional", |
| 1353 |
|
expectedExceptions = |
| 1354 |
|
{ IllegalArgumentException.class }) |
| 1355 |
|
public void testSetDataset_selfReference() |
| 1356 |
|
{ |
| 1357 |
1 |
SequenceI seq = new Sequence("a", "a"); |
| 1358 |
1 |
AlignmentI alignment = new Alignment(new SequenceI[] { seq }); |
| 1359 |
1 |
alignment.setDataset(alignment); |
| 1360 |
|
} |
| 1361 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
| 1362 |
1 |
@Test(groups = "Functional")... |
| 1363 |
|
public void testAppend() |
| 1364 |
|
{ |
| 1365 |
1 |
SequenceI seq = new Sequence("seq1", "FRMLPSRT-A--L-"); |
| 1366 |
1 |
AlignmentI alignment = new Alignment(new SequenceI[] { seq }); |
| 1367 |
1 |
alignment.setGapCharacter('-'); |
| 1368 |
1 |
SequenceI seq2 = new Sequence("seq1", "KP..L.FQII."); |
| 1369 |
1 |
AlignmentI alignment2 = new Alignment(new SequenceI[] { seq2 }); |
| 1370 |
1 |
alignment2.setGapCharacter('.'); |
| 1371 |
|
|
| 1372 |
1 |
alignment.append(alignment2); |
| 1373 |
|
|
| 1374 |
1 |
assertEquals('-', alignment.getGapCharacter()); |
| 1375 |
1 |
assertSame(seq, alignment.getSequenceAt(0)); |
| 1376 |
1 |
assertEquals("KP--L-FQII-", |
| 1377 |
|
alignment.getSequenceAt(1).getSequenceAsString()); |
| 1378 |
|
|
| 1379 |
|
|
| 1380 |
|
|
| 1381 |
|
} |
| 1382 |
|
|
| 1383 |
|
|
| 1384 |
|
|
| 1385 |
|
|
| 1386 |
|
|
| 1387 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 1388 |
1 |
@Test(groups = "Functional")... |
| 1389 |
|
public void testFindOrCreateForNullCalcId() |
| 1390 |
|
{ |
| 1391 |
1 |
SequenceI seq = new Sequence("seq1", "FRMLPSRT-A--L-"); |
| 1392 |
1 |
AlignmentI alignment = new Alignment(new SequenceI[] { seq }); |
| 1393 |
|
|
| 1394 |
1 |
AlignmentAnnotation ala = alignment.findOrCreateAnnotation( |
| 1395 |
|
"Temperature Factor", null, false, seq, null); |
| 1396 |
1 |
assertNotNull(ala); |
| 1397 |
1 |
assertEquals(seq, ala.sequenceRef); |
| 1398 |
1 |
assertEquals("", ala.calcId); |
| 1399 |
|
} |
| 1400 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (33) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
| 1401 |
1 |
@Test(groups = "Functional")... |
| 1402 |
|
public void testPropagateInsertions() |
| 1403 |
|
{ |
| 1404 |
|
|
| 1405 |
|
|
| 1406 |
1 |
AlignmentGenerator gen = new AlignmentGenerator(false); |
| 1407 |
1 |
AlignmentI al = gen.generate(25, 10, 1234, 0, 0); |
| 1408 |
|
|
| 1409 |
|
|
| 1410 |
1 |
SequenceI profileseq = al.getSequenceAt(0); |
| 1411 |
1 |
SequenceI gappedseq = new Sequence(profileseq); |
| 1412 |
1 |
gappedseq.insertCharAt(5, al.getGapCharacter()); |
| 1413 |
1 |
gappedseq.insertCharAt(6, al.getGapCharacter()); |
| 1414 |
1 |
gappedseq.insertCharAt(7, al.getGapCharacter()); |
| 1415 |
1 |
gappedseq.insertCharAt(8, al.getGapCharacter()); |
| 1416 |
|
|
| 1417 |
|
|
| 1418 |
1 |
al.getSequenceAt(3).deleteChars(2, 23); |
| 1419 |
1 |
al.getSequenceAt(4).deleteChars(2, 27); |
| 1420 |
1 |
al.getSequenceAt(5).deleteChars(10, 27); |
| 1421 |
|
|
| 1422 |
|
|
| 1423 |
1 |
SequenceI[] seqs = new SequenceI[1]; |
| 1424 |
1 |
seqs[0] = gappedseq; |
| 1425 |
1 |
AlignmentI newal = new Alignment(seqs); |
| 1426 |
1 |
HiddenColumns hidden = new HiddenColumns(); |
| 1427 |
1 |
hidden.hideColumns(15, 17); |
| 1428 |
|
|
| 1429 |
1 |
AlignmentView view = new AlignmentView(newal, hidden, null, true, false, |
| 1430 |
|
false); |
| 1431 |
|
|
| 1432 |
|
|
| 1433 |
1 |
Iterator<int[]> visible = hidden.getVisContigsIterator(0, 25, false); |
| 1434 |
1 |
int[] region = visible.next(); |
| 1435 |
1 |
assertEquals("[0, 14]", Arrays.toString(region)); |
| 1436 |
1 |
region = visible.next(); |
| 1437 |
1 |
assertEquals("[18, 24]", Arrays.toString(region)); |
| 1438 |
|
|
| 1439 |
|
|
| 1440 |
1 |
HiddenColumns result = al.propagateInsertions(profileseq, view); |
| 1441 |
|
|
| 1442 |
|
|
| 1443 |
1 |
visible = result.getVisContigsIterator(0, 25, false); |
| 1444 |
1 |
region = visible.next(); |
| 1445 |
1 |
assertEquals("[0, 10]", Arrays.toString(region)); |
| 1446 |
1 |
region = visible.next(); |
| 1447 |
1 |
assertEquals("[14, 24]", Arrays.toString(region)); |
| 1448 |
|
|
| 1449 |
|
|
| 1450 |
|
|
| 1451 |
1 |
assertFalse(Comparison.isGap(al.getSequenceAt(1).getSequence()[10])); |
| 1452 |
1 |
assertTrue(Comparison.isGap(al.getSequenceAt(1).getSequence()[11])); |
| 1453 |
1 |
assertTrue(Comparison.isGap(al.getSequenceAt(1).getSequence()[12])); |
| 1454 |
1 |
assertTrue(Comparison.isGap(al.getSequenceAt(1).getSequence()[13])); |
| 1455 |
1 |
assertFalse(Comparison.isGap(al.getSequenceAt(1).getSequence()[14])); |
| 1456 |
|
|
| 1457 |
|
} |
| 1458 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
| 1459 |
1 |
@Test(groups = "Functional")... |
| 1460 |
|
public void testPropagateInsertionsOverlap() |
| 1461 |
|
{ |
| 1462 |
|
|
| 1463 |
|
|
| 1464 |
|
|
| 1465 |
|
|
| 1466 |
1 |
AlignmentGenerator gen = new AlignmentGenerator(false); |
| 1467 |
1 |
AlignmentI al = gen.generate(20, 10, 1234, 0, 0); |
| 1468 |
|
|
| 1469 |
|
|
| 1470 |
1 |
SequenceI profileseq = al.getSequenceAt(0); |
| 1471 |
1 |
SequenceI gappedseq = new Sequence(profileseq); |
| 1472 |
1 |
gappedseq.insertCharAt(5, al.getGapCharacter()); |
| 1473 |
1 |
gappedseq.insertCharAt(6, al.getGapCharacter()); |
| 1474 |
1 |
gappedseq.insertCharAt(7, al.getGapCharacter()); |
| 1475 |
1 |
gappedseq.insertCharAt(8, al.getGapCharacter()); |
| 1476 |
|
|
| 1477 |
|
|
| 1478 |
1 |
SequenceI[] seqs = new SequenceI[1]; |
| 1479 |
1 |
seqs[0] = gappedseq; |
| 1480 |
1 |
AlignmentI newal = new Alignment(seqs); |
| 1481 |
|
|
| 1482 |
|
|
| 1483 |
1 |
HiddenColumns hidden = new HiddenColumns(); |
| 1484 |
1 |
hidden.hideColumns(7, 10); |
| 1485 |
|
|
| 1486 |
1 |
AlignmentView view = new AlignmentView(newal, hidden, null, true, false, |
| 1487 |
|
false); |
| 1488 |
|
|
| 1489 |
|
|
| 1490 |
1 |
Iterator<int[]> visible = hidden.getVisContigsIterator(0, 20, false); |
| 1491 |
1 |
int[] region = visible.next(); |
| 1492 |
1 |
assertEquals("[0, 6]", Arrays.toString(region)); |
| 1493 |
1 |
region = visible.next(); |
| 1494 |
1 |
assertEquals("[11, 19]", Arrays.toString(region)); |
| 1495 |
1 |
assertFalse(visible.hasNext()); |
| 1496 |
|
|
| 1497 |
|
|
| 1498 |
1 |
HiddenColumns result = al.propagateInsertions(profileseq, view); |
| 1499 |
|
|
| 1500 |
|
|
| 1501 |
1 |
visible = result.getVisContigsIterator(0, 20, false); |
| 1502 |
1 |
region = visible.next(); |
| 1503 |
1 |
assertEquals("[0, 4]", Arrays.toString(region)); |
| 1504 |
1 |
region = visible.next(); |
| 1505 |
1 |
assertEquals("[7, 19]", Arrays.toString(region)); |
| 1506 |
1 |
assertFalse(visible.hasNext()); |
| 1507 |
|
|
| 1508 |
|
|
| 1509 |
|
|
| 1510 |
1 |
assertFalse(Comparison.isGap(al.getSequenceAt(1).getSequence()[4])); |
| 1511 |
1 |
assertTrue(Comparison.isGap(al.getSequenceAt(1).getSequence()[5])); |
| 1512 |
1 |
assertTrue(Comparison.isGap(al.getSequenceAt(1).getSequence()[6])); |
| 1513 |
1 |
assertFalse(Comparison.isGap(al.getSequenceAt(1).getSequence()[7])); |
| 1514 |
|
} |
| 1515 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
| 1516 |
1 |
@Test(groups = { "Functional" })... |
| 1517 |
|
public void testPadGaps() |
| 1518 |
|
{ |
| 1519 |
1 |
SequenceI seq1 = new Sequence("seq1", "ABCDEF--"); |
| 1520 |
1 |
SequenceI seq2 = new Sequence("seq2", "-JKLMNO--"); |
| 1521 |
1 |
SequenceI seq3 = new Sequence("seq2", "-PQR"); |
| 1522 |
1 |
AlignmentI a = new Alignment(new SequenceI[] { seq1, seq2, seq3 }); |
| 1523 |
1 |
a.setGapCharacter('.'); |
| 1524 |
1 |
assertEquals("ABCDEF..", seq1.getSequenceAsString()); |
| 1525 |
1 |
a.padGaps(); |
| 1526 |
|
|
| 1527 |
1 |
assertEquals("ABCDEF.", seq1.getSequenceAsString()); |
| 1528 |
1 |
assertEquals(".JKLMNO", seq2.getSequenceAsString()); |
| 1529 |
1 |
assertEquals(".PQR...", seq3.getSequenceAsString()); |
| 1530 |
|
} |
| 1531 |
|
|
| 1532 |
|
|
| 1533 |
|
|
| 1534 |
|
|
| 1535 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
| 1536 |
1 |
@Test(groups = { "Functional" })... |
| 1537 |
|
public void testSetHiddenColumns() |
| 1538 |
|
{ |
| 1539 |
1 |
AlignmentI al = new Alignment(new SequenceI[] {}); |
| 1540 |
1 |
assertFalse(al.getHiddenColumns().hasHiddenColumns()); |
| 1541 |
|
|
| 1542 |
1 |
HiddenColumns hc = new HiddenColumns(); |
| 1543 |
1 |
assertFalse(al.setHiddenColumns(hc)); |
| 1544 |
1 |
assertSame(hc, al.getHiddenColumns()); |
| 1545 |
|
|
| 1546 |
1 |
hc.hideColumns(2, 4); |
| 1547 |
1 |
assertTrue(al.getHiddenColumns().hasHiddenColumns()); |
| 1548 |
|
|
| 1549 |
|
|
| 1550 |
|
|
| 1551 |
|
|
| 1552 |
1 |
HiddenColumns hc2 = new HiddenColumns(); |
| 1553 |
1 |
hc2.hideColumns(2, 4); |
| 1554 |
1 |
assertFalse(al.setHiddenColumns(hc2)); |
| 1555 |
1 |
assertSame(hc2, al.getHiddenColumns()); |
| 1556 |
|
|
| 1557 |
1 |
assertTrue(al.setHiddenColumns(null)); |
| 1558 |
1 |
assertNull(al.getHiddenColumns()); |
| 1559 |
1 |
assertTrue(al.setHiddenColumns(hc)); |
| 1560 |
1 |
assertSame(hc, al.getHiddenColumns()); |
| 1561 |
|
|
| 1562 |
1 |
al.getHiddenColumns().hideColumns(10, 12); |
| 1563 |
1 |
hc2.hideColumns(10, 12); |
| 1564 |
1 |
assertFalse(al.setHiddenColumns(hc2)); |
| 1565 |
|
|
| 1566 |
|
|
| 1567 |
|
|
| 1568 |
|
|
| 1569 |
|
|
| 1570 |
|
|
| 1571 |
|
|
| 1572 |
1 |
assertSame(hc2, al.getHiddenColumns()); |
| 1573 |
1 |
hc.hideColumns(15, 16); |
| 1574 |
1 |
hc.hideColumns(17, 18); |
| 1575 |
1 |
hc2.hideColumns(15, 18); |
| 1576 |
1 |
assertFalse(hc.equals(hc2)); |
| 1577 |
1 |
assertTrue(al.setHiddenColumns(hc)); |
| 1578 |
|
} |
| 1579 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 1580 |
1 |
@Test(groups = { "Functional" })... |
| 1581 |
|
public void testGetWidth() |
| 1582 |
|
{ |
| 1583 |
1 |
SequenceI seq1 = new Sequence("seq1", "ABCDEF--"); |
| 1584 |
1 |
SequenceI seq2 = new Sequence("seq2", "-JKLMNO--"); |
| 1585 |
1 |
SequenceI seq3 = new Sequence("seq2", "-PQR"); |
| 1586 |
1 |
AlignmentI a = new Alignment(new SequenceI[] { seq1, seq2, seq3 }); |
| 1587 |
|
|
| 1588 |
1 |
assertEquals(9, a.getWidth()); |
| 1589 |
|
|
| 1590 |
|
|
| 1591 |
1 |
a.getHiddenColumns().hideColumns(2, 5); |
| 1592 |
1 |
assertEquals(9, a.getWidth()); |
| 1593 |
|
} |
| 1594 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 1595 |
1 |
@Test(groups = { "Functional" })... |
| 1596 |
|
public void testGetVisibleWidth() |
| 1597 |
|
{ |
| 1598 |
1 |
SequenceI seq1 = new Sequence("seq1", "ABCDEF--"); |
| 1599 |
1 |
SequenceI seq2 = new Sequence("seq2", "-JKLMNO--"); |
| 1600 |
1 |
SequenceI seq3 = new Sequence("seq2", "-PQR"); |
| 1601 |
1 |
AlignmentI a = new Alignment(new SequenceI[] { seq1, seq2, seq3 }); |
| 1602 |
|
|
| 1603 |
1 |
assertEquals(9, a.getVisibleWidth()); |
| 1604 |
|
|
| 1605 |
|
|
| 1606 |
1 |
a.getHiddenColumns().hideColumns(2, 5); |
| 1607 |
1 |
assertEquals(5, a.getVisibleWidth()); |
| 1608 |
|
} |
| 1609 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
1PASS
|
|
| 1610 |
1 |
@Test(groups = { "Functional" })... |
| 1611 |
|
public void testGetContactMap() |
| 1612 |
|
{ |
| 1613 |
|
|
| 1614 |
|
|
| 1615 |
|
|
| 1616 |
|
|
| 1617 |
|
|
| 1618 |
|
|
| 1619 |
|
|
| 1620 |
|
|
| 1621 |
|
} |
| 1622 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 1623 |
1 |
@Test(groups = { "Functional" })... |
| 1624 |
|
public void testEquals() |
| 1625 |
|
{ |
| 1626 |
1 |
SequenceI seq1 = new Sequence("seq1", "ABCDEF--"); |
| 1627 |
1 |
SequenceI seq2 = new Sequence("seq2", "-JKLMNO--"); |
| 1628 |
1 |
SequenceI seq3 = new Sequence("seq2", "-PQR"); |
| 1629 |
1 |
AlignmentI a = new Alignment(new SequenceI[] { seq1, seq2, seq3 }); |
| 1630 |
1 |
a.setDataset(null); |
| 1631 |
1 |
assertEquals(a.getDataset(), a.getDataset()); |
| 1632 |
|
} |
| 1633 |
|
} |