1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
package jalview.io; |
27 |
|
|
28 |
|
import jalview.datamodel.Alignment; |
29 |
|
import jalview.datamodel.AlignmentAnnotation; |
30 |
|
import jalview.datamodel.Sequence; |
31 |
|
import jalview.datamodel.SequenceI; |
32 |
|
import jalview.util.MessageManager; |
33 |
|
|
34 |
|
import java.io.IOException; |
35 |
|
import java.util.Hashtable; |
36 |
|
import java.util.StringTokenizer; |
37 |
|
import java.util.Vector; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
@author |
52 |
|
@version |
53 |
|
|
|
|
| 0% |
Uncovered Elements: 178 (178) |
Complexity: 44 |
Complexity Density: 0.38 |
|
54 |
|
public class JPredFile extends AlignFile |
55 |
|
{ |
56 |
|
Vector ids; |
57 |
|
|
58 |
|
Vector conf; |
59 |
|
|
60 |
|
Hashtable Scores; |
61 |
|
|
62 |
|
Hashtable Symscores; |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
private int QuerySeqPosition; |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
@param |
74 |
|
|
75 |
|
@param |
76 |
|
|
77 |
|
|
78 |
|
@throws |
79 |
|
|
80 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
0 |
public JPredFile(Object inFile, DataSourceType sourceType)... |
82 |
|
throws IOException |
83 |
|
{ |
84 |
0 |
super(inFile, sourceType); |
85 |
|
} |
86 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
87 |
0 |
public JPredFile(FileParse source) throws IOException... |
88 |
|
{ |
89 |
0 |
super(source); |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
@param |
96 |
|
|
97 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
0 |
public void setQuerySeqPosition(int QuerySeqPosition)... |
99 |
|
{ |
100 |
0 |
this.QuerySeqPosition = QuerySeqPosition; |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
@return |
107 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
108 |
0 |
public int getQuerySeqPosition()... |
109 |
|
{ |
110 |
0 |
return QuerySeqPosition; |
111 |
|
} |
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
@return |
117 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
118 |
0 |
public Hashtable getScores()... |
119 |
|
{ |
120 |
0 |
return Scores; |
121 |
|
} |
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
@return |
127 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
128 |
0 |
public Hashtable getSymscores()... |
129 |
|
{ |
130 |
0 |
return Symscores; |
131 |
|
} |
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
136 |
0 |
@Override... |
137 |
|
public void initData() |
138 |
|
{ |
139 |
0 |
super.initData(); |
140 |
0 |
Scores = new Hashtable(); |
141 |
0 |
ids = null; |
142 |
0 |
conf = null; |
143 |
|
} |
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
|
|
| 0% |
Uncovered Elements: 125 (125) |
Complexity: 28 |
Complexity Density: 0.34 |
|
148 |
0 |
@Override... |
149 |
|
public void parse() throws IOException |
150 |
|
{ |
151 |
|
|
152 |
0 |
String line; |
153 |
0 |
QuerySeqPosition = -1; |
154 |
0 |
noSeqs = 0; |
155 |
|
|
156 |
0 |
Vector seq_entries = new Vector(); |
157 |
0 |
Vector ids = new Vector(); |
158 |
0 |
Hashtable Symscores = new Hashtable(); |
159 |
|
|
160 |
0 |
while ((line = nextLine()) != null) |
161 |
|
{ |
162 |
|
|
163 |
0 |
StringTokenizer str = new StringTokenizer(line, ":"); |
164 |
0 |
String id = ""; |
165 |
|
|
166 |
0 |
if (!str.hasMoreTokens()) |
167 |
|
{ |
168 |
0 |
continue; |
169 |
|
} |
170 |
|
|
171 |
0 |
id = str.nextToken(); |
172 |
|
|
173 |
0 |
String seqsym = str.nextToken(); |
174 |
0 |
StringTokenizer symbols = new StringTokenizer(seqsym, ","); |
175 |
|
|
176 |
|
|
177 |
0 |
int numSymbols = symbols.countTokens(); |
178 |
|
|
179 |
0 |
if (numSymbols == 0) |
180 |
|
{ |
181 |
0 |
continue; |
182 |
|
} |
183 |
|
|
184 |
0 |
if (seqsym.length() != (2 * numSymbols)) |
185 |
|
{ |
186 |
|
|
187 |
0 |
if (Scores.containsKey(id)) |
188 |
|
{ |
189 |
0 |
int i = 1; |
190 |
|
|
191 |
0 |
while (Scores.containsKey(id + "_" + i)) |
192 |
|
{ |
193 |
0 |
i++; |
194 |
|
} |
195 |
|
|
196 |
0 |
id = id + "_" + i; |
197 |
|
} |
198 |
|
|
199 |
0 |
Vector scores = new Vector(); |
200 |
|
|
201 |
|
|
202 |
0 |
int i = 0; |
203 |
0 |
String ascore = "dead"; |
204 |
|
|
205 |
0 |
try |
206 |
|
{ |
207 |
|
|
208 |
0 |
while (symbols.hasMoreTokens()) |
209 |
|
{ |
210 |
0 |
ascore = symbols.nextToken(); |
211 |
|
|
212 |
0 |
Float score = new Float(ascore); |
213 |
0 |
scores.addElement(score); |
214 |
|
} |
215 |
|
|
216 |
0 |
Scores.put(id, scores); |
217 |
|
} catch (Exception e) |
218 |
|
{ |
219 |
|
|
220 |
0 |
i = scores.size(); |
221 |
|
|
222 |
0 |
for (int j = 0; j < i; j++) |
223 |
|
{ |
224 |
0 |
scores.setElementAt(((Float) scores.elementAt(j)).toString(), |
225 |
|
j); |
226 |
|
} |
227 |
|
|
228 |
0 |
scores.addElement(ascore); |
229 |
|
|
230 |
0 |
while (symbols.hasMoreTokens()) |
231 |
|
{ |
232 |
0 |
ascore = symbols.nextToken(); |
233 |
0 |
scores.addElement(ascore); |
234 |
|
} |
235 |
|
|
236 |
0 |
Scores.put(id, scores); |
237 |
|
} |
238 |
|
} |
239 |
0 |
else if (id.equals("jnetconf")) |
240 |
|
{ |
241 |
|
|
242 |
0 |
id = "Prediction Confidence"; |
243 |
0 |
this.conf = new Vector(numSymbols); |
244 |
|
|
245 |
0 |
for (int i = 0; i < numSymbols; i++) |
246 |
|
{ |
247 |
0 |
conf.setElementAt(symbols.nextToken(), i); |
248 |
|
} |
249 |
|
} |
250 |
|
else |
251 |
|
{ |
252 |
|
|
253 |
0 |
StringBuffer newseq = new StringBuffer(); |
254 |
|
|
255 |
0 |
for (int i = 0; i < numSymbols; i++) |
256 |
|
{ |
257 |
0 |
newseq.append(symbols.nextToken()); |
258 |
|
} |
259 |
|
|
260 |
0 |
if (id.indexOf(";") > -1) |
261 |
|
{ |
262 |
0 |
seq_entries.addElement(newseq); |
263 |
|
|
264 |
0 |
int i = 1; |
265 |
0 |
String name = id.substring(id.indexOf(";") + 1); |
266 |
|
|
267 |
0 |
while (ids.lastIndexOf(name) > -1) |
268 |
|
{ |
269 |
0 |
name = id.substring(id.indexOf(";") + 1) + "_" + ++i; |
270 |
|
} |
271 |
|
|
272 |
0 |
if (QuerySeqPosition == -1) |
273 |
|
{ |
274 |
0 |
QuerySeqPosition = ids.size(); |
275 |
|
} |
276 |
0 |
ids.addElement(name); |
277 |
0 |
noSeqs++; |
278 |
|
} |
279 |
|
else |
280 |
|
{ |
281 |
0 |
if (id.equals("JNETPRED")) |
282 |
|
{ |
283 |
0 |
id = "Predicted Secondary Structure"; |
284 |
|
} |
285 |
|
|
286 |
0 |
seq_entries.addElement(newseq.toString()); |
287 |
0 |
ids.addElement(id); |
288 |
0 |
Symscores.put(id, new Integer(ids.size() - 1)); |
289 |
|
} |
290 |
|
} |
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
0 |
maxLength = seq_entries.elementAt(0).toString().length(); |
299 |
|
|
300 |
0 |
for (int i = 0; i < ids.size(); i++) |
301 |
|
{ |
302 |
|
|
303 |
0 |
Sequence newSeq = new Sequence(ids.elementAt(i).toString(), |
304 |
|
seq_entries.elementAt(i).toString(), 1, |
305 |
|
seq_entries.elementAt(i).toString().length()); |
306 |
|
|
307 |
0 |
if (maxLength != seq_entries.elementAt(i).toString().length()) |
308 |
|
{ |
309 |
0 |
throw new IOException(MessageManager.formatMessage( |
310 |
|
"exception.jpredconcide_entry_has_unexpected_number_of_columns", |
311 |
|
new String[] |
312 |
|
{ ids.elementAt(i).toString() })); |
313 |
|
} |
314 |
|
|
315 |
0 |
if ((newSeq.getName().startsWith("QUERY") |
316 |
|
|| newSeq.getName().startsWith("align;")) |
317 |
|
&& (QuerySeqPosition == -1)) |
318 |
|
{ |
319 |
0 |
QuerySeqPosition = seqs.size(); |
320 |
|
} |
321 |
|
|
322 |
0 |
seqs.addElement(newSeq); |
323 |
|
} |
324 |
0 |
if (seqs.size() > 0 && QuerySeqPosition > -1) |
325 |
|
{ |
326 |
|
|
327 |
|
|
328 |
|
|
329 |
0 |
Alignment tal = new Alignment(this.getSeqsAsArray()); |
330 |
0 |
try |
331 |
|
{ |
332 |
0 |
JnetAnnotationMaker.add_annotation(this, tal, QuerySeqPosition, |
333 |
|
true); |
334 |
|
} catch (Exception e) |
335 |
|
{ |
336 |
0 |
tal = null; |
337 |
0 |
IOException ex = new IOException(MessageManager.formatMessage( |
338 |
|
"exception.couldnt_parse_concise_annotation_for_prediction", |
339 |
|
new String[] |
340 |
|
{ e.getMessage() })); |
341 |
0 |
e.printStackTrace(); |
342 |
|
|
343 |
0 |
throw ex; |
344 |
|
} |
345 |
0 |
this.annotations = new Vector(); |
346 |
0 |
AlignmentAnnotation[] aan = tal.getAlignmentAnnotation(); |
347 |
0 |
for (int aai = 0; aan != null && aai < aan.length; aai++) |
348 |
|
{ |
349 |
0 |
annotations.addElement(aan[aai]); |
350 |
|
} |
351 |
|
} |
352 |
|
} |
353 |
|
|
354 |
|
|
355 |
|
|
356 |
|
|
357 |
|
@return |
358 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
359 |
0 |
@Override... |
360 |
|
public String print(SequenceI[] sqs, boolean jvsuffix) |
361 |
|
{ |
362 |
0 |
return "Not Supported"; |
363 |
|
} |
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
@param |
369 |
|
|
370 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
371 |
0 |
public static void main(String[] args)... |
372 |
|
{ |
373 |
0 |
try |
374 |
|
{ |
375 |
0 |
JPredFile jpred = new JPredFile(args[0], DataSourceType.FILE); |
376 |
|
|
377 |
0 |
for (int i = 0; i < jpred.seqs.size(); i++) |
378 |
|
{ |
379 |
0 |
System.out.println(((Sequence) jpred.seqs.elementAt(i)).getName() |
380 |
|
+ "\n" |
381 |
|
+ ((Sequence) jpred.seqs.elementAt(i)).getSequenceAsString() |
382 |
|
+ "\n"); |
383 |
|
} |
384 |
|
} catch (java.io.IOException e) |
385 |
|
{ |
386 |
0 |
System.err.println("Exception " + e); |
387 |
|
|
388 |
|
} |
389 |
|
} |
390 |
|
|
391 |
|
Vector annotSeqs = null; |
392 |
|
|
393 |
|
|
394 |
|
|
395 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 5 |
Complexity Density: 0.31 |
|
396 |
0 |
public void removeNonSequences()... |
397 |
|
{ |
398 |
0 |
if (annotSeqs != null) |
399 |
|
{ |
400 |
0 |
return; |
401 |
|
} |
402 |
0 |
annotSeqs = new Vector(); |
403 |
0 |
Vector newseqs = new Vector(); |
404 |
0 |
int i = 0; |
405 |
0 |
int j = seqs.size(); |
406 |
0 |
for (; i < QuerySeqPosition; i++) |
407 |
|
{ |
408 |
0 |
annotSeqs.addElement(seqs.elementAt(i)); |
409 |
|
} |
410 |
|
|
411 |
|
{ |
412 |
0 |
SequenceI sq = seqs.elementAt(j - 1); |
413 |
0 |
if (sq.getName().toUpperCase().startsWith("JPRED")) |
414 |
|
{ |
415 |
0 |
annotSeqs.addElement(sq); |
416 |
0 |
seqs.removeElementAt(--j); |
417 |
|
} |
418 |
|
} |
419 |
0 |
for (; i < j; i++) |
420 |
|
{ |
421 |
0 |
newseqs.addElement(seqs.elementAt(i)); |
422 |
|
} |
423 |
|
|
424 |
0 |
seqs.removeAllElements(); |
425 |
0 |
seqs = newseqs; |
426 |
|
} |
427 |
|
} |
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
|
440 |
|
|
441 |
|
|
442 |
|
|
443 |
|
|
444 |
|
|
445 |
|
|
446 |
|
|
447 |
|
|
448 |
|
|
449 |
|
|
450 |
|
|
451 |
|
|