1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.datamodel; |
22 |
|
|
23 |
|
import jalview.util.CaseInsensitiveString; |
24 |
|
|
25 |
|
import java.util.Collections; |
26 |
|
import java.util.Enumeration; |
27 |
|
import java.util.Hashtable; |
28 |
|
|
|
|
| 97.5% |
Uncovered Elements: 4 (157) |
Complexity: 66 |
Complexity Density: 0.79 |
|
29 |
|
public class PDBEntry |
30 |
|
{ |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
private static final String CHAIN_ID = "chain_code"; |
36 |
|
|
37 |
|
private Hashtable<String, Object> properties; |
38 |
|
|
39 |
|
private static final int PDB_ID_LENGTH = 4; |
40 |
|
|
41 |
|
private String file; |
42 |
|
|
43 |
|
private String type; |
44 |
|
|
45 |
|
private String id; |
46 |
|
|
|
|
| 75% |
Uncovered Elements: 4 (16) |
Complexity: 6 |
Complexity Density: 0.67 |
|
47 |
|
public enum Type |
48 |
|
{ |
49 |
|
|
50 |
|
|
51 |
|
PDB("pdb", "pdb"), MMCIF("mmcif", "cif"), FILE("?", "?"); |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
@see |
57 |
|
|
58 |
|
String ext; |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
@see |
63 |
|
|
64 |
|
String format; |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
66 |
3 |
private Type(String fmt, String ex)... |
67 |
|
{ |
68 |
3 |
format = fmt; |
69 |
3 |
ext = ex; |
70 |
|
} |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
0 |
public String getFormat()... |
73 |
|
{ |
74 |
0 |
return format; |
75 |
|
} |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
0 |
public String getExtension()... |
78 |
|
{ |
79 |
0 |
return ext; |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
@param |
86 |
|
@return |
87 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
88 |
103 |
public static Type getType(String value)... |
89 |
|
{ |
90 |
103 |
for (Type t : Type.values()) |
91 |
|
{ |
92 |
111 |
if (t.toString().equalsIgnoreCase(value)) |
93 |
|
{ |
94 |
102 |
return t; |
95 |
|
} |
96 |
|
} |
97 |
1 |
return null; |
98 |
|
} |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
@param |
104 |
|
@return |
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
106 |
4 |
public boolean matches(String t)... |
107 |
|
{ |
108 |
4 |
return (this.toString().equalsIgnoreCase(t)); |
109 |
|
} |
110 |
|
} |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 7 |
Complexity Density: 0.64 |
|
116 |
270 |
@Override... |
117 |
|
public boolean equals(Object obj) |
118 |
|
{ |
119 |
270 |
if (obj == null || !(obj instanceof PDBEntry)) |
120 |
|
{ |
121 |
2 |
return false; |
122 |
|
} |
123 |
268 |
if (obj == this) |
124 |
|
{ |
125 |
11 |
return true; |
126 |
|
} |
127 |
257 |
PDBEntry o = (PDBEntry) obj; |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
257 |
boolean idMatches = id == o.id |
135 |
|
|| (id != null && id.equalsIgnoreCase(o.id)); |
136 |
257 |
boolean fileMatches = file == o.file |
137 |
|
|| (file != null && file.equals(o.file)); |
138 |
257 |
boolean typeMatches = type == o.type |
139 |
|
|| (type != null && type.equals(o.type)); |
140 |
257 |
if (idMatches && fileMatches && typeMatches) |
141 |
|
{ |
142 |
166 |
return properties == o.properties |
143 |
|
|| (properties != null && properties.equals(o.properties)); |
144 |
|
} |
145 |
91 |
return false; |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
151 |
375 |
public PDBEntry()... |
152 |
|
{ |
153 |
|
} |
154 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
155 |
82 |
public PDBEntry(String pdbId, String chain, PDBEntry.Type type,... |
156 |
|
String filePath) |
157 |
|
{ |
158 |
82 |
init(pdbId, chain, type, filePath); |
159 |
|
} |
160 |
|
|
161 |
|
|
162 |
|
@param |
163 |
|
@param |
164 |
|
@param |
165 |
|
@param |
166 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
167 |
132 |
void init(String pdbId, String chain, PDBEntry.Type entryType,... |
168 |
|
String filePath) |
169 |
|
{ |
170 |
132 |
this.id = pdbId; |
171 |
132 |
this.type = entryType == null ? null : entryType.toString(); |
172 |
132 |
this.file = filePath; |
173 |
132 |
setChainCode(chain); |
174 |
|
} |
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
@param |
180 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
181 |
6 |
public PDBEntry(PDBEntry entry)... |
182 |
|
{ |
183 |
6 |
file = entry.file; |
184 |
6 |
type = entry.type; |
185 |
6 |
id = entry.id; |
186 |
6 |
if (entry.properties != null) |
187 |
|
{ |
188 |
6 |
properties = (Hashtable<String, Object>) entry.properties.clone(); |
189 |
|
} |
190 |
|
} |
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
@param |
198 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 7 |
Complexity Density: 0.7 |
|
199 |
51 |
public PDBEntry(DBRefEntry dbr)... |
200 |
|
{ |
201 |
51 |
if (!DBRefSource.PDB.equals(dbr.getSource())) |
202 |
|
{ |
203 |
1 |
throw new IllegalArgumentException( |
204 |
|
"Invalid source: " + dbr.getSource()); |
205 |
|
} |
206 |
|
|
207 |
50 |
String pdbId = dbr.getAccessionId(); |
208 |
50 |
String chainCode = null; |
209 |
50 |
if (pdbId.length() == PDB_ID_LENGTH + 1) |
210 |
|
{ |
211 |
17 |
char chain = pdbId.charAt(PDB_ID_LENGTH); |
212 |
17 |
if (('a' <= chain && chain <= 'z') || ('A' <= chain && chain <= 'Z')) |
213 |
|
{ |
214 |
15 |
pdbId = pdbId.substring(0, PDB_ID_LENGTH); |
215 |
15 |
chainCode = String.valueOf(chain); |
216 |
|
} |
217 |
|
} |
218 |
50 |
init(pdbId, chainCode, null, null); |
219 |
|
} |
220 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
221 |
322 |
public void setFile(String f)... |
222 |
|
{ |
223 |
322 |
this.file = f; |
224 |
|
} |
225 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
226 |
1037 |
public String getFile()... |
227 |
|
{ |
228 |
1037 |
return file; |
229 |
|
} |
230 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
231 |
183 |
public void setType(String t)... |
232 |
|
{ |
233 |
183 |
this.type = t; |
234 |
|
} |
235 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
236 |
73 |
public void setType(PDBEntry.Type type)... |
237 |
|
{ |
238 |
73 |
this.type = type == null ? null : type.toString(); |
239 |
|
} |
240 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
241 |
268 |
public String getType()... |
242 |
|
{ |
243 |
268 |
return type; |
244 |
|
} |
245 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
246 |
375 |
public void setId(String id)... |
247 |
|
{ |
248 |
375 |
this.id = id; |
249 |
|
} |
250 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
251 |
1000 |
public String getId()... |
252 |
|
{ |
253 |
1000 |
return id; |
254 |
|
} |
255 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
256 |
320 |
public void setProperty(String key, Object value)... |
257 |
|
{ |
258 |
320 |
if (this.properties == null) |
259 |
|
{ |
260 |
304 |
this.properties = new Hashtable<String, Object>(); |
261 |
|
} |
262 |
320 |
properties.put(key, value); |
263 |
|
} |
264 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
265 |
197 |
public Object getProperty(String key)... |
266 |
|
{ |
267 |
197 |
return properties == null ? null : properties.get(key); |
268 |
|
} |
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
@return |
275 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
276 |
144 |
public Enumeration<String> getProperties()... |
277 |
|
{ |
278 |
144 |
if (properties == null) |
279 |
|
{ |
280 |
49 |
return Collections.emptyEnumeration(); |
281 |
|
} |
282 |
95 |
return properties.keys(); |
283 |
|
} |
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
@return |
288 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 3 |
Complexity Density: 3 |
|
289 |
300 |
public String getChainCode()... |
290 |
|
{ |
291 |
300 |
return (properties == null || properties.get(CHAIN_ID) == null) ? null |
292 |
|
: properties.get(CHAIN_ID).toString(); |
293 |
|
} |
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
@param |
301 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
302 |
343 |
public void setChainCode(String chainCode)... |
303 |
|
{ |
304 |
343 |
if (chainCode == null) |
305 |
|
{ |
306 |
65 |
deleteProperty(CHAIN_ID); |
307 |
|
} |
308 |
|
else |
309 |
|
{ |
310 |
278 |
setProperty(CHAIN_ID, new CaseInsensitiveString(chainCode)); |
311 |
|
} |
312 |
|
} |
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
|
317 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
318 |
65 |
Object deleteProperty(String key)... |
319 |
|
{ |
320 |
65 |
Object result = null; |
321 |
65 |
if (properties != null) |
322 |
|
{ |
323 |
1 |
result = properties.remove(key); |
324 |
|
} |
325 |
65 |
return result; |
326 |
|
} |
327 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
328 |
26 |
@Override... |
329 |
|
public String toString() |
330 |
|
{ |
331 |
26 |
return id; |
332 |
|
} |
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
@deprecated |
339 |
|
@see |
340 |
|
@see |
341 |
|
@see |
342 |
|
@return |
343 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
344 |
28 |
@Deprecated... |
345 |
|
public Hashtable<String, Object> getProps() |
346 |
|
{ |
347 |
28 |
return properties; |
348 |
|
} |
349 |
|
|
350 |
|
|
351 |
|
|
352 |
|
|
353 |
|
|
354 |
|
@deprecated |
355 |
|
@return |
356 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
357 |
8 |
@Deprecated... |
358 |
|
public void setProps(Hashtable<String, Object> props) |
359 |
|
{ |
360 |
8 |
properties = props; |
361 |
|
} |
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
|
369 |
|
|
370 |
|
|
371 |
|
@param |
372 |
|
@return |
373 |
|
|
|
|
| 95.8% |
Uncovered Elements: 2 (48) |
Complexity: 22 |
Complexity Density: 0.79 |
|
374 |
228 |
public boolean updateFrom(PDBEntry newEntry)... |
375 |
|
{ |
376 |
228 |
if (this.equals(newEntry)) |
377 |
|
{ |
378 |
112 |
return true; |
379 |
|
} |
380 |
|
|
381 |
116 |
String newId = newEntry.getId(); |
382 |
116 |
if (newId == null || getId() == null) |
383 |
|
{ |
384 |
0 |
return false; |
385 |
|
} |
386 |
|
|
387 |
|
|
388 |
|
|
389 |
|
|
390 |
116 |
if (!getId().equalsIgnoreCase(newId)) |
391 |
|
{ |
392 |
24 |
return false; |
393 |
|
} |
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
|
398 |
92 |
String newFile = newEntry.getFile(); |
399 |
92 |
if (newFile != null && getFile() != null && !newFile.equals(getFile())) |
400 |
|
{ |
401 |
3 |
return false; |
402 |
|
} |
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
89 |
String newChain = newEntry.getChainCode(); |
408 |
89 |
if (newChain != null && newChain.length() > 0 && getChainCode() != null |
409 |
|
&& getChainCode().length() > 0 |
410 |
|
&& !getChainCode().equalsIgnoreCase(newChain)) |
411 |
|
{ |
412 |
8 |
return false; |
413 |
|
} |
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
81 |
String newType = newEntry.getType(); |
419 |
81 |
if (getFile() == null && newFile != null) |
420 |
|
{ |
421 |
3 |
setFile(newFile); |
422 |
3 |
setType(newType); |
423 |
|
} |
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
|
429 |
81 |
if (getType() == null && newType != null) |
430 |
|
{ |
431 |
11 |
setType(newType); |
432 |
|
} |
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
81 |
if (newChain != null && newChain.length() > 0 |
439 |
|
&& !newChain.equalsIgnoreCase(getChainCode())) |
440 |
|
{ |
441 |
25 |
setChainCode(newChain); |
442 |
|
} |
443 |
|
|
444 |
|
|
445 |
|
|
446 |
|
|
447 |
81 |
Enumeration<String> newProps = newEntry.getProperties(); |
448 |
131 |
while (newProps.hasMoreElements()) |
449 |
|
{ |
450 |
|
|
451 |
|
|
452 |
|
|
453 |
|
|
454 |
50 |
String key = newProps.nextElement(); |
455 |
50 |
Object value = newEntry.getProperty(key); |
456 |
50 |
if (!value.equals(getProperty(key))) |
457 |
|
{ |
458 |
11 |
setProperty(key, value); |
459 |
|
} |
460 |
|
} |
461 |
81 |
return true; |
462 |
|
} |
463 |
|
} |