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 jalview.analysis.AlignSeq; |
24 |
|
import jalview.api.FeatureSettingsModelI; |
25 |
|
import jalview.datamodel.Alignment; |
26 |
|
import jalview.datamodel.AlignmentAnnotation; |
27 |
|
import jalview.datamodel.AlignmentI; |
28 |
|
import jalview.datamodel.DBRefEntry; |
29 |
|
import jalview.datamodel.DBRefSource; |
30 |
|
import jalview.datamodel.PDBEntry; |
31 |
|
import jalview.datamodel.PDBEntry.Type; |
32 |
|
import jalview.datamodel.SequenceI; |
33 |
|
import jalview.structure.StructureImportSettings; |
34 |
|
|
35 |
|
import java.awt.Color; |
36 |
|
import java.io.IOException; |
37 |
|
import java.lang.reflect.Constructor; |
38 |
|
import java.util.List; |
39 |
|
import java.util.Vector; |
40 |
|
|
41 |
|
import mc_view.PDBChain; |
42 |
|
|
|
|
| 74.4% |
Uncovered Elements: 50 (195) |
Complexity: 62 |
Complexity Density: 0.5 |
|
43 |
|
public abstract class StructureFile extends AlignFile |
44 |
|
{ |
45 |
|
private String id; |
46 |
|
|
47 |
|
private PDBEntry.Type dbRefType; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
protected boolean visibleChainAnnotation = false; |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
protected boolean predictSecondaryStructure = false; |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
protected boolean externalSecondaryStructure = false; |
66 |
|
|
67 |
|
private Vector<PDBChain> chains; |
68 |
|
|
69 |
|
private boolean pdbIdAvailable; |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
14 |
public StructureFile(Object inFile, DataSourceType sourceType)... |
72 |
|
throws IOException |
73 |
|
{ |
74 |
14 |
super(inFile, sourceType); |
75 |
|
} |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
2 |
public StructureFile(FileParse fp) throws IOException... |
78 |
|
{ |
79 |
2 |
super(fp); |
80 |
|
} |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
82 |
83 |
public void addSettings(boolean addAlignmentAnnotations,... |
83 |
|
boolean predictSecondaryStructure, boolean externalSecStr) |
84 |
|
{ |
85 |
83 |
this.visibleChainAnnotation = addAlignmentAnnotations; |
86 |
83 |
this.predictSecondaryStructure = predictSecondaryStructure; |
87 |
83 |
this.externalSecondaryStructure = externalSecStr; |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
90 |
92 |
public void xferSettings()... |
91 |
|
{ |
92 |
92 |
this.visibleChainAnnotation = StructureImportSettings |
93 |
|
.isVisibleChainAnnotation(); |
94 |
92 |
this.predictSecondaryStructure = StructureImportSettings |
95 |
|
.isProcessSecondaryStructure(); |
96 |
92 |
this.externalSecondaryStructure = StructureImportSettings |
97 |
|
.isExternalSecondaryStructure(); |
98 |
|
|
99 |
|
} |
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
101 |
83 |
public StructureFile(boolean parseImmediately, Object dataObject,... |
102 |
|
DataSourceType sourceType) throws IOException |
103 |
|
{ |
104 |
83 |
super(parseImmediately, dataObject, sourceType); |
105 |
|
} |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
0 |
public StructureFile(boolean a, FileParse fp) throws IOException... |
108 |
|
{ |
109 |
0 |
super(a, fp); |
110 |
|
} |
111 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
112 |
1 |
public StructureFile()... |
113 |
|
{ |
114 |
|
} |
115 |
|
|
|
|
| 96.9% |
Uncovered Elements: 1 (32) |
Complexity: 6 |
Complexity Density: 0.25 |
|
116 |
157 |
protected SequenceI postProcessChain(PDBChain chain)... |
117 |
|
{ |
118 |
157 |
SequenceI pdbSequence = chain.sequence; |
119 |
157 |
pdbSequence.setName(getId() + "|" + pdbSequence.getName()); |
120 |
157 |
PDBEntry entry = new PDBEntry(); |
121 |
157 |
entry.setId(getId()); |
122 |
157 |
entry.setType(getStructureFileType()); |
123 |
157 |
if (chain.id != null) |
124 |
|
{ |
125 |
157 |
entry.setChainCode(chain.id); |
126 |
|
} |
127 |
157 |
if (inFile != null) |
128 |
|
{ |
129 |
137 |
entry.setFile(inFile.getAbsolutePath()); |
130 |
|
} |
131 |
|
else |
132 |
|
{ |
133 |
20 |
entry.setFile(getDataName()); |
134 |
|
} |
135 |
|
|
136 |
157 |
DBRefEntry sourceDBRef = new DBRefEntry(); |
137 |
157 |
sourceDBRef.setAccessionId(getId()); |
138 |
157 |
sourceDBRef.setSource(DBRefSource.PDB); |
139 |
|
|
140 |
|
|
141 |
157 |
sourceDBRef.setVersion(""); |
142 |
157 |
pdbSequence.addPDBId(entry); |
143 |
157 |
pdbSequence.addDBRef(sourceDBRef); |
144 |
157 |
SequenceI chainseq = pdbSequence; |
145 |
157 |
seqs.addElement(chainseq); |
146 |
157 |
AlignmentAnnotation[] chainannot = chainseq.getAnnotation(); |
147 |
|
|
148 |
157 |
if (chainannot != null && visibleChainAnnotation) |
149 |
|
{ |
150 |
234 |
for (int ai = 0; ai < chainannot.length; ai++) |
151 |
|
{ |
152 |
117 |
chainannot[ai].visible = visibleChainAnnotation; |
153 |
117 |
annotations.addElement(chainannot[ai]); |
154 |
|
} |
155 |
|
} |
156 |
157 |
return chainseq; |
157 |
|
} |
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
String structureFileType = PDBEntry.Type.PDB.toString(); |
163 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
164 |
92 |
protected void setStructureFileType(String structureFileType)... |
165 |
|
{ |
166 |
92 |
this.structureFileType = structureFileType; |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
@return |
173 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
174 |
157 |
public String getStructureFileType()... |
175 |
|
{ |
176 |
157 |
return structureFileType; |
177 |
|
} |
178 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 6 |
Complexity Density: 0.5 |
|
179 |
0 |
@SuppressWarnings({ "unchecked", "rawtypes" })... |
180 |
|
protected void processPdbFileWithAnnotate3d(List<SequenceI> rna) |
181 |
|
throws Exception |
182 |
|
{ |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
0 |
try |
188 |
|
{ |
189 |
0 |
Class cl = Class.forName("jalview.ws.jws1.Annotate3D"); |
190 |
0 |
if (cl != null) |
191 |
|
{ |
192 |
|
|
193 |
|
|
194 |
0 |
Object annotate3d = cl.getConstructor(new Class[] {}) |
195 |
|
.newInstance(new Object[] {}); |
196 |
0 |
AlignmentI al = ((AlignmentI) cl |
197 |
|
.getMethod("getRNAMLFor", new Class[] |
198 |
|
{ FileParse.class }) |
199 |
|
.invoke(annotate3d, new Object[] |
200 |
|
{ new FileParse(getDataName(), dataSourceType) })); |
201 |
0 |
for (SequenceI sq : al.getSequences()) |
202 |
|
{ |
203 |
0 |
if (sq.getDatasetSequence() != null) |
204 |
|
{ |
205 |
0 |
if (sq.getDatasetSequence().getAllPDBEntries() != null) |
206 |
|
{ |
207 |
0 |
sq.getDatasetSequence().getAllPDBEntries().clear(); |
208 |
|
} |
209 |
|
} |
210 |
|
else |
211 |
|
{ |
212 |
0 |
if (sq.getAllPDBEntries() != null) |
213 |
|
{ |
214 |
0 |
sq.getAllPDBEntries().clear(); |
215 |
|
} |
216 |
|
} |
217 |
|
} |
218 |
0 |
replaceAndUpdateChains(rna, al, AlignSeq.DNA, false); |
219 |
|
} |
220 |
|
} catch (ClassNotFoundException x) |
221 |
|
{ |
222 |
|
|
223 |
|
} |
224 |
|
} |
225 |
|
|
|
|
| 93.8% |
Uncovered Elements: 1 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
226 |
2 |
@SuppressWarnings("unchecked")... |
227 |
|
protected void replaceAndUpdateChains(List<SequenceI> prot, AlignmentI al, |
228 |
|
String pep, boolean b) |
229 |
|
{ |
230 |
2 |
List<List<? extends Object>> replaced = AlignSeq |
231 |
|
.replaceMatchingSeqsWith(seqs, annotations, prot, al, pep, |
232 |
|
false); |
233 |
2 |
for (PDBChain ch : getChains()) |
234 |
|
{ |
235 |
8 |
int p = 0; |
236 |
8 |
for (SequenceI sq : (List<SequenceI>) replaced.get(0)) |
237 |
|
{ |
238 |
20 |
p++; |
239 |
20 |
if (sq == ch.sequence || sq.getDatasetSequence() == ch.sequence) |
240 |
|
{ |
241 |
8 |
p = -p; |
242 |
8 |
break; |
243 |
|
} |
244 |
|
} |
245 |
8 |
if (p < 0) |
246 |
|
{ |
247 |
8 |
p = -p - 1; |
248 |
|
|
249 |
8 |
ch.shadow = (SequenceI) replaced.get(1).get(p); |
250 |
8 |
ch.shadowMap = ((AlignSeq) replaced.get(2).get(p)) |
251 |
|
.getMappingFromS1(false); |
252 |
|
} |
253 |
|
} |
254 |
|
} |
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
@param |
261 |
|
@param |
262 |
|
|
|
|
| 42.9% |
Uncovered Elements: 8 (14) |
Complexity: 6 |
Complexity Density: 0.6 |
|
263 |
2 |
protected void addSecondaryStructure(List<SequenceI> rnaSequences,... |
264 |
|
List<SequenceI> proteinSequences) |
265 |
|
{ |
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
2 |
if (externalSecondaryStructure && rnaSequences.size() > 0) |
271 |
|
{ |
272 |
0 |
try |
273 |
|
{ |
274 |
0 |
processPdbFileWithAnnotate3d(rnaSequences); |
275 |
|
} catch (Exception x) |
276 |
|
{ |
277 |
0 |
System.err.println("Exceptions when dealing with RNA in pdb file"); |
278 |
0 |
x.printStackTrace(); |
279 |
|
|
280 |
|
} |
281 |
|
} |
282 |
|
|
283 |
|
|
284 |
|
|
285 |
|
|
286 |
2 |
if (proteinSequences.size() > 0) |
287 |
|
{ |
288 |
2 |
try |
289 |
|
{ |
290 |
2 |
processWithJmolParser(proteinSequences); |
291 |
|
} catch (Exception x) |
292 |
|
{ |
293 |
0 |
System.err.println( |
294 |
|
"Exceptions from Jmol when processing data in pdb file"); |
295 |
0 |
x.printStackTrace(); |
296 |
|
} |
297 |
|
} |
298 |
|
} |
299 |
|
|
|
|
| 86.4% |
Uncovered Elements: 3 (22) |
Complexity: 4 |
Complexity Density: 0.22 |
|
300 |
2 |
@SuppressWarnings({ "unchecked", "rawtypes" })... |
301 |
|
private void processWithJmolParser(List<SequenceI> prot) throws Exception |
302 |
|
{ |
303 |
2 |
try |
304 |
|
{ |
305 |
|
|
306 |
2 |
Class cl = Class.forName("jalview.ext.jmol.JmolParser"); |
307 |
2 |
if (cl != null) |
308 |
|
{ |
309 |
2 |
final Constructor constructor = cl |
310 |
|
.getConstructor(new Class[] |
311 |
|
{ FileParse.class }); |
312 |
2 |
final Object[] args = new Object[] { |
313 |
|
new FileParse(getDataName(), dataSourceType) }; |
314 |
|
|
315 |
2 |
StructureImportSettings.setShowSeqFeatures(false); |
316 |
2 |
StructureImportSettings.setVisibleChainAnnotation(false); |
317 |
2 |
StructureImportSettings |
318 |
|
.setProcessSecondaryStructure(predictSecondaryStructure); |
319 |
2 |
StructureImportSettings |
320 |
|
.setExternalSecondaryStructure(externalSecondaryStructure); |
321 |
2 |
Object jmf = constructor.newInstance(args); |
322 |
2 |
AlignmentI al = new Alignment((SequenceI[]) cl |
323 |
|
.getMethod("getSeqsAsArray", new Class[] {}).invoke(jmf)); |
324 |
2 |
cl.getMethod("addAnnotations", new Class[] { AlignmentI.class }) |
325 |
|
.invoke(jmf, al); |
326 |
2 |
for (SequenceI sq : al.getSequences()) |
327 |
|
{ |
328 |
8 |
if (sq.getDatasetSequence() != null) |
329 |
|
{ |
330 |
0 |
sq.getDatasetSequence().getAllPDBEntries().clear(); |
331 |
|
} |
332 |
|
else |
333 |
|
{ |
334 |
8 |
sq.getAllPDBEntries().clear(); |
335 |
|
} |
336 |
|
} |
337 |
2 |
replaceAndUpdateChains(prot, al, AlignSeq.PEP, false); |
338 |
|
} |
339 |
|
} catch (ClassNotFoundException q) |
340 |
|
{ |
341 |
|
} |
342 |
2 |
StructureImportSettings.setShowSeqFeatures(true); |
343 |
|
} |
344 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
345 |
22363 |
public PDBChain findChain(String id) throws Exception... |
346 |
|
{ |
347 |
22363 |
for (PDBChain chain : getChains()) |
348 |
|
{ |
349 |
39600 |
if (chain.id.equals(id)) |
350 |
|
{ |
351 |
22206 |
return chain; |
352 |
|
} |
353 |
|
} |
354 |
157 |
throw new Exception("PDB chain not Found!"); |
355 |
|
} |
356 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
357 |
99 |
public void makeResidueList()... |
358 |
|
{ |
359 |
99 |
for (PDBChain chain : getChains()) |
360 |
|
{ |
361 |
157 |
chain.makeResidueList(visibleChainAnnotation); |
362 |
|
} |
363 |
|
} |
364 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
365 |
99 |
public void makeCaBondList()... |
366 |
|
{ |
367 |
99 |
for (PDBChain chain : getChains()) |
368 |
|
{ |
369 |
157 |
chain.makeCaBondList(); |
370 |
|
} |
371 |
|
} |
372 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
373 |
0 |
public void setChargeColours()... |
374 |
|
{ |
375 |
0 |
for (PDBChain chain : getChains()) |
376 |
|
{ |
377 |
0 |
chain.setChargeColours(); |
378 |
|
} |
379 |
|
} |
380 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
381 |
0 |
public void setColours(jalview.schemes.ColourSchemeI cs)... |
382 |
|
{ |
383 |
0 |
for (PDBChain chain : getChains()) |
384 |
|
{ |
385 |
0 |
chain.setChainColours(cs); |
386 |
|
} |
387 |
|
} |
388 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
389 |
0 |
public void setChainColours()... |
390 |
|
{ |
391 |
0 |
int i = 0; |
392 |
0 |
for (PDBChain chain : getChains()) |
393 |
|
{ |
394 |
0 |
chain.setChainColours(Color.getHSBColor(1.0f / i++, .4f, 1.0f)); |
395 |
|
} |
396 |
|
} |
397 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 6 |
Complexity Density: 1 |
|
398 |
161 |
public static boolean isRNA(SequenceI seq)... |
399 |
|
{ |
400 |
161 |
int length = seq.getLength(); |
401 |
328 |
for (int i = 0; i < length; i++) |
402 |
|
{ |
403 |
327 |
char c = seq.getCharAt(i); |
404 |
327 |
if ((c != 'A') && (c != 'C') && (c != 'G') && (c != 'U')) |
405 |
|
{ |
406 |
160 |
return false; |
407 |
|
} |
408 |
|
} |
409 |
1 |
return true; |
410 |
|
} |
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
@param |
416 |
|
@return |
417 |
|
|
418 |
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
419 |
8 |
protected String safeName(String dataName)... |
420 |
|
{ |
421 |
8 |
int p = 0; |
422 |
? |
while ((p = dataName.indexOf("/")) > -1 && p < dataName.length()) |
423 |
|
{ |
424 |
9 |
dataName = dataName.substring(p + 1); |
425 |
|
} |
426 |
8 |
if (dataName.indexOf(".") > -1) |
427 |
|
{ |
428 |
6 |
dataName = dataName.substring(0, dataName.lastIndexOf(".")); |
429 |
|
} |
430 |
8 |
return dataName; |
431 |
|
} |
432 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
433 |
1055 |
public String getId()... |
434 |
|
{ |
435 |
1055 |
return id; |
436 |
|
} |
437 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
438 |
106 |
public void setId(String id)... |
439 |
|
{ |
440 |
106 |
this.id = id; |
441 |
|
} |
442 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
443 |
23028 |
public Vector<PDBChain> getChains()... |
444 |
|
{ |
445 |
23028 |
return chains; |
446 |
|
} |
447 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
448 |
99 |
public void setChains(Vector<PDBChain> chains)... |
449 |
|
{ |
450 |
99 |
this.chains = chains; |
451 |
|
} |
452 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
453 |
0 |
public Type getDbRefType()... |
454 |
|
{ |
455 |
0 |
return dbRefType; |
456 |
|
} |
457 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
458 |
7 |
public void setDbRefType(String dbRefType)... |
459 |
|
{ |
460 |
7 |
this.dbRefType = Type.getType(dbRefType); |
461 |
|
} |
462 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
463 |
11 |
public void setDbRefType(Type dbRefType)... |
464 |
|
{ |
465 |
11 |
this.dbRefType = dbRefType; |
466 |
|
} |
467 |
|
|
468 |
|
|
469 |
|
|
470 |
|
|
471 |
|
|
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
|
476 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
477 |
10 |
@Override... |
478 |
|
public FeatureSettingsModelI getFeatureColourScheme() |
479 |
|
{ |
480 |
10 |
return new PDBFeatureSettings(); |
481 |
|
} |
482 |
|
|
483 |
|
|
484 |
|
|
485 |
|
|
486 |
|
@return |
487 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
488 |
9 |
public boolean isPPDBIdAvailable()... |
489 |
|
{ |
490 |
9 |
return pdbIdAvailable; |
491 |
|
} |
492 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
493 |
92 |
public void setPDBIdAvailable(boolean pdbIdAvailable)... |
494 |
|
{ |
495 |
92 |
this.pdbIdAvailable = pdbIdAvailable; |
496 |
|
} |
497 |
|
} |