1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package mc_view; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertFalse; |
25 |
|
import static org.testng.AssertJUnit.assertNull; |
26 |
|
import static org.testng.AssertJUnit.assertSame; |
27 |
|
import static org.testng.AssertJUnit.assertTrue; |
28 |
|
|
29 |
|
import java.io.IOException; |
30 |
|
import java.util.List; |
31 |
|
|
32 |
|
import org.testng.annotations.BeforeClass; |
33 |
|
import org.testng.annotations.BeforeMethod; |
34 |
|
import org.testng.annotations.Test; |
35 |
|
|
36 |
|
import jalview.bin.Cache; |
37 |
|
import jalview.datamodel.Alignment; |
38 |
|
import jalview.datamodel.AlignmentAnnotation; |
39 |
|
import jalview.datamodel.AlignmentI; |
40 |
|
import jalview.datamodel.PDBEntry; |
41 |
|
import jalview.datamodel.Sequence; |
42 |
|
import jalview.datamodel.SequenceI; |
43 |
|
import jalview.gui.JvOptionPane; |
44 |
|
import jalview.io.DataSourceType; |
45 |
|
import jalview.structure.StructureImportSettings; |
46 |
|
|
|
|
| 98.5% |
Uncovered Elements: 2 (132) |
Complexity: 10 |
Complexity Density: 0.08 |
|
47 |
|
public class PDBfileTest |
48 |
|
{ |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
50 |
1 |
@BeforeClass(alwaysRun = true)... |
51 |
|
public void setUpJvOptionPane() |
52 |
|
{ |
53 |
1 |
JvOptionPane.setInteractiveMode(false); |
54 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
55 |
|
} |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
57 |
1 |
@Test(groups = { "Functional" })... |
58 |
|
public void testIsRna() |
59 |
|
{ |
60 |
1 |
SequenceI seq = new Sequence("Seq1", "CGAU"); |
61 |
1 |
assertTrue(PDBfile.isRNA(seq)); |
62 |
|
|
63 |
1 |
seq.setSequence("CGAu"); |
64 |
1 |
assertFalse(PDBfile.isRNA(seq)); |
65 |
|
|
66 |
1 |
seq.setSequence("CGAT"); |
67 |
1 |
assertFalse(PDBfile.isRNA(seq)); |
68 |
|
|
69 |
1 |
seq.setSequence("GRSWYFLAVM"); |
70 |
1 |
assertFalse(PDBfile.isRNA(seq)); |
71 |
|
} |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
@throws |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (52) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
79 |
1 |
@Test(groups = { "Functional" })... |
80 |
|
public void testParse() throws IOException |
81 |
|
{ |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
1 |
PDBfile pf = new PDBfile(false, false, false, "examples/3W5V.pdb", |
86 |
|
DataSourceType.FILE); |
87 |
|
|
88 |
1 |
assertEquals("3W5V", pf.getId()); |
89 |
|
|
90 |
1 |
assertNull(getAlignmentAnnotations(pf)); |
91 |
|
|
92 |
1 |
assertEquals(4, pf.getChains().size()); |
93 |
1 |
assertEquals("A", pf.getChains().get(0).id); |
94 |
1 |
assertEquals("B", pf.getChains().get(1).id); |
95 |
1 |
assertEquals("C", pf.getChains().get(2).id); |
96 |
1 |
assertEquals("D", pf.getChains().get(3).id); |
97 |
|
|
98 |
1 |
PDBChain chainA = pf.getChains().get(0); |
99 |
1 |
SequenceI seqA = pf.getSeqs().get(0); |
100 |
|
|
101 |
1 |
assertEquals(0, chainA.seqstart); |
102 |
1 |
assertEquals(0, chainA.seqend); |
103 |
1 |
assertEquals(18, chainA.sequence.getStart()); |
104 |
1 |
assertEquals(314, chainA.sequence.getEnd()); |
105 |
1 |
assertTrue( |
106 |
|
chainA.sequence.getSequenceAsString().startsWith("KCSKKQEE")); |
107 |
1 |
assertTrue(chainA.sequence.getSequenceAsString().endsWith("WNVEVY")); |
108 |
1 |
assertEquals("3W5V|A", chainA.sequence.getName()); |
109 |
1 |
assertNull(chainA.sequence.getAnnotation()); |
110 |
1 |
assertEquals(1, seqA.getAllPDBEntries().size()); |
111 |
1 |
PDBEntry pdb = seqA.getAllPDBEntries().get(0); |
112 |
1 |
assertEquals("A", pdb.getChainCode()); |
113 |
1 |
assertEquals("PDB", pdb.getType()); |
114 |
1 |
assertEquals("3W5V", pdb.getId()); |
115 |
|
|
116 |
1 |
PDBChain chainB = pf.getChains().get(1); |
117 |
1 |
assertEquals(1, chainB.sequence.getStart()); |
118 |
1 |
assertEquals(96, chainB.sequence.getEnd()); |
119 |
1 |
assertTrue(chainB.sequence.getSequenceAsString().startsWith("ATYNVK")); |
120 |
1 |
assertTrue(chainB.sequence.getSequenceAsString().endsWith("KEEELT")); |
121 |
1 |
assertEquals("3W5V|B", chainB.sequence.getName()); |
122 |
|
|
123 |
1 |
PDBChain chainC = pf.getChains().get(2); |
124 |
1 |
assertEquals(18, chainC.sequence.getStart()); |
125 |
1 |
assertEquals(314, chainC.sequence.getEnd()); |
126 |
1 |
assertTrue( |
127 |
|
chainC.sequence.getSequenceAsString().startsWith("KCSKKQEE")); |
128 |
1 |
assertTrue(chainC.sequence.getSequenceAsString().endsWith("WNVEVY")); |
129 |
1 |
assertEquals("3W5V|C", chainC.sequence.getName()); |
130 |
|
|
131 |
1 |
PDBChain chainD = pf.getChains().get(3); |
132 |
1 |
assertEquals(1, chainD.sequence.getStart()); |
133 |
1 |
assertEquals(96, chainD.sequence.getEnd()); |
134 |
1 |
assertTrue(chainD.sequence.getSequenceAsString().startsWith("ATYNVK")); |
135 |
1 |
assertTrue(chainD.sequence.getSequenceAsString().endsWith("KEEELT")); |
136 |
1 |
assertEquals("3W5V|D", chainD.sequence.getName()); |
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
1 |
List<SequenceI> seqs = pf.getSeqs(); |
142 |
1 |
assertEquals(4, seqs.size()); |
143 |
1 |
assertEquals("3W5V|A", seqs.get(0).getName()); |
144 |
1 |
assertEquals("3W5V|B", seqs.get(1).getName()); |
145 |
1 |
assertEquals("3W5V|C", seqs.get(2).getName()); |
146 |
1 |
assertEquals("3W5V|D", seqs.get(3).getName()); |
147 |
1 |
assertEquals(1, seqs.get(0).getAllPDBEntries().size()); |
148 |
1 |
PDBEntry pdbe = seqs.get(0).getAllPDBEntries().get(0); |
149 |
1 |
assertEquals("A", pdbe.getChainCode()); |
150 |
1 |
assertEquals("3W5V", pdbe.getId()); |
151 |
1 |
assertEquals(PDBEntry.Type.PDB.toString(), pdbe.getType()); |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
@throws |
159 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
160 |
1 |
@Test(groups = { "Functional" })... |
161 |
|
public void testParse_withAnnotations_noSS() throws IOException |
162 |
|
{ |
163 |
1 |
PDBfile pf = new PDBfile(true, false, false, "examples/3W5V.pdb", |
164 |
|
DataSourceType.FILE); |
165 |
|
|
166 |
1 |
AlignmentAnnotation[] anns = getAlignmentAnnotations(pf); |
167 |
1 |
assertEquals(4, anns.length); |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
1 |
AlignmentAnnotation chainAnnotation = anns[0]; |
173 |
1 |
assertEquals("Temperature Factor", chainAnnotation.label); |
174 |
|
|
175 |
1 |
assertEquals("Temperature Factor for 3w5vA", |
176 |
|
chainAnnotation.description); |
177 |
1 |
assertSame(pf.getSeqs().get(0), chainAnnotation.sequenceRef); |
178 |
1 |
assertEquals(AlignmentAnnotation.LINE_GRAPH, chainAnnotation.graph); |
179 |
1 |
assertEquals(0f, chainAnnotation.graphMin, 0.001f); |
180 |
1 |
assertEquals(40f, chainAnnotation.graphMax, 0.001f); |
181 |
1 |
assertEquals(297, chainAnnotation.annotations.length); |
182 |
1 |
assertEquals(40f, chainAnnotation.annotations[0].value, 0.001f); |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
1 |
chainAnnotation = anns[1]; |
188 |
1 |
assertEquals("Temperature Factor for 3w5vB", |
189 |
|
chainAnnotation.description); |
190 |
1 |
assertSame(pf.getSeqs().get(1), chainAnnotation.sequenceRef); |
191 |
1 |
assertEquals(96, chainAnnotation.annotations.length); |
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
1 |
chainAnnotation = anns[2]; |
197 |
1 |
assertEquals("Temperature Factor for 3w5vC", |
198 |
|
chainAnnotation.description); |
199 |
1 |
assertSame(pf.getSeqs().get(2), chainAnnotation.sequenceRef); |
200 |
1 |
assertEquals(297, chainAnnotation.annotations.length); |
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
1 |
chainAnnotation = anns[3]; |
206 |
1 |
assertEquals("Temperature Factor for 3w5vD", |
207 |
|
chainAnnotation.description); |
208 |
1 |
assertSame(pf.getSeqs().get(3), chainAnnotation.sequenceRef); |
209 |
1 |
assertEquals(96, chainAnnotation.annotations.length); |
210 |
|
} |
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
@throws |
217 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
218 |
1 |
@Test(groups = { "Functional" })... |
219 |
|
public void testParse_withJmol_noAnnotations() throws IOException |
220 |
|
{ |
221 |
1 |
PDBfile pf = new PDBfile(false, true, false, "examples/3W5V.pdb", |
222 |
|
DataSourceType.FILE); |
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
1 |
final AlignmentAnnotation[] anns = getAlignmentAnnotations(pf); |
229 |
1 |
assertEquals(4, anns.length); |
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
1 |
for (PDBChain c : pf.getChains()) |
236 |
|
{ |
237 |
4 |
assertNull(c.sequence.getAnnotation()); |
238 |
|
} |
239 |
|
} |
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
@throws |
246 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 2 |
Complexity Density: 0.1 |
1PASS
|
|
247 |
1 |
@Test(groups = { "Functional" })... |
248 |
|
public void testParse_withJmolAddAlignmentAnnotations() throws IOException |
249 |
|
{ |
250 |
1 |
PDBfile pf = new PDBfile(true, true, false, "examples/3W5V.pdb", |
251 |
|
DataSourceType.FILE); |
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
1 |
AlignmentAnnotation[] anns = getAlignmentAnnotations(pf); |
257 |
1 |
assertEquals(8, anns.length); |
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
262 |
1 |
assertEquals("Temperature Factor for 3w5vA", anns[1].description); |
263 |
1 |
assertEquals("Temperature Factor for 3w5vB", anns[3].description); |
264 |
1 |
assertEquals("Temperature Factor for 3w5vC", anns[5].description); |
265 |
1 |
assertEquals("Temperature Factor for 3w5vD", anns[7].description); |
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
1 |
assertEquals("Secondary Structure for 3w5vA", anns[0].description); |
271 |
1 |
assertEquals("Secondary Structure for 3w5vB", anns[2].description); |
272 |
1 |
assertEquals("Secondary Structure for 3w5vC", anns[4].description); |
273 |
1 |
assertEquals("Secondary Structure for 3w5vD", anns[6].description); |
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
1 |
assertSame(pf.getSeqs().get(0), anns[0].sequenceRef); |
279 |
1 |
assertSame(pf.getSeqs().get(1), anns[2].sequenceRef); |
280 |
1 |
assertSame(pf.getSeqs().get(2), anns[4].sequenceRef); |
281 |
1 |
assertSame(pf.getSeqs().get(3), anns[6].sequenceRef); |
282 |
|
|
283 |
|
|
284 |
|
|
285 |
|
|
286 |
21 |
for (int i = 0; i < 20; i++) |
287 |
|
{ |
288 |
20 |
assertNull(anns[0].annotations[i]); |
289 |
20 |
assertNull(anns[0].annotations[20].displayCharacter); |
290 |
20 |
assertEquals('E', anns[0].annotations[20].secondaryStructure); |
291 |
20 |
assertEquals('E', anns[2].annotations[18].secondaryStructure); |
292 |
20 |
assertEquals('H', anns[2].annotations[23].secondaryStructure); |
293 |
|
} |
294 |
|
} |
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
@throws |
301 |
|
|
302 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
303 |
0 |
@Test(groups = { "Functional" }, enabled = false)... |
304 |
|
public void testParse_withAnnotate3D() throws IOException |
305 |
|
{ |
306 |
|
|
307 |
|
|
308 |
0 |
PDBfile pf = new PDBfile(true, true, true, "examples/2GIS.pdb", |
309 |
|
DataSourceType.FILE); |
310 |
|
} |
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
|
315 |
|
@param |
316 |
|
@return |
317 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
318 |
4 |
private AlignmentAnnotation[] getAlignmentAnnotations(PDBfile pf)... |
319 |
|
{ |
320 |
4 |
AlignmentI al = new Alignment(pf.getSeqsAsArray()); |
321 |
4 |
pf.addAnnotations(al); |
322 |
4 |
return al.getAlignmentAnnotation(); |
323 |
|
} |
324 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
325 |
5 |
@BeforeMethod(alwaysRun = true)... |
326 |
|
public void setUp() |
327 |
|
{ |
328 |
5 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
329 |
5 |
Cache.applicationProperties.setProperty("STRUCT_FROM_PDB", |
330 |
|
Boolean.TRUE.toString()); |
331 |
5 |
Cache.applicationProperties.setProperty("ADD_TEMPFACT_ANN", |
332 |
|
Boolean.TRUE.toString()); |
333 |
5 |
Cache.applicationProperties.setProperty("ADD_SS_ANN", |
334 |
|
Boolean.TRUE.toString()); |
335 |
5 |
StructureImportSettings.setDefaultStructureFileFormat("PDB"); |
336 |
|
} |
337 |
|
} |