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