1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertNotNull; |
24 |
|
|
25 |
|
import jalview.api.AlignExportSettingsI; |
26 |
|
import jalview.datamodel.AlignExportSettingsAdapter; |
27 |
|
import jalview.datamodel.Alignment; |
28 |
|
import jalview.datamodel.AlignmentAnnotation; |
29 |
|
import jalview.datamodel.AlignmentI; |
30 |
|
import jalview.datamodel.Annotation; |
31 |
|
import jalview.datamodel.HiddenColumns; |
32 |
|
import jalview.datamodel.Sequence; |
33 |
|
import jalview.datamodel.SequenceFeature; |
34 |
|
import jalview.datamodel.SequenceGroup; |
35 |
|
import jalview.datamodel.SequenceI; |
36 |
|
import jalview.datamodel.features.SequenceFeatures; |
37 |
|
import jalview.gui.AlignFrame; |
38 |
|
import jalview.gui.JvOptionPane; |
39 |
|
import jalview.json.binding.biojson.v1.ColourSchemeMapper; |
40 |
|
import jalview.schemes.ColourSchemeI; |
41 |
|
import jalview.schemes.ResidueColourScheme; |
42 |
|
|
43 |
|
import java.io.IOException; |
44 |
|
import java.util.ArrayList; |
45 |
|
import java.util.HashMap; |
46 |
|
import java.util.Iterator; |
47 |
|
import java.util.List; |
48 |
|
import java.util.Map; |
49 |
|
|
50 |
|
import org.testng.Assert; |
51 |
|
import org.testng.AssertJUnit; |
52 |
|
import org.testng.annotations.AfterTest; |
53 |
|
import org.testng.annotations.BeforeClass; |
54 |
|
import org.testng.annotations.BeforeMethod; |
55 |
|
import org.testng.annotations.BeforeTest; |
56 |
|
import org.testng.annotations.Test; |
57 |
|
|
|
|
| 83.3% |
Uncovered Elements: 46 (275) |
Complexity: 57 |
Complexity Density: 0.25 |
|
58 |
|
public class JSONFileTest |
59 |
|
{ |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
61 |
1 |
@BeforeClass(alwaysRun = true)... |
62 |
|
public void setUpJvOptionPane() |
63 |
|
{ |
64 |
1 |
JvOptionPane.setInteractiveMode(false); |
65 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
66 |
|
} |
67 |
|
|
68 |
|
private int TEST_SEQ_HEIGHT = 0; |
69 |
|
|
70 |
|
private int TEST_GRP_HEIGHT = 0; |
71 |
|
|
72 |
|
private int TEST_ANOT_HEIGHT = 0; |
73 |
|
|
74 |
|
private int TEST_CS_HEIGHT = 0; |
75 |
|
|
76 |
|
private String TEST_JSON_FILE = "examples/example.json"; |
77 |
|
|
78 |
|
private Alignment alignment; |
79 |
|
|
80 |
|
private HashMap<String, SequenceI> expectedSeqs = new HashMap<>(); |
81 |
|
|
82 |
|
private HashMap<String, AlignmentAnnotation> expectedAnnots = new HashMap<>(); |
83 |
|
|
84 |
|
private HashMap<String, SequenceGroup> expectedGrps = new HashMap<>(); |
85 |
|
|
86 |
|
private HiddenColumns expectedColSel = new HiddenColumns(); |
87 |
|
|
88 |
|
private SequenceI[] expectedHiddenSeqs = new SequenceI[1]; |
89 |
|
|
90 |
|
private AlignmentI testAlignment; |
91 |
|
|
92 |
|
private int passedCount; |
93 |
|
|
94 |
|
private JSONFile testJsonFile; |
95 |
|
|
96 |
|
private JSONFile jf; |
97 |
|
|
98 |
|
private AlignExportSettingsI exportSettings; |
99 |
|
|
|
|
| 98.9% |
Uncovered Elements: 1 (91) |
Complexity: 2 |
Complexity Density: 0.02 |
|
100 |
1 |
@BeforeTest(alwaysRun = true)... |
101 |
|
public void setup() throws Exception |
102 |
|
{ |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
1 |
Sequence[] seqs = new Sequence[5]; |
109 |
1 |
seqs[0] = new Sequence("FER_CAPAN", |
110 |
|
"SVSATMISTSFMPRKPAVTSL-KPIPNVGE--ALF", 3, 34); |
111 |
1 |
seqs[1] = new Sequence("FER1_SOLLC", |
112 |
|
"SISGTMISTSFLPRKPAVTSL-KAISNVGE--ALF", 3, 34); |
113 |
1 |
seqs[2] = new Sequence("Q93XJ9_SOLTU", |
114 |
|
"SISGTMISTSFLPRKPVVTSL-KAISNVGE--ALF", 3, 34); |
115 |
1 |
seqs[3] = new Sequence("FER1_PEA", |
116 |
|
"ALYGTAVSTSFLRTQPMPMSV-TTTKAFSN--GFL", 6, 37); |
117 |
1 |
seqs[4] = new Sequence("Q7XA98_TRIPR", |
118 |
|
"ALYGTAVSTSFMRRQPVPMSV-ATTTTTKAFPSGF", 6, 39); |
119 |
|
|
120 |
1 |
SequenceI hiddenSeq = new Sequence("FER_TOCH", |
121 |
|
"FILGTMISKSFLFRKPAVTSL-KAISNVGE--ALF", 3, 34); |
122 |
1 |
expectedHiddenSeqs[0] = hiddenSeq; |
123 |
|
|
124 |
|
|
125 |
1 |
SequenceFeature seqFeature2 = new SequenceFeature("feature_x", |
126 |
|
"theDesc", 6, 15, "Jalview"); |
127 |
1 |
SequenceFeature seqFeature3 = new SequenceFeature("feature_x", |
128 |
|
"theDesc", 9, 18, "Jalview"); |
129 |
1 |
SequenceFeature seqFeature4 = new SequenceFeature("feature_x", |
130 |
|
"theDesc", 9, 18, "Jalview"); |
131 |
|
|
132 |
1 |
SequenceFeature seqFeature5 = new SequenceFeature("Domain", |
133 |
|
"My description", 0, 0, "Pfam"); |
134 |
1 |
seqs[2].addSequenceFeature(seqFeature2); |
135 |
1 |
seqs[3].addSequenceFeature(seqFeature3); |
136 |
1 |
seqs[4].addSequenceFeature(seqFeature4); |
137 |
1 |
seqs[2].addSequenceFeature(seqFeature5); |
138 |
|
|
139 |
1 |
for (Sequence seq : seqs) |
140 |
|
{ |
141 |
5 |
seq.createDatasetSequence(); |
142 |
5 |
expectedSeqs.put(seq.getName(), seq); |
143 |
|
} |
144 |
|
|
145 |
|
|
146 |
1 |
List<SequenceI> grpSeqs = new ArrayList<>(); |
147 |
1 |
grpSeqs.add(seqs[1]); |
148 |
1 |
grpSeqs.add(seqs[2]); |
149 |
1 |
grpSeqs.add(seqs[3]); |
150 |
1 |
grpSeqs.add(seqs[4]); |
151 |
1 |
SequenceGroup seqGrp = new SequenceGroup(grpSeqs, |
152 |
|
"JGroup:1883305585", |
153 |
|
null, true, true, false, 21, 29); |
154 |
1 |
ColourSchemeI scheme = ColourSchemeMapper.getJalviewColourScheme( |
155 |
|
"zappo", seqGrp); |
156 |
1 |
seqGrp.cs.setColourScheme(scheme); |
157 |
1 |
seqGrp.setShowNonconserved(false); |
158 |
1 |
seqGrp.setDescription(null); |
159 |
|
|
160 |
1 |
expectedGrps.put(seqGrp.getName(), seqGrp); |
161 |
|
|
162 |
|
|
163 |
1 |
Annotation[] annot = new Annotation[35]; |
164 |
1 |
annot[0] = new Annotation("", "", '\u0000', 0); |
165 |
1 |
annot[1] = new Annotation("", "", '\u0000', 0); |
166 |
1 |
annot[2] = new Annotation("α", "", 'H', 0); |
167 |
1 |
annot[3] = new Annotation("α", "", 'H', 0); |
168 |
1 |
annot[4] = new Annotation("α", "", 'H', 0); |
169 |
1 |
annot[5] = new Annotation("", "", '\u0000', 0); |
170 |
1 |
annot[6] = new Annotation("", "", '\u0000', 0); |
171 |
1 |
annot[7] = new Annotation("", "", '\u0000', 0); |
172 |
1 |
annot[8] = new Annotation("β", "", 'E', 0); |
173 |
1 |
annot[9] = new Annotation("β", "", 'E', 0); |
174 |
1 |
annot[10] = new Annotation("β", "", 'E', 0); |
175 |
1 |
annot[11] = new Annotation("β", "", 'E', 0); |
176 |
1 |
annot[12] = new Annotation("β", "", 'E', 0); |
177 |
1 |
annot[13] = new Annotation("β", "", 'E', 0); |
178 |
1 |
annot[14] = new Annotation("β", "", 'E', 0); |
179 |
1 |
annot[15] = new Annotation("β", "", 'E', 0); |
180 |
1 |
annot[16] = new Annotation("", "", '\u0000', 0); |
181 |
1 |
annot[17] = new Annotation("", "", '\u0000', 0); |
182 |
1 |
annot[18] = new Annotation("", "", '\u0000', 0); |
183 |
1 |
annot[19] = new Annotation("", "", '\u0000', 0); |
184 |
1 |
annot[20] = new Annotation("", "", '\u0000', 0); |
185 |
1 |
annot[21] = new Annotation("", "", '\u0000', 0); |
186 |
1 |
annot[22] = new Annotation("", "", '\u0000', 0); |
187 |
1 |
annot[23] = new Annotation("", "", '\u0000', 0); |
188 |
1 |
annot[24] = new Annotation("", "", '\u0000', 0); |
189 |
1 |
annot[25] = new Annotation("", "", '\u0000', 0); |
190 |
1 |
annot[26] = new Annotation("α", "", 'H', 0); |
191 |
1 |
annot[27] = new Annotation("α", "", 'H', 0); |
192 |
1 |
annot[28] = new Annotation("α", "", 'H', 0); |
193 |
1 |
annot[29] = new Annotation("α", "", 'H', 0); |
194 |
1 |
annot[30] = new Annotation("α", "", 'H', 0); |
195 |
1 |
annot[31] = new Annotation("", "", '\u0000', 0); |
196 |
1 |
annot[32] = new Annotation("", "", '\u0000', 0); |
197 |
1 |
annot[33] = new Annotation("", "", '\u0000', 0); |
198 |
1 |
annot[34] = new Annotation("", "", '\u0000', 0); |
199 |
|
|
200 |
1 |
AlignmentAnnotation alignAnnot = new AlignmentAnnotation( |
201 |
|
"Secondary Structure", "New description", annot); |
202 |
1 |
expectedAnnots.put(alignAnnot.label, alignAnnot); |
203 |
|
|
204 |
1 |
expectedColSel.hideColumns(32, 33); |
205 |
1 |
expectedColSel.hideColumns(34, 34); |
206 |
|
|
207 |
1 |
TEST_SEQ_HEIGHT = expectedSeqs.size(); |
208 |
1 |
TEST_GRP_HEIGHT = expectedGrps.size(); |
209 |
1 |
TEST_ANOT_HEIGHT = expectedAnnots.size(); |
210 |
1 |
TEST_CS_HEIGHT = expectedColSel.getNumberOfRegions(); |
211 |
|
|
212 |
1 |
exportSettings = new AlignExportSettingsAdapter(true); |
213 |
|
|
214 |
1 |
AppletFormatAdapter formatAdapter = new AppletFormatAdapter(); |
215 |
1 |
try |
216 |
|
{ |
217 |
1 |
alignment = (Alignment) formatAdapter.readFile(TEST_JSON_FILE, |
218 |
|
DataSourceType.FILE, FileFormat.Json); |
219 |
1 |
jf = (JSONFile) formatAdapter.getAlignFile(); |
220 |
|
|
221 |
1 |
AlignFrame af = new AlignFrame(alignment, jf.getHiddenSequences(), |
222 |
|
jf.getHiddenColumns(), AlignFrame.DEFAULT_WIDTH, |
223 |
|
AlignFrame.DEFAULT_HEIGHT); |
224 |
1 |
af.getViewport().setShowSequenceFeatures(jf.isShowSeqFeatures()); |
225 |
1 |
String colourSchemeName = jf.getGlobalColourScheme(); |
226 |
1 |
ColourSchemeI cs = ColourSchemeMapper.getJalviewColourScheme( |
227 |
|
colourSchemeName, alignment); |
228 |
1 |
af.changeColour(cs); |
229 |
1 |
af.getViewport().setFeaturesDisplayed(jf.getDisplayedFeatures()); |
230 |
|
|
231 |
1 |
formatAdapter = new AppletFormatAdapter(af.alignPanel, exportSettings); |
232 |
1 |
String jsonOutput = formatAdapter.formatSequences(FileFormat.Json, |
233 |
|
af.alignPanel.getAlignment(), false); |
234 |
|
|
235 |
1 |
formatAdapter = new AppletFormatAdapter(); |
236 |
1 |
testAlignment = formatAdapter.readFile(jsonOutput, |
237 |
|
DataSourceType.PASTE, FileFormat.Json); |
238 |
1 |
testJsonFile = (JSONFile) formatAdapter.getAlignFile(); |
239 |
|
|
240 |
|
} catch (IOException e) |
241 |
|
{ |
242 |
0 |
e.printStackTrace(); |
243 |
|
} |
244 |
|
|
245 |
|
} |
246 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
247 |
10 |
@BeforeMethod(alwaysRun = true)... |
248 |
|
public void methodSetup() |
249 |
|
{ |
250 |
10 |
passedCount = 0; |
251 |
|
} |
252 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
253 |
1 |
@AfterTest(alwaysRun = true)... |
254 |
|
public void tearDown() throws Exception |
255 |
|
{ |
256 |
1 |
testJsonFile = null; |
257 |
1 |
alignment = null; |
258 |
1 |
expectedSeqs = null; |
259 |
1 |
expectedAnnots = null; |
260 |
1 |
expectedGrps = null; |
261 |
1 |
testAlignment = null; |
262 |
1 |
jf = null; |
263 |
|
} |
264 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
265 |
1 |
@Test(groups = { "Functional" })... |
266 |
|
public void roundTripTest() |
267 |
|
{ |
268 |
1 |
assertNotNull("JSON roundtrip test failed!", testJsonFile); |
269 |
|
} |
270 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
271 |
1 |
@Test(groups = { "Functional" })... |
272 |
|
public void testSeqParsed() |
273 |
|
{ |
274 |
1 |
assertNotNull("Couldn't read supplied alignment data.", testAlignment); |
275 |
1 |
Assert.assertNotNull(testAlignment.getSequences()); |
276 |
1 |
for (SequenceI seq : testAlignment.getSequences()) |
277 |
|
{ |
278 |
5 |
SequenceI expectedSeq = expectedSeqs.get(seq.getName()); |
279 |
5 |
AssertJUnit.assertTrue( |
280 |
|
"Failed Sequence Test for >>> " + seq.getName(), |
281 |
|
isSeqMatched(expectedSeq, seq)); |
282 |
5 |
passedCount++; |
283 |
|
} |
284 |
1 |
AssertJUnit.assertEquals("Some Sequences did not pass the test", |
285 |
|
TEST_SEQ_HEIGHT, passedCount); |
286 |
|
} |
287 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
288 |
1 |
@Test(groups = { "Functional" })... |
289 |
|
public void hiddenColsTest() |
290 |
|
{ |
291 |
1 |
HiddenColumns cs = testJsonFile.getHiddenColumns(); |
292 |
1 |
Assert.assertNotNull(cs); |
293 |
|
|
294 |
1 |
Iterator<int[]> it = cs.iterator(); |
295 |
1 |
Iterator<int[]> colselit = expectedColSel.iterator(); |
296 |
1 |
Assert.assertTrue(it.hasNext()); |
297 |
1 |
Assert.assertEquals(cs.getNumberOfRegions(), TEST_CS_HEIGHT); |
298 |
1 |
Assert.assertEquals(it.next(), colselit.next(), |
299 |
|
"Mismatched hidden columns!"); |
300 |
|
} |
301 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
302 |
1 |
@Test(groups = { "Functional" })... |
303 |
|
public void hiddenSeqsTest() |
304 |
|
{ |
305 |
1 |
Assert.assertNotNull(testJsonFile.getHiddenSequences(), |
306 |
|
"Hidden sequence Expected but found Null"); |
307 |
1 |
Assert.assertEquals(jf.getHiddenSequences().length, 1, |
308 |
|
"Hidden sequence"); |
309 |
|
} |
310 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
311 |
1 |
@Test(groups = { "Functional" })... |
312 |
|
public void colorSchemeTest() |
313 |
|
{ |
314 |
1 |
Assert.assertNotNull(testJsonFile.getGlobalColourScheme(), |
315 |
|
"Colourscheme is null, parsing failed!"); |
316 |
1 |
Assert.assertEquals(testJsonFile.getGlobalColourScheme(), "Zappo", |
317 |
|
"Zappo colour scheme expected!"); |
318 |
|
} |
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
|
|
|
| 94.7% |
Uncovered Elements: 1 (19) |
Complexity: 2 |
Complexity Density: 0.11 |
1PASS
|
|
324 |
1 |
@Test(groups = { "Functional" })... |
325 |
|
public void testBioJSONRoundTripWithColourSchemeNone() |
326 |
|
{ |
327 |
1 |
AppletFormatAdapter formatAdapter = new AppletFormatAdapter(); |
328 |
|
|
329 |
1 |
Alignment _alignment; |
330 |
1 |
try |
331 |
|
{ |
332 |
|
|
333 |
1 |
_alignment = (Alignment) formatAdapter.readFile(TEST_JSON_FILE, |
334 |
|
DataSourceType.FILE, FileFormat.Json); |
335 |
1 |
JSONFile bioJsonFile = (JSONFile) formatAdapter.getAlignFile(); |
336 |
1 |
AlignFrame alignFrame = new AlignFrame(_alignment, |
337 |
|
bioJsonFile.getHiddenSequences(), |
338 |
|
bioJsonFile.getHiddenColumns(), AlignFrame.DEFAULT_WIDTH, |
339 |
|
AlignFrame.DEFAULT_HEIGHT); |
340 |
|
|
341 |
|
|
342 |
|
|
343 |
|
|
344 |
|
|
345 |
1 |
SequenceGroup sg = new SequenceGroup(); |
346 |
1 |
sg.addSequence(_alignment.getSequenceAt(0), false); |
347 |
1 |
sg.setColourScheme(null); |
348 |
1 |
ColourSchemeI cs = ColourSchemeMapper.getJalviewColourScheme( |
349 |
|
ResidueColourScheme.NONE, _alignment); |
350 |
1 |
alignFrame.changeColour(cs); |
351 |
1 |
alignFrame.getViewport().setFeaturesDisplayed( |
352 |
|
bioJsonFile.getDisplayedFeatures()); |
353 |
1 |
formatAdapter = new AppletFormatAdapter(alignFrame.alignPanel, |
354 |
|
exportSettings); |
355 |
|
|
356 |
1 |
String jsonOutput = formatAdapter.formatSequences(FileFormat.Json, |
357 |
|
alignFrame.alignPanel.getAlignment(), false); |
358 |
|
|
359 |
1 |
formatAdapter = new AppletFormatAdapter(); |
360 |
1 |
formatAdapter.readFile(jsonOutput, DataSourceType.PASTE, |
361 |
|
FileFormat.Json); |
362 |
|
|
363 |
1 |
JSONFile _bioJsonFile = (JSONFile) formatAdapter.getAlignFile(); |
364 |
1 |
Assert.assertEquals(_bioJsonFile.getGlobalColourScheme(), |
365 |
|
ResidueColourScheme.NONE); |
366 |
|
} catch (IOException e) |
367 |
|
{ |
368 |
0 |
e.printStackTrace(); |
369 |
|
} |
370 |
|
} |
371 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
372 |
1 |
@Test(groups = { "Functional" })... |
373 |
|
public void isShowSeqFeaturesSet() |
374 |
|
{ |
375 |
1 |
Assert.assertTrue(testJsonFile.isShowSeqFeatures(), |
376 |
|
"Sequence feature isDisplayed setting expected to be true"); |
377 |
|
} |
378 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
379 |
1 |
@Test(groups = { "Functional" })... |
380 |
|
public void testGrpParsed() |
381 |
|
{ |
382 |
1 |
Assert.assertNotNull(testAlignment.getGroups()); |
383 |
1 |
for (SequenceGroup seqGrp : testAlignment.getGroups()) |
384 |
|
{ |
385 |
1 |
SequenceGroup expectedGrp = expectedGrps.get(seqGrp.getName()); |
386 |
1 |
AssertJUnit.assertTrue( |
387 |
|
"Failed SequenceGroup Test for >>> " + seqGrp.getName(), |
388 |
|
isGroupMatched(expectedGrp, seqGrp)); |
389 |
1 |
passedCount++; |
390 |
|
} |
391 |
1 |
AssertJUnit.assertEquals("Some SequenceGroups did not pass the test", |
392 |
|
TEST_GRP_HEIGHT, passedCount); |
393 |
|
} |
394 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
395 |
1 |
@Test(groups = { "Functional" })... |
396 |
|
public void testAnnotationParsed() |
397 |
|
{ |
398 |
1 |
Assert.assertNotNull(testAlignment.getAlignmentAnnotation()); |
399 |
1 |
for (AlignmentAnnotation annot : testAlignment.getAlignmentAnnotation()) |
400 |
|
{ |
401 |
1 |
AlignmentAnnotation expectedAnnot = expectedAnnots.get(annot.label); |
402 |
1 |
AssertJUnit.assertTrue("Failed AlignmentAnnotation Test for >>> " |
403 |
|
+ annot.label, isAnnotationMatched(expectedAnnot, annot)); |
404 |
1 |
passedCount++; |
405 |
|
} |
406 |
1 |
AssertJUnit.assertEquals("Some Sequences did not pass the test", |
407 |
|
TEST_ANOT_HEIGHT, passedCount); |
408 |
|
} |
409 |
|
|
|
|
| 71.4% |
Uncovered Elements: 4 (14) |
Complexity: 8 |
Complexity Density: 1 |
|
410 |
1 |
public boolean isAnnotationMatched(AlignmentAnnotation eAnnot,... |
411 |
|
AlignmentAnnotation annot) |
412 |
|
{ |
413 |
1 |
if (!eAnnot.label.equals(annot.label) |
414 |
|
|| !eAnnot.description.equals(annot.description) |
415 |
|
|| eAnnot.annotations.length != annot.annotations.length) |
416 |
|
{ |
417 |
0 |
return false; |
418 |
|
} |
419 |
|
|
420 |
36 |
for (int x = 0; x < annot.annotations.length; x++) |
421 |
|
{ |
422 |
35 |
Annotation y = annot.annotations[x]; |
423 |
35 |
Annotation z = annot.annotations[x]; |
424 |
|
|
425 |
35 |
if (!y.displayCharacter.equals(z.displayCharacter) |
426 |
|
|| y.value != z.value |
427 |
|
|| y.secondaryStructure != z.secondaryStructure) |
428 |
|
{ |
429 |
0 |
return false; |
430 |
|
} |
431 |
|
} |
432 |
1 |
return true; |
433 |
|
} |
434 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 6 |
Complexity Density: 1.5 |
|
435 |
5 |
boolean isSeqMatched(SequenceI expectedSeq, SequenceI actualSeq)... |
436 |
|
{ |
437 |
5 |
System.out.println("Testing >>> " + actualSeq.getName()); |
438 |
|
|
439 |
5 |
if (expectedSeq.getName().equals(actualSeq.getName()) |
440 |
|
&& expectedSeq.getSequenceAsString().equals( |
441 |
|
actualSeq.getSequenceAsString()) |
442 |
|
&& expectedSeq.getStart() == actualSeq.getStart() |
443 |
|
&& expectedSeq.getEnd() == actualSeq.getEnd() |
444 |
|
&& featuresMatched(expectedSeq, actualSeq)) |
445 |
|
{ |
446 |
5 |
return true; |
447 |
|
} |
448 |
0 |
return false; |
449 |
|
} |
450 |
|
|
|
|
| 86.7% |
Uncovered Elements: 2 (15) |
Complexity: 9 |
Complexity Density: 0.69 |
|
451 |
2 |
public boolean isGroupMatched(SequenceGroup expectedGrp,... |
452 |
|
SequenceGroup actualGrp) |
453 |
|
{ |
454 |
|
|
455 |
2 |
System.out.println("Testing >>> " + actualGrp.getName()); |
456 |
2 |
System.out.println(expectedGrp.getName() + " | " + actualGrp.getName()); |
457 |
2 |
System.out.println(expectedGrp.getColourText() + " | " |
458 |
|
+ actualGrp.getColourText()); |
459 |
2 |
System.out.println(expectedGrp.getDisplayBoxes() + " | " |
460 |
|
+ actualGrp.getDisplayBoxes()); |
461 |
2 |
System.out.println(expectedGrp.getIgnoreGapsConsensus() + " | " |
462 |
|
+ actualGrp.getIgnoreGapsConsensus()); |
463 |
2 |
System.out.println(expectedGrp.getSequences().size() + " | " |
464 |
|
+ actualGrp.getSequences().size()); |
465 |
2 |
System.out.println(expectedGrp.getStartRes() + " | " |
466 |
|
+ actualGrp.getStartRes()); |
467 |
2 |
System.out.println(expectedGrp.getEndRes() + " | " |
468 |
|
+ actualGrp.getEndRes()); |
469 |
2 |
System.out.println(expectedGrp.cs.getColourScheme() + " | " |
470 |
|
+ actualGrp.cs.getColourScheme()); |
471 |
|
|
472 |
2 |
boolean colourSchemeMatches = (expectedGrp.cs.getColourScheme() == null && actualGrp.cs |
473 |
|
.getColourScheme() == null) |
474 |
|
|| expectedGrp.cs.getColourScheme().getClass() |
475 |
|
.equals(actualGrp.cs.getColourScheme().getClass()); |
476 |
2 |
if (expectedGrp.getName().equals(actualGrp.getName()) |
477 |
|
&& expectedGrp.getColourText() == actualGrp.getColourText() |
478 |
|
&& expectedGrp.getDisplayBoxes() == actualGrp.getDisplayBoxes() |
479 |
|
&& expectedGrp.getIgnoreGapsConsensus() == actualGrp |
480 |
|
.getIgnoreGapsConsensus() |
481 |
|
&& colourSchemeMatches |
482 |
|
&& expectedGrp.getSequences().size() == actualGrp |
483 |
|
.getSequences().size() |
484 |
|
&& expectedGrp.getStartRes() == actualGrp.getStartRes() |
485 |
|
&& expectedGrp.getEndRes() == actualGrp.getEndRes()) |
486 |
|
{ |
487 |
2 |
return true; |
488 |
|
} |
489 |
0 |
return false; |
490 |
|
} |
491 |
|
|
|
|
| 64% |
Uncovered Elements: 9 (25) |
Complexity: 6 |
Complexity Density: 0.32 |
|
492 |
5 |
private boolean featuresMatched(SequenceI seq1, SequenceI seq2)... |
493 |
|
{ |
494 |
5 |
try |
495 |
|
{ |
496 |
5 |
if (seq1 == null && seq2 == null) |
497 |
|
{ |
498 |
0 |
return true; |
499 |
|
} |
500 |
|
|
501 |
5 |
List<SequenceFeature> inFeature = seq1.getFeatures().getAllFeatures(); |
502 |
5 |
List<SequenceFeature> outFeature = seq2.getFeatures() |
503 |
|
.getAllFeatures(); |
504 |
|
|
505 |
5 |
if (inFeature.size() != outFeature.size()) |
506 |
|
{ |
507 |
0 |
System.err.println("Feature count in: " + inFeature.size() |
508 |
|
+ ", out: " + outFeature.size()); |
509 |
0 |
return false; |
510 |
|
} |
511 |
|
|
512 |
5 |
SequenceFeatures.sortFeatures(inFeature, true); |
513 |
5 |
SequenceFeatures.sortFeatures(outFeature, true); |
514 |
5 |
int i = 0; |
515 |
5 |
for (SequenceFeature in : inFeature) |
516 |
|
{ |
517 |
4 |
SequenceFeature out = outFeature.get(i); |
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
|
523 |
4 |
if (!in.equals(out)) |
524 |
|
{ |
525 |
0 |
System.err.println("Mismatch of " + in.toString() + " " |
526 |
|
+ out.toString()); |
527 |
0 |
return false; |
528 |
|
} |
529 |
|
|
530 |
|
|
531 |
|
|
532 |
|
|
533 |
|
|
534 |
|
|
535 |
|
|
536 |
|
|
537 |
|
|
538 |
|
|
539 |
|
|
540 |
|
|
541 |
|
|
542 |
|
|
543 |
|
|
544 |
|
|
545 |
4 |
i++; |
546 |
|
} |
547 |
|
} catch (Exception e) |
548 |
|
{ |
549 |
0 |
e.printStackTrace(); |
550 |
|
} |
551 |
|
|
552 |
5 |
return true; |
553 |
|
} |
554 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 12 |
Complexity Density: 0.75 |
|
555 |
0 |
boolean mapsMatch(Map<String, Object> m1, Map<String, Object> m2)... |
556 |
|
{ |
557 |
0 |
if (m1 == null || m2 == null) |
558 |
|
{ |
559 |
0 |
if (m1 != null || m2 != null) |
560 |
|
{ |
561 |
0 |
System.err |
562 |
|
.println("only one SequenceFeature.otherDetails is not null"); |
563 |
0 |
return false; |
564 |
|
} |
565 |
|
else |
566 |
|
{ |
567 |
0 |
return true; |
568 |
|
} |
569 |
|
} |
570 |
0 |
if (m1.size() != m2.size()) |
571 |
|
{ |
572 |
0 |
System.err.println("otherDetails map different sizes"); |
573 |
0 |
return false; |
574 |
|
} |
575 |
0 |
for (String key : m1.keySet()) |
576 |
|
{ |
577 |
0 |
if (!m2.containsKey(key)) |
578 |
|
{ |
579 |
0 |
System.err.println(key + " in only one otherDetails"); |
580 |
0 |
return false; |
581 |
|
} |
582 |
0 |
if (m1.get(key) == null && m2.get(key) != null || m1.get(key) != null |
583 |
|
&& m2.get(key) == null || !m1.get(key).equals(m2.get(key))) |
584 |
|
{ |
585 |
0 |
System.err.println(key + " values in otherDetails don't match"); |
586 |
0 |
return false; |
587 |
|
} |
588 |
|
} |
589 |
0 |
return true; |
590 |
|
} |
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
|
595 |
|
@throws |
596 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
597 |
1 |
@Test(groups = { "Functional" })... |
598 |
|
public void testGrpParsed_colourNone() throws IOException |
599 |
|
{ |
600 |
1 |
AlignmentI copy = new Alignment(testAlignment); |
601 |
1 |
SequenceGroup sg = testAlignment.getGroups().get(0); |
602 |
1 |
SequenceGroup copySg = new SequenceGroup(new ArrayList<SequenceI>(), |
603 |
|
sg.getName(), |
604 |
|
null, sg.getDisplayBoxes(), sg.getDisplayText(), |
605 |
|
sg.getColourText(), sg.getStartRes(), sg.getEndRes()); |
606 |
1 |
for (SequenceI seq : sg.getSequences()) |
607 |
|
{ |
608 |
4 |
int seqIndex = testAlignment.findIndex(seq); |
609 |
4 |
copySg.addSequence(copy.getSequenceAt(seqIndex), false); |
610 |
|
} |
611 |
1 |
copy.addGroup(copySg); |
612 |
|
|
613 |
1 |
AlignFrame af = new AlignFrame(copy, copy.getWidth(), copy.getHeight()); |
614 |
1 |
AppletFormatAdapter formatAdapter = new AppletFormatAdapter( |
615 |
|
af.alignPanel); |
616 |
1 |
String jsonOutput = formatAdapter.formatSequences(FileFormat.Json, |
617 |
|
copy, false); |
618 |
1 |
formatAdapter = new AppletFormatAdapter(); |
619 |
1 |
AlignmentI newAlignment = formatAdapter.readFile(jsonOutput, |
620 |
|
DataSourceType.PASTE, FileFormat.Json); |
621 |
|
|
622 |
1 |
Assert.assertNotNull(newAlignment.getGroups()); |
623 |
1 |
for (SequenceGroup seqGrp : newAlignment.getGroups()) |
624 |
|
{ |
625 |
1 |
SequenceGroup expectedGrp = copySg; |
626 |
1 |
AssertJUnit.assertTrue( |
627 |
|
"Failed SequenceGroup Test for >>> " + seqGrp.getName(), |
628 |
|
isGroupMatched(expectedGrp, seqGrp)); |
629 |
1 |
passedCount++; |
630 |
|
} |
631 |
1 |
AssertJUnit.assertEquals("Some SequenceGroups did not pass the test", |
632 |
|
TEST_GRP_HEIGHT, passedCount); |
633 |
|
} |
634 |
|
} |