1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui.structurechooser; |
22 |
|
|
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.Arrays; |
25 |
|
import java.util.Collection; |
26 |
|
import java.util.Comparator; |
27 |
|
import java.util.HashSet; |
28 |
|
import java.util.LinkedHashSet; |
29 |
|
import java.util.List; |
30 |
|
import java.util.Locale; |
31 |
|
import java.util.Set; |
32 |
|
|
33 |
|
import javax.swing.JTable; |
34 |
|
|
35 |
|
import jalview.bin.Console; |
36 |
|
import jalview.datamodel.DBRefEntry; |
37 |
|
import jalview.datamodel.DBRefSource; |
38 |
|
import jalview.datamodel.PDBEntry; |
39 |
|
import jalview.datamodel.SequenceI; |
40 |
|
import jalview.fts.api.FTSData; |
41 |
|
import jalview.fts.api.FTSDataColumnI; |
42 |
|
import jalview.fts.api.FTSRestClientI; |
43 |
|
import jalview.fts.core.FTSDataColumnPreferences; |
44 |
|
import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource; |
45 |
|
import jalview.fts.core.FTSRestRequest; |
46 |
|
import jalview.fts.core.FTSRestResponse; |
47 |
|
import jalview.fts.service.threedbeacons.TDB_FTSData; |
48 |
|
import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient; |
49 |
|
import jalview.jbgui.FilterOption; |
50 |
|
import jalview.structure.StructureImportSettings.TFType; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@author |
56 |
|
|
|
|
| 53.4% |
Uncovered Elements: 163 (350) |
Complexity: 84 |
Complexity Density: 0.37 |
|
57 |
|
public class ThreeDBStructureChooserQuerySource |
58 |
|
extends StructureChooserQuerySource |
59 |
|
{ |
60 |
|
|
61 |
|
private Set<String> tdBeaconsFilters = null, defaultFilters = null; |
62 |
|
|
63 |
|
public static final String FILTER_TDBEACONS_COVERAGE = "3d_beacons_coverage"; |
64 |
|
|
65 |
|
public static final String FILTER_FIRST_BEST_COVERAGE = "3d_beacons_first_best_coverage"; |
66 |
|
|
67 |
|
private static final String FILTER_SOURCE_PREFIX = "only_"; |
68 |
|
|
69 |
|
protected FTSRestRequest lastTdbRequest; |
70 |
|
|
71 |
|
protected FTSRestClientI tdbRestClient; |
72 |
|
|
73 |
|
private FTSRestRequest lastPdbRequest; |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
75 |
70 |
public ThreeDBStructureChooserQuerySource()... |
76 |
|
{ |
77 |
70 |
defaultFilters = new LinkedHashSet<String>(); |
78 |
70 |
defaultFilters.add(FILTER_TDBEACONS_COVERAGE); |
79 |
70 |
defaultFilters.add(FILTER_FIRST_BEST_COVERAGE); |
80 |
|
|
81 |
70 |
tdbRestClient = TDBeaconsFTSRestClient.getInstance(); |
82 |
70 |
docFieldPrefs = new FTSDataColumnPreferences( |
83 |
|
PreferenceSource.STRUCTURE_CHOOSER, |
84 |
|
TDBeaconsFTSRestClient.getInstance()); |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
@param |
92 |
|
|
93 |
|
@return |
94 |
|
|
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
96 |
15 |
@Override... |
97 |
|
public String buildQuery(SequenceI seq) |
98 |
|
{ |
99 |
15 |
List<DBRefEntry> refs = seq.getDBRefs(); |
100 |
15 |
int ib = checkUniprotRefs(refs); |
101 |
15 |
if (ib > -1) |
102 |
|
{ |
103 |
14 |
return getDBRefId(refs.get(ib)); |
104 |
|
} |
105 |
1 |
return null; |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
@param |
112 |
|
@return |
113 |
|
|
114 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 7 |
Complexity Density: 0.78 |
|
115 |
83 |
public static int checkUniprotRefs(List<DBRefEntry> refs)... |
116 |
|
{ |
117 |
83 |
boolean hasUniprot = false; |
118 |
83 |
if (refs != null && refs.size() != 0) |
119 |
|
{ |
120 |
57 |
for (int ib = 0, nb = refs.size(); ib < nb; ib++) |
121 |
|
{ |
122 |
46 |
DBRefEntry dbRef = refs.get(ib); |
123 |
46 |
if (dbRef.getSource().equalsIgnoreCase(DBRefSource.UNIPROT)) |
124 |
|
{ |
125 |
26 |
hasUniprot = true; |
126 |
26 |
if (dbRef.isCanonical()) |
127 |
|
{ |
128 |
23 |
return ib; |
129 |
|
} |
130 |
|
} |
131 |
|
} |
132 |
|
} |
133 |
60 |
return hasUniprot ? -1 : -2; |
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
@param |
141 |
|
@return |
142 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
143 |
0 |
static boolean isValidSeqName(String seqName)... |
144 |
|
{ |
145 |
0 |
String ignoreList = "pdb,uniprot,swiss-prot"; |
146 |
0 |
if (seqName.length() < 3) |
147 |
|
{ |
148 |
0 |
return false; |
149 |
|
} |
150 |
0 |
if (seqName.contains(":")) |
151 |
|
{ |
152 |
0 |
return false; |
153 |
|
} |
154 |
0 |
seqName = seqName.toLowerCase(Locale.ROOT); |
155 |
0 |
for (String ignoredEntry : ignoreList.split(",")) |
156 |
|
{ |
157 |
0 |
if (seqName.contains(ignoredEntry)) |
158 |
|
{ |
159 |
0 |
return false; |
160 |
|
} |
161 |
|
} |
162 |
0 |
return true; |
163 |
|
} |
164 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
165 |
14 |
static String getDBRefId(DBRefEntry dbRef)... |
166 |
|
{ |
167 |
14 |
String ref = dbRef.getAccessionId().replaceAll("GO:", ""); |
168 |
14 |
return ref; |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
@param |
176 |
|
|
177 |
|
@param |
178 |
|
|
179 |
|
@param |
180 |
|
|
181 |
|
@param |
182 |
|
|
183 |
|
@return |
184 |
|
@throws |
185 |
|
|
|
|
| 64.7% |
Uncovered Elements: 6 (17) |
Complexity: 4 |
Complexity Density: 0.31 |
|
186 |
12 |
@Override... |
187 |
|
public FTSRestResponse fetchStructuresMetaData(SequenceI seq, |
188 |
|
Collection<FTSDataColumnI> wantedFields, |
189 |
|
FilterOption selectedFilterOpt, boolean b) throws Exception |
190 |
|
{ |
191 |
12 |
FTSRestResponse resultList; |
192 |
12 |
if (selectedFilterOpt != null |
193 |
|
&& tdBeaconsFilter(selectedFilterOpt.getValue())) |
194 |
|
{ |
195 |
12 |
FTSRestRequest tdbRequest = getTDBeaconsRequest(seq, wantedFields); |
196 |
12 |
resultList = tdbRestClient.executeRequest(tdbRequest); |
197 |
|
|
198 |
12 |
lastTdbRequest = tdbRequest; |
199 |
12 |
if (resultList != null) |
200 |
|
{ |
201 |
12 |
List<FTSRestResponse> pdbResponse = fetchStructuresMetaDataFor( |
202 |
|
getPDBQuerySource(), resultList); |
203 |
|
|
204 |
12 |
resultList = joinResponses(resultList, pdbResponse); |
205 |
|
} |
206 |
12 |
return resultList; |
207 |
|
} |
208 |
|
|
209 |
0 |
resultList = getPDBQuerySource().fetchStructuresMetaData(seq, |
210 |
|
wantedFields, selectedFilterOpt, b); |
211 |
0 |
lastTdbRequest = getPDBQuerySource().lastPdbRequest; |
212 |
0 |
lastPdbRequest = lastTdbRequest; |
213 |
|
|
214 |
0 |
return resultList; |
215 |
|
|
216 |
|
} |
217 |
|
|
218 |
|
PDBStructureChooserQuerySource pdbQuerySource = null; |
219 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
220 |
19 |
private PDBStructureChooserQuerySource getPDBQuerySource()... |
221 |
|
{ |
222 |
19 |
if (pdbQuerySource == null) |
223 |
|
{ |
224 |
6 |
pdbQuerySource = new PDBStructureChooserQuerySource(); |
225 |
|
} |
226 |
19 |
return pdbQuerySource; |
227 |
|
} |
228 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
229 |
12 |
private FTSRestRequest getTDBeaconsRequest(SequenceI seq,... |
230 |
|
Collection<FTSDataColumnI> wantedFields) |
231 |
|
{ |
232 |
12 |
FTSRestRequest pdbRequest = new FTSRestRequest(); |
233 |
12 |
pdbRequest.setAllowEmptySeq(false); |
234 |
12 |
pdbRequest.setResponseSize(500); |
235 |
12 |
pdbRequest.setWantedFields(wantedFields); |
236 |
12 |
String query = buildQuery(seq); |
237 |
12 |
if (query == null) |
238 |
|
{ |
239 |
0 |
return null; |
240 |
|
} |
241 |
12 |
pdbRequest.setSearchTerm(query + ".json"); |
242 |
12 |
pdbRequest.setAssociatedSequence(seq); |
243 |
12 |
return pdbRequest; |
244 |
|
} |
245 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
246 |
7 |
@Override... |
247 |
|
public List<FilterOption> getAvailableFilterOptions(String VIEWS_FILTER) |
248 |
|
{ |
249 |
7 |
List<FilterOption> filters = getPDBQuerySource() |
250 |
|
.getAvailableFilterOptions(VIEWS_FILTER); |
251 |
7 |
tdBeaconsFilters = new LinkedHashSet<String>(); |
252 |
7 |
tdBeaconsFilters.addAll(defaultFilters); |
253 |
7 |
filters.add(0, new FilterOption("Best 3D-Beacons Coverage", |
254 |
|
FILTER_FIRST_BEST_COVERAGE, VIEWS_FILTER, false, this)); |
255 |
7 |
filters.add(1, new FilterOption("Multiple 3D-Beacons Coverage", |
256 |
|
FILTER_TDBEACONS_COVERAGE, VIEWS_FILTER, true, this)); |
257 |
|
|
258 |
7 |
return filters; |
259 |
|
} |
260 |
|
|
|
|
| 63.3% |
Uncovered Elements: 11 (30) |
Complexity: 8 |
Complexity Density: 0.44 |
|
261 |
7 |
@Override... |
262 |
|
public void updateAvailableFilterOptions(String VIEWS_FILTER, |
263 |
|
List<FilterOption> xtantOptions, Collection<FTSData> tdbEntries) |
264 |
|
{ |
265 |
7 |
if (tdbEntries != null && lastTdbRequest != null) |
266 |
|
{ |
267 |
6 |
boolean hasPDBe = false; |
268 |
6 |
for (FTSData _row : tdbEntries) |
269 |
|
{ |
270 |
|
|
271 |
2515 |
TDB_FTSData row = (TDB_FTSData) _row; |
272 |
2515 |
String provider = row.getProvider(); |
273 |
2515 |
FilterOption providerOpt = new FilterOption( |
274 |
|
"3DB Provider - " + provider, |
275 |
|
FILTER_SOURCE_PREFIX + provider, VIEWS_FILTER, false, this); |
276 |
2515 |
if (!xtantOptions.contains(providerOpt)) |
277 |
|
{ |
278 |
27 |
xtantOptions.add(1, providerOpt); |
279 |
27 |
tdBeaconsFilters.add(FILTER_SOURCE_PREFIX + provider); |
280 |
27 |
if ("PDBe".equalsIgnoreCase(provider)) |
281 |
|
{ |
282 |
6 |
hasPDBe = true; |
283 |
|
} |
284 |
|
} |
285 |
|
} |
286 |
6 |
if (!hasPDBe) |
287 |
|
{ |
288 |
|
|
289 |
0 |
int op = 0; |
290 |
0 |
while (op < xtantOptions.size()) |
291 |
|
{ |
292 |
0 |
FilterOption filter = xtantOptions.get(op); |
293 |
0 |
if (filter |
294 |
|
.getQuerySource() instanceof PDBStructureChooserQuerySource) |
295 |
|
{ |
296 |
0 |
xtantOptions.remove(op); |
297 |
|
} |
298 |
|
else |
299 |
|
{ |
300 |
0 |
op++; |
301 |
|
} |
302 |
|
} |
303 |
|
} |
304 |
|
} |
305 |
|
|
306 |
|
} |
307 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
308 |
19 |
private boolean tdBeaconsFilter(String fieldToFilterBy)... |
309 |
|
{ |
310 |
19 |
return tdBeaconsFilters != null |
311 |
|
&& tdBeaconsFilters.contains(fieldToFilterBy); |
312 |
|
} |
313 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 4 |
Complexity Density: 1.33 |
|
314 |
7 |
protected String remove_prefix(String fieldToFilterBy)... |
315 |
|
{ |
316 |
7 |
if (tdBeaconsFilters != null |
317 |
|
&& tdBeaconsFilters.contains(fieldToFilterBy) |
318 |
|
&& !defaultFilters.contains(fieldToFilterBy)) |
319 |
|
{ |
320 |
0 |
return fieldToFilterBy.substring(FILTER_SOURCE_PREFIX.length()); |
321 |
|
} |
322 |
|
else |
323 |
|
{ |
324 |
7 |
return null; |
325 |
|
} |
326 |
|
} |
327 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
328 |
1 |
@Override... |
329 |
|
public boolean needsRefetch(FilterOption selectedFilterOpt) |
330 |
|
{ |
331 |
1 |
return selectedFilterOpt == null |
332 |
|
|| !tdBeaconsFilter(selectedFilterOpt.getValue()) |
333 |
|
&& lastPdbRequest != lastTdbRequest; |
334 |
|
} |
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
@param |
341 |
|
|
342 |
|
@param |
343 |
|
|
344 |
|
@param |
345 |
|
|
346 |
|
@param |
347 |
|
|
348 |
|
@return |
349 |
|
@throws |
350 |
|
|
|
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
351 |
6 |
@Override... |
352 |
|
public FTSRestResponse selectFirstRankedQuery(SequenceI seq, |
353 |
|
Collection<FTSData> collectedResults, |
354 |
|
Collection<FTSDataColumnI> wantedFields, String fieldToFilterBy, |
355 |
|
boolean b) throws Exception |
356 |
|
{ |
357 |
6 |
if (fieldToFilterBy != null && tdBeaconsFilter(fieldToFilterBy)) |
358 |
|
{ |
359 |
6 |
TDBResultAnalyser analyser = new TDBResultAnalyser(seq, |
360 |
|
collectedResults, lastTdbRequest, fieldToFilterBy, |
361 |
|
remove_prefix(fieldToFilterBy)); |
362 |
|
|
363 |
6 |
FTSRestResponse resultList = new FTSRestResponse(); |
364 |
|
|
365 |
6 |
List<FTSData> filteredResponse = analyser.getFilteredResponse(); |
366 |
|
|
367 |
6 |
List<FTSData> selectedStructures = analyser |
368 |
|
.selectStructures(filteredResponse); |
369 |
6 |
resultList.setNumberOfItemsFound(selectedStructures.size()); |
370 |
6 |
resultList.setSearchSummary(selectedStructures); |
371 |
6 |
return resultList; |
372 |
|
} |
373 |
|
|
374 |
0 |
return getPDBQuerySource().selectFirstRankedQuery(seq, collectedResults, |
375 |
|
wantedFields, fieldToFilterBy, b); |
376 |
|
} |
377 |
|
|
|
|
| 0% |
Uncovered Elements: 99 (99) |
Complexity: 23 |
Complexity Density: 0.35 |
|
378 |
0 |
@Override... |
379 |
|
public PDBEntry[] collectSelectedRows(JTable restable, int[] selectedRows, |
380 |
|
List<SequenceI> selectedSeqsToView) |
381 |
|
{ |
382 |
0 |
int refSeqColIndex = restable.getColumn("Ref Sequence").getModelIndex(); |
383 |
|
|
384 |
0 |
PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length]; |
385 |
0 |
int count = 0; |
386 |
0 |
int idColumnIndex = restable.getColumn("Model id").getModelIndex(); |
387 |
0 |
int urlColumnIndex = restable.getColumn("Url").getModelIndex(); |
388 |
0 |
int typeColumnIndex = restable.getColumn("Provider").getModelIndex(); |
389 |
0 |
int humanUrl = restable.getColumn("Page URL").getModelIndex(); |
390 |
0 |
int modelformat = restable.getColumn("Model Format").getModelIndex(); |
391 |
0 |
int idx_mcat = restable.getColumn("Model Category").getModelIndex(); |
392 |
0 |
int idx_mqual = restable.getColumn("Confidence").getModelIndex(); |
393 |
0 |
int idx_mqualtype = restable.getColumn("Confidence Score Type").getModelIndex(); |
394 |
0 |
int idx_mqualtypever = restable.getColumn("Confidence Score Version").getModelIndex(); |
395 |
|
|
396 |
|
|
397 |
|
|
398 |
0 |
final int up_start_idx = restable.getColumn("Uniprot Start") |
399 |
|
.getModelIndex(); |
400 |
0 |
final int up_end_idx = restable.getColumn("Uniprot End") |
401 |
|
.getModelIndex(); |
402 |
0 |
int i = 0; |
403 |
|
|
404 |
|
|
405 |
0 |
Integer[] sellist = new Integer[selectedRows.length]; |
406 |
0 |
for (Integer row : selectedRows) |
407 |
|
{ |
408 |
0 |
sellist[i++] = row; |
409 |
|
} |
410 |
|
|
411 |
0 |
Arrays.sort(sellist, new Comparator<Integer>() |
412 |
|
{ |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
413 |
0 |
@Override... |
414 |
|
public int compare(Integer o1, Integer o2) |
415 |
|
{ |
416 |
0 |
int o1_xt = ((Integer) restable.getValueAt(o1, up_end_idx)) |
417 |
|
- (Integer) restable.getValueAt(o1, up_start_idx); |
418 |
0 |
int o2_xt = ((Integer) restable.getValueAt(o2, up_end_idx)) |
419 |
|
- (Integer) restable.getValueAt(o2, up_start_idx); |
420 |
0 |
return o2_xt - o1_xt; |
421 |
|
} |
422 |
|
}); |
423 |
|
|
424 |
0 |
for (int row : sellist) |
425 |
|
{ |
426 |
|
|
427 |
|
|
428 |
0 |
String pdbIdStr = restable.getValueAt(row, idColumnIndex).toString(); |
429 |
0 |
String urlStr = restable.getValueAt(row, urlColumnIndex).toString(); |
430 |
0 |
String typeColumn = restable.getValueAt(row, typeColumnIndex) |
431 |
|
.toString(); |
432 |
0 |
String modelPage = humanUrl < 1 ? null |
433 |
|
: (String) restable.getValueAt(row, humanUrl); |
434 |
|
|
435 |
0 |
String modelCategory = idx_mcat < 1 ? null |
436 |
|
: (String) restable.getValueAt(row, idx_mcat); |
437 |
|
|
438 |
|
|
439 |
0 |
Double modelConf = idx_mqual < 1 ? null |
440 |
|
: (Double) restable.getValueAt(row, idx_mqual); |
441 |
|
|
442 |
0 |
String modelConfType = idx_mqualtype < 1 ? null |
443 |
|
: (String) restable.getValueAt(row, idx_mqualtype); |
444 |
0 |
String modelConfVer = idx_mqualtypever < 1 ? null |
445 |
|
: (String) restable.getValueAt(row, idx_mqualtypever); |
446 |
|
|
447 |
0 |
String tftype = (modelConfType==null) ? null: modelConfType.toUpperCase(Locale.ROOT); |
448 |
0 |
TFType tempfacType = (tftype==null) ? null : TFType.valueOf(tftype); |
449 |
0 |
if (tftype==null || "".equals(tftype) || TFType.valueOf(tftype) == null ) |
450 |
|
{ |
451 |
|
|
452 |
0 |
if (typeColumn.toLowerCase(Locale.ROOT).startsWith("alpha") || (tftype!=null && tftype.startsWith("ALPHAFOLD"))) { |
453 |
0 |
tftype = TFType.PLDDT.toString(); |
454 |
0 |
modelConfVer = null; |
455 |
|
} |
456 |
0 |
if (!typeColumn.toLowerCase(Locale.ROOT).startsWith("pdbe")) { |
457 |
0 |
tftype = TFType.QMEANDISCO.toString(); |
458 |
|
} |
459 |
|
} |
460 |
|
|
461 |
0 |
String strucFormat = restable.getValueAt(row, modelformat).toString(); |
462 |
|
|
463 |
0 |
SequenceI selectedSeq = (SequenceI) restable.getValueAt(row, |
464 |
|
refSeqColIndex); |
465 |
0 |
selectedSeqsToView.add(selectedSeq); |
466 |
0 |
PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr); |
467 |
0 |
if (pdbEntry == null) |
468 |
|
{ |
469 |
0 |
pdbEntry = getFindEntry(pdbIdStr, selectedSeq.getAllPDBEntries()); |
470 |
|
} |
471 |
|
|
472 |
0 |
if (pdbEntry == null) |
473 |
|
{ |
474 |
0 |
pdbEntry = new PDBEntry(); |
475 |
0 |
pdbEntry.setId(pdbIdStr); |
476 |
0 |
pdbEntry.setAuthoritative(true); |
477 |
0 |
try |
478 |
|
{ |
479 |
0 |
pdbEntry.setType(PDBEntry.Type.valueOf(strucFormat)); |
480 |
|
} catch (Exception q) |
481 |
|
{ |
482 |
0 |
Console.warn("Unknown filetype for 3D Beacons Model from: " |
483 |
|
+ strucFormat + " - " + pdbIdStr + " - " + modelPage); |
484 |
|
} |
485 |
|
|
486 |
0 |
if (!"PDBe".equalsIgnoreCase(typeColumn)) |
487 |
|
{ |
488 |
0 |
pdbEntry.setRetrievalUrl(urlStr); |
489 |
|
} |
490 |
0 |
pdbEntry.setProvider(typeColumn); |
491 |
0 |
if (modelPage != null) |
492 |
|
{ |
493 |
0 |
pdbEntry.setProviderPage(modelPage); |
494 |
|
} |
495 |
0 |
pdbEntry.setProviderCategory(modelCategory); |
496 |
0 |
pdbEntry.setTempFacType(tempfacType); |
497 |
0 |
if (modelConf != null) { |
498 |
0 |
pdbEntry.setModelConfidence(modelConf); |
499 |
|
} |
500 |
0 |
if (modelConfType != null) { |
501 |
0 |
pdbEntry.setModelConfidenceType(modelConfType); |
502 |
|
} |
503 |
0 |
if (modelConfVer != null) { |
504 |
0 |
pdbEntry.setModelConfidenceVersion(modelConfVer); |
505 |
|
} |
506 |
|
|
507 |
0 |
selectedSeq.getDatasetSequence().addPDBId(pdbEntry); |
508 |
|
} |
509 |
0 |
pdbEntriesToView[count++] = pdbEntry; |
510 |
|
} |
511 |
0 |
return pdbEntriesToView; |
512 |
|
} |
513 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
514 |
97 |
@Override... |
515 |
|
protected FTSRestRequest getLastFTSRequest() |
516 |
|
{ |
517 |
97 |
return lastTdbRequest; |
518 |
|
} |
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
|
523 |
|
@param |
524 |
|
@param |
525 |
|
@return |
526 |
|
|
527 |
|
|
|
|
| 96.4% |
Uncovered Elements: 1 (28) |
Complexity: 5 |
Complexity Density: 0.25 |
|
528 |
22 |
public List<String> buildPDBFTSQueryFor(FTSRestResponse upResponse)... |
529 |
|
{ |
530 |
22 |
List<String> ftsQueries = new ArrayList<String>(); |
531 |
22 |
Set<String> pdbIds = new HashSet<String>(); |
532 |
22 |
int idx_modelId = getLastFTSRequest().getFieldIndex("Model id"); |
533 |
22 |
int idx_provider = getLastFTSRequest().getFieldIndex("Provider"); |
534 |
22 |
for (FTSData row : upResponse.getSearchSummary()) |
535 |
|
{ |
536 |
9934 |
String id = (String) row.getSummaryData()[idx_modelId]; |
537 |
9934 |
String provider = (String) row.getSummaryData()[idx_provider]; |
538 |
9934 |
if ("PDBe".equalsIgnoreCase(provider)) |
539 |
|
{ |
540 |
9468 |
pdbIds.add(id); |
541 |
|
} |
542 |
|
} |
543 |
22 |
StringBuilder sb = new StringBuilder(); |
544 |
22 |
for (String pdbId : pdbIds) |
545 |
|
{ |
546 |
7556 |
if (sb.length() > 2500) |
547 |
|
{ |
548 |
20 |
ftsQueries.add(sb.toString()); |
549 |
20 |
sb.setLength(0); |
550 |
|
} |
551 |
7556 |
if (sb.length() > 0) |
552 |
|
{ |
553 |
7514 |
sb.append(" OR "); |
554 |
|
} |
555 |
7556 |
sb.append(pdbId); |
556 |
|
} |
557 |
22 |
if (sb.length() > 0) |
558 |
|
{ |
559 |
22 |
ftsQueries.add(sb.toString()); |
560 |
|
} |
561 |
22 |
return ftsQueries; |
562 |
|
} |
563 |
|
|
564 |
|
|
565 |
|
|
566 |
|
|
567 |
|
@param |
568 |
|
@param |
569 |
|
@return |
570 |
|
|
|
|
| 79.2% |
Uncovered Elements: 5 (24) |
Complexity: 4 |
Complexity Density: 0.2 |
|
571 |
17 |
public List<FTSRestResponse> fetchStructuresMetaDataFor(... |
572 |
|
PDBStructureChooserQuerySource pdbquery, |
573 |
|
FTSRestResponse upResponse) throws Exception |
574 |
|
{ |
575 |
17 |
List<String> pdb_Queries = buildPDBFTSQueryFor(upResponse); |
576 |
17 |
if (pdb_Queries.size() == 0) |
577 |
|
{ |
578 |
0 |
return null; |
579 |
|
} |
580 |
17 |
List<FTSRestResponse> results = new ArrayList<FTSRestResponse>(); |
581 |
|
|
582 |
17 |
for (String pdb_Query : pdb_Queries) |
583 |
|
{ |
584 |
32 |
FTSRestResponse resultList; |
585 |
32 |
FTSRestRequest pdbRequest = new FTSRestRequest(); |
586 |
32 |
pdbRequest.setAllowEmptySeq(false); |
587 |
32 |
pdbRequest.setResponseSize(500); |
588 |
32 |
pdbRequest.setFieldToSearchBy("("); |
589 |
|
|
590 |
32 |
pdbRequest.setWantedFields( |
591 |
|
pdbquery.getDocFieldPrefs().getStructureSummaryFields()); |
592 |
32 |
pdbRequest.setSearchTerm(pdb_Query + ")"); |
593 |
|
|
594 |
|
|
595 |
|
|
596 |
32 |
try |
597 |
|
{ |
598 |
32 |
resultList = pdbquery.executePDBFTSRestRequest(pdbRequest); |
599 |
32 |
if (resultList.getNumberOfItemsFound() == 0) |
600 |
|
{ |
601 |
0 |
Console.info("Unexpectedly returned no results for pdbe query: " |
602 |
|
+ pdb_Query); |
603 |
|
} |
604 |
32 |
results.add(resultList); |
605 |
32 |
lastPdbRequest = pdbRequest; |
606 |
|
} catch (Exception ex) |
607 |
|
{ |
608 |
0 |
Console.error("PDBFTSQuery failed", ex); |
609 |
|
} |
610 |
|
|
611 |
|
} |
612 |
|
|
613 |
17 |
return results; |
614 |
|
} |
615 |
|
|
|
|
| 86.2% |
Uncovered Elements: 4 (29) |
Complexity: 6 |
Complexity Density: 0.32 |
|
616 |
17 |
public FTSRestResponse joinResponses(FTSRestResponse upResponse,... |
617 |
|
List<FTSRestResponse> pdbResponses) |
618 |
|
{ |
619 |
17 |
boolean hasPdbResp = lastPdbRequest != null; |
620 |
|
|
621 |
17 |
int idx_provider = getLastFTSRequest().getFieldIndex("Provider"); |
622 |
|
|
623 |
17 |
int idx_modelId = getLastFTSRequest().getFieldIndex("Model id"); |
624 |
17 |
int pdbIdx = hasPdbResp ? lastPdbRequest.getFieldIndex("PDB Id") : -1; |
625 |
17 |
int pdbTitle_idx = hasPdbResp ? lastPdbRequest.getFieldIndex("Title") |
626 |
|
: -1; |
627 |
17 |
int tdbTitle_idx = getLastFTSRequest().getFieldIndex("Title"); |
628 |
|
|
629 |
17 |
for (final FTSData row : upResponse.getSearchSummary()) |
630 |
|
{ |
631 |
7482 |
String id = (String) row.getSummaryData()[idx_modelId]; |
632 |
7482 |
String provider = (String) row.getSummaryData()[idx_provider]; |
633 |
7482 |
if ("PDBe".equalsIgnoreCase(provider)) |
634 |
|
{ |
635 |
7116 |
if (!hasPdbResp) |
636 |
|
{ |
637 |
0 |
jalview.bin.Console.outPrintln( |
638 |
|
"Warning: seems like we couldn't get to the PDBe search interface."); |
639 |
|
} |
640 |
|
else |
641 |
|
{ |
642 |
7116 |
for (final FTSRestResponse pdbResponse : pdbResponses) |
643 |
|
{ |
644 |
29043 |
for (final FTSData pdbrow : pdbResponse.getSearchSummary()) |
645 |
|
{ |
646 |
11189136 |
String pdbid = (String) pdbrow.getSummaryData()[pdbIdx]; |
647 |
11189136 |
if (id.equalsIgnoreCase(pdbid)) |
648 |
|
{ |
649 |
12527 |
row.getSummaryData()[tdbTitle_idx] = pdbrow |
650 |
|
.getSummaryData()[pdbTitle_idx]; |
651 |
|
} |
652 |
|
} |
653 |
|
} |
654 |
|
} |
655 |
|
|
656 |
|
} |
657 |
|
else |
658 |
|
{ |
659 |
366 |
row.getSummaryData()[tdbTitle_idx] = "Model from TDB"; |
660 |
|
} |
661 |
|
} |
662 |
17 |
return upResponse; |
663 |
|
} |
664 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
665 |
0 |
public TDB_FTSData getFTSDataFor(JTable restable, int selectedRow,... |
666 |
|
Collection<FTSData> discoveredStructuresSet) |
667 |
|
{ |
668 |
0 |
int idColumnIndex = restable.getColumn("Model id").getModelIndex(); |
669 |
|
|
670 |
0 |
String modelId = (String) restable.getValueAt(selectedRow, |
671 |
|
idColumnIndex); |
672 |
0 |
for (FTSData row : discoveredStructuresSet) |
673 |
|
{ |
674 |
0 |
if (row instanceof TDB_FTSData |
675 |
|
&& ((TDB_FTSData) row).getModelId().equals(modelId)) |
676 |
|
{ |
677 |
0 |
return ((TDB_FTSData) row); |
678 |
|
} |
679 |
|
} |
680 |
0 |
return null; |
681 |
|
} |
682 |
|
|
683 |
|
} |