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