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.Locale; |
24 |
|
|
25 |
|
import java.util.Collection; |
26 |
|
import java.util.List; |
27 |
|
import java.util.Objects; |
28 |
|
import java.util.Vector; |
29 |
|
|
30 |
|
import javax.swing.JTable; |
31 |
|
import javax.swing.table.TableModel; |
32 |
|
|
33 |
|
import jalview.datamodel.DBRefEntry; |
34 |
|
import jalview.datamodel.PDBEntry; |
35 |
|
import jalview.datamodel.SequenceI; |
36 |
|
import jalview.fts.api.FTSData; |
37 |
|
import jalview.fts.api.FTSDataColumnI; |
38 |
|
import jalview.fts.api.FTSRestClientI; |
39 |
|
import jalview.fts.core.FTSDataColumnPreferences; |
40 |
|
import jalview.fts.core.FTSRestRequest; |
41 |
|
import jalview.fts.core.FTSRestResponse; |
42 |
|
import jalview.jbgui.FilterOption; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@author |
48 |
|
|
49 |
|
@param |
50 |
|
|
|
|
| 44% |
Uncovered Elements: 42 (75) |
Complexity: 25 |
Complexity Density: 0.54 |
|
51 |
|
public abstract class StructureChooserQuerySource |
52 |
|
{ |
53 |
|
|
54 |
|
protected FTSDataColumnPreferences docFieldPrefs; |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
protected static int MAX_QLENGTH = 7820; |
60 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
61 |
138 |
public StructureChooserQuerySource()... |
62 |
|
{ |
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
0 |
public static StructureChooserQuerySource getPDBfts()... |
66 |
|
{ |
67 |
0 |
return new PDBStructureChooserQuerySource(); |
68 |
|
} |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
0 |
public static StructureChooserQuerySource getTDBfts()... |
71 |
|
{ |
72 |
0 |
return new ThreeDBStructureChooserQuerySource(); |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
75 |
107 |
public FTSDataColumnPreferences getDocFieldPrefs()... |
76 |
|
{ |
77 |
107 |
return docFieldPrefs; |
78 |
|
} |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
0 |
public void setDocFieldPrefs(FTSDataColumnPreferences docFieldPrefs)... |
81 |
|
{ |
82 |
0 |
this.docFieldPrefs = docFieldPrefs; |
83 |
|
} |
84 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
0 |
public FTSDataColumnPreferences getInitialFieldPreferences()... |
86 |
|
{ |
87 |
0 |
return docFieldPrefs; |
88 |
|
} |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
@param |
94 |
|
|
95 |
|
@return |
96 |
|
|
97 |
|
|
98 |
|
public abstract String buildQuery(SequenceI seq); |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
@param |
105 |
|
@return |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
107 |
0 |
public static String sanitizeSeqName(String seqName)... |
108 |
|
{ |
109 |
0 |
Objects.requireNonNull(seqName); |
110 |
0 |
return seqName.replaceAll("\\[\\d*\\]", "") |
111 |
|
.replaceAll("[^\\dA-Za-z|_]", "").replaceAll("\\s+", "+"); |
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
@param |
119 |
|
@return |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
121 |
0 |
static boolean isValidSeqName(String seqName)... |
122 |
|
{ |
123 |
|
|
124 |
0 |
String ignoreList = "pdb,uniprot,swiss-prot"; |
125 |
0 |
if (seqName.length() < 3) |
126 |
|
{ |
127 |
0 |
return false; |
128 |
|
} |
129 |
0 |
if (seqName.contains(":")) |
130 |
|
{ |
131 |
0 |
return false; |
132 |
|
} |
133 |
0 |
seqName = seqName.toLowerCase(Locale.ROOT); |
134 |
0 |
for (String ignoredEntry : ignoreList.split(",")) |
135 |
|
{ |
136 |
0 |
if (seqName.contains(ignoredEntry)) |
137 |
|
{ |
138 |
0 |
return false; |
139 |
|
} |
140 |
|
} |
141 |
0 |
return true; |
142 |
|
} |
143 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
144 |
0 |
static String getDBRefId(DBRefEntry dbRef)... |
145 |
|
{ |
146 |
0 |
String ref = dbRef.getAccessionId().replaceAll("GO:", ""); |
147 |
0 |
return ref; |
148 |
|
} |
149 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
150 |
0 |
static PDBEntry getFindEntry(String id, Vector<PDBEntry> pdbEntries)... |
151 |
|
{ |
152 |
0 |
Objects.requireNonNull(id); |
153 |
0 |
Objects.requireNonNull(pdbEntries); |
154 |
0 |
PDBEntry foundEntry = null; |
155 |
0 |
for (PDBEntry entry : pdbEntries) |
156 |
|
{ |
157 |
0 |
if (entry.getId().equalsIgnoreCase(id)) |
158 |
|
{ |
159 |
0 |
return entry; |
160 |
|
} |
161 |
|
} |
162 |
0 |
return foundEntry; |
163 |
|
} |
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
@param |
170 |
|
|
171 |
|
@param |
172 |
|
|
173 |
|
@param |
174 |
|
|
175 |
|
@param |
176 |
|
|
177 |
|
@return |
178 |
|
@throws |
179 |
|
|
180 |
|
public abstract FTSRestResponse fetchStructuresMetaData(SequenceI seq, |
181 |
|
Collection<FTSDataColumnI> wantedFields, |
182 |
|
FilterOption selectedFilterOpt, boolean b) throws Exception; |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
@param |
189 |
|
|
190 |
|
@param |
191 |
|
|
192 |
|
@param |
193 |
|
|
194 |
|
@param |
195 |
|
|
196 |
|
@param |
197 |
|
|
198 |
|
@return |
199 |
|
@throws |
200 |
|
|
201 |
|
public abstract FTSRestResponse selectFirstRankedQuery(SequenceI seq, |
202 |
|
Collection<FTSData> discoveredStructuresSet, |
203 |
|
Collection<FTSDataColumnI> wantedFields, String fieldToFilterBy, |
204 |
|
boolean b) throws Exception; |
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
@param |
209 |
|
@return |
210 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
211 |
3 |
public TableModel getTableModel(... |
212 |
|
Collection<FTSData> discoveredStructuresSet) |
213 |
|
{ |
214 |
3 |
return FTSRestResponse.getTableModel(getLastFTSRequest(), |
215 |
|
discoveredStructuresSet); |
216 |
|
} |
217 |
|
|
218 |
|
protected abstract FTSRestRequest getLastFTSRequest(); |
219 |
|
|
220 |
|
public abstract PDBEntry[] collectSelectedRows(JTable restable, |
221 |
|
int[] selectedRows, List<SequenceI> selectedSeqsToView); |
222 |
|
|
223 |
|
|
224 |
|
@param |
225 |
|
|
226 |
|
|
227 |
|
@return |
228 |
|
|
229 |
|
|
230 |
|
public abstract List<FilterOption> getAvailableFilterOptions( |
231 |
|
String VIEWS_FILTER); |
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
@param |
237 |
|
@return |
238 |
|
|
|
|
| 96.3% |
Uncovered Elements: 1 (27) |
Complexity: 9 |
Complexity Density: 0.47 |
|
239 |
65 |
public static StructureChooserQuerySource getQuerySourceFor(... |
240 |
|
SequenceI[] selectedSeqs) |
241 |
|
{ |
242 |
65 |
ThreeDBStructureChooserQuerySource tdbSource = new ThreeDBStructureChooserQuerySource(); |
243 |
65 |
boolean hasUniprot = false, hasCanonical = false; |
244 |
65 |
boolean hasNA = false, hasProtein = false; |
245 |
65 |
int protWithoutUni = 0; |
246 |
65 |
int protWithoutCanon = 0; |
247 |
65 |
for (SequenceI seq : selectedSeqs) |
248 |
|
{ |
249 |
65 |
hasNA |= !seq.isProtein(); |
250 |
65 |
hasProtein |= seq.isProtein(); |
251 |
65 |
if (seq.isProtein()) |
252 |
|
{ |
253 |
65 |
int refsAvailable = ThreeDBStructureChooserQuerySource |
254 |
|
.checkUniprotRefs(seq.getDBRefs()); |
255 |
65 |
if (refsAvailable > -2) |
256 |
|
{ |
257 |
10 |
if (refsAvailable > -1) |
258 |
|
{ |
259 |
8 |
hasCanonical = true; |
260 |
|
} |
261 |
|
else |
262 |
|
{ |
263 |
2 |
protWithoutCanon++; |
264 |
|
} |
265 |
10 |
hasUniprot = true; |
266 |
|
} |
267 |
|
else |
268 |
|
{ |
269 |
55 |
protWithoutUni++; |
270 |
|
|
271 |
|
} |
272 |
|
} |
273 |
|
} |
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
65 |
if (hasProtein && hasCanonical && !hasNA && protWithoutCanon == 0 |
279 |
|
&& protWithoutUni == 0) |
280 |
|
|
281 |
|
{ |
282 |
8 |
return tdbSource; |
283 |
|
} |
284 |
57 |
return new PDBStructureChooserQuerySource(); |
285 |
|
} |
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
@param |
291 |
|
@return |
292 |
|
|
293 |
|
public abstract boolean needsRefetch(FilterOption selectedFilterOpt); |
294 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
295 |
4 |
public void updateAvailableFilterOptions(String VIEWS_FILTER,... |
296 |
|
List<FilterOption> xtantOptions, Collection<FTSData> lastFTSData) |
297 |
|
{ |
298 |
|
|
299 |
|
|
300 |
|
} |
301 |
|
} |