1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.structure; |
22 |
|
|
23 |
|
import jalview.datamodel.AlignmentAnnotation; |
24 |
|
import jalview.datamodel.Mapping; |
25 |
|
import jalview.datamodel.SequenceI; |
26 |
|
|
27 |
|
import java.util.ArrayList; |
28 |
|
import java.util.HashMap; |
29 |
|
import java.util.List; |
30 |
|
|
|
|
| 71% |
Uncovered Elements: 56 (193) |
Complexity: 53 |
Complexity Density: 0.51 |
|
31 |
|
public class StructureMapping |
32 |
|
{ |
33 |
|
public static final int UNASSIGNED_VALUE = Integer.MIN_VALUE; |
34 |
|
|
35 |
|
private static final int PDB_RES_NUM_INDEX = 0; |
36 |
|
|
37 |
|
private static final int PDB_ATOM_NUM_INDEX = 1; |
38 |
|
|
39 |
|
String mappingDetails; |
40 |
|
|
41 |
|
SequenceI sequence; |
42 |
|
|
43 |
|
String pdbfile; |
44 |
|
|
45 |
|
String pdbid; |
46 |
|
|
47 |
|
String pdbchain; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
HashMap<Integer, int[]> mapping; |
52 |
|
|
53 |
|
jalview.datamodel.Mapping seqToPdbMapping = null; |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
@param |
59 |
|
@param |
60 |
|
@param |
61 |
|
@param |
62 |
|
@param |
63 |
|
|
64 |
|
|
65 |
|
@param |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
67 |
204 |
public StructureMapping(SequenceI seq, String pdbfile, String pdbid,... |
68 |
|
String chain, HashMap<Integer, int[]> mapping, |
69 |
|
String mappingDetails) |
70 |
|
{ |
71 |
204 |
sequence = seq; |
72 |
204 |
this.pdbfile = pdbfile; |
73 |
204 |
this.pdbid = pdbid; |
74 |
204 |
this.pdbchain = chain; |
75 |
204 |
this.mapping = mapping; |
76 |
204 |
this.mappingDetails = mappingDetails; |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
79 |
9 |
public StructureMapping(SequenceI seq, String pdbFile2, String pdbId2,... |
80 |
|
String chain, HashMap<Integer, int[]> mapping2, |
81 |
|
String mappingOutput, Mapping seqToPdbMapping) |
82 |
|
{ |
83 |
9 |
this(seq, pdbFile2, pdbId2, chain, mapping2, mappingOutput); |
84 |
9 |
this.seqToPdbMapping = seqToPdbMapping; |
85 |
|
} |
86 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
87 |
543 |
public SequenceI getSequence()... |
88 |
|
{ |
89 |
543 |
return sequence; |
90 |
|
} |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
39208 |
public String getChain()... |
93 |
|
{ |
94 |
39208 |
return pdbchain; |
95 |
|
} |
96 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
97 |
9 |
public String getPdbId()... |
98 |
|
{ |
99 |
9 |
return pdbid; |
100 |
|
} |
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
@param |
105 |
|
@return |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
107 |
0 |
public int getAtomNum(int seqpos)... |
108 |
|
{ |
109 |
0 |
int[] resNumAtomMap = mapping.get(seqpos); |
110 |
0 |
if (resNumAtomMap != null) |
111 |
|
{ |
112 |
0 |
return resNumAtomMap[PDB_ATOM_NUM_INDEX]; |
113 |
|
} |
114 |
|
else |
115 |
|
{ |
116 |
0 |
return UNASSIGNED_VALUE; |
117 |
|
} |
118 |
|
} |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
@param |
123 |
|
@return |
124 |
|
|
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
126 |
40097 |
public int getPDBResNum(int seqpos)... |
127 |
|
{ |
128 |
40097 |
int[] resNumAtomMap = mapping.get(seqpos); |
129 |
40099 |
if (resNumAtomMap != null) |
130 |
|
{ |
131 |
40075 |
return resNumAtomMap[PDB_RES_NUM_INDEX]; |
132 |
|
} |
133 |
|
else |
134 |
|
{ |
135 |
24 |
return UNASSIGNED_VALUE; |
136 |
|
} |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
@param |
144 |
|
@param |
145 |
|
@return |
146 |
|
|
|
|
| 92.1% |
Uncovered Elements: 3 (38) |
Complexity: 9 |
Complexity Density: 0.38 |
|
147 |
5 |
public List<int[]> getPDBResNumRanges(int fromSeqPos, int toSeqPos)... |
148 |
|
{ |
149 |
5 |
List<int[]> result = new ArrayList<>(); |
150 |
5 |
int startRes = -1; |
151 |
5 |
int endRes = -1; |
152 |
|
|
153 |
18 |
for (int i = fromSeqPos; i <= toSeqPos; i++) |
154 |
|
{ |
155 |
13 |
int resNo = getPDBResNum(i); |
156 |
13 |
if (resNo == UNASSIGNED_VALUE) |
157 |
|
{ |
158 |
7 |
continue; |
159 |
|
} |
160 |
6 |
if (startRes == -1) |
161 |
|
{ |
162 |
3 |
startRes = resNo; |
163 |
3 |
endRes = resNo; |
164 |
|
} |
165 |
6 |
if (resNo >= startRes && resNo <= endRes) |
166 |
|
{ |
167 |
|
|
168 |
3 |
continue; |
169 |
|
} |
170 |
3 |
if (resNo == startRes - 1) |
171 |
|
{ |
172 |
|
|
173 |
0 |
startRes--; |
174 |
0 |
continue; |
175 |
|
} |
176 |
3 |
if (resNo == endRes + 1) |
177 |
|
{ |
178 |
|
|
179 |
2 |
endRes++; |
180 |
2 |
continue; |
181 |
|
} |
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
1 |
result.add(new int[] { startRes, endRes }); |
188 |
1 |
startRes = resNo; |
189 |
1 |
endRes = resNo; |
190 |
|
} |
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
5 |
if (startRes != -1) |
196 |
|
{ |
197 |
3 |
result.add(new int[] { startRes, endRes }); |
198 |
|
} |
199 |
|
|
200 |
5 |
return result; |
201 |
|
} |
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
@param |
206 |
|
@return |
207 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
208 |
1 |
public int getSeqPos(int pdbResNum)... |
209 |
|
{ |
210 |
1 |
for (Integer seqPos : mapping.keySet()) |
211 |
|
{ |
212 |
276 |
if (pdbResNum == getPDBResNum(seqPos)) |
213 |
|
{ |
214 |
1 |
return seqPos; |
215 |
|
} |
216 |
|
} |
217 |
0 |
return UNASSIGNED_VALUE; |
218 |
|
} |
219 |
|
|
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
@param |
225 |
|
@return |
226 |
|
|
227 |
|
|
228 |
|
|
229 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
230 |
0 |
public AlignmentAnnotation transfer(AlignmentAnnotation ana)... |
231 |
|
{ |
232 |
0 |
AlignmentAnnotation ala_copy = new AlignmentAnnotation(ana); |
233 |
0 |
SequenceI ds = sequence; |
234 |
0 |
while (ds.getDatasetSequence() != null) |
235 |
|
{ |
236 |
0 |
ds = ds.getDatasetSequence(); |
237 |
|
} |
238 |
|
|
239 |
|
|
240 |
|
|
241 |
0 |
ala_copy.remap(ds, mapping, -1, -1, 0); |
242 |
0 |
ds.addAlignmentAnnotation(ala_copy); |
243 |
0 |
if (ds != sequence) |
244 |
|
{ |
245 |
|
|
246 |
|
|
247 |
0 |
ala_copy = new AlignmentAnnotation(ala_copy); |
248 |
0 |
sequence.addAlignmentAnnotation(ala_copy); |
249 |
|
} |
250 |
0 |
return ala_copy; |
251 |
|
} |
252 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
253 |
0 |
public String getMappingDetailsOutput()... |
254 |
|
{ |
255 |
0 |
return mappingDetails; |
256 |
|
} |
257 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
258 |
0 |
public HashMap<Integer, int[]> getMapping()... |
259 |
|
{ |
260 |
0 |
return mapping; |
261 |
|
} |
262 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
263 |
0 |
public Mapping getSeqToPdbMapping()... |
264 |
|
{ |
265 |
0 |
return seqToPdbMapping; |
266 |
|
} |
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
|
|
| 71.4% |
Uncovered Elements: 6 (21) |
Complexity: 7 |
Complexity Density: 0.78 |
|
272 |
2 |
@Override... |
273 |
|
public int hashCode() |
274 |
|
{ |
275 |
2 |
final int prime = 31; |
276 |
2 |
int result = 1; |
277 |
2 |
result = prime * result |
278 |
2 |
+ ((mappingDetails == null) ? 0 : mappingDetails.hashCode()); |
279 |
2 |
result = prime * result |
280 |
2 |
+ ((pdbchain == null) ? 0 : pdbchain.hashCode()); |
281 |
2 |
result = prime * result + ((pdbfile == null) ? 0 : pdbfile.hashCode()); |
282 |
2 |
result = prime * result + ((pdbid == null) ? 0 : pdbid.hashCode()); |
283 |
2 |
result = prime * result |
284 |
2 |
+ ((seqToPdbMapping == null) ? 0 : seqToPdbMapping.hashCode()); |
285 |
2 |
result = prime * result |
286 |
2 |
+ ((sequence == null) ? 0 : sequence.hashCode()); |
287 |
2 |
return result; |
288 |
|
} |
289 |
|
|
|
|
| 75.3% |
Uncovered Elements: 18 (73) |
Complexity: 20 |
Complexity Density: 0.57 |
|
290 |
177 |
@Override... |
291 |
|
public boolean equals(Object obj) |
292 |
|
{ |
293 |
177 |
if (this == obj) |
294 |
|
{ |
295 |
0 |
return true; |
296 |
|
} |
297 |
177 |
if (obj == null) |
298 |
|
{ |
299 |
1 |
return false; |
300 |
|
} |
301 |
176 |
if (getClass() != obj.getClass()) |
302 |
|
{ |
303 |
1 |
return false; |
304 |
|
} |
305 |
175 |
StructureMapping other = (StructureMapping) obj; |
306 |
175 |
if (mappingDetails == null) |
307 |
|
{ |
308 |
5 |
if (other.mappingDetails != null) |
309 |
|
{ |
310 |
0 |
return false; |
311 |
|
} |
312 |
|
} |
313 |
170 |
else if (!mappingDetails.equals(other.mappingDetails)) |
314 |
|
{ |
315 |
76 |
return false; |
316 |
|
} |
317 |
99 |
if (pdbchain == null) |
318 |
|
{ |
319 |
3 |
if (other.pdbchain != null) |
320 |
|
{ |
321 |
0 |
return false; |
322 |
|
} |
323 |
|
} |
324 |
96 |
else if (!pdbchain.equals(other.pdbchain)) |
325 |
|
{ |
326 |
4 |
return false; |
327 |
|
} |
328 |
95 |
if (pdbfile == null) |
329 |
|
{ |
330 |
0 |
if (other.pdbfile != null) |
331 |
|
{ |
332 |
0 |
return false; |
333 |
|
} |
334 |
|
} |
335 |
95 |
else if (!pdbfile.equals(other.pdbfile)) |
336 |
|
{ |
337 |
20 |
return false; |
338 |
|
} |
339 |
75 |
if (pdbid == null) |
340 |
|
{ |
341 |
0 |
if (other.pdbid != null) |
342 |
|
{ |
343 |
0 |
return false; |
344 |
|
} |
345 |
|
} |
346 |
75 |
else if (!pdbid.equals(other.pdbid)) |
347 |
|
{ |
348 |
2 |
return false; |
349 |
|
} |
350 |
73 |
if (seqToPdbMapping == null) |
351 |
|
{ |
352 |
65 |
if (other.seqToPdbMapping != null) |
353 |
|
{ |
354 |
0 |
return false; |
355 |
|
} |
356 |
|
} |
357 |
8 |
else if (!seqToPdbMapping.equals(other.seqToPdbMapping)) |
358 |
|
{ |
359 |
2 |
return false; |
360 |
|
} |
361 |
71 |
if (sequence != other.sequence) |
362 |
|
{ |
363 |
8 |
return false; |
364 |
|
} |
365 |
|
|
366 |
63 |
return true; |
367 |
|
} |
368 |
|
} |