1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.sifts; |
22 |
|
|
23 |
|
import jalview.analysis.AlignSeq; |
24 |
|
import jalview.analysis.scoremodels.ScoreMatrix; |
25 |
|
import jalview.analysis.scoremodels.ScoreModels; |
26 |
|
import jalview.api.DBRefEntryI; |
27 |
|
import jalview.api.SiftsClientI; |
28 |
|
import jalview.datamodel.DBRefEntry; |
29 |
|
import jalview.datamodel.DBRefSource; |
30 |
|
import jalview.datamodel.SequenceI; |
31 |
|
import jalview.io.StructureFile; |
32 |
|
import jalview.schemes.ResidueProperties; |
33 |
|
import jalview.structure.StructureMapping; |
34 |
|
import jalview.util.Comparison; |
35 |
|
import jalview.util.DBRefUtils; |
36 |
|
import jalview.util.Format; |
37 |
|
import jalview.xml.binding.sifts.Entry; |
38 |
|
import jalview.xml.binding.sifts.Entry.Entity; |
39 |
|
import jalview.xml.binding.sifts.Entry.Entity.Segment; |
40 |
|
import jalview.xml.binding.sifts.Entry.Entity.Segment.ListMapRegion.MapRegion; |
41 |
|
import jalview.xml.binding.sifts.Entry.Entity.Segment.ListResidue.Residue; |
42 |
|
import jalview.xml.binding.sifts.Entry.Entity.Segment.ListResidue.Residue.CrossRefDb; |
43 |
|
import jalview.xml.binding.sifts.Entry.Entity.Segment.ListResidue.Residue.ResidueDetail; |
44 |
|
|
45 |
|
import java.io.File; |
46 |
|
import java.io.FileInputStream; |
47 |
|
import java.io.FileOutputStream; |
48 |
|
import java.io.IOException; |
49 |
|
import java.io.InputStream; |
50 |
|
import java.io.PrintStream; |
51 |
|
import java.net.URL; |
52 |
|
import java.net.URLConnection; |
53 |
|
import java.nio.file.Files; |
54 |
|
import java.nio.file.Path; |
55 |
|
import java.nio.file.attribute.BasicFileAttributes; |
56 |
|
import java.util.ArrayList; |
57 |
|
import java.util.Arrays; |
58 |
|
import java.util.Collection; |
59 |
|
import java.util.Collections; |
60 |
|
import java.util.Date; |
61 |
|
import java.util.HashMap; |
62 |
|
import java.util.HashSet; |
63 |
|
import java.util.List; |
64 |
|
import java.util.Map; |
65 |
|
import java.util.Set; |
66 |
|
import java.util.TreeMap; |
67 |
|
import java.util.zip.GZIPInputStream; |
68 |
|
|
69 |
|
import javax.xml.bind.JAXBContext; |
70 |
|
import javax.xml.bind.Unmarshaller; |
71 |
|
import javax.xml.stream.XMLInputFactory; |
72 |
|
import javax.xml.stream.XMLStreamReader; |
73 |
|
|
74 |
|
import mc_view.Atom; |
75 |
|
import mc_view.PDBChain; |
76 |
|
|
|
|
| 22.8% |
Uncovered Elements: 423 (548) |
Complexity: 126 |
Complexity Density: 0.33 |
|
77 |
|
public class SiftsClient implements SiftsClientI |
78 |
|
{ |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
private static File mockSiftsFile; |
84 |
|
|
85 |
|
private Entry siftsEntry; |
86 |
|
|
87 |
|
private StructureFile pdb; |
88 |
|
|
89 |
|
private String pdbId; |
90 |
|
|
91 |
|
private String structId; |
92 |
|
|
93 |
|
private CoordinateSys seqCoordSys = CoordinateSys.UNIPROT; |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
private jalview.datamodel.Mapping seqFromPdbMapping; |
102 |
|
|
103 |
|
private static final int BUFFER_SIZE = 4096; |
104 |
|
|
105 |
|
public static final int UNASSIGNED = Integer.MIN_VALUE; |
106 |
|
|
107 |
|
private static final int PDB_RES_POS = 0; |
108 |
|
|
109 |
|
private static final int PDB_ATOM_POS = 1; |
110 |
|
|
111 |
|
private static final int PDBE_POS = 2; |
112 |
|
|
113 |
|
private static final String NOT_OBSERVED = "Not_Observed"; |
114 |
|
|
115 |
|
private static final String SIFTS_FTP_BASE_URL = "http://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/"; |
116 |
|
|
117 |
|
private final static String NEWLINE = System.lineSeparator(); |
118 |
|
|
119 |
|
private String curSourceDBRef; |
120 |
|
|
121 |
|
private HashSet<String> curDBRefAccessionIdsString; |
122 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
123 |
|
private enum CoordinateSys |
124 |
|
{ |
125 |
|
UNIPROT("UniProt"), PDB("PDBresnum"), PDBe("PDBe"); |
126 |
|
private String name; |
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
128 |
3 |
private CoordinateSys(String name)... |
129 |
|
{ |
130 |
3 |
this.name = name; |
131 |
|
} |
132 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
133 |
0 |
public String getName()... |
134 |
|
{ |
135 |
0 |
return name; |
136 |
|
} |
137 |
|
}; |
138 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
139 |
|
private enum ResidueDetailType |
140 |
|
{ |
141 |
|
NAME_SEC_STRUCTURE("nameSecondaryStructure"), |
142 |
|
CODE_SEC_STRUCTURE("codeSecondaryStructure"), ANNOTATION("Annotation"); |
143 |
|
private String code; |
144 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
145 |
0 |
private ResidueDetailType(String code)... |
146 |
|
{ |
147 |
0 |
this.code = code; |
148 |
|
} |
149 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
150 |
0 |
public String getCode()... |
151 |
|
{ |
152 |
0 |
return code; |
153 |
|
} |
154 |
|
}; |
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
@param |
161 |
|
@throws |
162 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
163 |
10 |
public SiftsClient(StructureFile pdb) throws SiftsException... |
164 |
|
{ |
165 |
10 |
this.pdb = pdb; |
166 |
10 |
this.pdbId = pdb.getId(); |
167 |
10 |
File siftsFile = getSiftsFile(pdbId); |
168 |
10 |
siftsEntry = parseSIFTs(siftsFile); |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
@param |
175 |
|
|
176 |
|
@return |
177 |
|
@throws |
178 |
|
|
179 |
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 6 |
Complexity Density: 0.67 |
|
180 |
10 |
private Entry parseSIFTs(File siftFile) throws SiftsException... |
181 |
|
{ |
182 |
10 |
try (InputStream in = new FileInputStream(siftFile); |
183 |
10 |
GZIPInputStream gzis = new GZIPInputStream(in);) |
184 |
|
{ |
185 |
|
|
186 |
10 |
JAXBContext jc = JAXBContext.newInstance("jalview.xml.binding.sifts"); |
187 |
10 |
XMLStreamReader streamReader = XMLInputFactory.newInstance() |
188 |
|
.createXMLStreamReader(gzis); |
189 |
10 |
Unmarshaller um = jc.createUnmarshaller(); |
190 |
10 |
return (Entry) um.unmarshal(streamReader); |
191 |
|
} catch (Exception e) |
192 |
|
{ |
193 |
0 |
e.printStackTrace(); |
194 |
0 |
throw new SiftsException(e.getMessage()); |
195 |
|
} |
196 |
|
} |
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
@param |
203 |
|
@return |
204 |
|
@throws |
205 |
|
|
|
|
| 63% |
Uncovered Elements: 10 (27) |
Complexity: 6 |
Complexity Density: 0.29 |
|
206 |
10 |
public static File getSiftsFile(String pdbId) throws SiftsException... |
207 |
|
{ |
208 |
|
|
209 |
|
|
210 |
|
|
211 |
10 |
if (mockSiftsFile != null) |
212 |
|
{ |
213 |
0 |
return mockSiftsFile; |
214 |
|
} |
215 |
|
|
216 |
10 |
String siftsFileName = SiftsSettings.getSiftDownloadDirectory() |
217 |
|
+ pdbId.toLowerCase() + ".xml.gz"; |
218 |
10 |
File siftsFile = new File(siftsFileName); |
219 |
10 |
if (siftsFile.exists()) |
220 |
|
{ |
221 |
|
|
222 |
10 |
System.out.println(">>> SIFTS File already downloaded for " + pdbId); |
223 |
|
|
224 |
10 |
if (isFileOlderThanThreshold(siftsFile, |
225 |
|
SiftsSettings.getCacheThresholdInDays())) |
226 |
|
{ |
227 |
4 |
File oldSiftsFile = new File(siftsFileName + "_old"); |
228 |
4 |
siftsFile.renameTo(oldSiftsFile); |
229 |
4 |
try |
230 |
|
{ |
231 |
4 |
siftsFile = downloadSiftsFile(pdbId.toLowerCase()); |
232 |
4 |
oldSiftsFile.delete(); |
233 |
4 |
return siftsFile; |
234 |
|
} catch (IOException e) |
235 |
|
{ |
236 |
0 |
e.printStackTrace(); |
237 |
0 |
oldSiftsFile.renameTo(siftsFile); |
238 |
0 |
return new File(siftsFileName); |
239 |
|
} |
240 |
|
} |
241 |
|
else |
242 |
|
{ |
243 |
6 |
return siftsFile; |
244 |
|
} |
245 |
|
} |
246 |
0 |
try |
247 |
|
{ |
248 |
0 |
siftsFile = downloadSiftsFile(pdbId.toLowerCase()); |
249 |
|
} catch (IOException e) |
250 |
|
{ |
251 |
0 |
throw new SiftsException(e.getMessage()); |
252 |
|
} |
253 |
0 |
return siftsFile; |
254 |
|
} |
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
@param |
261 |
|
|
262 |
|
@param |
263 |
|
|
264 |
|
@return |
265 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
266 |
10 |
public static boolean isFileOlderThanThreshold(File file, int noOfDays)... |
267 |
|
{ |
268 |
10 |
Path filePath = file.toPath(); |
269 |
10 |
BasicFileAttributes attr; |
270 |
10 |
int diffInDays = 0; |
271 |
10 |
try |
272 |
|
{ |
273 |
10 |
attr = Files.readAttributes(filePath, BasicFileAttributes.class); |
274 |
10 |
diffInDays = (int) ((new Date().getTime() |
275 |
|
- attr.lastModifiedTime().toMillis()) |
276 |
|
/ (1000 * 60 * 60 * 24)); |
277 |
|
|
278 |
|
} catch (IOException e) |
279 |
|
{ |
280 |
0 |
e.printStackTrace(); |
281 |
|
} |
282 |
10 |
return noOfDays <= diffInDays; |
283 |
|
} |
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
@param |
289 |
|
@return |
290 |
|
@throws |
291 |
|
@throws |
292 |
|
|
|
|
| 76% |
Uncovered Elements: 6 (25) |
Complexity: 4 |
Complexity Density: 0.21 |
|
293 |
4 |
public static File downloadSiftsFile(String pdbId)... |
294 |
|
throws SiftsException, IOException |
295 |
|
{ |
296 |
4 |
if (pdbId.contains(".cif")) |
297 |
|
{ |
298 |
0 |
pdbId = pdbId.replace(".cif", ""); |
299 |
|
} |
300 |
4 |
String siftFile = pdbId + ".xml.gz"; |
301 |
4 |
String siftsFileFTPURL = SIFTS_FTP_BASE_URL + siftFile; |
302 |
4 |
String downloadedSiftsFile = SiftsSettings.getSiftDownloadDirectory() |
303 |
|
+ siftFile; |
304 |
4 |
File siftsDownloadDir = new File( |
305 |
|
SiftsSettings.getSiftDownloadDirectory()); |
306 |
4 |
if (!siftsDownloadDir.exists()) |
307 |
|
{ |
308 |
0 |
siftsDownloadDir.mkdirs(); |
309 |
|
} |
310 |
|
|
311 |
|
|
312 |
4 |
URL url = new URL(siftsFileFTPURL); |
313 |
4 |
URLConnection conn = url.openConnection(); |
314 |
4 |
InputStream inputStream = conn.getInputStream(); |
315 |
4 |
FileOutputStream outputStream = new FileOutputStream( |
316 |
|
downloadedSiftsFile); |
317 |
4 |
byte[] buffer = new byte[BUFFER_SIZE]; |
318 |
4 |
int bytesRead = -1; |
319 |
? |
while ((bytesRead = inputStream.read(buffer)) != -1) |
320 |
|
{ |
321 |
40 |
outputStream.write(buffer, 0, bytesRead); |
322 |
|
} |
323 |
4 |
outputStream.close(); |
324 |
4 |
inputStream.close(); |
325 |
|
|
326 |
|
|
327 |
4 |
return new File(downloadedSiftsFile); |
328 |
|
} |
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
@param |
335 |
|
@return |
336 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
337 |
0 |
public static boolean deleteSiftsFileByPDBId(String pdbId)... |
338 |
|
{ |
339 |
0 |
File siftsFile = new File(SiftsSettings.getSiftDownloadDirectory() |
340 |
|
+ pdbId.toLowerCase() + ".xml.gz"); |
341 |
0 |
if (siftsFile.exists()) |
342 |
|
{ |
343 |
0 |
return siftsFile.delete(); |
344 |
|
} |
345 |
0 |
return true; |
346 |
|
} |
347 |
|
|
348 |
|
|
349 |
|
|
350 |
|
|
351 |
|
@param |
352 |
|
|
353 |
|
@return |
354 |
|
@throws |
355 |
|
|
356 |
|
|
|
|
| 25% |
Uncovered Elements: 12 (16) |
Complexity: 9 |
Complexity Density: 0.9 |
|
357 |
12 |
public DBRefEntryI getValidSourceDBRef(SequenceI seq)... |
358 |
|
throws SiftsException |
359 |
|
{ |
360 |
12 |
List<DBRefEntry> dbRefs = seq.getPrimaryDBRefs(); |
361 |
12 |
if (dbRefs == null || dbRefs.size() < 1) |
362 |
|
{ |
363 |
12 |
throw new SiftsException( |
364 |
|
"Source DBRef could not be determined. DBRefs might not have been retrieved."); |
365 |
|
} |
366 |
|
|
367 |
0 |
for (DBRefEntry dbRef : dbRefs) |
368 |
|
{ |
369 |
0 |
if (dbRef == null || dbRef.getAccessionId() == null |
370 |
|
|| dbRef.getSource() == null) |
371 |
|
{ |
372 |
0 |
continue; |
373 |
|
} |
374 |
0 |
String canonicalSource = DBRefUtils |
375 |
|
.getCanonicalName(dbRef.getSource()); |
376 |
0 |
if (isValidDBRefEntry(dbRef) |
377 |
|
&& (canonicalSource.equalsIgnoreCase(DBRefSource.UNIPROT) |
378 |
|
|| canonicalSource.equalsIgnoreCase(DBRefSource.PDB))) |
379 |
|
{ |
380 |
0 |
return dbRef; |
381 |
|
} |
382 |
|
} |
383 |
0 |
throw new SiftsException("Could not get source DB Ref"); |
384 |
|
} |
385 |
|
|
386 |
|
|
387 |
|
|
388 |
|
|
389 |
|
|
390 |
|
@param |
391 |
|
|
392 |
|
@return |
393 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
394 |
0 |
boolean isValidDBRefEntry(DBRefEntryI entry)... |
395 |
|
{ |
396 |
0 |
return entry != null && entry.getAccessionId() != null |
397 |
|
&& isFoundInSiftsEntry(entry.getAccessionId()); |
398 |
|
} |
399 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
400 |
0 |
@Override... |
401 |
|
public HashSet<String> getAllMappingAccession() |
402 |
|
{ |
403 |
0 |
HashSet<String> accessions = new HashSet<String>(); |
404 |
0 |
List<Entity> entities = siftsEntry.getEntity(); |
405 |
0 |
for (Entity entity : entities) |
406 |
|
{ |
407 |
0 |
List<Segment> segments = entity.getSegment(); |
408 |
0 |
for (Segment segment : segments) |
409 |
|
{ |
410 |
0 |
List<MapRegion> mapRegions = segment.getListMapRegion() |
411 |
|
.getMapRegion(); |
412 |
0 |
for (MapRegion mapRegion : mapRegions) |
413 |
|
{ |
414 |
0 |
accessions |
415 |
|
.add(mapRegion.getDb().getDbAccessionId().toLowerCase()); |
416 |
|
} |
417 |
|
} |
418 |
|
} |
419 |
0 |
return accessions; |
420 |
|
} |
421 |
|
|
|
|
| 73.3% |
Uncovered Elements: 4 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
422 |
12 |
@Override... |
423 |
|
public StructureMapping getSiftsStructureMapping(SequenceI seq, |
424 |
|
String pdbFile, String chain) throws SiftsException |
425 |
|
{ |
426 |
12 |
SequenceI aseq = seq; |
427 |
24 |
while (seq.getDatasetSequence() != null) |
428 |
|
{ |
429 |
12 |
seq = seq.getDatasetSequence(); |
430 |
|
} |
431 |
12 |
structId = (chain == null) ? pdbId : pdbId + "|" + chain; |
432 |
12 |
System.out.println("Getting SIFTS mapping for " + structId + ": seq " |
433 |
|
+ seq.getName()); |
434 |
|
|
435 |
12 |
final StringBuilder mappingDetails = new StringBuilder(128); |
436 |
12 |
PrintStream ps = new PrintStream(System.out) |
437 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
438 |
0 |
@Override... |
439 |
|
public void print(String x) |
440 |
|
{ |
441 |
0 |
mappingDetails.append(x); |
442 |
|
} |
443 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
444 |
0 |
@Override... |
445 |
|
public void println() |
446 |
|
{ |
447 |
0 |
mappingDetails.append(NEWLINE); |
448 |
|
} |
449 |
|
}; |
450 |
12 |
HashMap<Integer, int[]> mapping = getGreedyMapping(chain, seq, ps); |
451 |
|
|
452 |
0 |
String mappingOutput = mappingDetails.toString(); |
453 |
0 |
StructureMapping siftsMapping = new StructureMapping(aseq, pdbFile, |
454 |
|
pdbId, chain, mapping, mappingOutput, seqFromPdbMapping); |
455 |
|
|
456 |
0 |
return siftsMapping; |
457 |
|
} |
458 |
|
|
|
|
| 7.1% |
Uncovered Elements: 105 (113) |
Complexity: 15 |
Complexity Density: 0.16 |
|
459 |
12 |
@Override... |
460 |
|
public HashMap<Integer, int[]> getGreedyMapping(String entityId, |
461 |
|
SequenceI seq, java.io.PrintStream os) throws SiftsException |
462 |
|
{ |
463 |
12 |
List<Integer> omitNonObserved = new ArrayList<>(); |
464 |
12 |
int nonObservedShiftIndex = 0,pdbeNonObserved=0; |
465 |
|
|
466 |
12 |
Entity entity = null; |
467 |
12 |
entity = getEntityById(entityId); |
468 |
12 |
String originalSeq = AlignSeq.extractGaps( |
469 |
|
jalview.util.Comparison.GapChars, seq.getSequenceAsString()); |
470 |
12 |
HashMap<Integer, int[]> mapping = new HashMap<Integer, int[]>(); |
471 |
12 |
DBRefEntryI sourceDBRef; |
472 |
12 |
sourceDBRef = getValidSourceDBRef(seq); |
473 |
|
|
474 |
|
|
475 |
|
|
476 |
|
|
477 |
0 |
if (sourceDBRef.getSource().equalsIgnoreCase(DBRefSource.PDB)) |
478 |
|
{ |
479 |
0 |
seqCoordSys = CoordinateSys.PDB; |
480 |
|
} |
481 |
|
|
482 |
0 |
HashSet<String> dbRefAccessionIdsString = new HashSet<String>(); |
483 |
0 |
for (DBRefEntry dbref : seq.getDBRefs()) |
484 |
|
{ |
485 |
0 |
dbRefAccessionIdsString.add(dbref.getAccessionId().toLowerCase()); |
486 |
|
} |
487 |
0 |
dbRefAccessionIdsString.add(sourceDBRef.getAccessionId().toLowerCase()); |
488 |
|
|
489 |
0 |
curDBRefAccessionIdsString = dbRefAccessionIdsString; |
490 |
0 |
curSourceDBRef = sourceDBRef.getAccessionId(); |
491 |
|
|
492 |
0 |
TreeMap<Integer, String> resNumMap = new TreeMap<Integer, String>(); |
493 |
0 |
List<Segment> segments = entity.getSegment(); |
494 |
0 |
SegmentHelperPojo shp = new SegmentHelperPojo(seq, mapping, resNumMap, |
495 |
|
omitNonObserved, nonObservedShiftIndex,pdbeNonObserved); |
496 |
0 |
processSegments(segments, shp); |
497 |
0 |
try |
498 |
|
{ |
499 |
0 |
populateAtomPositions(entityId, mapping); |
500 |
|
} catch (Exception e) |
501 |
|
{ |
502 |
0 |
e.printStackTrace(); |
503 |
|
} |
504 |
0 |
if (seqCoordSys == CoordinateSys.UNIPROT) |
505 |
|
{ |
506 |
0 |
padWithGaps(resNumMap, omitNonObserved); |
507 |
|
} |
508 |
0 |
int seqStart = UNASSIGNED; |
509 |
0 |
int seqEnd = UNASSIGNED; |
510 |
0 |
int pdbStart = UNASSIGNED; |
511 |
0 |
int pdbEnd = UNASSIGNED; |
512 |
|
|
513 |
0 |
if (mapping.isEmpty()) |
514 |
|
{ |
515 |
0 |
throw new SiftsException("SIFTS mapping failed"); |
516 |
|
} |
517 |
|
|
518 |
|
|
519 |
0 |
Integer[] keys = mapping.keySet().toArray(new Integer[0]); |
520 |
0 |
Arrays.sort(keys); |
521 |
0 |
seqStart = keys[0]; |
522 |
0 |
seqEnd = keys[keys.length - 1]; |
523 |
0 |
List<int[]> from=new ArrayList<>(),to=new ArrayList<>(); |
524 |
0 |
int[]_cfrom=null,_cto=null; |
525 |
0 |
String matchedSeq = originalSeq; |
526 |
0 |
if (seqStart != UNASSIGNED) |
527 |
|
{ |
528 |
0 |
for (int seqps:keys) |
529 |
|
{ |
530 |
0 |
int pdbpos = mapping.get(seqps)[PDBE_POS]; |
531 |
0 |
if (pdbpos == UNASSIGNED) |
532 |
|
{ |
533 |
|
|
534 |
0 |
continue; |
535 |
|
} |
536 |
0 |
if (_cfrom==null || seqps!=_cfrom[1]+1) |
537 |
|
{ |
538 |
0 |
_cfrom = new int[] { seqps,seqps}; |
539 |
0 |
from.add(_cfrom); |
540 |
0 |
_cto = null; |
541 |
|
} else { |
542 |
0 |
_cfrom[1]= seqps; |
543 |
|
} |
544 |
0 |
if (_cto==null || pdbpos!=1+_cto[1]) |
545 |
|
{ |
546 |
0 |
_cto = new int[] { pdbpos,pdbpos}; |
547 |
0 |
to.add(_cto); |
548 |
|
} else { |
549 |
0 |
_cto[1] = pdbpos; |
550 |
|
} |
551 |
|
} |
552 |
0 |
_cfrom = new int[from.size() * 2]; |
553 |
0 |
_cto = new int[to.size() * 2]; |
554 |
0 |
int p = 0; |
555 |
0 |
for (int[] range : from) |
556 |
|
{ |
557 |
0 |
_cfrom[p++] = range[0]; |
558 |
0 |
_cfrom[p++] = range[1]; |
559 |
|
} |
560 |
0 |
; |
561 |
0 |
p = 0; |
562 |
0 |
for (int[] range : to) |
563 |
|
{ |
564 |
0 |
_cto[p++] = range[0]; |
565 |
0 |
_cto[p++] = range[1]; |
566 |
|
} |
567 |
0 |
; |
568 |
|
|
569 |
0 |
seqFromPdbMapping = new jalview.datamodel.Mapping(null, _cto, _cfrom, |
570 |
|
1, |
571 |
|
1); |
572 |
0 |
pdbStart = mapping.get(seqStart)[PDB_RES_POS]; |
573 |
0 |
pdbEnd = mapping.get(seqEnd)[PDB_RES_POS]; |
574 |
0 |
int orignalSeqStart = seq.getStart(); |
575 |
0 |
if (orignalSeqStart >= 1) |
576 |
|
{ |
577 |
0 |
int subSeqStart = (seqStart >= orignalSeqStart) |
578 |
|
? seqStart - orignalSeqStart |
579 |
|
: 0; |
580 |
0 |
int subSeqEnd = seqEnd - (orignalSeqStart - 1); |
581 |
0 |
subSeqEnd = originalSeq.length() < subSeqEnd ? originalSeq.length() |
582 |
|
: subSeqEnd; |
583 |
0 |
matchedSeq = originalSeq.substring(subSeqStart, subSeqEnd); |
584 |
|
} |
585 |
|
else |
586 |
|
{ |
587 |
0 |
matchedSeq = originalSeq.substring(1, originalSeq.length()); |
588 |
|
} |
589 |
|
} |
590 |
|
|
591 |
0 |
StringBuilder targetStrucSeqs = new StringBuilder(); |
592 |
0 |
for (String res : resNumMap.values()) |
593 |
|
{ |
594 |
0 |
targetStrucSeqs.append(res); |
595 |
|
} |
596 |
|
|
597 |
0 |
if (os != null) |
598 |
|
{ |
599 |
0 |
MappingOutputPojo mop = new MappingOutputPojo(); |
600 |
0 |
mop.setSeqStart(seqStart); |
601 |
0 |
mop.setSeqEnd(seqEnd); |
602 |
0 |
mop.setSeqName(seq.getName()); |
603 |
0 |
mop.setSeqResidue(matchedSeq); |
604 |
|
|
605 |
0 |
mop.setStrStart(pdbStart); |
606 |
0 |
mop.setStrEnd(pdbEnd); |
607 |
0 |
mop.setStrName(structId); |
608 |
0 |
mop.setStrResidue(targetStrucSeqs.toString()); |
609 |
|
|
610 |
0 |
mop.setType("pep"); |
611 |
0 |
os.print(getMappingOutput(mop).toString()); |
612 |
0 |
os.println(); |
613 |
|
} |
614 |
0 |
return mapping; |
615 |
|
} |
616 |
|
|
|
|
| 0% |
Uncovered Elements: 68 (68) |
Complexity: 15 |
Complexity Density: 0.36 |
|
617 |
0 |
void processSegments(List<Segment> segments, SegmentHelperPojo shp)... |
618 |
|
{ |
619 |
0 |
SequenceI seq = shp.getSeq(); |
620 |
0 |
HashMap<Integer, int[]> mapping = shp.getMapping(); |
621 |
0 |
TreeMap<Integer, String> resNumMap = shp.getResNumMap(); |
622 |
0 |
List<Integer> omitNonObserved = shp.getOmitNonObserved(); |
623 |
0 |
int nonObservedShiftIndex = shp.getNonObservedShiftIndex(); |
624 |
0 |
int pdbeNonObservedCount = shp.getPdbeNonObserved(); |
625 |
0 |
int firstPDBResNum = UNASSIGNED; |
626 |
0 |
for (Segment segment : segments) |
627 |
|
{ |
628 |
|
|
629 |
|
|
630 |
0 |
List<Residue> residues = segment.getListResidue().getResidue(); |
631 |
0 |
for (Residue residue : residues) |
632 |
|
{ |
633 |
0 |
boolean isObserved = isResidueObserved(residue); |
634 |
0 |
int pdbeIndex = getLeadingIntegerValue(residue.getDbResNum(), |
635 |
|
UNASSIGNED); |
636 |
0 |
int currSeqIndex = UNASSIGNED; |
637 |
0 |
List<CrossRefDb> cRefDbs = residue.getCrossRefDb(); |
638 |
0 |
CrossRefDb pdbRefDb = null; |
639 |
0 |
for (CrossRefDb cRefDb : cRefDbs) |
640 |
|
{ |
641 |
0 |
if (cRefDb.getDbSource().equalsIgnoreCase(DBRefSource.PDB)) |
642 |
|
{ |
643 |
0 |
pdbRefDb = cRefDb; |
644 |
0 |
if (firstPDBResNum == UNASSIGNED) |
645 |
|
{ |
646 |
0 |
firstPDBResNum = getLeadingIntegerValue(cRefDb.getDbResNum(), |
647 |
|
UNASSIGNED); |
648 |
|
} |
649 |
|
else |
650 |
|
{ |
651 |
0 |
if (isObserved) |
652 |
|
{ |
653 |
|
|
654 |
0 |
firstPDBResNum++; |
655 |
|
} |
656 |
|
} |
657 |
|
} |
658 |
0 |
if (cRefDb.getDbCoordSys().equalsIgnoreCase(seqCoordSys.getName()) |
659 |
|
&& isAccessionMatched(cRefDb.getDbAccessionId())) |
660 |
|
{ |
661 |
0 |
currSeqIndex = getLeadingIntegerValue(cRefDb.getDbResNum(), |
662 |
|
UNASSIGNED); |
663 |
0 |
if (pdbRefDb != null) |
664 |
|
{ |
665 |
0 |
break; |
666 |
|
} |
667 |
|
} |
668 |
|
} |
669 |
0 |
if (!isObserved) |
670 |
|
{ |
671 |
0 |
++pdbeNonObservedCount; |
672 |
|
} |
673 |
0 |
if (seqCoordSys == seqCoordSys.PDB) |
674 |
|
|
675 |
|
{ |
676 |
|
|
677 |
|
|
678 |
|
|
679 |
0 |
currSeqIndex = seq.getStart() - 1 + pdbeIndex; |
680 |
|
} |
681 |
0 |
if (!isObserved) |
682 |
|
{ |
683 |
0 |
if (seqCoordSys != CoordinateSys.UNIPROT) |
684 |
|
|
685 |
|
{ |
686 |
|
|
687 |
|
|
688 |
|
|
689 |
0 |
omitNonObserved.add(currSeqIndex); |
690 |
0 |
++nonObservedShiftIndex; |
691 |
|
} |
692 |
|
} |
693 |
0 |
if (currSeqIndex == UNASSIGNED) |
694 |
|
{ |
695 |
|
|
696 |
|
|
697 |
|
|
698 |
0 |
continue; |
699 |
|
} |
700 |
|
|
701 |
|
|
702 |
|
|
703 |
|
|
704 |
|
|
705 |
|
|
706 |
|
|
707 |
|
|
708 |
|
{ |
709 |
|
|
710 |
0 |
int resNum = (pdbRefDb == null) |
711 |
|
? getLeadingIntegerValue(residue.getDbResNum(), |
712 |
|
UNASSIGNED) |
713 |
|
: getLeadingIntegerValue(pdbRefDb.getDbResNum(), |
714 |
|
UNASSIGNED); |
715 |
|
|
716 |
0 |
if (isObserved) |
717 |
|
{ |
718 |
0 |
char resCharCode = ResidueProperties |
719 |
|
.getSingleCharacterCode(ResidueProperties |
720 |
|
.getCanonicalAminoAcid(residue.getDbResName())); |
721 |
0 |
resNumMap.put(currSeqIndex, String.valueOf(resCharCode)); |
722 |
|
|
723 |
0 |
int[] mappingcols = new int[] { Integer.valueOf(resNum), |
724 |
0 |
UNASSIGNED, isObserved ? firstPDBResNum : UNASSIGNED }; |
725 |
|
|
726 |
0 |
mapping.put(currSeqIndex - nonObservedShiftIndex, mappingcols); |
727 |
|
} |
728 |
|
} |
729 |
|
} |
730 |
|
} |
731 |
|
} |
732 |
|
|
733 |
|
|
734 |
|
|
735 |
|
|
736 |
|
@param |
737 |
|
|
738 |
|
@param |
739 |
|
|
740 |
|
@return |
741 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 5 |
Complexity Density: 0.83 |
|
742 |
0 |
static int getLeadingIntegerValue(String input, int failValue)... |
743 |
|
{ |
744 |
0 |
if (input == null) |
745 |
|
{ |
746 |
0 |
return failValue; |
747 |
|
} |
748 |
0 |
String[] parts = input.split("(?=\\D)(?<=\\d)"); |
749 |
0 |
if (parts != null && parts.length > 0 && parts[0].matches("[0-9]+")) |
750 |
|
{ |
751 |
0 |
return Integer.valueOf(parts[0]); |
752 |
|
} |
753 |
0 |
return failValue; |
754 |
|
} |
755 |
|
|
756 |
|
|
757 |
|
|
758 |
|
@param |
759 |
|
|
760 |
|
@param |
761 |
|
|
762 |
|
@throws |
763 |
|
|
764 |
|
@throws |
765 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 6 |
Complexity Density: 0.67 |
|
766 |
0 |
void populateAtomPositions(String chainId, Map<Integer, int[]> mapping)... |
767 |
|
throws IllegalArgumentException, SiftsException |
768 |
|
{ |
769 |
0 |
try |
770 |
|
{ |
771 |
0 |
PDBChain chain = pdb.findChain(chainId); |
772 |
|
|
773 |
0 |
if (chain == null || mapping == null) |
774 |
|
{ |
775 |
0 |
throw new IllegalArgumentException( |
776 |
|
"Chain id or mapping must not be null."); |
777 |
|
} |
778 |
0 |
for (int[] map : mapping.values()) |
779 |
|
{ |
780 |
0 |
if (map[PDB_RES_POS] != UNASSIGNED) |
781 |
|
{ |
782 |
0 |
map[PDB_ATOM_POS] = getAtomIndex(map[PDB_RES_POS], chain.atoms); |
783 |
|
} |
784 |
|
} |
785 |
|
} catch (NullPointerException e) |
786 |
|
{ |
787 |
0 |
throw new SiftsException(e.getMessage()); |
788 |
|
} catch (Exception e) |
789 |
|
{ |
790 |
0 |
throw new SiftsException(e.getMessage()); |
791 |
|
} |
792 |
|
} |
793 |
|
|
794 |
|
|
795 |
|
|
796 |
|
@param |
797 |
|
|
798 |
|
@param |
799 |
|
|
800 |
|
@return |
801 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
802 |
0 |
int getAtomIndex(int residueIndex, Collection<Atom> atoms)... |
803 |
|
{ |
804 |
0 |
if (atoms == null) |
805 |
|
{ |
806 |
0 |
throw new IllegalArgumentException( |
807 |
|
"atoms collection must not be null!"); |
808 |
|
} |
809 |
0 |
for (Atom atom : atoms) |
810 |
|
{ |
811 |
0 |
if (atom.resNumber == residueIndex) |
812 |
|
{ |
813 |
0 |
return atom.atomIndex; |
814 |
|
} |
815 |
|
} |
816 |
0 |
return UNASSIGNED; |
817 |
|
} |
818 |
|
|
819 |
|
|
820 |
|
|
821 |
|
|
822 |
|
@param |
823 |
|
@return |
824 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
825 |
0 |
private boolean isResidueObserved(Residue residue)... |
826 |
|
{ |
827 |
0 |
Set<String> annotations = getResidueAnnotaitons(residue, |
828 |
|
ResidueDetailType.ANNOTATION); |
829 |
0 |
if (annotations == null || annotations.isEmpty()) |
830 |
|
{ |
831 |
0 |
return true; |
832 |
|
} |
833 |
0 |
for (String annotation : annotations) |
834 |
|
{ |
835 |
0 |
if (annotation.equalsIgnoreCase(NOT_OBSERVED)) |
836 |
|
{ |
837 |
0 |
return false; |
838 |
|
} |
839 |
|
} |
840 |
0 |
return true; |
841 |
|
} |
842 |
|
|
843 |
|
|
844 |
|
|
845 |
|
|
846 |
|
@param |
847 |
|
@param |
848 |
|
@return |
849 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
850 |
0 |
private Set<String> getResidueAnnotaitons(Residue residue,... |
851 |
|
ResidueDetailType type) |
852 |
|
{ |
853 |
0 |
HashSet<String> foundAnnotations = new HashSet<String>(); |
854 |
0 |
List<ResidueDetail> resDetails = residue.getResidueDetail(); |
855 |
0 |
for (ResidueDetail resDetail : resDetails) |
856 |
|
{ |
857 |
0 |
if (resDetail.getProperty().equalsIgnoreCase(type.getCode())) |
858 |
|
{ |
859 |
0 |
foundAnnotations.add(resDetail.getContent()); |
860 |
|
} |
861 |
|
} |
862 |
0 |
return foundAnnotations; |
863 |
|
} |
864 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
865 |
0 |
@Override... |
866 |
|
public boolean isAccessionMatched(String accession) |
867 |
|
{ |
868 |
0 |
boolean isStrictMatch = true; |
869 |
0 |
return isStrictMatch ? curSourceDBRef.equalsIgnoreCase(accession) |
870 |
|
: curDBRefAccessionIdsString.contains(accession.toLowerCase()); |
871 |
|
} |
872 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
873 |
0 |
private boolean isFoundInSiftsEntry(String accessionId)... |
874 |
|
{ |
875 |
0 |
Set<String> siftsDBRefs = getAllMappingAccession(); |
876 |
0 |
return accessionId != null |
877 |
|
&& siftsDBRefs.contains(accessionId.toLowerCase()); |
878 |
|
} |
879 |
|
|
880 |
|
|
881 |
|
|
882 |
|
|
883 |
|
@param |
884 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 6 |
Complexity Density: 0.75 |
|
885 |
0 |
void padWithGaps(Map<Integer, String> resNumMap,... |
886 |
|
List<Integer> omitNonObserved) |
887 |
|
{ |
888 |
0 |
if (resNumMap == null || resNumMap.isEmpty()) |
889 |
|
{ |
890 |
0 |
return; |
891 |
|
} |
892 |
0 |
Integer[] keys = resNumMap.keySet().toArray(new Integer[0]); |
893 |
|
|
894 |
0 |
int firstIndex = keys[0]; |
895 |
0 |
int lastIndex = keys[keys.length - 1]; |
896 |
|
|
897 |
|
|
898 |
0 |
for (int x = firstIndex; x <= lastIndex; x++) |
899 |
|
{ |
900 |
0 |
if (!resNumMap.containsKey(x) && !omitNonObserved.contains(x)) |
901 |
|
{ |
902 |
0 |
resNumMap.put(x, "-"); |
903 |
|
} |
904 |
|
} |
905 |
|
} |
906 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
907 |
12 |
@Override... |
908 |
|
public Entity getEntityById(String id) throws SiftsException |
909 |
|
{ |
910 |
|
|
911 |
|
|
912 |
12 |
Entity entity = getEntityByMostOptimalMatchedId(id); |
913 |
12 |
if (entity != null) |
914 |
|
{ |
915 |
12 |
return entity; |
916 |
|
} |
917 |
0 |
throw new SiftsException("Entity " + id + " not found"); |
918 |
|
} |
919 |
|
|
920 |
|
|
921 |
|
|
922 |
|
|
923 |
|
|
924 |
|
|
925 |
|
@param |
926 |
|
@return |
927 |
|
|
|
|
| 89.5% |
Uncovered Elements: 4 (38) |
Complexity: 6 |
Complexity Density: 0.21 |
|
928 |
12 |
public Entity getEntityByMostOptimalMatchedId(String chainId)... |
929 |
|
{ |
930 |
|
|
931 |
|
|
932 |
12 |
List<Entity> entities = siftsEntry.getEntity(); |
933 |
12 |
SiftsEntitySortPojo[] sPojo = new SiftsEntitySortPojo[entities.size()]; |
934 |
12 |
int count = 0; |
935 |
12 |
for (Entity entity : entities) |
936 |
|
{ |
937 |
21 |
sPojo[count] = new SiftsEntitySortPojo(); |
938 |
21 |
sPojo[count].entityId = entity.getEntityId(); |
939 |
|
|
940 |
21 |
List<Segment> segments = entity.getSegment(); |
941 |
21 |
for (Segment segment : segments) |
942 |
|
{ |
943 |
33 |
List<Residue> residues = segment.getListResidue().getResidue(); |
944 |
33 |
for (Residue residue : residues) |
945 |
|
{ |
946 |
3582 |
List<CrossRefDb> cRefDbs = residue.getCrossRefDb(); |
947 |
3582 |
for (CrossRefDb cRefDb : cRefDbs) |
948 |
|
{ |
949 |
41364 |
if (!cRefDb.getDbSource().equalsIgnoreCase("PDB")) |
950 |
|
{ |
951 |
37782 |
continue; |
952 |
|
} |
953 |
3582 |
++sPojo[count].resCount; |
954 |
3582 |
if (cRefDb.getDbChainId().equalsIgnoreCase(chainId)) |
955 |
|
{ |
956 |
1881 |
++sPojo[count].chainIdFreq; |
957 |
|
} |
958 |
|
} |
959 |
|
} |
960 |
|
} |
961 |
21 |
sPojo[count].pid = (100 * sPojo[count].chainIdFreq) |
962 |
|
/ sPojo[count].resCount; |
963 |
21 |
++count; |
964 |
|
} |
965 |
12 |
Arrays.sort(sPojo, Collections.reverseOrder()); |
966 |
|
|
967 |
|
|
968 |
|
|
969 |
12 |
if (sPojo[0].entityId != null) |
970 |
|
{ |
971 |
12 |
if (sPojo[0].pid < 1) |
972 |
|
{ |
973 |
0 |
return null; |
974 |
|
} |
975 |
12 |
for (Entity entity : entities) |
976 |
|
{ |
977 |
18 |
if (!entity.getEntityId().equalsIgnoreCase(sPojo[0].entityId)) |
978 |
|
{ |
979 |
6 |
continue; |
980 |
|
} |
981 |
12 |
return entity; |
982 |
|
} |
983 |
|
} |
984 |
0 |
return null; |
985 |
|
} |
986 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
987 |
|
private class SiftsEntitySortPojo |
988 |
|
implements Comparable<SiftsEntitySortPojo> |
989 |
|
{ |
990 |
|
public String entityId; |
991 |
|
|
992 |
|
public int chainIdFreq; |
993 |
|
|
994 |
|
public int pid; |
995 |
|
|
996 |
|
public int resCount; |
997 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
998 |
9 |
@Override... |
999 |
|
public int compareTo(SiftsEntitySortPojo o) |
1000 |
|
{ |
1001 |
9 |
return this.pid - o.pid; |
1002 |
|
} |
1003 |
|
} |
1004 |
|
|
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 13 |
Complexity Density: 0.72 |
|
1005 |
|
private class SegmentHelperPojo |
1006 |
|
{ |
1007 |
|
private SequenceI seq; |
1008 |
|
|
1009 |
|
private HashMap<Integer, int[]> mapping; |
1010 |
|
|
1011 |
|
private TreeMap<Integer, String> resNumMap; |
1012 |
|
|
1013 |
|
private List<Integer> omitNonObserved; |
1014 |
|
|
1015 |
|
private int nonObservedShiftIndex; |
1016 |
|
|
1017 |
|
|
1018 |
|
|
1019 |
|
|
1020 |
|
|
1021 |
|
|
1022 |
|
private int pdbeNonObserved; |
1023 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
1024 |
0 |
public SegmentHelperPojo(SequenceI seq, HashMap<Integer, int[]> mapping,... |
1025 |
|
TreeMap<Integer, String> resNumMap, |
1026 |
|
List<Integer> omitNonObserved, int nonObservedShiftIndex, |
1027 |
|
int pdbeNonObserved) |
1028 |
|
{ |
1029 |
0 |
setSeq(seq); |
1030 |
0 |
setMapping(mapping); |
1031 |
0 |
setResNumMap(resNumMap); |
1032 |
0 |
setOmitNonObserved(omitNonObserved); |
1033 |
0 |
setNonObservedShiftIndex(nonObservedShiftIndex); |
1034 |
0 |
setPdbeNonObserved(pdbeNonObserved); |
1035 |
|
|
1036 |
|
} |
1037 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1038 |
0 |
public void setPdbeNonObserved(int pdbeNonObserved2)... |
1039 |
|
{ |
1040 |
0 |
this.pdbeNonObserved = pdbeNonObserved2; |
1041 |
|
} |
1042 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1043 |
0 |
public int getPdbeNonObserved()... |
1044 |
|
{ |
1045 |
0 |
return pdbeNonObserved; |
1046 |
|
} |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1047 |
0 |
public SequenceI getSeq()... |
1048 |
|
{ |
1049 |
0 |
return seq; |
1050 |
|
} |
1051 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1052 |
0 |
public void setSeq(SequenceI seq)... |
1053 |
|
{ |
1054 |
0 |
this.seq = seq; |
1055 |
|
} |
1056 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1057 |
0 |
public HashMap<Integer, int[]> getMapping()... |
1058 |
|
{ |
1059 |
0 |
return mapping; |
1060 |
|
} |
1061 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1062 |
0 |
public void setMapping(HashMap<Integer, int[]> mapping)... |
1063 |
|
{ |
1064 |
0 |
this.mapping = mapping; |
1065 |
|
} |
1066 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1067 |
0 |
public TreeMap<Integer, String> getResNumMap()... |
1068 |
|
{ |
1069 |
0 |
return resNumMap; |
1070 |
|
} |
1071 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1072 |
0 |
public void setResNumMap(TreeMap<Integer, String> resNumMap)... |
1073 |
|
{ |
1074 |
0 |
this.resNumMap = resNumMap; |
1075 |
|
} |
1076 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1077 |
0 |
public List<Integer> getOmitNonObserved()... |
1078 |
|
{ |
1079 |
0 |
return omitNonObserved; |
1080 |
|
} |
1081 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1082 |
0 |
public void setOmitNonObserved(List<Integer> omitNonObserved)... |
1083 |
|
{ |
1084 |
0 |
this.omitNonObserved = omitNonObserved; |
1085 |
|
} |
1086 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1087 |
0 |
public int getNonObservedShiftIndex()... |
1088 |
|
{ |
1089 |
0 |
return nonObservedShiftIndex; |
1090 |
|
} |
1091 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1092 |
0 |
public void setNonObservedShiftIndex(int nonObservedShiftIndex)... |
1093 |
|
{ |
1094 |
0 |
this.nonObservedShiftIndex = nonObservedShiftIndex; |
1095 |
|
} |
1096 |
|
|
1097 |
|
} |
1098 |
|
|
|
|
| 0% |
Uncovered Elements: 92 (92) |
Complexity: 16 |
Complexity Density: 0.24 |
|
1099 |
0 |
@Override... |
1100 |
|
public StringBuilder getMappingOutput(MappingOutputPojo mp) |
1101 |
|
throws SiftsException |
1102 |
|
{ |
1103 |
0 |
String seqRes = mp.getSeqResidue(); |
1104 |
0 |
String seqName = mp.getSeqName(); |
1105 |
0 |
int sStart = mp.getSeqStart(); |
1106 |
0 |
int sEnd = mp.getSeqEnd(); |
1107 |
|
|
1108 |
0 |
String strRes = mp.getStrResidue(); |
1109 |
0 |
String strName = mp.getStrName(); |
1110 |
0 |
int pdbStart = mp.getStrStart(); |
1111 |
0 |
int pdbEnd = mp.getStrEnd(); |
1112 |
|
|
1113 |
0 |
String type = mp.getType(); |
1114 |
|
|
1115 |
0 |
int maxid = (seqName.length() >= strName.length()) ? seqName.length() |
1116 |
|
: strName.length(); |
1117 |
0 |
int len = 72 - maxid - 1; |
1118 |
|
|
1119 |
0 |
int nochunks = ((seqRes.length()) / len) |
1120 |
0 |
+ ((seqRes.length()) % len > 0 ? 1 : 0); |
1121 |
|
|
1122 |
0 |
StringBuilder output = new StringBuilder(512); |
1123 |
0 |
output.append(NEWLINE); |
1124 |
0 |
output.append("Sequence \u27f7 Structure mapping details") |
1125 |
|
.append(NEWLINE); |
1126 |
0 |
output.append("Method: SIFTS"); |
1127 |
0 |
output.append(NEWLINE).append(NEWLINE); |
1128 |
|
|
1129 |
0 |
output.append(new Format("%" + maxid + "s").form(seqName)); |
1130 |
0 |
output.append(" : "); |
1131 |
0 |
output.append(String.valueOf(sStart)); |
1132 |
0 |
output.append(" - "); |
1133 |
0 |
output.append(String.valueOf(sEnd)); |
1134 |
0 |
output.append(" Maps to "); |
1135 |
0 |
output.append(NEWLINE); |
1136 |
0 |
output.append(new Format("%" + maxid + "s").form(structId)); |
1137 |
0 |
output.append(" : "); |
1138 |
0 |
output.append(String.valueOf(pdbStart)); |
1139 |
0 |
output.append(" - "); |
1140 |
0 |
output.append(String.valueOf(pdbEnd)); |
1141 |
0 |
output.append(NEWLINE).append(NEWLINE); |
1142 |
|
|
1143 |
0 |
ScoreMatrix pam250 = ScoreModels.getInstance().getPam250(); |
1144 |
0 |
int matchedSeqCount = 0; |
1145 |
0 |
for (int j = 0; j < nochunks; j++) |
1146 |
|
{ |
1147 |
|
|
1148 |
0 |
output.append(new Format("%" + (maxid) + "s").form(seqName)) |
1149 |
|
.append(" "); |
1150 |
|
|
1151 |
0 |
for (int i = 0; i < len; i++) |
1152 |
|
{ |
1153 |
0 |
if ((i + (j * len)) < seqRes.length()) |
1154 |
|
{ |
1155 |
0 |
output.append(seqRes.charAt(i + (j * len))); |
1156 |
|
} |
1157 |
|
} |
1158 |
|
|
1159 |
0 |
output.append(NEWLINE); |
1160 |
0 |
output.append(new Format("%" + (maxid) + "s").form(" ")).append(" "); |
1161 |
|
|
1162 |
|
|
1163 |
|
|
1164 |
|
|
1165 |
|
|
1166 |
|
|
1167 |
|
|
1168 |
0 |
for (int i = 0; i < len; i++) |
1169 |
|
{ |
1170 |
0 |
try |
1171 |
|
{ |
1172 |
0 |
if ((i + (j * len)) < seqRes.length()) |
1173 |
|
{ |
1174 |
0 |
char c1 = seqRes.charAt(i + (j * len)); |
1175 |
0 |
char c2 = strRes.charAt(i + (j * len)); |
1176 |
0 |
boolean sameChar = Comparison.isSameResidue(c1, c2, false); |
1177 |
0 |
if (sameChar && !Comparison.isGap(c1)) |
1178 |
|
{ |
1179 |
0 |
matchedSeqCount++; |
1180 |
0 |
output.append("|"); |
1181 |
|
} |
1182 |
0 |
else if (type.equals("pep")) |
1183 |
|
{ |
1184 |
0 |
if (pam250.getPairwiseScore(c1, c2) > 0) |
1185 |
|
{ |
1186 |
0 |
output.append("."); |
1187 |
|
} |
1188 |
|
else |
1189 |
|
{ |
1190 |
0 |
output.append(" "); |
1191 |
|
} |
1192 |
|
} |
1193 |
|
else |
1194 |
|
{ |
1195 |
0 |
output.append(" "); |
1196 |
|
} |
1197 |
|
} |
1198 |
|
} catch (IndexOutOfBoundsException e) |
1199 |
|
{ |
1200 |
0 |
continue; |
1201 |
|
} |
1202 |
|
} |
1203 |
|
|
1204 |
0 |
output = output.append(NEWLINE); |
1205 |
0 |
output = output.append(new Format("%" + (maxid) + "s").form(strName)) |
1206 |
|
.append(" "); |
1207 |
0 |
for (int i = 0; i < len; i++) |
1208 |
|
{ |
1209 |
0 |
if ((i + (j * len)) < strRes.length()) |
1210 |
|
{ |
1211 |
0 |
output.append(strRes.charAt(i + (j * len))); |
1212 |
|
} |
1213 |
|
} |
1214 |
0 |
output.append(NEWLINE).append(NEWLINE); |
1215 |
|
} |
1216 |
0 |
float pid = (float) matchedSeqCount / seqRes.length() * 100; |
1217 |
0 |
if (pid < SiftsSettings.getFailSafePIDThreshold()) |
1218 |
|
{ |
1219 |
0 |
throw new SiftsException(">>> Low PID detected for SIFTs mapping..."); |
1220 |
|
} |
1221 |
0 |
output.append("Length of alignment = " + seqRes.length()) |
1222 |
|
.append(NEWLINE); |
1223 |
0 |
output.append(new Format("Percentage ID = %2.2f").form(pid)); |
1224 |
0 |
return output; |
1225 |
|
} |
1226 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1227 |
0 |
@Override... |
1228 |
|
public int getEntityCount() |
1229 |
|
{ |
1230 |
0 |
return siftsEntry.getEntity().size(); |
1231 |
|
} |
1232 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1233 |
0 |
@Override... |
1234 |
|
public String getDbAccessionId() |
1235 |
|
{ |
1236 |
0 |
return siftsEntry.getDbAccessionId(); |
1237 |
|
} |
1238 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1239 |
0 |
@Override... |
1240 |
|
public String getDbCoordSys() |
1241 |
|
{ |
1242 |
0 |
return siftsEntry.getDbCoordSys(); |
1243 |
|
} |
1244 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1245 |
0 |
@Override... |
1246 |
|
public String getDbSource() |
1247 |
|
{ |
1248 |
0 |
return siftsEntry.getDbSource(); |
1249 |
|
} |
1250 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1251 |
0 |
@Override... |
1252 |
|
public String getDbVersion() |
1253 |
|
{ |
1254 |
0 |
return siftsEntry.getDbVersion(); |
1255 |
|
} |
1256 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1257 |
0 |
public static void setMockSiftsFile(File file)... |
1258 |
|
{ |
1259 |
0 |
mockSiftsFile = file; |
1260 |
|
} |
1261 |
|
|
1262 |
|
} |