1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
package jalview.io; |
25 |
|
|
26 |
|
import java.io.BufferedReader; |
27 |
|
import java.io.FileReader; |
28 |
|
import java.io.IOException; |
29 |
|
import java.util.ArrayList; |
30 |
|
import java.util.Enumeration; |
31 |
|
import java.util.Hashtable; |
32 |
|
import java.util.LinkedHashMap; |
33 |
|
import java.util.List; |
34 |
|
import java.util.Locale; |
35 |
|
import java.util.Map; |
36 |
|
import java.util.Vector; |
37 |
|
|
38 |
|
import com.stevesoft.pat.Regex; |
39 |
|
|
40 |
|
import fr.orsay.lri.varna.exceptions.ExceptionUnmatchedClosingParentheses; |
41 |
|
import fr.orsay.lri.varna.factories.RNAFactory; |
42 |
|
import fr.orsay.lri.varna.models.rna.RNA; |
43 |
|
import jalview.analysis.Rna; |
44 |
|
import jalview.datamodel.AlignmentAnnotation; |
45 |
|
import jalview.datamodel.AlignmentI; |
46 |
|
import jalview.datamodel.Annotation; |
47 |
|
import jalview.datamodel.DBRefEntry; |
48 |
|
import jalview.datamodel.DBRefSource; |
49 |
|
import jalview.datamodel.Mapping; |
50 |
|
import jalview.datamodel.Sequence; |
51 |
|
import jalview.datamodel.SequenceFeature; |
52 |
|
import jalview.datamodel.SequenceI; |
53 |
|
import jalview.schemes.ResidueProperties; |
54 |
|
import jalview.util.Comparison; |
55 |
|
import jalview.util.DBRefUtils; |
56 |
|
import jalview.util.Format; |
57 |
|
import jalview.util.MessageManager; |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
@author |
68 |
|
@author |
69 |
|
@author |
70 |
|
|
71 |
|
@author |
72 |
|
@version |
73 |
|
|
74 |
|
|
|
|
| 0% |
Uncovered Elements: 748 (748) |
Complexity: 177 |
Complexity Density: 0.37 |
|
75 |
|
public class StockholmFile extends AlignFile |
76 |
|
{ |
77 |
|
private static final String ANNOTATION = "annotation"; |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
public static final Regex DETECT_BRACKETS = new Regex( |
84 |
|
"(<|>|\\[|\\]|\\(|\\)|\\{|\\})"); |
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
public static final String RNASS_BRACKETS = "<>[](){}AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"; |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
private static final Regex NOT_RNASS = new Regex( |
93 |
|
"^[^<>[\\](){}ADFJ-RUVWYZadfj-ruvwyz]*$"); |
94 |
|
|
95 |
|
StringBuffer out; |
96 |
|
|
97 |
|
AlignmentI al; |
98 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
99 |
0 |
public StockholmFile()... |
100 |
|
{ |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
106 |
0 |
public StockholmFile(AlignmentI al)... |
107 |
|
{ |
108 |
0 |
this.al = al; |
109 |
|
} |
110 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
111 |
0 |
public StockholmFile(String inFile, DataSourceType type)... |
112 |
|
throws IOException |
113 |
|
{ |
114 |
0 |
super(inFile, type); |
115 |
|
} |
116 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
117 |
0 |
public StockholmFile(FileParse source) throws IOException... |
118 |
|
{ |
119 |
0 |
super(source); |
120 |
|
} |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
122 |
0 |
@Override... |
123 |
|
public void initData() |
124 |
|
{ |
125 |
0 |
super.initData(); |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
@throws |
132 |
|
|
133 |
|
|
|
|
| 0% |
Uncovered Elements: 35 (35) |
Complexity: 5 |
Complexity Density: 0.17 |
|
134 |
0 |
public void parse_with_VARNA(java.io.File inFile) throws IOException... |
135 |
|
{ |
136 |
0 |
FileReader fr = null; |
137 |
0 |
fr = new FileReader(inFile); |
138 |
|
|
139 |
0 |
BufferedReader r = new BufferedReader(fr); |
140 |
0 |
List<RNA> result = null; |
141 |
0 |
try |
142 |
|
{ |
143 |
0 |
result = RNAFactory.loadSecStrStockholm(r); |
144 |
|
} catch (ExceptionUnmatchedClosingParentheses umcp) |
145 |
|
{ |
146 |
0 |
errormessage = "Unmatched parentheses in annotation. Aborting (" |
147 |
|
+ umcp.getMessage() + ")"; |
148 |
0 |
throw new IOException(umcp); |
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
0 |
SequenceI[] seqs = new SequenceI[result.size()]; |
153 |
0 |
String id = null; |
154 |
0 |
for (int i = 0; i < result.size(); i++) |
155 |
|
{ |
156 |
|
|
157 |
|
|
158 |
0 |
RNA current = result.get(i); |
159 |
|
|
160 |
0 |
String seq = current.getSeq(); |
161 |
0 |
String rna = current.getStructDBN(true); |
162 |
|
|
163 |
|
|
164 |
0 |
int begin = 0; |
165 |
0 |
int end = seq.length() - 1; |
166 |
0 |
id = safeName(getDataName()); |
167 |
0 |
seqs[i] = new Sequence(id, seq, begin, end); |
168 |
0 |
String[] annot = new String[rna.length()]; |
169 |
0 |
Annotation[] ann = new Annotation[rna.length()]; |
170 |
0 |
for (int j = 0; j < rna.length(); j++) |
171 |
|
{ |
172 |
0 |
annot[j] = rna.substring(j, j + 1); |
173 |
|
|
174 |
|
} |
175 |
|
|
176 |
0 |
for (int k = 0; k < rna.length(); k++) |
177 |
|
{ |
178 |
0 |
ann[k] = new Annotation(annot[k], "", |
179 |
|
Rna.getRNASecStrucState(annot[k]).charAt(0), 0f); |
180 |
|
|
181 |
|
} |
182 |
0 |
AlignmentAnnotation align = new AlignmentAnnotation("Sec. str.", |
183 |
|
current.getID(), ann); |
184 |
|
|
185 |
0 |
seqs[i].addAlignmentAnnotation(align); |
186 |
0 |
seqs[i].setRNA(result.get(i)); |
187 |
0 |
this.annotations.addElement(align); |
188 |
|
} |
189 |
0 |
this.setSeqs(seqs); |
190 |
|
|
191 |
|
} |
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
@throws |
198 |
|
|
199 |
|
|
|
|
| 0% |
Uncovered Elements: 278 (278) |
Complexity: 60 |
Complexity Density: 0.33 |
|
200 |
0 |
@Override... |
201 |
|
public void parse() throws IOException |
202 |
|
{ |
203 |
0 |
StringBuffer treeString = new StringBuffer(); |
204 |
0 |
String treeName = null; |
205 |
|
|
206 |
0 |
String line; |
207 |
0 |
String version; |
208 |
|
|
209 |
0 |
Hashtable seqAnn = new Hashtable(); |
210 |
0 |
LinkedHashMap<String, String> seqs = new LinkedHashMap<>(); |
211 |
0 |
Regex p, r, rend, s, x; |
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
0 |
r = new Regex("# STOCKHOLM ([\\d\\.]+)"); |
220 |
0 |
if (!r.search(nextLine())) |
221 |
|
{ |
222 |
0 |
throw new IOException( |
223 |
|
MessageManager.getString("exception.stockholm_invalid_format") |
224 |
|
+ " (" + r + ")"); |
225 |
|
} |
226 |
|
else |
227 |
|
{ |
228 |
0 |
version = r.stringMatched(1); |
229 |
|
|
230 |
|
|
231 |
|
} |
232 |
|
|
233 |
|
|
234 |
0 |
rend = new Regex("^\\s*\\/\\/"); |
235 |
0 |
p = new Regex("(\\S+)\\/(\\d+)\\-(\\d+)"); |
236 |
|
|
237 |
0 |
s = new Regex("(\\S+)\\s+(\\S*)\\s+(.*)"); |
238 |
0 |
r = new Regex("#=(G[FSRC]?)\\s+(.*)"); |
239 |
0 |
x = new Regex("(\\S+)\\s+(\\S+)"); |
240 |
|
|
241 |
|
|
242 |
0 |
Regex openparen = new Regex("(<|\\[)", "("); |
243 |
0 |
Regex closeparen = new Regex("(>|\\])", ")"); |
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
0 |
rend.optimize(); |
249 |
0 |
p.optimize(); |
250 |
0 |
s.optimize(); |
251 |
0 |
r.optimize(); |
252 |
0 |
x.optimize(); |
253 |
0 |
openparen.optimize(); |
254 |
0 |
closeparen.optimize(); |
255 |
|
|
256 |
0 |
while ((line = nextLine()) != null) |
257 |
|
{ |
258 |
0 |
if (line.length() == 0) |
259 |
|
{ |
260 |
0 |
continue; |
261 |
|
} |
262 |
0 |
if (rend.search(line)) |
263 |
|
{ |
264 |
|
|
265 |
0 |
this.noSeqs = seqs.size(); |
266 |
|
|
267 |
0 |
String dbsource = null; |
268 |
0 |
Regex pf = new Regex("PF[0-9]{5}(.*)"); |
269 |
0 |
Regex rf = new Regex("RF[0-9]{5}(.*)"); |
270 |
0 |
if (getAlignmentProperty("AC") != null) |
271 |
|
{ |
272 |
0 |
String dbType = getAlignmentProperty("AC").toString(); |
273 |
0 |
if (pf.search(dbType)) |
274 |
|
{ |
275 |
|
|
276 |
0 |
dbsource = "PFAM"; |
277 |
|
} |
278 |
0 |
else if (rf.search(dbType)) |
279 |
|
{ |
280 |
0 |
dbsource = "RFAM"; |
281 |
|
} |
282 |
|
} |
283 |
|
|
284 |
0 |
for (Map.Entry<String, String> skey : seqs.entrySet()) |
285 |
|
{ |
286 |
|
|
287 |
0 |
String acc = skey.getKey(); |
288 |
0 |
String seq = skey.getValue(); |
289 |
0 |
if (maxLength < seq.length()) |
290 |
|
{ |
291 |
0 |
maxLength = seq.length(); |
292 |
|
} |
293 |
0 |
int start = 1; |
294 |
0 |
int end = -1; |
295 |
0 |
String sid = acc; |
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
0 |
Hashtable accAnnotations = null; |
301 |
|
|
302 |
0 |
if (seqAnn != null && seqAnn.containsKey(acc)) |
303 |
|
{ |
304 |
0 |
accAnnotations = (Hashtable) seqAnn.remove(acc); |
305 |
|
|
306 |
|
} |
307 |
|
|
308 |
|
|
309 |
0 |
if (p.search(acc)) |
310 |
|
{ |
311 |
0 |
sid = p.stringMatched(1); |
312 |
0 |
start = Integer.parseInt(p.stringMatched(2)); |
313 |
0 |
end = Integer.parseInt(p.stringMatched(3)); |
314 |
|
} |
315 |
|
|
316 |
|
|
317 |
0 |
Sequence seqO = new Sequence(sid, seq, start, end); |
318 |
|
|
319 |
0 |
if (accAnnotations != null && accAnnotations.containsKey("DE")) |
320 |
|
{ |
321 |
0 |
String desc = (String) accAnnotations.get("DE"); |
322 |
0 |
seqO.setDescription((desc == null) ? "" : desc); |
323 |
|
} |
324 |
|
|
325 |
0 |
if (accAnnotations != null && accAnnotations.containsKey("DR")) |
326 |
|
{ |
327 |
0 |
String dbr = (String) accAnnotations.get("DR"); |
328 |
0 |
if (dbr != null && dbr.indexOf(";") > -1) |
329 |
|
{ |
330 |
0 |
String src = dbr.substring(0, dbr.indexOf(";")); |
331 |
0 |
String acn = dbr.substring(dbr.indexOf(";") + 1); |
332 |
0 |
jalview.util.DBRefUtils.parseToDbRef(seqO, src, "0", acn); |
333 |
|
} |
334 |
|
} |
335 |
|
|
336 |
0 |
if (accAnnotations != null && accAnnotations.containsKey("AC")) |
337 |
|
{ |
338 |
0 |
String dbr = (String) accAnnotations.get("AC"); |
339 |
0 |
if (dbr != null) |
340 |
|
{ |
341 |
|
|
342 |
|
|
343 |
|
|
344 |
|
|
345 |
|
|
346 |
0 |
guessDatabaseFor(seqO, dbr, dbsource); |
347 |
|
} |
348 |
|
|
349 |
|
|
350 |
|
} |
351 |
|
|
352 |
0 |
Hashtable features = null; |
353 |
|
|
354 |
0 |
try |
355 |
|
{ |
356 |
0 |
features = (Hashtable) accAnnotations.remove("features"); |
357 |
|
} catch (java.lang.NullPointerException e) |
358 |
|
{ |
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
} |
363 |
|
|
364 |
0 |
if (features != null) |
365 |
|
{ |
366 |
0 |
int posmap[] = seqO.findPositionMap(); |
367 |
0 |
Enumeration i = features.keys(); |
368 |
0 |
while (i.hasMoreElements()) |
369 |
|
{ |
370 |
|
|
371 |
|
|
372 |
|
|
373 |
|
|
374 |
0 |
String type = i.nextElement().toString(); |
375 |
0 |
Hashtable content = (Hashtable) features.remove(type); |
376 |
|
|
377 |
|
|
378 |
0 |
String key = type2id(type); |
379 |
|
|
380 |
|
|
381 |
|
|
382 |
|
|
383 |
0 |
boolean annotsAdded = false; |
384 |
0 |
if (key != null) |
385 |
|
{ |
386 |
0 |
if (accAnnotations != null |
387 |
|
&& accAnnotations.containsKey(key)) |
388 |
|
{ |
389 |
0 |
Vector vv = (Vector) accAnnotations.get(key); |
390 |
0 |
for (int ii = 0; ii < vv.size(); ii++) |
391 |
|
{ |
392 |
0 |
annotsAdded = true; |
393 |
0 |
AlignmentAnnotation an = (AlignmentAnnotation) vv |
394 |
|
.elementAt(ii); |
395 |
0 |
seqO.addAlignmentAnnotation(an); |
396 |
0 |
annotations.add(an); |
397 |
|
} |
398 |
|
} |
399 |
|
} |
400 |
|
|
401 |
0 |
Enumeration j = content.keys(); |
402 |
0 |
while (j.hasMoreElements()) |
403 |
|
{ |
404 |
0 |
String desc = j.nextElement().toString(); |
405 |
0 |
if (ANNOTATION.equals(desc) && annotsAdded) |
406 |
|
{ |
407 |
|
|
408 |
0 |
continue; |
409 |
|
} |
410 |
0 |
String ns = content.get(desc).toString(); |
411 |
0 |
char[] byChar = ns.toCharArray(); |
412 |
0 |
for (int k = 0; k < byChar.length; k++) |
413 |
|
{ |
414 |
0 |
char c = byChar[k]; |
415 |
0 |
if (!(c == ' ' || c == '_' || c == '-' || c == '.')) |
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
{ |
422 |
0 |
int new_pos = posmap[k]; |
423 |
|
|
424 |
0 |
SequenceFeature feat = new SequenceFeature(type, desc, |
425 |
|
new_pos, new_pos, null); |
426 |
|
|
427 |
0 |
seqO.addSequenceFeature(feat); |
428 |
|
} |
429 |
|
} |
430 |
|
} |
431 |
|
|
432 |
|
} |
433 |
|
|
434 |
|
} |
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
0 |
this.seqs.addElement(seqO); |
440 |
|
} |
441 |
0 |
return; |
442 |
|
} |
443 |
0 |
else if (!r.search(line)) |
444 |
|
{ |
445 |
|
|
446 |
|
|
447 |
|
|
448 |
0 |
if (!x.search(line)) |
449 |
|
{ |
450 |
|
|
451 |
0 |
throw new IOException(MessageManager.formatMessage( |
452 |
|
"exception.couldnt_parse_sequence_line", new String[] |
453 |
|
{ line })); |
454 |
|
} |
455 |
0 |
String ns = seqs.get(x.stringMatched(1)); |
456 |
0 |
if (ns == null) |
457 |
|
{ |
458 |
0 |
ns = ""; |
459 |
|
} |
460 |
0 |
ns += x.stringMatched(2); |
461 |
|
|
462 |
0 |
seqs.put(x.stringMatched(1), ns); |
463 |
|
} |
464 |
|
else |
465 |
|
{ |
466 |
0 |
String annType = r.stringMatched(1); |
467 |
0 |
String annContent = r.stringMatched(2); |
468 |
|
|
469 |
|
|
470 |
|
|
471 |
|
|
472 |
0 |
if (annType.equals("GF")) |
473 |
|
{ |
474 |
|
|
475 |
|
|
476 |
|
|
477 |
|
|
478 |
|
|
479 |
|
|
480 |
|
|
481 |
|
|
482 |
|
|
483 |
|
|
484 |
|
|
485 |
|
|
486 |
|
|
487 |
|
|
488 |
|
|
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
|
493 |
|
|
494 |
|
|
495 |
|
|
496 |
|
|
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|
|
502 |
|
|
503 |
|
|
504 |
|
|
505 |
|
|
506 |
|
|
507 |
|
|
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
0 |
Regex an = new Regex("(\\w+)\\s*(.*)"); |
513 |
0 |
if (an.search(annContent)) |
514 |
|
{ |
515 |
0 |
if (an.stringMatched(1).equals("NH")) |
516 |
|
{ |
517 |
0 |
treeString.append(an.stringMatched(2)); |
518 |
|
} |
519 |
0 |
else if (an.stringMatched(1).equals("TN")) |
520 |
|
{ |
521 |
0 |
if (treeString.length() > 0) |
522 |
|
{ |
523 |
0 |
if (treeName == null) |
524 |
|
{ |
525 |
0 |
treeName = "Tree " + (getTreeCount() + 1); |
526 |
|
} |
527 |
0 |
addNewickTree(treeName, treeString.toString()); |
528 |
|
} |
529 |
0 |
treeName = an.stringMatched(2); |
530 |
0 |
treeString = new StringBuffer(); |
531 |
|
} |
532 |
|
|
533 |
|
|
534 |
|
|
535 |
|
|
536 |
|
|
537 |
0 |
setAlignmentProperty(an.stringMatched(1), an.stringMatched(2)); |
538 |
|
} |
539 |
|
} |
540 |
0 |
else if (annType.equals("GS")) |
541 |
|
{ |
542 |
|
|
543 |
|
|
544 |
|
|
545 |
|
|
546 |
|
|
547 |
|
|
548 |
|
|
549 |
|
|
550 |
0 |
if (s.search(annContent)) |
551 |
|
{ |
552 |
0 |
String acc = s.stringMatched(1); |
553 |
0 |
String type = s.stringMatched(2); |
554 |
0 |
String content = s.stringMatched(3); |
555 |
|
|
556 |
|
|
557 |
0 |
Hashtable ann; |
558 |
0 |
if (seqAnn.containsKey(acc)) |
559 |
|
{ |
560 |
0 |
ann = (Hashtable) seqAnn.get(acc); |
561 |
|
} |
562 |
|
else |
563 |
|
{ |
564 |
0 |
ann = new Hashtable(); |
565 |
|
} |
566 |
0 |
ann.put(type, content); |
567 |
0 |
seqAnn.put(acc, ann); |
568 |
|
} |
569 |
|
else |
570 |
|
{ |
571 |
|
|
572 |
0 |
jalview.bin.Console |
573 |
|
.errPrintln(">> missing annotation: " + line); |
574 |
|
} |
575 |
|
} |
576 |
0 |
else if (annType.equals("GC")) |
577 |
|
{ |
578 |
|
|
579 |
|
|
580 |
0 |
if (x.search(annContent)) |
581 |
|
{ |
582 |
|
|
583 |
0 |
parseAnnotationRow(annotations, x.stringMatched(1), |
584 |
|
x.stringMatched(2)); |
585 |
|
} |
586 |
|
} |
587 |
0 |
else if (annType.equals("GR")) |
588 |
|
{ |
589 |
|
|
590 |
|
|
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
|
595 |
|
|
596 |
|
|
597 |
|
|
598 |
|
|
599 |
0 |
if (s.search(annContent)) |
600 |
|
{ |
601 |
0 |
String acc = s.stringMatched(1); |
602 |
0 |
String type = s.stringMatched(2); |
603 |
0 |
String oseq = s.stringMatched(3); |
604 |
|
|
605 |
|
|
606 |
|
|
607 |
0 |
String seq = new String(oseq); |
608 |
|
|
609 |
0 |
Hashtable ann; |
610 |
|
|
611 |
0 |
if (seqAnn.containsKey(acc)) |
612 |
|
{ |
613 |
|
|
614 |
0 |
ann = (Hashtable) seqAnn.get(acc); |
615 |
|
} |
616 |
|
else |
617 |
|
{ |
618 |
|
|
619 |
0 |
ann = new Hashtable(); |
620 |
0 |
seqAnn.put(acc, ann); |
621 |
|
} |
622 |
|
|
623 |
|
|
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
|
628 |
0 |
Hashtable features; |
629 |
|
|
630 |
0 |
if (ann.containsKey("features")) |
631 |
|
{ |
632 |
|
|
633 |
0 |
features = (Hashtable) ann.get("features"); |
634 |
|
} |
635 |
|
else |
636 |
|
{ |
637 |
|
|
638 |
0 |
features = new Hashtable(); |
639 |
0 |
ann.put("features", features); |
640 |
|
} |
641 |
|
|
642 |
0 |
Hashtable content; |
643 |
0 |
if (features.containsKey(this.id2type(type))) |
644 |
|
{ |
645 |
|
|
646 |
0 |
content = (Hashtable) features.get(this.id2type(type)); |
647 |
|
} |
648 |
|
else |
649 |
|
{ |
650 |
|
|
651 |
|
|
652 |
0 |
content = new Hashtable(); |
653 |
0 |
features.put(this.id2type(type), content); |
654 |
|
} |
655 |
0 |
String ns = (String) content.get(ANNOTATION); |
656 |
|
|
657 |
0 |
if (ns == null) |
658 |
|
{ |
659 |
0 |
ns = ""; |
660 |
|
} |
661 |
|
|
662 |
0 |
ns += seq; |
663 |
0 |
content.put(ANNOTATION, ns); |
664 |
|
|
665 |
|
|
666 |
|
|
667 |
0 |
Hashtable strucAnn; |
668 |
0 |
if (seqAnn.containsKey(acc)) |
669 |
|
{ |
670 |
0 |
strucAnn = (Hashtable) seqAnn.get(acc); |
671 |
|
} |
672 |
|
else |
673 |
|
{ |
674 |
0 |
strucAnn = new Hashtable(); |
675 |
|
} |
676 |
|
|
677 |
0 |
Vector<AlignmentAnnotation> newStruc = new Vector<>(); |
678 |
0 |
parseAnnotationRow(newStruc, type, ns); |
679 |
0 |
for (AlignmentAnnotation alan : newStruc) |
680 |
|
{ |
681 |
0 |
alan.visible = false; |
682 |
|
} |
683 |
|
|
684 |
|
|
685 |
0 |
strucAnn.put(type, newStruc); |
686 |
0 |
seqAnn.put(acc, strucAnn); |
687 |
|
} |
688 |
|
|
689 |
|
else |
690 |
|
{ |
691 |
0 |
jalview.bin.Console.errPrintln( |
692 |
|
"Warning - couldn't parse sequence annotation row line:\n" |
693 |
|
+ line); |
694 |
|
|
695 |
|
} |
696 |
|
} |
697 |
|
else |
698 |
|
{ |
699 |
0 |
throw new IOException(MessageManager.formatMessage( |
700 |
|
"exception.unknown_annotation_detected", new String[] |
701 |
|
{ annType, annContent })); |
702 |
|
} |
703 |
|
} |
704 |
|
} |
705 |
0 |
if (treeString.length() > 0) |
706 |
|
{ |
707 |
0 |
if (treeName == null) |
708 |
|
{ |
709 |
0 |
treeName = "Tree " + (1 + getTreeCount()); |
710 |
|
} |
711 |
0 |
addNewickTree(treeName, treeString.toString()); |
712 |
|
} |
713 |
|
} |
714 |
|
|
715 |
|
|
716 |
|
|
717 |
|
|
718 |
|
|
719 |
|
@param |
720 |
|
|
721 |
|
@param |
722 |
|
|
723 |
|
@param |
724 |
|
|
725 |
|
|
|
|
| 0% |
Uncovered Elements: 71 (71) |
Complexity: 17 |
Complexity Density: 0.38 |
|
726 |
0 |
private void guessDatabaseFor(Sequence seqO, String dbr, String dbsource)... |
727 |
|
{ |
728 |
0 |
DBRefEntry dbrf = null; |
729 |
0 |
List<DBRefEntry> dbrs = new ArrayList<>(); |
730 |
0 |
String seqdb = "Unknown", sdbac = "" + dbr; |
731 |
0 |
int st = -1, en = -1, p; |
732 |
0 |
if ((st = sdbac.indexOf("/")) > -1) |
733 |
|
{ |
734 |
0 |
String num, range = sdbac.substring(st + 1); |
735 |
0 |
sdbac = sdbac.substring(0, st); |
736 |
0 |
if ((p = range.indexOf("-")) > -1) |
737 |
|
{ |
738 |
0 |
p++; |
739 |
0 |
if (p < range.length()) |
740 |
|
{ |
741 |
0 |
num = range.substring(p).trim(); |
742 |
0 |
try |
743 |
|
{ |
744 |
0 |
en = Integer.parseInt(num); |
745 |
|
} catch (NumberFormatException x) |
746 |
|
{ |
747 |
|
|
748 |
0 |
en = -1; |
749 |
|
} |
750 |
|
} |
751 |
|
} |
752 |
|
else |
753 |
|
{ |
754 |
0 |
p = range.length(); |
755 |
|
} |
756 |
0 |
num = range.substring(0, p).trim(); |
757 |
0 |
try |
758 |
|
{ |
759 |
0 |
st = Integer.parseInt(num); |
760 |
|
} catch (NumberFormatException x) |
761 |
|
{ |
762 |
|
|
763 |
0 |
st = -1; |
764 |
|
} |
765 |
|
} |
766 |
0 |
if (dbsource == null) |
767 |
|
{ |
768 |
|
|
769 |
|
|
770 |
|
|
771 |
0 |
dbsource = (seqO.isProtein()) ? "PFAM" : "RFAM"; |
772 |
|
} |
773 |
0 |
if (dbsource.equals("PFAM")) |
774 |
|
{ |
775 |
0 |
seqdb = "UNIPROT"; |
776 |
0 |
if (sdbac.indexOf(".") > -1) |
777 |
|
{ |
778 |
|
|
779 |
0 |
sdbac = sdbac.substring(0, sdbac.indexOf(".")); |
780 |
0 |
dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, seqdb, dbsource, |
781 |
|
sdbac); |
782 |
0 |
if (dbrf != null) |
783 |
|
{ |
784 |
0 |
dbrs.add(dbrf); |
785 |
|
} |
786 |
|
} |
787 |
0 |
dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, dbsource, dbsource, |
788 |
|
dbr); |
789 |
0 |
if (dbr != null) |
790 |
|
{ |
791 |
0 |
dbrs.add(dbrf); |
792 |
|
} |
793 |
|
} |
794 |
|
else |
795 |
|
{ |
796 |
0 |
seqdb = "EMBL"; |
797 |
|
|
798 |
0 |
if (sdbac.indexOf(".") > -1) |
799 |
|
{ |
800 |
|
|
801 |
0 |
sdbac = sdbac.substring(0, sdbac.indexOf(".")); |
802 |
0 |
dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, seqdb, dbsource, |
803 |
|
sdbac); |
804 |
0 |
if (dbrf != null) |
805 |
|
{ |
806 |
0 |
dbrs.add(dbrf); |
807 |
|
} |
808 |
|
} |
809 |
|
|
810 |
0 |
dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, dbsource, dbsource, |
811 |
|
dbr); |
812 |
0 |
if (dbrf != null) |
813 |
|
{ |
814 |
0 |
dbrs.add(dbrf); |
815 |
|
} |
816 |
|
} |
817 |
0 |
if (st != -1 && en != -1) |
818 |
|
{ |
819 |
0 |
for (DBRefEntry d : dbrs) |
820 |
|
{ |
821 |
0 |
jalview.util.MapList mp = new jalview.util.MapList( |
822 |
|
new int[] |
823 |
|
{ seqO.getStart(), seqO.getEnd() }, new int[] { st, en }, 1, |
824 |
|
1); |
825 |
0 |
jalview.datamodel.Mapping mping = new Mapping(mp); |
826 |
0 |
d.setMap(mping); |
827 |
|
} |
828 |
|
} |
829 |
|
} |
830 |
|
|
|
|
| 0% |
Uncovered Elements: 77 (77) |
Complexity: 18 |
Complexity Density: 0.37 |
|
831 |
0 |
protected static AlignmentAnnotation parseAnnotationRow(... |
832 |
|
Vector<AlignmentAnnotation> annotation, String label, |
833 |
|
String annots) |
834 |
|
{ |
835 |
0 |
String convert1, convert2 = null; |
836 |
|
|
837 |
|
|
838 |
|
|
839 |
|
|
840 |
|
|
841 |
0 |
String type = label; |
842 |
0 |
if (label.contains("_cons")) |
843 |
|
{ |
844 |
0 |
type = (label.indexOf("_cons") == label.length() - 5) |
845 |
|
? label.substring(0, label.length() - 5) |
846 |
|
: label; |
847 |
|
} |
848 |
0 |
boolean ss = false, posterior = false; |
849 |
0 |
type = id2type(type); |
850 |
|
|
851 |
0 |
boolean isrnass = false; |
852 |
0 |
if (type.equalsIgnoreCase("secondary structure")) |
853 |
|
{ |
854 |
0 |
ss = true; |
855 |
0 |
isrnass = !NOT_RNASS.search(annots); |
856 |
|
|
857 |
|
|
858 |
|
} |
859 |
0 |
if (type.equalsIgnoreCase("posterior probability")) |
860 |
|
{ |
861 |
0 |
posterior = true; |
862 |
|
} |
863 |
|
|
864 |
0 |
Annotation[] els = new Annotation[annots.length()]; |
865 |
0 |
for (int i = 0; i < annots.length(); i++) |
866 |
|
{ |
867 |
0 |
String pos = annots.substring(i, i + 1); |
868 |
0 |
Annotation ann; |
869 |
0 |
ann = new Annotation(pos, "", ' ', 0f); |
870 |
|
|
871 |
0 |
if (ss) |
872 |
|
{ |
873 |
|
|
874 |
|
{ |
875 |
0 |
if (isrnass && RNASS_BRACKETS.indexOf(pos) >= 0) |
876 |
|
{ |
877 |
0 |
ann.secondaryStructure = Rna.getRNASecStrucState(pos).charAt(0); |
878 |
0 |
ann.displayCharacter = "" + pos.charAt(0); |
879 |
|
} |
880 |
|
else |
881 |
|
{ |
882 |
0 |
ann.secondaryStructure = ResidueProperties.getDssp3state(pos) |
883 |
|
.charAt(0); |
884 |
|
|
885 |
0 |
if (ann.secondaryStructure == pos.charAt(0)) |
886 |
|
{ |
887 |
0 |
ann.displayCharacter = ""; |
888 |
|
} |
889 |
|
else |
890 |
|
{ |
891 |
0 |
ann.displayCharacter = " " + ann.displayCharacter; |
892 |
|
} |
893 |
|
} |
894 |
|
} |
895 |
|
|
896 |
|
} |
897 |
0 |
if (posterior && !ann.isWhitespace() |
898 |
|
&& !Comparison.isGap(pos.charAt(0))) |
899 |
|
{ |
900 |
0 |
float val = 0; |
901 |
|
|
902 |
0 |
if (pos.charAt(0) == '*') |
903 |
|
{ |
904 |
0 |
val = 10; |
905 |
|
} |
906 |
|
else |
907 |
|
{ |
908 |
0 |
val = pos.charAt(0) - '0'; |
909 |
0 |
if (val > 9) |
910 |
|
{ |
911 |
0 |
val = 10; |
912 |
|
} |
913 |
|
} |
914 |
0 |
ann.value = val; |
915 |
|
} |
916 |
|
|
917 |
0 |
els[i] = ann; |
918 |
|
} |
919 |
0 |
AlignmentAnnotation annot = null; |
920 |
0 |
Enumeration<AlignmentAnnotation> e = annotation.elements(); |
921 |
0 |
while (e.hasMoreElements()) |
922 |
|
{ |
923 |
0 |
annot = e.nextElement(); |
924 |
0 |
if (annot.label.equals(type)) |
925 |
|
{ |
926 |
0 |
break; |
927 |
|
} |
928 |
0 |
annot = null; |
929 |
|
} |
930 |
0 |
if (annot == null) |
931 |
|
{ |
932 |
0 |
annot = new AlignmentAnnotation(type, type, els); |
933 |
0 |
annotation.addElement(annot); |
934 |
|
} |
935 |
|
else |
936 |
|
{ |
937 |
0 |
Annotation[] anns = new Annotation[annot.annotations.length |
938 |
|
+ els.length]; |
939 |
0 |
System.arraycopy(annot.annotations, 0, anns, 0, |
940 |
|
annot.annotations.length); |
941 |
0 |
System.arraycopy(els, 0, anns, annot.annotations.length, els.length); |
942 |
0 |
annot.annotations = anns; |
943 |
|
|
944 |
|
} |
945 |
0 |
return annot; |
946 |
|
} |
947 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
948 |
0 |
private String dbref_to_ac_record(DBRefEntry ref)... |
949 |
|
{ |
950 |
0 |
return ref.getSource().toString() + " ; " |
951 |
|
+ ref.getAccessionId().toString(); |
952 |
|
} |
953 |
|
|
|
|
| 0% |
Uncovered Elements: 159 (159) |
Complexity: 39 |
Complexity Density: 0.38 |
|
954 |
0 |
@Override... |
955 |
|
public String print(SequenceI[] s, boolean jvSuffix) |
956 |
|
{ |
957 |
0 |
out = new StringBuffer(); |
958 |
0 |
out.append("# STOCKHOLM 1.0"); |
959 |
0 |
out.append(newline); |
960 |
|
|
961 |
|
|
962 |
0 |
int max = 0; |
963 |
0 |
int maxid = 0; |
964 |
0 |
int in = 0; |
965 |
0 |
int slen = s.length; |
966 |
0 |
SequenceI seq; |
967 |
0 |
Hashtable<String, String> dataRef = null; |
968 |
0 |
boolean isAA = s[in].isProtein(); |
969 |
0 |
while ((in < slen) && ((seq = s[in]) != null)) |
970 |
|
{ |
971 |
0 |
String tmp = printId(seq, jvSuffix); |
972 |
0 |
max = Math.max(max, seq.getLength()); |
973 |
|
|
974 |
0 |
if (tmp.length() > maxid) |
975 |
|
{ |
976 |
0 |
maxid = tmp.length(); |
977 |
|
} |
978 |
0 |
List<DBRefEntry> seqrefs = seq.getDBRefs(); |
979 |
0 |
int ndb; |
980 |
0 |
if (seqrefs != null && (ndb = seqrefs.size()) > 0) |
981 |
|
{ |
982 |
0 |
if (dataRef == null) |
983 |
|
{ |
984 |
0 |
dataRef = new Hashtable<>(); |
985 |
|
} |
986 |
0 |
List<DBRefEntry> primrefs = seq.getPrimaryDBRefs(); |
987 |
0 |
if (primrefs.size() >= 1) |
988 |
|
{ |
989 |
0 |
dataRef.put(tmp, dbref_to_ac_record(primrefs.get(0))); |
990 |
|
} |
991 |
|
else |
992 |
|
{ |
993 |
0 |
for (int idb = 0; idb < seq.getDBRefs().size(); idb++) |
994 |
|
{ |
995 |
0 |
DBRefEntry dbref = seq.getDBRefs().get(idb); |
996 |
0 |
dataRef.put(tmp, dbref_to_ac_record(dbref)); |
997 |
|
|
998 |
0 |
if (isAA && DBRefSource.UNIPROT |
999 |
|
.equals(DBRefUtils.getCanonicalName(dbref.getSource()))) |
1000 |
|
{ |
1001 |
0 |
break; |
1002 |
|
} |
1003 |
0 |
if (!isAA && DBRefSource.EMBL |
1004 |
|
.equals(DBRefUtils.getCanonicalName(dbref.getSource()))) |
1005 |
|
{ |
1006 |
0 |
break; |
1007 |
|
} |
1008 |
|
} |
1009 |
|
} |
1010 |
|
} |
1011 |
0 |
in++; |
1012 |
|
} |
1013 |
0 |
maxid += 9; |
1014 |
0 |
int i = 0; |
1015 |
|
|
1016 |
|
|
1017 |
0 |
if (al.getProperties() != null) |
1018 |
|
{ |
1019 |
0 |
if (!al.getProperties().isEmpty()) |
1020 |
|
{ |
1021 |
0 |
Enumeration key = al.getProperties().keys(); |
1022 |
0 |
Enumeration val = al.getProperties().elements(); |
1023 |
0 |
while (key.hasMoreElements()) |
1024 |
|
{ |
1025 |
0 |
out.append("#=GF " + key.nextElement() + " " + val.nextElement()); |
1026 |
0 |
out.append(newline); |
1027 |
|
} |
1028 |
|
} |
1029 |
|
} |
1030 |
|
|
1031 |
|
|
1032 |
0 |
if (dataRef != null) |
1033 |
|
{ |
1034 |
0 |
Enumeration<String> en = dataRef.keys(); |
1035 |
0 |
while (en.hasMoreElements()) |
1036 |
|
{ |
1037 |
0 |
Object idd = en.nextElement(); |
1038 |
0 |
String type = dataRef.remove(idd); |
1039 |
0 |
out.append(new Format("%-" + (maxid - 2) + "s") |
1040 |
|
.form("#=GS " + idd.toString() + " ")); |
1041 |
0 |
if (isAA && type.contains("UNIPROT") |
1042 |
|
|| (!isAA && type.contains("EMBL"))) |
1043 |
|
{ |
1044 |
|
|
1045 |
0 |
out.append(" AC " + type.substring(type.indexOf(";") + 1)); |
1046 |
|
} |
1047 |
|
else |
1048 |
|
{ |
1049 |
0 |
out.append(" DR " + type + " "); |
1050 |
|
} |
1051 |
0 |
out.append(newline); |
1052 |
|
} |
1053 |
|
} |
1054 |
|
|
1055 |
|
|
1056 |
|
|
1057 |
0 |
while (i < slen && (seq = s[i]) != null) |
1058 |
|
{ |
1059 |
0 |
if (seq.getDescription() != null) |
1060 |
|
{ |
1061 |
|
|
1062 |
0 |
out.append(new Format("%-" + maxid + "s").form("#=GS " |
1063 |
|
+ printId(seq, jvSuffix) + " DE " + seq.getDescription())); |
1064 |
0 |
out.append(newline); |
1065 |
|
} |
1066 |
|
|
1067 |
0 |
AlignmentAnnotation[] alAnot = seq.getAnnotation(); |
1068 |
0 |
if (alAnot != null) |
1069 |
|
{ |
1070 |
0 |
Annotation[] ann; |
1071 |
0 |
for (int j = 0, nj = alAnot.length; j < nj; j++) |
1072 |
|
{ |
1073 |
|
|
1074 |
0 |
String key = type2id(alAnot[j].label); |
1075 |
0 |
boolean isrna = alAnot[j].isValidStruc(); |
1076 |
|
|
1077 |
0 |
if (isrna) |
1078 |
|
{ |
1079 |
|
|
1080 |
|
|
1081 |
0 |
key = "SS"; |
1082 |
|
} |
1083 |
0 |
if (key == null) |
1084 |
|
{ |
1085 |
|
|
1086 |
0 |
continue; |
1087 |
|
} |
1088 |
|
|
1089 |
|
|
1090 |
0 |
out.append(new Format("%-" + maxid + "s").form( |
1091 |
|
"#=GR " + printId(seq, jvSuffix) + " " + key + " ")); |
1092 |
0 |
ann = alAnot[j].annotations; |
1093 |
0 |
String sseq = ""; |
1094 |
0 |
for (int k = 0, nk = ann.length; k < nk; k++) |
1095 |
|
{ |
1096 |
0 |
sseq += outputCharacter(key, k, isrna, ann, seq); |
1097 |
|
} |
1098 |
0 |
out.append(sseq); |
1099 |
0 |
out.append(newline); |
1100 |
|
} |
1101 |
|
} |
1102 |
|
|
1103 |
0 |
out.append(new Format("%-" + maxid + "s") |
1104 |
|
.form(printId(seq, jvSuffix) + " ")); |
1105 |
0 |
out.append(seq.getSequenceAsString()); |
1106 |
0 |
out.append(newline); |
1107 |
0 |
i++; |
1108 |
|
} |
1109 |
|
|
1110 |
|
|
1111 |
0 |
AlignmentAnnotation aa; |
1112 |
0 |
AlignmentAnnotation[] an = al.getAlignmentAnnotation(); |
1113 |
0 |
if (an != null) |
1114 |
|
{ |
1115 |
0 |
for (int ia = 0, na = an.length; ia < na; ia++) |
1116 |
|
{ |
1117 |
0 |
aa = an[ia]; |
1118 |
0 |
if (aa.autoCalculated || !aa.visible || aa.sequenceRef != null) |
1119 |
|
{ |
1120 |
0 |
continue; |
1121 |
|
} |
1122 |
0 |
String sseq = ""; |
1123 |
0 |
String label; |
1124 |
0 |
String key = ""; |
1125 |
0 |
if (aa.label.equals("seq")) |
1126 |
|
{ |
1127 |
0 |
label = "seq_cons"; |
1128 |
|
} |
1129 |
|
else |
1130 |
|
{ |
1131 |
0 |
key = type2id(aa.label.toLowerCase(Locale.ROOT)); |
1132 |
0 |
if (key == null) |
1133 |
|
{ |
1134 |
0 |
label = aa.label; |
1135 |
|
} |
1136 |
|
else |
1137 |
|
{ |
1138 |
0 |
label = key + "_cons"; |
1139 |
|
} |
1140 |
|
} |
1141 |
0 |
if (label == null) |
1142 |
|
{ |
1143 |
0 |
label = aa.label; |
1144 |
|
} |
1145 |
0 |
label = label.replace(" ", "_"); |
1146 |
|
|
1147 |
0 |
out.append( |
1148 |
|
new Format("%-" + maxid + "s").form("#=GC " + label + " ")); |
1149 |
0 |
boolean isrna = aa.isValidStruc(); |
1150 |
0 |
for (int j = 0, nj = aa.annotations.length; j < nj; j++) |
1151 |
|
{ |
1152 |
0 |
sseq += outputCharacter(key, j, isrna, aa.annotations, null); |
1153 |
|
} |
1154 |
0 |
out.append(sseq); |
1155 |
0 |
out.append(newline); |
1156 |
|
} |
1157 |
|
} |
1158 |
|
|
1159 |
0 |
out.append("//"); |
1160 |
0 |
out.append(newline); |
1161 |
|
|
1162 |
0 |
return out.toString(); |
1163 |
|
} |
1164 |
|
|
1165 |
|
|
1166 |
|
|
1167 |
|
|
1168 |
|
@param |
1169 |
|
@param |
1170 |
|
@param |
1171 |
|
@param |
1172 |
|
@param |
1173 |
|
@param |
1174 |
|
|
|
|
| 0% |
Uncovered Elements: 49 (49) |
Complexity: 20 |
Complexity Density: 0.87 |
|
1175 |
0 |
private char outputCharacter(String key, int k, boolean isrna,... |
1176 |
|
Annotation[] ann, SequenceI sequenceI) |
1177 |
|
{ |
1178 |
0 |
char seq = ' '; |
1179 |
0 |
Annotation annot = ann[k]; |
1180 |
0 |
String ch = (annot == null) |
1181 |
0 |
? ((sequenceI == null) ? "-" |
1182 |
|
: Character.toString(sequenceI.getCharAt(k))) |
1183 |
0 |
: (annot.displayCharacter == null |
1184 |
|
? String.valueOf(annot.secondaryStructure) |
1185 |
|
: annot.displayCharacter); |
1186 |
0 |
if (ch == null) |
1187 |
|
{ |
1188 |
0 |
ch = " "; |
1189 |
|
} |
1190 |
0 |
if (key != null && key.equals("SS")) |
1191 |
|
{ |
1192 |
0 |
char ssannotchar = ' '; |
1193 |
0 |
boolean charset = false; |
1194 |
0 |
if (annot == null) |
1195 |
|
{ |
1196 |
|
|
1197 |
0 |
ssannotchar = ' '; |
1198 |
0 |
charset = true; |
1199 |
|
} |
1200 |
|
else |
1201 |
|
{ |
1202 |
|
|
1203 |
0 |
if (annot.secondaryStructure > ' ' && ch.length() < 2) |
1204 |
|
{ |
1205 |
0 |
ssannotchar = annot.secondaryStructure; |
1206 |
0 |
charset = true; |
1207 |
|
} |
1208 |
|
} |
1209 |
0 |
if (charset) |
1210 |
|
{ |
1211 |
0 |
return (ssannotchar == ' ' && isrna) ? '.' : ssannotchar; |
1212 |
|
} |
1213 |
|
} |
1214 |
|
|
1215 |
0 |
if (ch.length() == 0) |
1216 |
|
{ |
1217 |
0 |
seq = '.'; |
1218 |
|
} |
1219 |
0 |
else if (ch.length() == 1) |
1220 |
|
{ |
1221 |
0 |
seq = ch.charAt(0); |
1222 |
|
} |
1223 |
0 |
else if (ch.length() > 1) |
1224 |
|
{ |
1225 |
0 |
seq = ch.charAt(1); |
1226 |
|
} |
1227 |
|
|
1228 |
0 |
return (seq == ' ' && key != null && key.equals("SS") && isrna) ? '.' |
1229 |
|
: seq; |
1230 |
|
} |
1231 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
1232 |
0 |
public String print()... |
1233 |
|
{ |
1234 |
0 |
out = new StringBuffer(); |
1235 |
0 |
out.append("# STOCKHOLM 1.0"); |
1236 |
0 |
out.append(newline); |
1237 |
0 |
print(getSeqsAsArray(), false); |
1238 |
|
|
1239 |
0 |
out.append("//"); |
1240 |
0 |
out.append(newline); |
1241 |
0 |
return out.toString(); |
1242 |
|
} |
1243 |
|
|
1244 |
|
private static Hashtable typeIds = null; |
1245 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 2 |
Complexity Density: 0.12 |
|
1246 |
0 |
static... |
1247 |
|
{ |
1248 |
0 |
if (typeIds == null) |
1249 |
|
{ |
1250 |
0 |
typeIds = new Hashtable(); |
1251 |
0 |
typeIds.put("SS", "Secondary Structure"); |
1252 |
0 |
typeIds.put("SA", "Surface Accessibility"); |
1253 |
0 |
typeIds.put("TM", "transmembrane"); |
1254 |
0 |
typeIds.put("PP", "Posterior Probability"); |
1255 |
0 |
typeIds.put("LI", "ligand binding"); |
1256 |
0 |
typeIds.put("AS", "active site"); |
1257 |
0 |
typeIds.put("IN", "intron"); |
1258 |
0 |
typeIds.put("IR", "interacting residue"); |
1259 |
0 |
typeIds.put("AC", "accession"); |
1260 |
0 |
typeIds.put("OS", "organism"); |
1261 |
0 |
typeIds.put("CL", "class"); |
1262 |
0 |
typeIds.put("DE", "description"); |
1263 |
0 |
typeIds.put("DR", "reference"); |
1264 |
0 |
typeIds.put("LO", "look"); |
1265 |
0 |
typeIds.put("RF", "Reference Positions"); |
1266 |
|
|
1267 |
|
} |
1268 |
|
} |
1269 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1270 |
0 |
protected static String id2type(String id)... |
1271 |
|
{ |
1272 |
0 |
if (typeIds.containsKey(id)) |
1273 |
|
{ |
1274 |
0 |
return (String) typeIds.get(id); |
1275 |
|
} |
1276 |
0 |
jalview.bin.Console.errPrintln( |
1277 |
|
"Warning : Unknown Stockholm annotation type code " + id); |
1278 |
0 |
return id; |
1279 |
|
} |
1280 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
1281 |
0 |
protected static String type2id(String type)... |
1282 |
|
{ |
1283 |
0 |
String key = null; |
1284 |
0 |
Enumeration e = typeIds.keys(); |
1285 |
0 |
while (e.hasMoreElements()) |
1286 |
|
{ |
1287 |
0 |
Object ll = e.nextElement(); |
1288 |
0 |
if (typeIds.get(ll).toString().equalsIgnoreCase(type)) |
1289 |
|
{ |
1290 |
0 |
key = (String) ll; |
1291 |
0 |
break; |
1292 |
|
} |
1293 |
|
} |
1294 |
0 |
if (key != null) |
1295 |
|
{ |
1296 |
0 |
return key; |
1297 |
|
} |
1298 |
0 |
jalview.bin.Console.errPrintln( |
1299 |
|
"Warning : Unknown Stockholm annotation type: " + type); |
1300 |
0 |
return key; |
1301 |
|
} |
1302 |
|
|
1303 |
|
|
1304 |
|
|
1305 |
|
|
1306 |
|
@param |
1307 |
|
@return |
1308 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
1309 |
0 |
private String safeName(String dataName)... |
1310 |
|
{ |
1311 |
0 |
int b = 0; |
1312 |
0 |
while ((b = dataName.indexOf("/")) > -1 && b < dataName.length()) |
1313 |
|
{ |
1314 |
0 |
dataName = dataName.substring(b + 1).trim(); |
1315 |
|
|
1316 |
|
} |
1317 |
0 |
int e = (dataName.length() - dataName.indexOf(".")) + 1; |
1318 |
0 |
dataName = dataName.substring(1, e).trim(); |
1319 |
0 |
return dataName; |
1320 |
|
} |
1321 |
|
} |