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.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.AlignmentAnnotation; |
29 |
|
import jalview.datamodel.AlignmentI; |
30 |
|
import jalview.datamodel.PDBEntry; |
31 |
|
import jalview.datamodel.SequenceFeature; |
32 |
|
import jalview.datamodel.SequenceI; |
33 |
|
import jalview.datamodel.features.SequenceFeatures; |
34 |
|
import jalview.gui.AlignFrame; |
35 |
|
import jalview.gui.JvOptionPane; |
36 |
|
import jalview.structure.StructureImportSettings; |
37 |
|
import jalview.structure.StructureImportSettings.StructureParser; |
38 |
|
|
39 |
|
import java.io.File; |
40 |
|
import java.util.List; |
41 |
|
|
42 |
|
import org.junit.Assert; |
43 |
|
import org.testng.annotations.AfterClass; |
44 |
|
import org.testng.annotations.BeforeClass; |
45 |
|
import org.testng.annotations.BeforeMethod; |
46 |
|
import org.testng.annotations.Test; |
47 |
|
|
|
|
| 84.3% |
Uncovered Elements: 17 (108) |
Complexity: 19 |
Complexity Density: 0.23 |
|
48 |
|
public class AnnotatedPDBFileInputTest |
49 |
|
{ |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
51 |
1 |
@BeforeClass(alwaysRun = true)... |
52 |
|
public void setUpJvOptionPane() |
53 |
|
{ |
54 |
1 |
JvOptionPane.setInteractiveMode(false); |
55 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
56 |
|
} |
57 |
|
|
58 |
|
AlignmentI al; |
59 |
|
|
60 |
|
String pdbId; |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
@throws |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
68 |
4 |
@BeforeMethod(alwaysRun = true)... |
69 |
|
public void setup() throws Exception |
70 |
|
{ |
71 |
4 |
Cache.applicationProperties.setProperty("STRUCT_FROM_PDB", |
72 |
|
Boolean.TRUE.toString()); |
73 |
4 |
Cache.applicationProperties.setProperty("ADD_SS_ANN", |
74 |
|
Boolean.TRUE.toString()); |
75 |
4 |
FileLoader loader = new FileLoader(false); |
76 |
4 |
AlignFrame af = loader.LoadFileWaitTillLoaded("examples/1gaq.txt", |
77 |
|
DataSourceType.FILE); |
78 |
4 |
al = af.getViewport().getAlignment(); |
79 |
4 |
pdbId = al.getSequenceAt(0).getDatasetSequence().getAllPDBEntries() |
80 |
|
.get(0).getId(); |
81 |
4 |
StructureImportSettings.setDefaultStructureFileFormat("PDB"); |
82 |
|
|
83 |
|
|
84 |
|
} |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
1PASS
|
|
86 |
1 |
@Test(groups = { "Functional" })... |
87 |
|
public void checkNoDuplicates() |
88 |
|
{ |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
1 |
assertNotNull(al.getAlignmentAnnotation()); |
93 |
|
|
94 |
1 |
AlignmentAnnotation[] avec = al.getAlignmentAnnotation(); |
95 |
11 |
for (int p = 0; p < avec.length; p++) |
96 |
|
{ |
97 |
55 |
for (int q = p + 1; q < avec.length; q++) |
98 |
|
{ |
99 |
45 |
assertTrue("Found a duplicate annotation row " + avec[p].label, |
100 |
|
avec[p] != avec[q]); |
101 |
|
} |
102 |
|
} |
103 |
|
} |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
1PASS
|
|
105 |
0 |
@Test(groups = { "Functional" }, enabled = false)... |
106 |
|
public void checkPDBannotationSource() |
107 |
|
{ |
108 |
0 |
Assert.fail( |
109 |
|
"This test is incorrect - does not verify that JmolParser's annotation rows can be recognised as generated by the Jmol parser."); |
110 |
0 |
for (SequenceI asq : al.getSequences()) |
111 |
|
{ |
112 |
0 |
for (AlignmentAnnotation aa : asq.getAnnotation()) |
113 |
|
{ |
114 |
|
|
115 |
0 |
System.out.println("CalcId: " + aa.getCalcId()); |
116 |
0 |
if (StructureImportSettings.getDefaultPDBFileParser() |
117 |
|
.equals(StructureParser.JALVIEW_PARSER)) |
118 |
|
{ |
119 |
0 |
assertTrue(mc_view.PDBfile.isCalcIdForFile(aa, pdbId)); |
120 |
|
} |
121 |
|
} |
122 |
|
} |
123 |
|
} |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
128 |
1 |
@Test(groups = { "Functional" })... |
129 |
|
public void checkPDBSequenceFeatures() |
130 |
|
{ |
131 |
|
|
132 |
|
|
133 |
|
|
134 |
1 |
List<SequenceFeature> sf = al.getSequenceAt(0).getSequenceFeatures(); |
135 |
1 |
SequenceFeatures.sortFeatures(sf, true); |
136 |
1 |
assertEquals(296, sf.size()); |
137 |
1 |
assertEquals("RESNUM", sf.get(0).getType()); |
138 |
1 |
assertEquals("GLU: 19 1gaqA", sf.get(0).getDescription()); |
139 |
1 |
assertEquals("RESNUM", sf.get(295).getType()); |
140 |
1 |
assertEquals("TYR: 314 1gaqA", sf.get(295).getDescription()); |
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
1 |
sf = al.getSequenceAt(1).getSequenceFeatures(); |
146 |
1 |
SequenceFeatures.sortFeatures(sf, true); |
147 |
1 |
assertEquals(98, sf.size()); |
148 |
1 |
assertEquals("RESNUM", sf.get(0).getType()); |
149 |
1 |
assertEquals("ALA: 1 1gaqB", sf.get(0).getDescription()); |
150 |
1 |
assertEquals("RESNUM", sf.get(97).getType()); |
151 |
1 |
assertEquals("ALA: 98 1gaqB", sf.get(97).getDescription()); |
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
1 |
sf = al.getSequenceAt(2).getSequenceFeatures(); |
157 |
1 |
SequenceFeatures.sortFeatures(sf, true); |
158 |
1 |
assertEquals(296, sf.size()); |
159 |
1 |
assertEquals("RESNUM", sf.get(0).getType()); |
160 |
1 |
assertEquals("GLU: 19 1gaqC", sf.get(0).getDescription()); |
161 |
1 |
assertEquals("RESNUM", sf.get(295).getType()); |
162 |
1 |
assertEquals("TYR: 314 1gaqC", sf.get(295).getDescription()); |
163 |
|
} |
164 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
1PASS
|
|
165 |
1 |
@Test(groups = { "Functional" })... |
166 |
|
public void checkAnnotationWiring() |
167 |
|
{ |
168 |
1 |
assertTrue(al.getAlignmentAnnotation() != null); |
169 |
|
|
170 |
1 |
for (AlignmentAnnotation aa : al.getAlignmentAnnotation()) |
171 |
|
{ |
172 |
10 |
if (aa.sequenceRef != null) |
173 |
|
{ |
174 |
6 |
assertTrue(al.getSequences().contains(aa.sequenceRef)); |
175 |
6 |
assertNotNull(aa.sequenceRef.getAnnotation()); |
176 |
6 |
boolean found = false; |
177 |
6 |
for (AlignmentAnnotation sqan : aa.sequenceRef.getAnnotation()) |
178 |
|
{ |
179 |
9 |
if (sqan == aa) |
180 |
|
{ |
181 |
6 |
found = true; |
182 |
6 |
break; |
183 |
|
} |
184 |
|
} |
185 |
6 |
assertTrue( |
186 |
|
"Couldn't find sequence associated annotation " |
187 |
|
+ aa.label |
188 |
|
+ " on the sequence it is associated with.\nSequence associated editing will fail.", |
189 |
|
found); |
190 |
|
} |
191 |
|
} |
192 |
|
} |
193 |
|
|
194 |
|
|
195 |
|
@throws |
196 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
197 |
1 |
@BeforeClass(alwaysRun = true)... |
198 |
|
public static void setUpBeforeClass() throws Exception |
199 |
|
{ |
200 |
1 |
jalview.bin.Jalview.main(new String[] { "-props", |
201 |
|
"test/jalview/io/testProps.jvprops" }); |
202 |
|
} |
203 |
|
|
204 |
|
|
205 |
|
@throws |
206 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
207 |
1 |
@AfterClass(alwaysRun = true)... |
208 |
|
public static void tearDownAfterClass() throws Exception |
209 |
|
{ |
210 |
1 |
jalview.gui.Desktop.instance.closeAll_actionPerformed(null); |
211 |
|
|
212 |
|
} |
213 |
|
|
|
|
| 77.1% |
Uncovered Elements: 8 (35) |
Complexity: 6 |
Complexity Density: 0.22 |
1PASS
|
|
214 |
1 |
@Test(groups = { "Functional" })... |
215 |
|
public void testJalviewProjectRelocationAnnotation() throws Exception |
216 |
|
{ |
217 |
|
|
218 |
1 |
String inFile = "examples/1gaq.txt"; |
219 |
1 |
String tfile = File.createTempFile("JalviewTest", ".jvp") |
220 |
|
.getAbsolutePath(); |
221 |
1 |
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded( |
222 |
|
inFile, DataSourceType.FILE); |
223 |
1 |
assertTrue("Didn't read input file " + inFile, af != null); |
224 |
1 |
af.saveAlignment(tfile, FileFormat.Jalview); |
225 |
1 |
assertTrue("Failed to store as a project.", |
226 |
|
af.isSaveAlignmentSuccessful()); |
227 |
1 |
af.closeMenuItem_actionPerformed(true); |
228 |
1 |
af = null; |
229 |
1 |
af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile, |
230 |
|
DataSourceType.FILE); |
231 |
1 |
assertTrue("Failed to import new project", af != null); |
232 |
1 |
for (SequenceI asq : af.getViewport().getAlignment().getSequences()) |
233 |
|
{ |
234 |
3 |
SequenceI sq = asq; |
235 |
6 |
while (sq.getDatasetSequence() != null) |
236 |
|
{ |
237 |
3 |
sq = sq.getDatasetSequence(); |
238 |
|
} |
239 |
3 |
assertNotNull(sq.getAllPDBEntries()); |
240 |
3 |
assertEquals("Expected only one PDB ID", 1, sq.getAllPDBEntries() |
241 |
|
.size()); |
242 |
3 |
for (PDBEntry pdbentry : sq.getAllPDBEntries()) |
243 |
|
{ |
244 |
3 |
System.err.println("PDB Entry " + pdbentry.getId() + " " |
245 |
|
+ pdbentry.getFile()); |
246 |
3 |
boolean exists = false, found = false; |
247 |
3 |
for (AlignmentAnnotation ana : sq.getAnnotation()) |
248 |
|
{ |
249 |
6 |
System.err.println("CalcId " + ana.getCalcId()); |
250 |
6 |
if (ana.getCalcId() != null |
251 |
|
&& mc_view.PDBfile.isCalcIdHandled(ana.getCalcId())) |
252 |
|
{ |
253 |
0 |
exists = true; |
254 |
0 |
if (mc_view.PDBfile.isCalcIdForFile(ana, pdbentry.getId())) |
255 |
|
{ |
256 |
0 |
found = true; |
257 |
|
} |
258 |
|
} |
259 |
|
} |
260 |
3 |
if (exists) |
261 |
|
{ |
262 |
0 |
assertTrue("Couldn't find any annotation for " + pdbentry.getId() |
263 |
|
+ " (file handle " + pdbentry.getFile() + ")", found); |
264 |
|
} |
265 |
|
} |
266 |
|
} |
267 |
|
} |
268 |
|
} |