1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ext.jmol; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertNotNull; |
25 |
|
import static org.testng.AssertJUnit.assertTrue; |
26 |
|
|
27 |
|
import jalview.bin.Cache; |
28 |
|
import jalview.datamodel.Alignment; |
29 |
|
import jalview.datamodel.AlignmentI; |
30 |
|
import jalview.datamodel.SequenceI; |
31 |
|
import jalview.gui.AlignFrame; |
32 |
|
import jalview.gui.JvOptionPane; |
33 |
|
import jalview.io.DataSourceType; |
34 |
|
import jalview.io.FileLoader; |
35 |
|
import jalview.structure.StructureImportSettings; |
36 |
|
import jalview.structure.StructureImportSettings.StructureParser; |
37 |
|
|
38 |
|
import java.util.Vector; |
39 |
|
|
40 |
|
import org.jmol.c.STR; |
41 |
|
import org.testng.annotations.BeforeClass; |
42 |
|
import org.testng.annotations.BeforeMethod; |
43 |
|
import org.testng.annotations.Test; |
44 |
|
|
45 |
|
import mc_view.PDBfile; |
46 |
|
|
47 |
|
|
48 |
|
@author |
49 |
|
|
50 |
|
|
|
|
| 93.1% |
Uncovered Elements: 7 (102) |
Complexity: 15 |
Complexity Density: 0.18 |
|
51 |
|
public class JmolParserTest |
52 |
|
{ |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
54 |
1 |
@BeforeClass(alwaysRun = true)... |
55 |
|
public void setUpJvOptionPane() |
56 |
|
{ |
57 |
1 |
JvOptionPane.setInteractiveMode(false); |
58 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
59 |
|
} |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
String[] testFile = new String[] { "./examples/1gaq.txt", |
66 |
|
"./test/jalview/ext/jmol/1xyz.pdb", |
67 |
|
"./test/jalview/ext/jmol/1QCF.pdb" }; |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
String pastePDBDataWithChainBreak = |
72 |
|
"HEADER TRANSPORT PROTEIN 08-APR-15 4UJ4\n" + |
73 |
|
|
74 |
|
"ATOM 1909 CA VAL B 358 21.329 -19.739 -67.740 1.00201.05 C\n" + |
75 |
|
"ATOM 1916 CA GLY B 359 21.694 -23.563 -67.661 1.00198.09 C\n" + |
76 |
|
"ATOM 1920 CA LYS B 367 32.471 -12.135 -77.100 1.00257.97 C\n" + |
77 |
|
"ATOM 1925 CA ALA B 368 31.032 -9.324 -74.946 1.00276.01 C\n" + |
78 |
|
|
79 |
|
"ATOM 1930 CA SER C 369 32.589 -7.517 -71.978 1.00265.44 C\n" + |
80 |
|
"ATOM 1936 CA ALA C 370 31.650 -6.849 -68.346 1.00249.48 C\n"; |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
String pdbWithAltLoc = |
86 |
|
"HEADER TRANSPORT PROTEIN 08-APR-15 1EJG\n" + |
87 |
|
"ATOM 448 CA ALA A 24 6.619 16.195 1.970 1.00 1.65 C\n" + |
88 |
|
"ATOM 458 CA ALEU A 25 3.048 14.822 1.781 0.57 1.48 C\n" + |
89 |
|
|
90 |
|
"ATOM 478 CA BILE A 25 3.048 14.822 1.781 0.21 1.48 C\n" + |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
"ATOM 512 CA CYS A 26 4.137 11.461 3.154 1.00 1.52 C\n"; |
95 |
|
|
96 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
97 |
6 |
@BeforeMethod(alwaysRun = true)... |
98 |
|
public void setUp() |
99 |
|
{ |
100 |
6 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
101 |
6 |
Cache.applicationProperties.setProperty("STRUCT_FROM_PDB", |
102 |
|
Boolean.TRUE.toString()); |
103 |
6 |
Cache.applicationProperties.setProperty("ADD_TEMPFACT_ANN", |
104 |
|
Boolean.FALSE.toString()); |
105 |
6 |
Cache.applicationProperties.setProperty("ADD_SS_ANN", |
106 |
|
Boolean.TRUE.toString()); |
107 |
6 |
StructureImportSettings.setDefaultStructureFileFormat("PDB"); |
108 |
6 |
StructureImportSettings |
109 |
|
.setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER); |
110 |
|
} |
111 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
112 |
1 |
@Test(groups = { "Functional" })... |
113 |
|
public void testAlignmentLoader() throws Exception |
114 |
|
{ |
115 |
1 |
for (String f : testFile) |
116 |
|
{ |
117 |
3 |
FileLoader fl = new jalview.io.FileLoader(false); |
118 |
3 |
AlignFrame af = fl.LoadFileWaitTillLoaded(f, DataSourceType.FILE); |
119 |
3 |
validateSecStrRows(af.getViewport().getAlignment()); |
120 |
|
} |
121 |
|
} |
122 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
1PASS
|
|
123 |
1 |
@Test(groups = { "Functional" })... |
124 |
|
public void testFileParser() throws Exception |
125 |
|
{ |
126 |
1 |
for (String pdbStr : testFile) |
127 |
|
{ |
128 |
3 |
PDBfile mctest = new PDBfile(false, false, false, pdbStr, |
129 |
|
DataSourceType.FILE); |
130 |
3 |
JmolParser jtest = new JmolParser(pdbStr, DataSourceType.FILE); |
131 |
3 |
Vector<SequenceI> seqs = jtest.getSeqs(), mcseqs = mctest.getSeqs(); |
132 |
|
|
133 |
3 |
assertTrue("No sequences extracted from testfile\n" |
134 |
3 |
+ (jtest.hasWarningMessage() ? jtest.getWarningMessage() |
135 |
|
: "(No warnings raised)"), |
136 |
|
seqs != null && seqs.size() > 0); |
137 |
3 |
for (SequenceI sq : seqs) |
138 |
|
{ |
139 |
6 |
assertEquals( |
140 |
|
"JMol didn't process " + pdbStr |
141 |
|
+ " to the same sequence as MCView", |
142 |
|
sq.getSequenceAsString(), |
143 |
|
mcseqs.remove(0).getSequenceAsString()); |
144 |
6 |
AlignmentI al = new Alignment(new SequenceI[] { sq }); |
145 |
6 |
validateSecStrRows(al); |
146 |
|
} |
147 |
|
} |
148 |
|
|
149 |
|
} |
150 |
|
|
|
|
| 62.5% |
Uncovered Elements: 6 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
151 |
9 |
private void validateSecStrRows(AlignmentI al)... |
152 |
|
{ |
153 |
9 |
if (!al.isNucleotide()) |
154 |
|
{ |
155 |
9 |
for (SequenceI asq : al.getSequences()) |
156 |
|
{ |
157 |
12 |
SequenceI sq = asq; |
158 |
12 |
boolean hasDs = false; |
159 |
12 |
while (sq.getDatasetSequence() != null |
160 |
|
&& sq.getAnnotation() == null) |
161 |
|
{ |
162 |
0 |
sq = sq.getDatasetSequence(); |
163 |
0 |
hasDs = true; |
164 |
|
} |
165 |
12 |
checkFirstAAIsAssoc(sq); |
166 |
12 |
if (hasDs) |
167 |
|
{ |
168 |
|
|
169 |
|
|
170 |
0 |
checkFirstAAIsAssoc(asq); |
171 |
|
} |
172 |
|
} |
173 |
|
} |
174 |
|
} |
175 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
176 |
12 |
private void checkFirstAAIsAssoc(SequenceI sq)... |
177 |
|
{ |
178 |
12 |
assertTrue( |
179 |
|
"No secondary structure assigned for protein sequence for " |
180 |
|
+ sq.getName(), |
181 |
|
sq.getAnnotation() != null && sq.getAnnotation().length >= 1 |
182 |
|
&& sq.getAnnotation()[0].hasIcons); |
183 |
12 |
assertTrue( |
184 |
|
"Secondary structure not associated for sequence " |
185 |
|
+ sq.getName(), |
186 |
|
sq.getAnnotation()[0].sequenceRef == sq); |
187 |
|
} |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
@throws |
193 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
194 |
1 |
@Test(groups = { "Functional" })... |
195 |
|
public void testParse_missingResidues() throws Exception |
196 |
|
{ |
197 |
1 |
PDBfile mctest = new PDBfile(false, false, false, |
198 |
|
pastePDBDataWithChainBreak, DataSourceType.PASTE); |
199 |
1 |
JmolParser jtest = new JmolParser(pastePDBDataWithChainBreak, |
200 |
|
DataSourceType.PASTE); |
201 |
1 |
Vector<SequenceI> seqs = jtest.getSeqs(); |
202 |
1 |
Vector<SequenceI> mcseqs = mctest.getSeqs(); |
203 |
|
|
204 |
1 |
assertEquals("Failed to find 2 sequences\n", 2, seqs.size()); |
205 |
1 |
assertEquals("Failed to find 2 sequences\n", 2, mcseqs.size()); |
206 |
1 |
assertEquals("VGKA", seqs.get(0).getSequenceAsString()); |
207 |
1 |
assertEquals("VGKA", mcseqs.get(0).getSequenceAsString()); |
208 |
1 |
assertEquals("SA", seqs.get(1).getSequenceAsString()); |
209 |
1 |
assertEquals("SA", mcseqs.get(1).getSequenceAsString()); |
210 |
|
} |
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
@throws |
216 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
217 |
1 |
@Test(groups = { "Functional" })... |
218 |
|
public void testParse_alternativeResidues() throws Exception |
219 |
|
{ |
220 |
1 |
PDBfile mctest = new PDBfile(false, false, false, pdbWithAltLoc, |
221 |
|
DataSourceType.PASTE); |
222 |
1 |
JmolParser jtest = new JmolParser(pdbWithAltLoc, DataSourceType.PASTE); |
223 |
1 |
Vector<SequenceI> seqs = jtest.getSeqs(); |
224 |
1 |
Vector<SequenceI> mcseqs = mctest.getSeqs(); |
225 |
|
|
226 |
1 |
assertEquals("Failed to find 1 sequence\n", 1, seqs.size()); |
227 |
1 |
assertEquals("Failed to find 1 sequence\n", 1, mcseqs.size()); |
228 |
1 |
assertEquals("ALC", seqs.get(0).getSequenceAsString()); |
229 |
1 |
assertEquals("ALC", mcseqs.get(0).getSequenceAsString()); |
230 |
|
} |
231 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
232 |
1 |
@Test(groups = "Functional")... |
233 |
|
public void testSetSecondaryStructure() |
234 |
|
{ |
235 |
1 |
JmolParser testee = new JmolParser(); |
236 |
1 |
char[] struct = new char[10]; |
237 |
1 |
char[] structCode = new char[10]; |
238 |
1 |
struct[0] = '1'; |
239 |
1 |
structCode[0] = '1'; |
240 |
|
|
241 |
1 |
testee.setSecondaryStructure(STR.NONE, 0, struct, structCode); |
242 |
1 |
testee.setSecondaryStructure(STR.HELIX, 1, struct, structCode); |
243 |
1 |
testee.setSecondaryStructure(STR.HELIX310, 2, struct, structCode); |
244 |
1 |
testee.setSecondaryStructure(STR.HELIXALPHA, 3, struct, structCode); |
245 |
1 |
testee.setSecondaryStructure(STR.HELIXPI, 4, struct, structCode); |
246 |
1 |
testee.setSecondaryStructure(STR.SHEET, 5, struct, structCode); |
247 |
|
|
248 |
1 |
assertEquals(0, struct[0]); |
249 |
1 |
assertEquals('H', struct[1]); |
250 |
1 |
assertEquals('3', struct[2]); |
251 |
1 |
assertEquals('H', struct[3]); |
252 |
1 |
assertEquals('P', struct[4]); |
253 |
1 |
assertEquals('E', struct[5]); |
254 |
|
|
255 |
1 |
assertEquals(0, structCode[0]); |
256 |
1 |
assertEquals('H', structCode[1]); |
257 |
1 |
assertEquals('H', structCode[2]); |
258 |
1 |
assertEquals('H', structCode[3]); |
259 |
1 |
assertEquals('H', structCode[4]); |
260 |
1 |
assertEquals('E', structCode[5]); |
261 |
|
} |
262 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
263 |
1 |
@Test(groups = "Functional")... |
264 |
|
public void testLocalPDBId() throws Exception |
265 |
|
{ |
266 |
1 |
JmolParser structureData; |
267 |
|
|
268 |
|
|
269 |
|
|
270 |
1 |
structureData = new JmolParser("examples/testdata/localstruct.pdb", |
271 |
|
DataSourceType.FILE); |
272 |
1 |
assertNotNull(structureData); |
273 |
|
|
274 |
|
|
275 |
|
|
276 |
1 |
assertNotNull(structureData.getId()); |
277 |
1 |
assertEquals(structureData.getId(), "localstruct"); |
278 |
1 |
assertNotNull(structureData.getSeqs()); |
279 |
|
|
280 |
|
|
281 |
|
|
282 |
1 |
assertTrue(structureData.getSeqs().get(0).getAllPDBEntries().get(0) |
283 |
|
.fakedPDBId()); |
284 |
|
|
285 |
|
|
286 |
|
|
287 |
1 |
String featureGroup = structureData.getSeqs().get(0) |
288 |
|
.getSequenceFeatures().get(0).featureGroup; |
289 |
1 |
assertNotNull(featureGroup); |
290 |
1 |
assertEquals(featureGroup, "localstruct"); |
291 |
|
} |
292 |
|
} |