1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.project; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.assertFalse; |
25 |
|
import static org.testng.Assert.assertNotNull; |
26 |
|
import static org.testng.Assert.assertNull; |
27 |
|
import static org.testng.Assert.assertSame; |
28 |
|
import static org.testng.Assert.assertTrue; |
29 |
|
|
30 |
|
import java.awt.Color; |
31 |
|
import java.io.File; |
32 |
|
import java.io.IOException; |
33 |
|
import java.util.ArrayList; |
34 |
|
import java.util.HashMap; |
35 |
|
import java.util.List; |
36 |
|
import java.util.Map; |
37 |
|
|
38 |
|
import javax.swing.JInternalFrame; |
39 |
|
|
40 |
|
import org.testng.Assert; |
41 |
|
import org.testng.AssertJUnit; |
42 |
|
import org.testng.annotations.BeforeClass; |
43 |
|
import org.testng.annotations.Test; |
44 |
|
|
45 |
|
import jalview.analysis.scoremodels.SimilarityParams; |
46 |
|
import jalview.api.AlignViewportI; |
47 |
|
import jalview.api.AlignmentViewPanel; |
48 |
|
import jalview.api.FeatureColourI; |
49 |
|
import jalview.api.ViewStyleI; |
50 |
|
import jalview.datamodel.AlignmentAnnotation; |
51 |
|
import jalview.datamodel.AlignmentI; |
52 |
|
import jalview.datamodel.DBRefEntry; |
53 |
|
import jalview.datamodel.GeneLocus; |
54 |
|
import jalview.datamodel.HiddenSequences; |
55 |
|
import jalview.datamodel.Mapping; |
56 |
|
import jalview.datamodel.PDBEntry; |
57 |
|
import jalview.datamodel.PDBEntry.Type; |
58 |
|
import jalview.datamodel.Sequence.DBModList; |
59 |
|
import jalview.datamodel.SequenceCollectionI; |
60 |
|
import jalview.datamodel.SequenceFeature; |
61 |
|
import jalview.datamodel.SequenceGroup; |
62 |
|
import jalview.datamodel.SequenceI; |
63 |
|
import jalview.datamodel.features.FeatureMatcher; |
64 |
|
import jalview.datamodel.features.FeatureMatcherSet; |
65 |
|
import jalview.datamodel.features.FeatureMatcherSetI; |
66 |
|
import jalview.gui.AlignFrame; |
67 |
|
import jalview.gui.AlignViewport; |
68 |
|
import jalview.gui.AlignmentPanel; |
69 |
|
import jalview.gui.Desktop; |
70 |
|
import jalview.gui.JvOptionPane; |
71 |
|
import jalview.gui.PCAPanel; |
72 |
|
import jalview.gui.PopupMenu; |
73 |
|
import jalview.gui.SliderPanel; |
74 |
|
import jalview.io.DataSourceType; |
75 |
|
import jalview.io.FileFormat; |
76 |
|
import jalview.io.FileLoader; |
77 |
|
import jalview.io.Jalview2xmlBase; |
78 |
|
import jalview.renderer.ResidueShaderI; |
79 |
|
import jalview.schemes.AnnotationColourGradient; |
80 |
|
import jalview.schemes.BuriedColourScheme; |
81 |
|
import jalview.schemes.ColourSchemeI; |
82 |
|
import jalview.schemes.ColourSchemeProperty; |
83 |
|
import jalview.schemes.FeatureColour; |
84 |
|
import jalview.schemes.JalviewColourScheme; |
85 |
|
import jalview.schemes.RNAHelicesColour; |
86 |
|
import jalview.schemes.StrandColourScheme; |
87 |
|
import jalview.schemes.TCoffeeColourScheme; |
88 |
|
import jalview.structure.StructureImportSettings; |
89 |
|
import jalview.util.MapList; |
90 |
|
import jalview.util.matcher.Condition; |
91 |
|
import jalview.viewmodel.AlignmentViewport; |
92 |
|
import jalview.viewmodel.seqfeatures.FeatureRendererModel; |
93 |
|
|
94 |
|
@Test(singleThreaded = true) |
|
|
| 97.1% |
Uncovered Elements: 18 (623) |
Complexity: 54 |
Complexity Density: 0.1 |
|
95 |
|
public class Jalview2xmlTests extends Jalview2xmlBase |
96 |
|
{ |
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
98 |
1 |
@Override... |
99 |
|
@BeforeClass(alwaysRun = true) |
100 |
|
public void setUpJvOptionPane() |
101 |
|
{ |
102 |
1 |
JvOptionPane.setInteractiveMode(false); |
103 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
104 |
|
} |
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
106 |
1 |
@Test(groups = { "Functional" })... |
107 |
|
public void testRNAStructureRecovery() throws Exception |
108 |
|
{ |
109 |
1 |
String inFile = "examples/RF00031_folded.stk"; |
110 |
1 |
String tfile = File.createTempFile("JalviewTest", ".jvp") |
111 |
|
.getAbsolutePath(); |
112 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile, |
113 |
|
DataSourceType.FILE); |
114 |
1 |
assertNotNull(af, "Didn't read input file " + inFile); |
115 |
1 |
int olddsann = countDsAnn(af.getViewport()); |
116 |
1 |
assertTrue(olddsann > 0, "Didn't find any dataset annotations"); |
117 |
1 |
af.changeColour_actionPerformed( |
118 |
|
JalviewColourScheme.RNAHelices.toString()); |
119 |
1 |
assertTrue( |
120 |
|
af.getViewport() |
121 |
|
.getGlobalColourScheme() instanceof RNAHelicesColour, |
122 |
|
"Couldn't apply RNA helices colourscheme"); |
123 |
1 |
af.saveAlignment(tfile, FileFormat.Jalview); |
124 |
1 |
assertTrue(af.isSaveAlignmentSuccessful(), |
125 |
|
"Failed to store as a project."); |
126 |
1 |
af.closeMenuItem_actionPerformed(true); |
127 |
1 |
af = null; |
128 |
1 |
af = new FileLoader().LoadFileWaitTillLoaded(tfile, |
129 |
|
DataSourceType.FILE); |
130 |
1 |
assertNotNull(af, "Failed to import new project"); |
131 |
1 |
int newdsann = countDsAnn(af.getViewport()); |
132 |
1 |
assertEquals(olddsann, newdsann, |
133 |
|
"Differing numbers of dataset sequence annotation\nOriginally " |
134 |
|
+ olddsann + " and now " + newdsann); |
135 |
1 |
System.out.println( |
136 |
|
"Read in same number of annotations as originally present (" |
137 |
|
+ olddsann + ")"); |
138 |
1 |
assertTrue( |
139 |
|
|
140 |
|
af.getViewport() |
141 |
|
.getGlobalColourScheme() instanceof RNAHelicesColour, |
142 |
|
"RNA helices colourscheme was not applied on import."); |
143 |
|
} |
144 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
145 |
1 |
@Test(groups = { "Functional" })... |
146 |
|
public void testTCoffeeScores() throws Exception |
147 |
|
{ |
148 |
1 |
String inFile = "examples/uniref50.fa", |
149 |
|
inAnnot = "examples/uniref50.score_ascii"; |
150 |
1 |
String tfile = File.createTempFile("JalviewTest", ".jvp") |
151 |
|
.getAbsolutePath(); |
152 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile, |
153 |
|
DataSourceType.FILE); |
154 |
1 |
assertNotNull(af, "Didn't read input file " + inFile); |
155 |
1 |
af.loadJalviewDataFile(inAnnot, DataSourceType.FILE, null, null); |
156 |
1 |
AlignViewport viewport = af.getViewport(); |
157 |
1 |
assertSame(viewport.getGlobalColourScheme().getClass(), |
158 |
|
TCoffeeColourScheme.class, "Didn't set T-coffee colourscheme"); |
159 |
1 |
assertNotNull( |
160 |
|
ColourSchemeProperty.getColourScheme(viewport, |
161 |
|
viewport.getAlignment(), |
162 |
|
viewport.getGlobalColourScheme() |
163 |
|
.getSchemeName()), |
164 |
|
"Recognise T-Coffee score from string"); |
165 |
|
|
166 |
1 |
af.saveAlignment(tfile, FileFormat.Jalview); |
167 |
1 |
assertTrue(af.isSaveAlignmentSuccessful(), |
168 |
|
"Failed to store as a project."); |
169 |
1 |
af.closeMenuItem_actionPerformed(true); |
170 |
1 |
af = null; |
171 |
1 |
af = new FileLoader().LoadFileWaitTillLoaded(tfile, |
172 |
|
DataSourceType.FILE); |
173 |
1 |
assertNotNull(af, "Failed to import new project"); |
174 |
1 |
assertSame(af.getViewport().getGlobalColourScheme().getClass(), |
175 |
|
TCoffeeColourScheme.class, |
176 |
|
"Didn't set T-coffee colourscheme for imported project."); |
177 |
1 |
System.out.println( |
178 |
|
"T-Coffee score shading successfully recovered from project."); |
179 |
|
} |
180 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (56) |
Complexity: 9 |
Complexity Density: 0.19 |
1PASS
|
|
181 |
1 |
@Test(groups = { "Functional" })... |
182 |
|
public void testColourByAnnotScores() throws Exception |
183 |
|
{ |
184 |
1 |
String inFile = "examples/uniref50.fa", |
185 |
|
inAnnot = "examples/testdata/uniref50_iupred.jva"; |
186 |
1 |
String tfile = File.createTempFile("JalviewTest", ".jvp") |
187 |
|
.getAbsolutePath(); |
188 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile, |
189 |
|
DataSourceType.FILE); |
190 |
1 |
assertNotNull(af, "Didn't read input file " + inFile); |
191 |
1 |
af.loadJalviewDataFile(inAnnot, DataSourceType.FILE, null, null); |
192 |
1 |
AlignmentAnnotation[] aa = af.getViewport().getAlignment() |
193 |
|
.getSequenceAt(0).getAnnotation("IUPredWS (Short)"); |
194 |
1 |
assertTrue( |
195 |
|
|
196 |
|
aa != null && aa.length > 0, |
197 |
|
"Didn't find any IUPred annotation to use to shade alignment."); |
198 |
1 |
AnnotationColourGradient cs = new AnnotationColourGradient(aa[0], null, |
199 |
|
AnnotationColourGradient.ABOVE_THRESHOLD); |
200 |
1 |
AnnotationColourGradient gcs = new AnnotationColourGradient(aa[0], null, |
201 |
|
AnnotationColourGradient.BELOW_THRESHOLD); |
202 |
1 |
cs.setSeqAssociated(true); |
203 |
1 |
gcs.setSeqAssociated(true); |
204 |
1 |
af.changeColour(cs); |
205 |
1 |
SequenceGroup sg = new SequenceGroup(); |
206 |
1 |
sg.setStartRes(57); |
207 |
1 |
sg.setEndRes(92); |
208 |
1 |
sg.cs.setColourScheme(gcs); |
209 |
1 |
af.getViewport().getAlignment().addGroup(sg); |
210 |
1 |
sg.addSequence(af.getViewport().getAlignment().getSequenceAt(1), false); |
211 |
1 |
sg.addSequence(af.getViewport().getAlignment().getSequenceAt(2), true); |
212 |
1 |
af.alignPanel.alignmentChanged(); |
213 |
1 |
af.saveAlignment(tfile, FileFormat.Jalview); |
214 |
1 |
assertTrue(af.isSaveAlignmentSuccessful(), |
215 |
|
"Failed to store as a project."); |
216 |
1 |
af.closeMenuItem_actionPerformed(true); |
217 |
1 |
af = null; |
218 |
1 |
af = new FileLoader().LoadFileWaitTillLoaded(tfile, |
219 |
|
DataSourceType.FILE); |
220 |
1 |
assertNotNull(af, "Failed to import new project"); |
221 |
|
|
222 |
|
|
223 |
|
|
224 |
1 |
ColourSchemeI _rcs = af.getViewport().getGlobalColourScheme(); |
225 |
1 |
ColourSchemeI _rgcs = af.getViewport().getAlignment().getGroups().get(0) |
226 |
|
.getColourScheme(); |
227 |
1 |
assertNotNull(_rcs, "Didn't recover global colourscheme"); |
228 |
1 |
assertTrue(_rcs instanceof AnnotationColourGradient, |
229 |
|
"Didn't recover annotation colour global scheme"); |
230 |
1 |
AnnotationColourGradient __rcs = (AnnotationColourGradient) _rcs; |
231 |
1 |
assertTrue(__rcs.isSeqAssociated(), |
232 |
|
"Annotation colourscheme wasn't sequence associated"); |
233 |
|
|
234 |
1 |
boolean diffseqcols = false, diffgseqcols = false; |
235 |
1 |
SequenceI[] sqs = af.getViewport().getAlignment().getSequencesArray(); |
236 |
1 |
for (int p = 0, pSize = af.getViewport().getAlignment() |
237 |
158 |
.getWidth(); p < pSize && (!diffseqcols || !diffgseqcols); p++) |
238 |
|
{ |
239 |
157 |
if (_rcs.findColour(sqs[0].getCharAt(p), p, sqs[0], null, 0f) != _rcs |
240 |
|
.findColour(sqs[5].getCharAt(p), p, sqs[5], null, 0f)) |
241 |
|
{ |
242 |
20 |
diffseqcols = true; |
243 |
|
} |
244 |
|
} |
245 |
1 |
assertTrue(diffseqcols, "Got Different sequence colours"); |
246 |
1 |
System.out.println( |
247 |
|
"Per sequence colourscheme (Background) successfully applied and recovered."); |
248 |
|
|
249 |
1 |
assertNotNull(_rgcs, "Didn't recover group colourscheme"); |
250 |
1 |
assertTrue(_rgcs instanceof AnnotationColourGradient, |
251 |
|
"Didn't recover annotation colour group colourscheme"); |
252 |
1 |
__rcs = (AnnotationColourGradient) _rgcs; |
253 |
1 |
assertTrue(__rcs.isSeqAssociated(), |
254 |
|
"Group Annotation colourscheme wasn't sequence associated"); |
255 |
|
|
256 |
1 |
for (int p = 0, pSize = af.getViewport().getAlignment() |
257 |
14 |
.getWidth(); p < pSize && (!diffseqcols || !diffgseqcols); p++) |
258 |
|
{ |
259 |
13 |
if (_rgcs.findColour(sqs[1].getCharAt(p), p, sqs[1], null, |
260 |
|
0f) != _rgcs.findColour(sqs[2].getCharAt(p), p, sqs[2], null, |
261 |
|
0f)) |
262 |
|
{ |
263 |
1 |
diffgseqcols = true; |
264 |
|
} |
265 |
|
} |
266 |
1 |
assertTrue(diffgseqcols, "Got Different group sequence colours"); |
267 |
1 |
System.out.println( |
268 |
|
"Per sequence (Group) colourscheme successfully applied and recovered."); |
269 |
|
} |
270 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
271 |
1 |
@Test(groups = { "Functional" })... |
272 |
|
public void gatherViewsHere() throws Exception |
273 |
|
{ |
274 |
1 |
int origCount = Desktop.getAlignFrames() == null ? 0 |
275 |
|
: Desktop.getAlignFrames().length; |
276 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
277 |
|
"examples/exampleFile_2_7.jar", DataSourceType.FILE); |
278 |
1 |
assertNotNull(af, "Didn't read in the example file correctly."); |
279 |
1 |
assertTrue(Desktop.getAlignFrames().length == 1 + origCount, |
280 |
|
"Didn't gather the views in the example file."); |
281 |
|
|
282 |
|
} |
283 |
|
|
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
@throws |
288 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
289 |
1 |
@Test(groups = { "Functional" })... |
290 |
|
public void noDuplicatePdbMappingsMade() throws Exception |
291 |
|
{ |
292 |
1 |
StructureImportSettings.setProcessSecondaryStructure(true); |
293 |
1 |
StructureImportSettings.setVisibleChainAnnotation(true); |
294 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
295 |
|
"examples/exampleFile_2_7.jar", DataSourceType.FILE); |
296 |
1 |
assertNotNull(af, "Didn't read in the example file correctly."); |
297 |
|
|
298 |
|
|
299 |
|
|
300 |
1 |
String pdbFile = af.getCurrentView().getStructureSelectionManager() |
301 |
|
.findFileForPDBId("1A70"); |
302 |
1 |
assertEquals( |
303 |
|
af.getCurrentView().getStructureSelectionManager() |
304 |
|
.getMapping(pdbFile).length, |
305 |
|
2, "Expected only two mappings for 1A70"); |
306 |
|
|
307 |
|
} |
308 |
|
|
|
|
| 94.6% |
Uncovered Elements: 2 (37) |
Complexity: 6 |
Complexity Density: 0.21 |
1PASS
|
|
309 |
1 |
@Test(groups = { "Functional" })... |
310 |
|
public void viewRefPdbAnnotation() throws Exception |
311 |
|
{ |
312 |
1 |
StructureImportSettings.setProcessSecondaryStructure(true); |
313 |
1 |
StructureImportSettings.setVisibleChainAnnotation(true); |
314 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
315 |
|
"examples/exampleFile_2_7.jar", DataSourceType.FILE); |
316 |
1 |
assertNotNull(af, "Didn't read in the example file correctly."); |
317 |
1 |
AlignmentViewPanel sps = null; |
318 |
1 |
for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels()) |
319 |
|
{ |
320 |
5 |
if ("Spinach Feredoxin Structure".equals(ap.getViewName())) |
321 |
|
{ |
322 |
1 |
sps = ap; |
323 |
1 |
break; |
324 |
|
} |
325 |
|
} |
326 |
1 |
assertNotNull(sps, "Couldn't find the structure view"); |
327 |
1 |
AlignmentAnnotation refan = null; |
328 |
1 |
for (AlignmentAnnotation ra : sps.getAlignment() |
329 |
|
.getAlignmentAnnotation()) |
330 |
|
{ |
331 |
1 |
if (ra.graph != 0) |
332 |
|
{ |
333 |
1 |
refan = ra; |
334 |
1 |
break; |
335 |
|
} |
336 |
|
} |
337 |
1 |
assertNotNull(refan, "Annotation secondary structure not found."); |
338 |
1 |
SequenceI sq = sps.getAlignment().findName("1A70|"); |
339 |
1 |
assertNotNull(sq, "Couldn't find 1a70 null chain"); |
340 |
|
|
341 |
|
|
342 |
1 |
assertNotNull(sq.getDatasetSequence().getAnnotation(), |
343 |
|
"1a70 has no annotation"); |
344 |
1 |
for (AlignmentAnnotation ala : sq.getDatasetSequence().getAnnotation()) |
345 |
|
{ |
346 |
2 |
AlignmentAnnotation alaa; |
347 |
2 |
sq.addAlignmentAnnotation(alaa = new AlignmentAnnotation(ala)); |
348 |
2 |
alaa.adjustForAlignment(); |
349 |
2 |
if (ala.graph == refan.graph) |
350 |
|
{ |
351 |
98 |
for (int p = 0; p < ala.annotations.length; p++) |
352 |
|
{ |
353 |
97 |
sq.findPosition(p); |
354 |
97 |
try |
355 |
|
{ |
356 |
97 |
assertTrue((alaa.annotations[p] == null |
357 |
|
&& refan.annotations[p] == null) |
358 |
|
|| alaa.annotations[p].value == refan.annotations[p].value, |
359 |
|
"Mismatch at alignment position " + p); |
360 |
|
} catch (NullPointerException q) |
361 |
|
{ |
362 |
0 |
Assert.fail("Mismatch of alignment annotations at position " + p |
363 |
|
+ " Ref seq ann: " + refan.annotations[p] |
364 |
|
+ " alignment " + alaa.annotations[p]); |
365 |
|
} |
366 |
|
} |
367 |
|
} |
368 |
|
} |
369 |
|
|
370 |
|
} |
371 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 3 |
Complexity Density: 0.19 |
1PASS
|
|
372 |
1 |
@Test(groups = { "Functional" })... |
373 |
|
public void testCopyViewSettings() throws Exception |
374 |
|
{ |
375 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
376 |
|
"examples/exampleFile_2_7.jar", DataSourceType.FILE); |
377 |
1 |
assertNotNull(af, "Didn't read in the example file correctly."); |
378 |
1 |
AlignmentViewPanel sps = null, groups = null; |
379 |
1 |
for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels()) |
380 |
|
{ |
381 |
5 |
if ("Spinach Feredoxin Structure".equals(ap.getViewName())) |
382 |
|
{ |
383 |
1 |
sps = ap; |
384 |
|
} |
385 |
5 |
if (ap.getViewName().contains("MAFFT")) |
386 |
|
{ |
387 |
1 |
groups = ap; |
388 |
|
} |
389 |
|
} |
390 |
1 |
assertNotNull(sps, "Couldn't find the structure view"); |
391 |
1 |
assertNotNull(groups, "Couldn't find the MAFFT view"); |
392 |
|
|
393 |
1 |
ViewStyleI structureStyle = sps.getAlignViewport().getViewStyle(); |
394 |
1 |
ViewStyleI groupStyle = groups.getAlignViewport().getViewStyle(); |
395 |
1 |
AssertJUnit.assertFalse(structureStyle.sameStyle(groupStyle)); |
396 |
|
|
397 |
1 |
groups.getAlignViewport().setViewStyle(structureStyle); |
398 |
1 |
AssertJUnit.assertFalse( |
399 |
|
groupStyle.sameStyle(groups.getAlignViewport().getViewStyle())); |
400 |
1 |
Assert.assertTrue(structureStyle |
401 |
|
.sameStyle(groups.getAlignViewport().getViewStyle())); |
402 |
|
|
403 |
|
} |
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
@throws |
409 |
|
|
|
|
| 81.8% |
Uncovered Elements: 4 (22) |
Complexity: 4 |
Complexity Density: 0.2 |
1PASS
|
|
410 |
1 |
@Test(groups = { "Functional" }, enabled = true)... |
411 |
|
public void testStoreAndRecoverExpandedviews() throws Exception |
412 |
|
{ |
413 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
414 |
|
|
415 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
416 |
|
"examples/exampleFile_2_7.jar", DataSourceType.FILE); |
417 |
1 |
Assert.assertEquals(Desktop.getAlignFrames().length, 1); |
418 |
1 |
String afid = af.getViewport().getSequenceSetId(); |
419 |
|
|
420 |
|
|
421 |
|
|
422 |
1 |
assertSame(af, Desktop.getAlignFrameFor(af.getViewport()), |
423 |
|
"Jalview2XML.loadAlignFrame() didn't return correct AlignFrame reference for multiple view window"); |
424 |
|
|
425 |
1 |
Desktop.explodeViews(af); |
426 |
|
|
427 |
1 |
int oldviews = Desktop.getAlignFrames().length; |
428 |
1 |
Assert.assertEquals(Desktop.getAlignFrames().length, |
429 |
|
Desktop.getAlignmentPanels(afid).length); |
430 |
1 |
File tfile = File.createTempFile("testStoreAndRecoverExpanded", ".jvp"); |
431 |
1 |
try |
432 |
|
{ |
433 |
1 |
new Jalview2XML(false).saveState(tfile); |
434 |
|
} catch (Error e) |
435 |
|
{ |
436 |
0 |
Assert.fail("Didn't save the expanded view state", e); |
437 |
|
} catch (Exception e) |
438 |
|
{ |
439 |
0 |
Assert.fail("Didn't save the expanded view state", e); |
440 |
|
} |
441 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
442 |
1 |
if (Desktop.getAlignFrames() != null) |
443 |
|
{ |
444 |
0 |
Assert.assertEquals(Desktop.getAlignFrames().length, 0); |
445 |
|
} |
446 |
1 |
af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(), |
447 |
|
DataSourceType.FILE); |
448 |
1 |
Assert.assertNotNull(af); |
449 |
1 |
Assert.assertEquals(Desktop.getAlignFrames().length, |
450 |
|
Desktop.getAlignmentPanels( |
451 |
|
af.getViewport().getSequenceSetId()).length); |
452 |
1 |
Assert.assertEquals( |
453 |
|
Desktop.getAlignmentPanels( |
454 |
|
af.getViewport().getSequenceSetId()).length, |
455 |
|
oldviews); |
456 |
|
} |
457 |
|
|
458 |
|
|
459 |
|
|
460 |
|
|
461 |
|
|
462 |
|
@throws |
463 |
|
|
|
|
| 91.2% |
Uncovered Elements: 3 (34) |
Complexity: 3 |
Complexity Density: 0.09 |
1PASS
|
|
464 |
1 |
@Test(groups = { "Functional" })... |
465 |
|
public void testStoreAndRecoverReferenceSeqSettings() throws Exception |
466 |
|
{ |
467 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
468 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
469 |
|
"examples/exampleFile_2_7.jar", DataSourceType.FILE); |
470 |
1 |
assertNotNull(af, "Didn't read in the example file correctly."); |
471 |
1 |
String afid = af.getViewport().getSequenceSetId(); |
472 |
|
|
473 |
|
|
474 |
1 |
Map<String, SequenceI> refseqs = new HashMap<>(); |
475 |
|
|
476 |
|
|
477 |
|
|
478 |
|
|
479 |
|
|
480 |
1 |
int n = 1; |
481 |
1 |
for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid)) |
482 |
|
{ |
483 |
5 |
AlignViewportI av = ap.getAlignViewport(); |
484 |
5 |
AlignmentI alignment = ap.getAlignment(); |
485 |
5 |
int repIndex = n % alignment.getHeight(); |
486 |
5 |
SequenceI rep = alignment.getSequenceAt(repIndex); |
487 |
5 |
refseqs.put(ap.getViewName(), rep); |
488 |
|
|
489 |
|
|
490 |
|
|
491 |
5 |
av.setDisplayReferenceSeq(true); |
492 |
5 |
av.setColourByReferenceSeq(true); |
493 |
5 |
av.getAlignment().setSeqrep(rep); |
494 |
|
|
495 |
5 |
n++; |
496 |
|
} |
497 |
1 |
File tfile = File.createTempFile("testStoreAndRecoverReferenceSeq", |
498 |
|
".jvp"); |
499 |
1 |
try |
500 |
|
{ |
501 |
1 |
new Jalview2XML(false).saveState(tfile); |
502 |
|
} catch (Throwable e) |
503 |
|
{ |
504 |
0 |
Assert.fail("Didn't save the expanded view state", e); |
505 |
|
} |
506 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
507 |
1 |
if (Desktop.getAlignFrames() != null) |
508 |
|
{ |
509 |
0 |
Assert.assertEquals(Desktop.getAlignFrames().length, 0); |
510 |
|
} |
511 |
|
|
512 |
1 |
af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(), |
513 |
|
DataSourceType.FILE); |
514 |
1 |
afid = af.getViewport().getSequenceSetId(); |
515 |
|
|
516 |
1 |
for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid)) |
517 |
|
{ |
518 |
|
|
519 |
5 |
AlignmentI alignment = ap.getAlignment(); |
520 |
5 |
SequenceI rep = alignment.getSeqrep(); |
521 |
5 |
Assert.assertNotNull(rep, |
522 |
|
"Couldn't restore sequence representative from project"); |
523 |
|
|
524 |
|
|
525 |
|
|
526 |
|
|
527 |
5 |
Assert.assertEquals(refseqs.get(ap.getViewName()).toString(), |
528 |
|
rep.toString(), |
529 |
|
"Representative wasn't the same when recovered."); |
530 |
5 |
Assert.assertTrue(ap.getAlignViewport().isDisplayReferenceSeq(), |
531 |
|
"Display reference sequence view setting not set."); |
532 |
5 |
Assert.assertTrue(ap.getAlignViewport().isColourByReferenceSeq(), |
533 |
|
"Colour By Reference Seq view setting not set."); |
534 |
|
} |
535 |
|
} |
536 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
537 |
1 |
@Test(groups = { "Functional" })... |
538 |
|
public void testIsVersionStringLaterThan() |
539 |
|
{ |
540 |
|
|
541 |
|
|
542 |
|
|
543 |
|
|
544 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan(null, null)); |
545 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", null)); |
546 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan(null, "2.8.3")); |
547 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan(null, |
548 |
|
"Development Build")); |
549 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan(null, |
550 |
|
"DEVELOPMENT BUILD")); |
551 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", |
552 |
|
"Development Build")); |
553 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan(null, "Test")); |
554 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan(null, "TEST")); |
555 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "Test")); |
556 |
1 |
assertTrue( |
557 |
|
Jalview2XML.isVersionStringLaterThan(null, "Automated Build")); |
558 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", |
559 |
|
"Automated Build")); |
560 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", |
561 |
|
"AUTOMATED BUILD")); |
562 |
|
|
563 |
|
|
564 |
|
|
565 |
|
|
566 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8", "2.8")); |
567 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.3")); |
568 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3b1")); |
569 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3B1", "2.8.3b1")); |
570 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3B1")); |
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.4")); |
576 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.9")); |
577 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.9.2")); |
578 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8", "2.8.3")); |
579 |
1 |
assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.3b1")); |
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
1 |
assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8")); |
585 |
1 |
assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.4", "2.8.3")); |
586 |
1 |
assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3")); |
587 |
1 |
assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.2b1")); |
588 |
1 |
assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.0b2", "2.8.0b1")); |
589 |
|
} |
590 |
|
|
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
|
595 |
|
@throws |
596 |
|
|
|
|
| 95.3% |
Uncovered Elements: 3 (64) |
Complexity: 3 |
Complexity Density: 0.05 |
1PASS
|
|
597 |
1 |
@Test(groups = { "Functional" })... |
598 |
|
public void testStoreAndRecoverGroupRepSeqs() throws Exception |
599 |
|
{ |
600 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
601 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
602 |
|
"examples/uniref50.fa", DataSourceType.FILE); |
603 |
1 |
assertNotNull(af, "Didn't read in the example file correctly."); |
604 |
1 |
String afid = af.getViewport().getSequenceSetId(); |
605 |
|
|
606 |
1 |
af.newView_actionPerformed(null); |
607 |
|
|
608 |
|
|
609 |
|
|
610 |
|
|
611 |
|
|
612 |
1 |
Map<String, SequenceI> repSeqs = new HashMap<>(); |
613 |
1 |
Map<String, List<String>> hiddenSeqNames = new HashMap<>(); |
614 |
|
|
615 |
|
|
616 |
|
|
617 |
|
|
618 |
|
|
619 |
1 |
int n = 1; |
620 |
1 |
for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid)) |
621 |
|
{ |
622 |
2 |
AlignViewportI av = ap.getAlignViewport(); |
623 |
2 |
AlignmentI alignment = ap.getAlignment(); |
624 |
2 |
int repIndex = n % alignment.getHeight(); |
625 |
|
|
626 |
2 |
repIndex = Math.max(repIndex, 1); |
627 |
2 |
SequenceI repSeq = alignment.getSequenceAt(repIndex); |
628 |
2 |
repSeqs.put(ap.getViewName(), repSeq); |
629 |
2 |
List<String> hiddenNames = new ArrayList<>(); |
630 |
2 |
hiddenSeqNames.put(ap.getViewName(), hiddenNames); |
631 |
|
|
632 |
|
|
633 |
|
|
634 |
|
|
635 |
|
|
636 |
2 |
SequenceGroup sg = new SequenceGroup(); |
637 |
2 |
sg.addSequence(repSeq, false); |
638 |
2 |
SequenceI precedingSeq = alignment.getSequenceAt(repIndex - 1); |
639 |
2 |
sg.addSequence(precedingSeq, false); |
640 |
2 |
sg.setSeqrep(repSeq); |
641 |
2 |
assertTrue(sg.getSequences().contains(repSeq)); |
642 |
2 |
assertTrue(sg.getSequences().contains(precedingSeq)); |
643 |
2 |
av.setSelectionGroup(sg); |
644 |
2 |
assertSame(repSeq, sg.getSeqrep()); |
645 |
|
|
646 |
|
|
647 |
|
|
648 |
|
|
649 |
|
|
650 |
2 |
((AlignmentViewport) av).hideSequences(repSeq, true); |
651 |
2 |
assertSame(repSeq, sg.getSeqrep()); |
652 |
2 |
assertTrue(sg.getSequences().contains(repSeq)); |
653 |
2 |
assertTrue(sg.getSequences().contains(precedingSeq)); |
654 |
2 |
assertTrue(alignment.getGroups().isEmpty(), "alignment has groups"); |
655 |
2 |
Map<SequenceI, SequenceCollectionI> hiddenRepSeqsMap = av |
656 |
|
.getHiddenRepSequences(); |
657 |
2 |
assertNotNull(hiddenRepSeqsMap); |
658 |
2 |
assertEquals(1, hiddenRepSeqsMap.size()); |
659 |
2 |
assertSame(sg, hiddenRepSeqsMap.get(repSeq)); |
660 |
2 |
assertTrue(alignment.getHiddenSequences().isHidden(precedingSeq)); |
661 |
2 |
assertFalse(alignment.getHiddenSequences().isHidden(repSeq)); |
662 |
2 |
hiddenNames.add(precedingSeq.getName()); |
663 |
|
|
664 |
2 |
n++; |
665 |
|
} |
666 |
1 |
File tfile = File.createTempFile("testStoreAndRecoverGroupReps", |
667 |
|
".jvp"); |
668 |
1 |
try |
669 |
|
{ |
670 |
1 |
new Jalview2XML(false).saveState(tfile); |
671 |
|
} catch (Throwable e) |
672 |
|
{ |
673 |
0 |
Assert.fail("Didn't save the expanded view state", e); |
674 |
|
} |
675 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
676 |
1 |
if (Desktop.getAlignFrames() != null) |
677 |
|
{ |
678 |
0 |
Assert.assertEquals(Desktop.getAlignFrames().length, 0); |
679 |
|
} |
680 |
|
|
681 |
1 |
af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(), |
682 |
|
DataSourceType.FILE); |
683 |
1 |
afid = af.getViewport().getSequenceSetId(); |
684 |
|
|
685 |
1 |
for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid)) |
686 |
|
{ |
687 |
2 |
String viewName = ap.getViewName(); |
688 |
2 |
AlignViewportI av = ap.getAlignViewport(); |
689 |
2 |
AlignmentI alignment = ap.getAlignment(); |
690 |
2 |
List<SequenceGroup> groups = alignment.getGroups(); |
691 |
2 |
assertNotNull(groups); |
692 |
2 |
assertTrue(groups.isEmpty(), "Alignment has groups"); |
693 |
2 |
Map<SequenceI, SequenceCollectionI> hiddenRepSeqsMap = av |
694 |
|
.getHiddenRepSequences(); |
695 |
2 |
assertNotNull(hiddenRepSeqsMap, "No hidden represented sequences"); |
696 |
2 |
assertEquals(1, hiddenRepSeqsMap.size()); |
697 |
2 |
assertEquals(repSeqs.get(viewName).getDisplayId(true), |
698 |
|
hiddenRepSeqsMap.keySet().iterator().next() |
699 |
|
.getDisplayId(true)); |
700 |
|
|
701 |
|
|
702 |
|
|
703 |
|
|
704 |
2 |
List<String> hidden = hiddenSeqNames.get(ap.getViewName()); |
705 |
2 |
HiddenSequences hs = alignment.getHiddenSequences(); |
706 |
2 |
assertEquals(hidden.size(), hs.getSize(), |
707 |
|
"wrong number of restored hidden sequences in " |
708 |
|
+ ap.getViewName()); |
709 |
|
} |
710 |
|
} |
711 |
|
|
712 |
|
|
713 |
|
|
714 |
|
|
715 |
|
@throws |
716 |
|
|
|
|
| 95.2% |
Uncovered Elements: 3 (63) |
Complexity: 4 |
Complexity Density: 0.07 |
1PASS
|
|
717 |
1 |
@Test(groups = { "Functional" })... |
718 |
|
public void testStoreAndRecoverPDBEntry() throws Exception |
719 |
|
{ |
720 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
721 |
1 |
String exampleFile = "examples/3W5V.pdb"; |
722 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(exampleFile, |
723 |
|
DataSourceType.FILE); |
724 |
1 |
assertNotNull(af, "Didn't read in the example file correctly."); |
725 |
1 |
String afid = af.getViewport().getSequenceSetId(); |
726 |
|
|
727 |
1 |
AlignmentPanel[] alignPanels = Desktop.getAlignmentPanels(afid); |
728 |
1 |
System.out.println(); |
729 |
1 |
AlignmentViewPanel ap = alignPanels[0]; |
730 |
1 |
String tfileBase = new File(".").getAbsolutePath().replace(".", ""); |
731 |
1 |
String testFile = tfileBase + exampleFile; |
732 |
1 |
AlignmentI alignment = ap.getAlignment(); |
733 |
1 |
System.out.println("blah"); |
734 |
1 |
SequenceI[] seqs = alignment.getSequencesArray(); |
735 |
1 |
Assert.assertNotNull(seqs[0]); |
736 |
1 |
Assert.assertNotNull(seqs[1]); |
737 |
1 |
Assert.assertNotNull(seqs[2]); |
738 |
1 |
Assert.assertNotNull(seqs[3]); |
739 |
1 |
Assert.assertNotNull(seqs[0].getDatasetSequence()); |
740 |
1 |
Assert.assertNotNull(seqs[1].getDatasetSequence()); |
741 |
1 |
Assert.assertNotNull(seqs[2].getDatasetSequence()); |
742 |
1 |
Assert.assertNotNull(seqs[3].getDatasetSequence()); |
743 |
1 |
PDBEntry[] pdbEntries = new PDBEntry[4]; |
744 |
1 |
pdbEntries[0] = new PDBEntry("3W5V", "A", Type.PDB, testFile); |
745 |
1 |
pdbEntries[1] = new PDBEntry("3W5V", "B", Type.PDB, testFile); |
746 |
1 |
pdbEntries[2] = new PDBEntry("3W5V", "C", Type.PDB, testFile); |
747 |
1 |
pdbEntries[3] = new PDBEntry("3W5V", "D", Type.PDB, testFile); |
748 |
1 |
Assert.assertEquals( |
749 |
|
seqs[0].getDatasetSequence().getAllPDBEntries().get(0), |
750 |
|
pdbEntries[0]); |
751 |
1 |
Assert.assertEquals( |
752 |
|
seqs[1].getDatasetSequence().getAllPDBEntries().get(0), |
753 |
|
pdbEntries[1]); |
754 |
1 |
Assert.assertEquals( |
755 |
|
seqs[2].getDatasetSequence().getAllPDBEntries().get(0), |
756 |
|
pdbEntries[2]); |
757 |
1 |
Assert.assertEquals( |
758 |
|
seqs[3].getDatasetSequence().getAllPDBEntries().get(0), |
759 |
|
pdbEntries[3]); |
760 |
|
|
761 |
1 |
File tfile = File.createTempFile("testStoreAndRecoverPDBEntry", ".jvp"); |
762 |
1 |
try |
763 |
|
{ |
764 |
1 |
new Jalview2XML(false).saveState(tfile); |
765 |
|
} catch (Throwable e) |
766 |
|
{ |
767 |
0 |
Assert.fail("Didn't save the state", e); |
768 |
|
} |
769 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
770 |
1 |
if (Desktop.getAlignFrames() != null) |
771 |
|
{ |
772 |
0 |
Assert.assertEquals(Desktop.getAlignFrames().length, 0); |
773 |
|
} |
774 |
|
|
775 |
1 |
AlignFrame restoredFrame = new FileLoader().LoadFileWaitTillLoaded( |
776 |
|
tfile.getAbsolutePath(), DataSourceType.FILE); |
777 |
1 |
String rfid = restoredFrame.getViewport().getSequenceSetId(); |
778 |
1 |
AlignmentPanel[] rAlignPanels = Desktop.getAlignmentPanels(rfid); |
779 |
1 |
AlignmentViewPanel rap = rAlignPanels[0]; |
780 |
1 |
AlignmentI rAlignment = rap.getAlignment(); |
781 |
1 |
System.out.println("blah"); |
782 |
1 |
SequenceI[] rseqs = rAlignment.getSequencesArray(); |
783 |
1 |
Assert.assertNotNull(rseqs[0]); |
784 |
1 |
Assert.assertNotNull(rseqs[1]); |
785 |
1 |
Assert.assertNotNull(rseqs[2]); |
786 |
1 |
Assert.assertNotNull(rseqs[3]); |
787 |
1 |
Assert.assertNotNull(rseqs[0].getDatasetSequence()); |
788 |
1 |
Assert.assertNotNull(rseqs[1].getDatasetSequence()); |
789 |
1 |
Assert.assertNotNull(rseqs[2].getDatasetSequence()); |
790 |
1 |
Assert.assertNotNull(rseqs[3].getDatasetSequence()); |
791 |
|
|
792 |
|
|
793 |
|
|
794 |
5 |
for (int chain = 0; chain < 4; chain++) |
795 |
|
{ |
796 |
4 |
PDBEntry recov = rseqs[chain].getDatasetSequence().getAllPDBEntries() |
797 |
|
.get(0); |
798 |
4 |
PDBEntry expected = pdbEntries[chain]; |
799 |
4 |
Assert.assertEquals(recov.getId(), expected.getId(), |
800 |
|
"Mismatch PDB ID"); |
801 |
4 |
Assert.assertEquals(recov.getChainCode(), expected.getChainCode(), |
802 |
|
"Mismatch PDB ID"); |
803 |
4 |
Assert.assertEquals(recov.getType(), expected.getType(), |
804 |
|
"Mismatch PDBEntry 'Type'"); |
805 |
4 |
Assert.assertNotNull(recov.getFile(), |
806 |
|
"Recovered PDBEntry should have a non-null file entry"); |
807 |
|
} |
808 |
|
} |
809 |
|
|
810 |
|
|
811 |
|
|
812 |
|
|
813 |
|
|
814 |
|
|
815 |
|
@throws |
816 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (57) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
817 |
1 |
@Test(groups = { "Functional" })... |
818 |
|
public void testStoreAndRecoverColourThresholds() throws IOException |
819 |
|
{ |
820 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
821 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
822 |
|
"examples/uniref50.fa", DataSourceType.FILE); |
823 |
|
|
824 |
1 |
AlignViewport av = af.getViewport(); |
825 |
1 |
AlignmentI al = av.getAlignment(); |
826 |
|
|
827 |
|
|
828 |
|
|
829 |
|
|
830 |
1 |
av.setColourAppliesToAllGroups(false); |
831 |
1 |
af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString()); |
832 |
1 |
assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme); |
833 |
1 |
af.abovePIDThreshold_actionPerformed(true); |
834 |
1 |
SliderPanel sp = SliderPanel.getSliderPanel(); |
835 |
1 |
assertFalse(sp.isForConservation()); |
836 |
1 |
sp.valueChanged(10); |
837 |
1 |
af.conservationMenuItem_actionPerformed(true); |
838 |
1 |
sp = SliderPanel.getSliderPanel(); |
839 |
1 |
assertTrue(sp.isForConservation()); |
840 |
1 |
sp.valueChanged(20); |
841 |
1 |
ResidueShaderI rs = av.getResidueShading(); |
842 |
1 |
assertEquals(rs.getThreshold(), 10); |
843 |
1 |
assertTrue(rs.conservationApplied()); |
844 |
1 |
assertEquals(rs.getConservationInc(), 20); |
845 |
|
|
846 |
|
|
847 |
|
|
848 |
|
|
849 |
|
|
850 |
|
|
851 |
|
|
852 |
1 |
SequenceGroup sg = new SequenceGroup(); |
853 |
1 |
sg.addSequence(al.getSequenceAt(0), false); |
854 |
1 |
sg.setStartRes(15); |
855 |
1 |
sg.setEndRes(25); |
856 |
1 |
av.setSelectionGroup(sg); |
857 |
1 |
PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(2), |
858 |
|
null); |
859 |
1 |
popupMenu.changeColour_actionPerformed( |
860 |
|
JalviewColourScheme.Strand.toString()); |
861 |
1 |
assertTrue(sg.getColourScheme() instanceof StrandColourScheme); |
862 |
1 |
assertEquals(al.getGroups().size(), 1); |
863 |
1 |
assertSame(al.getGroups().get(0), sg); |
864 |
1 |
popupMenu.conservationMenuItem_actionPerformed(true); |
865 |
1 |
sp = SliderPanel.getSliderPanel(); |
866 |
1 |
assertTrue(sp.isForConservation()); |
867 |
1 |
sp.valueChanged(30); |
868 |
1 |
popupMenu.abovePIDColour_actionPerformed(true); |
869 |
1 |
sp = SliderPanel.getSliderPanel(); |
870 |
1 |
assertFalse(sp.isForConservation()); |
871 |
1 |
sp.valueChanged(40); |
872 |
1 |
assertTrue(sg.getGroupColourScheme().conservationApplied()); |
873 |
1 |
assertEquals(sg.getGroupColourScheme().getConservationInc(), 30); |
874 |
1 |
assertEquals(sg.getGroupColourScheme().getThreshold(), 40); |
875 |
|
|
876 |
|
|
877 |
|
|
878 |
|
|
879 |
1 |
File tfile = File.createTempFile("testStoreAndRecoverColourThresholds", |
880 |
|
".jvp"); |
881 |
1 |
tfile.deleteOnExit(); |
882 |
1 |
new Jalview2XML(false).saveState(tfile); |
883 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
884 |
1 |
af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(), |
885 |
|
DataSourceType.FILE); |
886 |
1 |
Assert.assertNotNull(af, "Failed to reload project"); |
887 |
|
|
888 |
|
|
889 |
|
|
890 |
|
|
891 |
1 |
rs = af.getViewport().getResidueShading(); |
892 |
1 |
assertTrue(rs.getColourScheme() instanceof BuriedColourScheme); |
893 |
1 |
assertEquals(rs.getThreshold(), 10); |
894 |
1 |
assertTrue(rs.conservationApplied()); |
895 |
1 |
assertEquals(rs.getConservationInc(), 20); |
896 |
|
|
897 |
|
|
898 |
|
|
899 |
|
|
900 |
1 |
assertEquals(1, af.getViewport().getAlignment().getGroups().size(), 1); |
901 |
1 |
rs = af.getViewport().getAlignment().getGroups().get(0) |
902 |
|
.getGroupColourScheme(); |
903 |
1 |
assertTrue(rs.getColourScheme() instanceof StrandColourScheme); |
904 |
1 |
assertEquals(rs.getThreshold(), 40); |
905 |
1 |
assertTrue(rs.conservationApplied()); |
906 |
1 |
assertEquals(rs.getConservationInc(), 30); |
907 |
|
} |
908 |
|
|
909 |
|
|
910 |
|
|
911 |
|
|
912 |
|
@throws |
913 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (71) |
Complexity: 1 |
Complexity Density: 0.01 |
1PASS
|
|
914 |
1 |
@Test(groups = { "Functional" })... |
915 |
|
public void testSaveLoadFeatureColoursAndFilters() throws IOException |
916 |
|
{ |
917 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
918 |
|
">Seq1\nACDEFGHIKLM", DataSourceType.PASTE); |
919 |
1 |
SequenceI seq1 = af.getViewport().getAlignment().getSequenceAt(0); |
920 |
|
|
921 |
|
|
922 |
|
|
923 |
|
|
924 |
1 |
int score = 1; |
925 |
1 |
addFeatures(seq1, "type1", score++); |
926 |
1 |
addFeatures(seq1, "type2", score++); |
927 |
1 |
addFeatures(seq1, "type3", score++); |
928 |
1 |
addFeatures(seq1, "type4", score++); |
929 |
1 |
addFeatures(seq1, "type5", score++); |
930 |
|
|
931 |
|
|
932 |
|
|
933 |
|
|
934 |
1 |
FeatureRendererModel fr = af.getFeatureRenderer(); |
935 |
1 |
fr.findAllFeatures(true); |
936 |
|
|
937 |
|
|
938 |
1 |
fr.setColour("type1", new FeatureColour(Color.red)); |
939 |
|
|
940 |
|
|
941 |
1 |
FeatureColourI byLabel = new FeatureColour(); |
942 |
1 |
byLabel.setColourByLabel(true); |
943 |
1 |
fr.setColour("type2", byLabel); |
944 |
|
|
945 |
|
|
946 |
1 |
FeatureColourI byScore = new FeatureColour(null, Color.BLACK, |
947 |
|
Color.BLUE, null, 1, 10); |
948 |
1 |
byScore.setAboveThreshold(true); |
949 |
1 |
byScore.setThreshold(2f); |
950 |
1 |
fr.setColour("type3", byScore); |
951 |
|
|
952 |
|
|
953 |
1 |
FeatureColourI byAF = new FeatureColour(); |
954 |
1 |
byAF.setColourByLabel(true); |
955 |
1 |
byAF.setAttributeName("AF"); |
956 |
1 |
fr.setColour("type4", byAF); |
957 |
|
|
958 |
|
|
959 |
1 |
FeatureColourI byPolyPhen = new FeatureColour(null, Color.BLACK, |
960 |
|
Color.BLUE, null, 1, 10); |
961 |
1 |
byPolyPhen.setBelowThreshold(true); |
962 |
1 |
byPolyPhen.setThreshold(3f); |
963 |
1 |
byPolyPhen.setAttributeName("CSQ", "PolyPhen"); |
964 |
1 |
fr.setColour("type5", byPolyPhen); |
965 |
|
|
966 |
|
|
967 |
|
|
968 |
|
|
969 |
|
|
970 |
|
|
971 |
1 |
FeatureMatcherSetI filterByX = new FeatureMatcherSet(); |
972 |
1 |
filterByX.and(FeatureMatcher.byLabel(Condition.Contains, "x")); |
973 |
1 |
fr.setFeatureFilter("type1", filterByX); |
974 |
|
|
975 |
|
|
976 |
1 |
FeatureMatcherSetI filterByScore = new FeatureMatcherSet(); |
977 |
1 |
filterByScore.and(FeatureMatcher.byScore(Condition.LE, "2.4")); |
978 |
1 |
filterByScore.and(FeatureMatcher.byScore(Condition.GT, "1.1")); |
979 |
1 |
fr.setFeatureFilter("type2", filterByScore); |
980 |
|
|
981 |
|
|
982 |
1 |
FeatureMatcherSetI filterByXY = new FeatureMatcherSet(); |
983 |
1 |
filterByXY |
984 |
|
.and(FeatureMatcher.byAttribute(Condition.Contains, "X", "AF")); |
985 |
1 |
filterByXY.or(FeatureMatcher.byAttribute(Condition.NE, "0", "CSQ", |
986 |
|
"PolyPhen")); |
987 |
1 |
fr.setFeatureFilter("type3", filterByXY); |
988 |
|
|
989 |
|
|
990 |
|
|
991 |
|
|
992 |
1 |
File tfile = File.createTempFile("JalviewTest", ".jvp"); |
993 |
1 |
tfile.deleteOnExit(); |
994 |
1 |
String filePath = tfile.getAbsolutePath(); |
995 |
1 |
af.saveAlignment(filePath, FileFormat.Jalview); |
996 |
1 |
assertTrue(af.isSaveAlignmentSuccessful(), |
997 |
|
"Failed to store as a project."); |
998 |
|
|
999 |
|
|
1000 |
|
|
1001 |
|
|
1002 |
1 |
af.closeMenuItem_actionPerformed(true); |
1003 |
1 |
af = null; |
1004 |
1 |
af = new FileLoader().LoadFileWaitTillLoaded(filePath, |
1005 |
|
DataSourceType.FILE); |
1006 |
1 |
assertNotNull(af, "Failed to import new project"); |
1007 |
|
|
1008 |
|
|
1009 |
|
|
1010 |
|
|
1011 |
1 |
fr = af.getFeatureRenderer(); |
1012 |
1 |
FeatureColourI fc = fr.getFeatureStyle("type1"); |
1013 |
1 |
assertTrue(fc.isSimpleColour()); |
1014 |
1 |
assertEquals(fc.getColour(), Color.red); |
1015 |
1 |
fc = fr.getFeatureStyle("type2"); |
1016 |
1 |
assertTrue(fc.isColourByLabel()); |
1017 |
1 |
fc = fr.getFeatureStyle("type3"); |
1018 |
1 |
assertTrue(fc.isGraduatedColour()); |
1019 |
1 |
assertNull(fc.getAttributeName()); |
1020 |
1 |
assertTrue(fc.isAboveThreshold()); |
1021 |
1 |
assertEquals(fc.getThreshold(), 2f); |
1022 |
1 |
fc = fr.getFeatureStyle("type4"); |
1023 |
1 |
assertTrue(fc.isColourByLabel()); |
1024 |
1 |
assertTrue(fc.isColourByAttribute()); |
1025 |
1 |
assertEquals(fc.getAttributeName(), new String[] { "AF" }); |
1026 |
1 |
fc = fr.getFeatureStyle("type5"); |
1027 |
1 |
assertTrue(fc.isGraduatedColour()); |
1028 |
1 |
assertTrue(fc.isColourByAttribute()); |
1029 |
1 |
assertEquals(fc.getAttributeName(), new String[] { "CSQ", "PolyPhen" }); |
1030 |
1 |
assertTrue(fc.isBelowThreshold()); |
1031 |
1 |
assertEquals(fc.getThreshold(), 3f); |
1032 |
|
|
1033 |
1 |
assertEquals(fr.getFeatureFilter("type1").toStableString(), |
1034 |
|
"Label Contains x"); |
1035 |
1 |
assertEquals(fr.getFeatureFilter("type2").toStableString(), |
1036 |
|
"(Score LE 2.4) AND (Score GT 1.1)"); |
1037 |
1 |
assertEquals(fr.getFeatureFilter("type3").toStableString(), |
1038 |
|
"(AF Contains X) OR (CSQ:PolyPhen NE 0)"); |
1039 |
|
} |
1040 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
1041 |
10 |
private void addFeature(SequenceI seq, String featureType, int score)... |
1042 |
|
{ |
1043 |
10 |
SequenceFeature sf = new SequenceFeature(featureType, "desc", 1, 2, |
1044 |
|
score, "grp"); |
1045 |
10 |
sf.setValue("AF", score); |
1046 |
10 |
sf.setValue("CSQ", new HashMap<String, String>() |
1047 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1048 |
10 |
{... |
1049 |
10 |
put("PolyPhen", Integer.toString(score)); |
1050 |
|
} |
1051 |
|
}); |
1052 |
10 |
seq.addSequenceFeature(sf); |
1053 |
|
} |
1054 |
|
|
1055 |
|
|
1056 |
|
|
1057 |
|
|
1058 |
|
|
1059 |
|
@param |
1060 |
|
@param |
1061 |
|
@param |
1062 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1063 |
5 |
private void addFeatures(SequenceI seq, String featureType, int score)... |
1064 |
|
{ |
1065 |
5 |
addFeature(seq, featureType, score++); |
1066 |
5 |
addFeature(seq, featureType, score); |
1067 |
|
} |
1068 |
|
|
1069 |
|
|
1070 |
|
|
1071 |
|
|
1072 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
1073 |
1 |
@Test(groups = { "Functional" })... |
1074 |
|
public void testMergeDatasetsforViews() throws IOException |
1075 |
|
{ |
1076 |
|
|
1077 |
1 |
AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded( |
1078 |
|
"examples/testdata/projects/twoViews.jvp", DataSourceType.FILE); |
1079 |
1 |
assertNotNull(af); |
1080 |
1 |
assertTrue(af.getAlignPanels().size() > 1); |
1081 |
1 |
verifyDs(af); |
1082 |
|
} |
1083 |
|
|
1084 |
|
|
1085 |
|
|
1086 |
|
|
1087 |
|
|
1088 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
1PASS
|
|
1089 |
1 |
@Test(groups = { "Functional" })... |
1090 |
|
public void testMergeDatasetsforManyViews() throws IOException |
1091 |
|
{ |
1092 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
1093 |
|
|
1094 |
|
|
1095 |
1 |
AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded( |
1096 |
|
"examples/testdata/projects/manyViews.jvp", |
1097 |
|
DataSourceType.FILE); |
1098 |
1 |
assertNotNull(af); |
1099 |
|
|
1100 |
1 |
AlignmentI ds = null; |
1101 |
1 |
for (AlignFrame alignFrame : Desktop.getAlignFrames()) |
1102 |
|
{ |
1103 |
3 |
if (ds == null) |
1104 |
|
{ |
1105 |
1 |
ds = verifyDs(alignFrame); |
1106 |
|
} |
1107 |
|
else |
1108 |
|
{ |
1109 |
|
|
1110 |
2 |
assertTrue(ds == verifyDs(alignFrame)); |
1111 |
|
} |
1112 |
|
} |
1113 |
|
} |
1114 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
1115 |
4 |
private AlignmentI verifyDs(AlignFrame af)... |
1116 |
|
{ |
1117 |
4 |
AlignmentI ds = null; |
1118 |
4 |
for (AlignmentViewPanel ap : af.getAlignPanels()) |
1119 |
|
{ |
1120 |
10 |
if (ds == null) |
1121 |
|
{ |
1122 |
4 |
ds = ap.getAlignment().getDataset(); |
1123 |
|
} |
1124 |
|
else |
1125 |
|
{ |
1126 |
6 |
assertTrue(ap.getAlignment().getDataset() == ds, |
1127 |
|
"Dataset was not the same for imported 2.10.5 project with several alignment views"); |
1128 |
|
} |
1129 |
|
} |
1130 |
4 |
return ds; |
1131 |
|
} |
1132 |
|
|
|
|
| 96.9% |
Uncovered Elements: 1 (32) |
Complexity: 3 |
Complexity Density: 0.11 |
1PASS
|
|
1133 |
1 |
@Test(groups = "Functional")... |
1134 |
|
public void testPcaViewAssociation() throws IOException |
1135 |
|
{ |
1136 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
1137 |
1 |
final String PCAVIEWNAME = "With PCA"; |
1138 |
|
|
1139 |
1 |
File tempfile = File.createTempFile("jvPCAviewAssoc", "jvp"); |
1140 |
|
|
1141 |
|
{ |
1142 |
1 |
String exampleFile = "examples/uniref50.fa"; |
1143 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(exampleFile, |
1144 |
|
DataSourceType.FILE); |
1145 |
1 |
assertNotNull(af, "Didn't read in the example file correctly."); |
1146 |
1 |
AlignmentPanel origView = (AlignmentPanel) af.getAlignPanels().get(0); |
1147 |
1 |
AlignmentPanel newview = af.newView(PCAVIEWNAME, true); |
1148 |
|
|
1149 |
1 |
af.newView("Not the PCA View", true); |
1150 |
1 |
PCAPanel pcaPanel = new PCAPanel(origView, "BLOSUM62", |
1151 |
|
new SimilarityParams(true, true, true, false)); |
1152 |
|
|
1153 |
1 |
pcaPanel.run(); |
1154 |
|
|
1155 |
|
|
1156 |
1 |
pcaPanel.selectAssociatedView(newview); |
1157 |
|
|
1158 |
1 |
assertTrue(pcaPanel.getAlignViewport() == newview.getAlignViewport(), |
1159 |
|
"PCA should be associated with 'With PCA' view: test is broken"); |
1160 |
|
|
1161 |
|
|
1162 |
1 |
Jalview2XML jv2xml = new jalview.project.Jalview2XML(false); |
1163 |
1 |
tempfile.delete(); |
1164 |
1 |
jv2xml.saveState(tempfile); |
1165 |
1 |
assertTrue(jv2xml.errorMessage == null, |
1166 |
|
"Failed to save dummy project with PCA: test broken"); |
1167 |
|
} |
1168 |
|
|
1169 |
|
|
1170 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
1171 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
1172 |
|
tempfile.getCanonicalPath(), DataSourceType.FILE); |
1173 |
1 |
JInternalFrame[] frames = Desktop.instance.getAllFrames(); |
1174 |
|
|
1175 |
|
|
1176 |
1 |
assertEquals(frames.length, 2, |
1177 |
|
"PCA and the tabbed alignment view should be the only two windows on the desktop"); |
1178 |
1 |
PCAPanel pcaPanel = (PCAPanel) frames[frames[0] == af ? 1 : 0]; |
1179 |
|
|
1180 |
1 |
AlignmentViewPanel restoredNewView = null; |
1181 |
1 |
for (AlignmentViewPanel alignpanel : Desktop.getAlignmentPanels(null)) |
1182 |
|
{ |
1183 |
3 |
if (alignpanel.getAlignViewport() == pcaPanel.getAlignViewport()) |
1184 |
|
{ |
1185 |
1 |
restoredNewView = alignpanel; |
1186 |
|
} |
1187 |
|
} |
1188 |
1 |
assertEquals(restoredNewView.getViewName(), PCAVIEWNAME); |
1189 |
1 |
assertTrue( |
1190 |
|
restoredNewView.getAlignViewport() == pcaPanel |
1191 |
|
.getAlignViewport(), |
1192 |
|
"Didn't restore correct view association for the PCA view"); |
1193 |
|
} |
1194 |
|
|
1195 |
|
|
1196 |
|
|
1197 |
|
|
1198 |
|
@throws |
1199 |
|
|
|
|
| 97.5% |
Uncovered Elements: 1 (40) |
Complexity: 2 |
Complexity Density: 0.05 |
1PASS
|
|
1200 |
1 |
@Test(groups = { "Functional" })... |
1201 |
|
public void testStoreAndRecoverGeneLocus() throws Exception |
1202 |
|
{ |
1203 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
1204 |
1 |
String seqData = ">P30419\nACDE\n>X1235\nGCCTGTGACGAA"; |
1205 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(seqData, |
1206 |
|
DataSourceType.PASTE); |
1207 |
1 |
assertNotNull(af, "Didn't read in the example file correctly."); |
1208 |
|
|
1209 |
1 |
AlignmentViewPanel ap = Desktop.getAlignmentPanels(null)[0]; |
1210 |
1 |
SequenceI pep = ap.getAlignment().getSequenceAt(0); |
1211 |
1 |
SequenceI cds = ap.getAlignment().getSequenceAt(1); |
1212 |
|
|
1213 |
|
|
1214 |
|
|
1215 |
|
|
1216 |
|
|
1217 |
1 |
DBRefEntry dbref1 = new DBRefEntry("Uniprot", "1", "P30419", null); |
1218 |
1 |
pep.addDBRef(dbref1); |
1219 |
1 |
Mapping cdsmap = new Mapping(cds, |
1220 |
|
new MapList(new int[] |
1221 |
|
{ 1, 4 }, new int[] { 1, 12 }, 1, 3)); |
1222 |
1 |
DBRefEntry dbref2 = new DBRefEntry("EMBLCDS", "2", "X1235", cdsmap); |
1223 |
1 |
pep.addDBRef(dbref2); |
1224 |
1 |
Mapping locusmap = new Mapping(null, |
1225 |
|
new MapList(new int[] |
1226 |
|
{ 1, 4 }, new int[] { 2674123, 2674135 }, 1, 3)); |
1227 |
1 |
DBRefEntry dbref3 = new GeneLocus("human", "GRCh38", "5", locusmap); |
1228 |
1 |
pep.addDBRef(dbref3); |
1229 |
|
|
1230 |
1 |
File tfile = File.createTempFile("testStoreAndRecoverGeneLocus", |
1231 |
|
".jvp"); |
1232 |
1 |
try |
1233 |
|
{ |
1234 |
1 |
new Jalview2XML(false).saveState(tfile); |
1235 |
|
} catch (Throwable e) |
1236 |
|
{ |
1237 |
0 |
Assert.fail("Didn't save the state", e); |
1238 |
|
} |
1239 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
1240 |
|
|
1241 |
1 |
new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(), |
1242 |
|
DataSourceType.FILE); |
1243 |
1 |
AlignmentViewPanel rap = Desktop.getAlignmentPanels(null)[0]; |
1244 |
1 |
SequenceI rpep = rap.getAlignment().getSequenceAt(0); |
1245 |
1 |
DBModList<DBRefEntry> dbrefs = rpep.getDBRefs(); |
1246 |
1 |
assertEquals(rpep.getName(), "P30419"); |
1247 |
1 |
assertEquals(dbrefs.size(), 3); |
1248 |
1 |
DBRefEntry dbRef = dbrefs.get(0); |
1249 |
1 |
assertFalse(dbRef instanceof GeneLocus); |
1250 |
1 |
assertNull(dbRef.getMap()); |
1251 |
1 |
assertEquals(dbRef, dbref1); |
1252 |
|
|
1253 |
|
|
1254 |
|
|
1255 |
|
|
1256 |
|
|
1257 |
1 |
dbRef = dbrefs.get(1); |
1258 |
1 |
assertFalse(dbRef instanceof GeneLocus); |
1259 |
1 |
assertTrue(dbRef.equalRef(dbref2)); |
1260 |
1 |
assertNotNull(dbRef.getMap()); |
1261 |
1 |
SequenceI rcds = rap.getAlignment().getSequenceAt(1); |
1262 |
1 |
assertSame(dbRef.getMap().getTo(), rcds); |
1263 |
|
|
1264 |
1 |
assertEquals(dbRef.getMap().getMap(), dbref2.getMap().getMap()); |
1265 |
|
|
1266 |
|
|
1267 |
|
|
1268 |
|
|
1269 |
1 |
dbRef = dbrefs.get(2); |
1270 |
1 |
assertTrue(dbRef instanceof GeneLocus); |
1271 |
1 |
assertEquals(dbRef, dbref3); |
1272 |
|
} |
1273 |
|
} |