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 |
|
|
|
|
| 76.3% |
Uncovered Elements: 177 (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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
106 |
60 |
public StockholmFile(AlignmentI al)... |
107 |
|
{ |
108 |
60 |
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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
117 |
45 |
public StockholmFile(FileParse source) throws IOException... |
118 |
|
{ |
119 |
45 |
super(source); |
120 |
|
} |
121 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
122 |
105 |
@Override... |
123 |
|
public void initData() |
124 |
|
{ |
125 |
105 |
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 |
|
|
|
|
| 77.7% |
Uncovered Elements: 62 (278) |
Complexity: 60 |
Complexity Density: 0.33 |
|
200 |
45 |
@Override... |
201 |
|
public void parse() throws IOException |
202 |
|
{ |
203 |
45 |
StringBuffer treeString = new StringBuffer(); |
204 |
45 |
String treeName = null; |
205 |
|
|
206 |
45 |
String line; |
207 |
45 |
String version; |
208 |
|
|
209 |
45 |
Hashtable seqAnn = new Hashtable(); |
210 |
45 |
LinkedHashMap<String, String> seqs = new LinkedHashMap<>(); |
211 |
45 |
Regex p, r, rend, s, x; |
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
45 |
r = new Regex("# STOCKHOLM ([\\d\\.]+)"); |
220 |
45 |
if (!r.search(nextLine())) |
221 |
|
{ |
222 |
0 |
throw new IOException( |
223 |
|
MessageManager.getString("exception.stockholm_invalid_format") |
224 |
|
+ " (" + r + ")"); |
225 |
|
} |
226 |
|
else |
227 |
|
{ |
228 |
45 |
version = r.stringMatched(1); |
229 |
|
|
230 |
|
|
231 |
|
} |
232 |
|
|
233 |
|
|
234 |
45 |
rend = new Regex("^\\s*\\/\\/"); |
235 |
45 |
p = new Regex("(\\S+)\\/(\\d+)\\-(\\d+)"); |
236 |
|
|
237 |
45 |
s = new Regex("(\\S+)\\s+(\\S*)\\s+(.*)"); |
238 |
45 |
r = new Regex("#=(G[FSRC]?)\\s+(.*)"); |
239 |
45 |
x = new Regex("(\\S+)\\s+(\\S+)"); |
240 |
|
|
241 |
|
|
242 |
45 |
Regex openparen = new Regex("(<|\\[)", "("); |
243 |
45 |
Regex closeparen = new Regex("(>|\\])", ")"); |
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
45 |
rend.optimize(); |
249 |
45 |
p.optimize(); |
250 |
45 |
s.optimize(); |
251 |
45 |
r.optimize(); |
252 |
45 |
x.optimize(); |
253 |
45 |
openparen.optimize(); |
254 |
45 |
closeparen.optimize(); |
255 |
|
|
256 |
? |
while ((line = nextLine()) != null) |
257 |
|
{ |
258 |
2512 |
if (line.length() == 0) |
259 |
|
{ |
260 |
6 |
continue; |
261 |
|
} |
262 |
2506 |
if (rend.search(line)) |
263 |
|
{ |
264 |
|
|
265 |
45 |
this.noSeqs = seqs.size(); |
266 |
|
|
267 |
45 |
String dbsource = null; |
268 |
45 |
Regex pf = new Regex("PF[0-9]{5}(.*)"); |
269 |
45 |
Regex rf = new Regex("RF[0-9]{5}(.*)"); |
270 |
45 |
if (getAlignmentProperty("AC") != null) |
271 |
|
{ |
272 |
6 |
String dbType = getAlignmentProperty("AC").toString(); |
273 |
6 |
if (pf.search(dbType)) |
274 |
|
{ |
275 |
|
|
276 |
3 |
dbsource = "PFAM"; |
277 |
|
} |
278 |
3 |
else if (rf.search(dbType)) |
279 |
|
{ |
280 |
3 |
dbsource = "RFAM"; |
281 |
|
} |
282 |
|
} |
283 |
|
|
284 |
45 |
for (Map.Entry<String, String> skey : seqs.entrySet()) |
285 |
|
{ |
286 |
|
|
287 |
917 |
String acc = skey.getKey(); |
288 |
917 |
String seq = skey.getValue(); |
289 |
917 |
if (maxLength < seq.length()) |
290 |
|
{ |
291 |
45 |
maxLength = seq.length(); |
292 |
|
} |
293 |
917 |
int start = 1; |
294 |
917 |
int end = -1; |
295 |
917 |
String sid = acc; |
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
917 |
Hashtable accAnnotations = null; |
301 |
|
|
302 |
917 |
if (seqAnn != null && seqAnn.containsKey(acc)) |
303 |
|
{ |
304 |
916 |
accAnnotations = (Hashtable) seqAnn.remove(acc); |
305 |
|
|
306 |
|
} |
307 |
|
|
308 |
|
|
309 |
917 |
if (p.search(acc)) |
310 |
|
{ |
311 |
684 |
sid = p.stringMatched(1); |
312 |
684 |
start = Integer.parseInt(p.stringMatched(2)); |
313 |
684 |
end = Integer.parseInt(p.stringMatched(3)); |
314 |
|
} |
315 |
|
|
316 |
|
|
317 |
917 |
Sequence seqO = new Sequence(sid, seq, start, end); |
318 |
|
|
319 |
917 |
if (accAnnotations != null && accAnnotations.containsKey("DE")) |
320 |
|
{ |
321 |
16 |
String desc = (String) accAnnotations.get("DE"); |
322 |
16 |
seqO.setDescription((desc == null) ? "" : desc); |
323 |
|
} |
324 |
|
|
325 |
917 |
if (accAnnotations != null && accAnnotations.containsKey("DR")) |
326 |
|
{ |
327 |
26 |
String dbr = (String) accAnnotations.get("DR"); |
328 |
26 |
if (dbr != null && dbr.indexOf(";") > -1) |
329 |
|
{ |
330 |
26 |
String src = dbr.substring(0, dbr.indexOf(";")); |
331 |
26 |
String acn = dbr.substring(dbr.indexOf(";") + 1); |
332 |
26 |
jalview.util.DBRefUtils.parseToDbRef(seqO, src, "0", acn); |
333 |
|
} |
334 |
|
} |
335 |
|
|
336 |
917 |
if (accAnnotations != null && accAnnotations.containsKey("AC")) |
337 |
|
{ |
338 |
895 |
String dbr = (String) accAnnotations.get("AC"); |
339 |
895 |
if (dbr != null) |
340 |
|
{ |
341 |
|
|
342 |
|
|
343 |
|
|
344 |
|
|
345 |
|
|
346 |
895 |
guessDatabaseFor(seqO, dbr, dbsource); |
347 |
|
} |
348 |
|
|
349 |
|
|
350 |
|
} |
351 |
|
|
352 |
917 |
Hashtable features = null; |
353 |
|
|
354 |
917 |
try |
355 |
|
{ |
356 |
917 |
features = (Hashtable) accAnnotations.remove("features"); |
357 |
|
} catch (java.lang.NullPointerException e) |
358 |
|
{ |
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
} |
363 |
|
|
364 |
917 |
if (features != null) |
365 |
|
{ |
366 |
320 |
int posmap[] = seqO.findPositionMap(); |
367 |
320 |
Enumeration i = features.keys(); |
368 |
640 |
while (i.hasMoreElements()) |
369 |
|
{ |
370 |
|
|
371 |
|
|
372 |
|
|
373 |
|
|
374 |
320 |
String type = i.nextElement().toString(); |
375 |
320 |
Hashtable content = (Hashtable) features.remove(type); |
376 |
|
|
377 |
|
|
378 |
320 |
String key = type2id(type); |
379 |
|
|
380 |
|
|
381 |
|
|
382 |
|
|
383 |
320 |
boolean annotsAdded = false; |
384 |
320 |
if (key != null) |
385 |
|
{ |
386 |
320 |
if (accAnnotations != null |
387 |
|
&& accAnnotations.containsKey(key)) |
388 |
|
{ |
389 |
320 |
Vector vv = (Vector) accAnnotations.get(key); |
390 |
640 |
for (int ii = 0; ii < vv.size(); ii++) |
391 |
|
{ |
392 |
320 |
annotsAdded = true; |
393 |
320 |
AlignmentAnnotation an = (AlignmentAnnotation) vv |
394 |
|
.elementAt(ii); |
395 |
320 |
seqO.addAlignmentAnnotation(an); |
396 |
320 |
annotations.add(an); |
397 |
|
} |
398 |
|
} |
399 |
|
} |
400 |
|
|
401 |
320 |
Enumeration j = content.keys(); |
402 |
640 |
while (j.hasMoreElements()) |
403 |
|
{ |
404 |
320 |
String desc = j.nextElement().toString(); |
405 |
320 |
if (ANNOTATION.equals(desc) && annotsAdded) |
406 |
|
{ |
407 |
|
|
408 |
320 |
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 |
917 |
this.seqs.addElement(seqO); |
440 |
|
} |
441 |
45 |
return; |
442 |
|
} |
443 |
2461 |
else if (!r.search(line)) |
444 |
|
{ |
445 |
|
|
446 |
|
|
447 |
|
|
448 |
917 |
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 |
917 |
String ns = seqs.get(x.stringMatched(1)); |
456 |
917 |
if (ns == null) |
457 |
|
{ |
458 |
917 |
ns = ""; |
459 |
|
} |
460 |
917 |
ns += x.stringMatched(2); |
461 |
|
|
462 |
917 |
seqs.put(x.stringMatched(1), ns); |
463 |
|
} |
464 |
|
else |
465 |
|
{ |
466 |
1544 |
String annType = r.stringMatched(1); |
467 |
1544 |
String annContent = r.stringMatched(2); |
468 |
|
|
469 |
|
|
470 |
|
|
471 |
|
|
472 |
1544 |
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 |
152 |
Regex an = new Regex("(\\w+)\\s*(.*)"); |
513 |
152 |
if (an.search(annContent)) |
514 |
|
{ |
515 |
152 |
if (an.stringMatched(1).equals("NH")) |
516 |
|
{ |
517 |
0 |
treeString.append(an.stringMatched(2)); |
518 |
|
} |
519 |
152 |
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 |
152 |
setAlignmentProperty(an.stringMatched(1), an.stringMatched(2)); |
538 |
|
} |
539 |
|
} |
540 |
1392 |
else if (annType.equals("GS")) |
541 |
|
{ |
542 |
|
|
543 |
|
|
544 |
|
|
545 |
|
|
546 |
|
|
547 |
|
|
548 |
|
|
549 |
|
|
550 |
1059 |
if (s.search(annContent)) |
551 |
|
{ |
552 |
1059 |
String acc = s.stringMatched(1); |
553 |
1059 |
String type = s.stringMatched(2); |
554 |
1059 |
String content = s.stringMatched(3); |
555 |
|
|
556 |
|
|
557 |
1059 |
Hashtable ann; |
558 |
1059 |
if (seqAnn.containsKey(acc)) |
559 |
|
{ |
560 |
148 |
ann = (Hashtable) seqAnn.get(acc); |
561 |
|
} |
562 |
|
else |
563 |
|
{ |
564 |
911 |
ann = new Hashtable(); |
565 |
|
} |
566 |
1059 |
ann.put(type, content); |
567 |
1059 |
seqAnn.put(acc, ann); |
568 |
|
} |
569 |
|
else |
570 |
|
{ |
571 |
|
|
572 |
0 |
jalview.bin.Console |
573 |
|
.errPrintln(">> missing annotation: " + line); |
574 |
|
} |
575 |
|
} |
576 |
333 |
else if (annType.equals("GC")) |
577 |
|
{ |
578 |
|
|
579 |
|
|
580 |
13 |
if (x.search(annContent)) |
581 |
|
{ |
582 |
|
|
583 |
13 |
parseAnnotationRow(annotations, x.stringMatched(1), |
584 |
|
x.stringMatched(2)); |
585 |
|
} |
586 |
|
} |
587 |
320 |
else if (annType.equals("GR")) |
588 |
|
{ |
589 |
|
|
590 |
|
|
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
|
595 |
|
|
596 |
|
|
597 |
|
|
598 |
|
|
599 |
320 |
if (s.search(annContent)) |
600 |
|
{ |
601 |
320 |
String acc = s.stringMatched(1); |
602 |
320 |
String type = s.stringMatched(2); |
603 |
320 |
String oseq = s.stringMatched(3); |
604 |
|
|
605 |
|
|
606 |
|
|
607 |
320 |
String seq = new String(oseq); |
608 |
|
|
609 |
320 |
Hashtable ann; |
610 |
|
|
611 |
320 |
if (seqAnn.containsKey(acc)) |
612 |
|
{ |
613 |
|
|
614 |
315 |
ann = (Hashtable) seqAnn.get(acc); |
615 |
|
} |
616 |
|
else |
617 |
|
{ |
618 |
|
|
619 |
5 |
ann = new Hashtable(); |
620 |
5 |
seqAnn.put(acc, ann); |
621 |
|
} |
622 |
|
|
623 |
|
|
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
|
628 |
320 |
Hashtable features; |
629 |
|
|
630 |
320 |
if (ann.containsKey("features")) |
631 |
|
{ |
632 |
|
|
633 |
0 |
features = (Hashtable) ann.get("features"); |
634 |
|
} |
635 |
|
else |
636 |
|
{ |
637 |
|
|
638 |
320 |
features = new Hashtable(); |
639 |
320 |
ann.put("features", features); |
640 |
|
} |
641 |
|
|
642 |
320 |
Hashtable content; |
643 |
320 |
if (features.containsKey(this.id2type(type))) |
644 |
|
{ |
645 |
|
|
646 |
0 |
content = (Hashtable) features.get(this.id2type(type)); |
647 |
|
} |
648 |
|
else |
649 |
|
{ |
650 |
|
|
651 |
|
|
652 |
320 |
content = new Hashtable(); |
653 |
320 |
features.put(this.id2type(type), content); |
654 |
|
} |
655 |
320 |
String ns = (String) content.get(ANNOTATION); |
656 |
|
|
657 |
320 |
if (ns == null) |
658 |
|
{ |
659 |
320 |
ns = ""; |
660 |
|
} |
661 |
|
|
662 |
320 |
ns += seq; |
663 |
320 |
content.put(ANNOTATION, ns); |
664 |
|
|
665 |
|
|
666 |
|
|
667 |
320 |
Hashtable strucAnn; |
668 |
320 |
if (seqAnn.containsKey(acc)) |
669 |
|
{ |
670 |
320 |
strucAnn = (Hashtable) seqAnn.get(acc); |
671 |
|
} |
672 |
|
else |
673 |
|
{ |
674 |
0 |
strucAnn = new Hashtable(); |
675 |
|
} |
676 |
|
|
677 |
320 |
Vector<AlignmentAnnotation> newStruc = new Vector<>(); |
678 |
320 |
parseAnnotationRow(newStruc, type, ns); |
679 |
320 |
for (AlignmentAnnotation alan : newStruc) |
680 |
|
{ |
681 |
320 |
alan.visible = false; |
682 |
|
} |
683 |
|
|
684 |
|
|
685 |
320 |
strucAnn.put(type, newStruc); |
686 |
320 |
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 |
|
|
|
|
| 77.5% |
Uncovered Elements: 16 (71) |
Complexity: 17 |
Complexity Density: 0.38 |
|
726 |
895 |
private void guessDatabaseFor(Sequence seqO, String dbr, String dbsource)... |
727 |
|
{ |
728 |
895 |
DBRefEntry dbrf = null; |
729 |
895 |
List<DBRefEntry> dbrs = new ArrayList<>(); |
730 |
895 |
String seqdb = "Unknown", sdbac = "" + dbr; |
731 |
895 |
int st = -1, en = -1, p; |
732 |
? |
if ((st = sdbac.indexOf("/")) > -1) |
733 |
|
{ |
734 |
215 |
String num, range = sdbac.substring(st + 1); |
735 |
215 |
sdbac = sdbac.substring(0, st); |
736 |
? |
if ((p = range.indexOf("-")) > -1) |
737 |
|
{ |
738 |
215 |
p++; |
739 |
215 |
if (p < range.length()) |
740 |
|
{ |
741 |
215 |
num = range.substring(p).trim(); |
742 |
215 |
try |
743 |
|
{ |
744 |
215 |
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 |
215 |
num = range.substring(0, p).trim(); |
757 |
215 |
try |
758 |
|
{ |
759 |
215 |
st = Integer.parseInt(num); |
760 |
|
} catch (NumberFormatException x) |
761 |
|
{ |
762 |
|
|
763 |
215 |
st = -1; |
764 |
|
} |
765 |
|
} |
766 |
895 |
if (dbsource == null) |
767 |
|
{ |
768 |
|
|
769 |
|
|
770 |
|
|
771 |
94 |
dbsource = (seqO.isProtein()) ? "PFAM" : "RFAM"; |
772 |
|
} |
773 |
895 |
if (dbsource.equals("PFAM")) |
774 |
|
{ |
775 |
619 |
seqdb = "UNIPROT"; |
776 |
619 |
if (sdbac.indexOf(".") > -1) |
777 |
|
{ |
778 |
|
|
779 |
412 |
sdbac = sdbac.substring(0, sdbac.indexOf(".")); |
780 |
412 |
dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, seqdb, dbsource, |
781 |
|
sdbac); |
782 |
412 |
if (dbrf != null) |
783 |
|
{ |
784 |
412 |
dbrs.add(dbrf); |
785 |
|
} |
786 |
|
} |
787 |
619 |
dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, dbsource, dbsource, |
788 |
|
dbr); |
789 |
619 |
if (dbr != null) |
790 |
|
{ |
791 |
619 |
dbrs.add(dbrf); |
792 |
|
} |
793 |
|
} |
794 |
|
else |
795 |
|
{ |
796 |
276 |
seqdb = "EMBL"; |
797 |
|
|
798 |
276 |
if (sdbac.indexOf(".") > -1) |
799 |
|
{ |
800 |
|
|
801 |
215 |
sdbac = sdbac.substring(0, sdbac.indexOf(".")); |
802 |
215 |
dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, seqdb, dbsource, |
803 |
|
sdbac); |
804 |
215 |
if (dbrf != null) |
805 |
|
{ |
806 |
215 |
dbrs.add(dbrf); |
807 |
|
} |
808 |
|
} |
809 |
|
|
810 |
276 |
dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, dbsource, dbsource, |
811 |
|
dbr); |
812 |
276 |
if (dbrf != null) |
813 |
|
{ |
814 |
276 |
dbrs.add(dbrf); |
815 |
|
} |
816 |
|
} |
817 |
895 |
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 |
|
|
|
|
| 71.4% |
Uncovered Elements: 22 (77) |
Complexity: 18 |
Complexity Density: 0.37 |
|
831 |
333 |
protected static AlignmentAnnotation parseAnnotationRow(... |
832 |
|
Vector<AlignmentAnnotation> annotation, String label, |
833 |
|
String annots) |
834 |
|
{ |
835 |
333 |
String convert1, convert2 = null; |
836 |
|
|
837 |
|
|
838 |
|
|
839 |
|
|
840 |
|
|
841 |
333 |
String type = label; |
842 |
333 |
if (label.contains("_cons")) |
843 |
|
{ |
844 |
11 |
type = (label.indexOf("_cons") == label.length() - 5) |
845 |
|
? label.substring(0, label.length() - 5) |
846 |
|
: label; |
847 |
|
} |
848 |
333 |
boolean ss = false, posterior = false; |
849 |
333 |
type = id2type(type); |
850 |
|
|
851 |
333 |
boolean isrnass = false; |
852 |
333 |
if (type.equalsIgnoreCase("secondary structure")) |
853 |
|
{ |
854 |
327 |
ss = true; |
855 |
327 |
isrnass = !NOT_RNASS.search(annots); |
856 |
|
|
857 |
|
|
858 |
|
} |
859 |
333 |
if (type.equalsIgnoreCase("posterior probability")) |
860 |
|
{ |
861 |
0 |
posterior = true; |
862 |
|
} |
863 |
|
|
864 |
333 |
Annotation[] els = new Annotation[annots.length()]; |
865 |
25982 |
for (int i = 0; i < annots.length(); i++) |
866 |
|
{ |
867 |
25649 |
String pos = annots.substring(i, i + 1); |
868 |
25649 |
Annotation ann; |
869 |
25649 |
ann = new Annotation(pos, "", ' ', 0f); |
870 |
|
|
871 |
25649 |
if (ss) |
872 |
|
{ |
873 |
|
|
874 |
|
{ |
875 |
24998 |
if (isrnass && RNASS_BRACKETS.indexOf(pos) >= 0) |
876 |
|
{ |
877 |
8020 |
ann.secondaryStructure = Rna.getRNASecStrucState(pos).charAt(0); |
878 |
8020 |
ann.displayCharacter = "" + pos.charAt(0); |
879 |
|
} |
880 |
|
else |
881 |
|
{ |
882 |
16978 |
ann.secondaryStructure = ResidueProperties.getDssp3state(pos) |
883 |
|
.charAt(0); |
884 |
|
|
885 |
16978 |
if (ann.secondaryStructure == pos.charAt(0)) |
886 |
|
{ |
887 |
1766 |
ann.displayCharacter = ""; |
888 |
|
} |
889 |
|
else |
890 |
|
{ |
891 |
15212 |
ann.displayCharacter = " " + ann.displayCharacter; |
892 |
|
} |
893 |
|
} |
894 |
|
} |
895 |
|
|
896 |
|
} |
897 |
25649 |
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 |
25649 |
els[i] = ann; |
918 |
|
} |
919 |
333 |
AlignmentAnnotation annot = null; |
920 |
333 |
Enumeration<AlignmentAnnotation> e = annotation.elements(); |
921 |
339 |
while (e.hasMoreElements()) |
922 |
|
{ |
923 |
6 |
annot = e.nextElement(); |
924 |
6 |
if (annot.label.equals(type)) |
925 |
|
{ |
926 |
0 |
break; |
927 |
|
} |
928 |
6 |
annot = null; |
929 |
|
} |
930 |
333 |
if (annot == null) |
931 |
|
{ |
932 |
333 |
annot = new AlignmentAnnotation(type, type, els); |
933 |
333 |
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 |
333 |
return annot; |
946 |
|
} |
947 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
948 |
281 |
private String dbref_to_ac_record(DBRefEntry ref)... |
949 |
|
{ |
950 |
281 |
return ref.getSource().toString() + " ; " |
951 |
|
+ ref.getAccessionId().toString(); |
952 |
|
} |
953 |
|
|
|
|
| 91.2% |
Uncovered Elements: 14 (159) |
Complexity: 39 |
Complexity Density: 0.38 |
|
954 |
60 |
@Override... |
955 |
|
public String print(SequenceI[] s, boolean jvSuffix) |
956 |
|
{ |
957 |
60 |
out = new StringBuffer(); |
958 |
60 |
out.append("# STOCKHOLM 1.0"); |
959 |
60 |
out.append(newline); |
960 |
|
|
961 |
|
|
962 |
60 |
int max = 0; |
963 |
60 |
int maxid = 0; |
964 |
60 |
int in = 0; |
965 |
60 |
int slen = s.length; |
966 |
60 |
SequenceI seq; |
967 |
60 |
Hashtable<String, String> dataRef = null; |
968 |
60 |
boolean isAA = s[in].isProtein(); |
969 |
? |
while ((in < slen) && ((seq = s[in]) != null)) |
970 |
|
{ |
971 |
344 |
String tmp = printId(seq, jvSuffix); |
972 |
344 |
max = Math.max(max, seq.getLength()); |
973 |
|
|
974 |
344 |
if (tmp.length() > maxid) |
975 |
|
{ |
976 |
65 |
maxid = tmp.length(); |
977 |
|
} |
978 |
344 |
List<DBRefEntry> seqrefs = seq.getDBRefs(); |
979 |
344 |
int ndb; |
980 |
? |
if (seqrefs != null && (ndb = seqrefs.size()) > 0) |
981 |
|
{ |
982 |
268 |
if (dataRef == null) |
983 |
|
{ |
984 |
3 |
dataRef = new Hashtable<>(); |
985 |
|
} |
986 |
268 |
List<DBRefEntry> primrefs = seq.getPrimaryDBRefs(); |
987 |
268 |
if (primrefs.size() >= 1) |
988 |
|
{ |
989 |
1 |
dataRef.put(tmp, dbref_to_ac_record(primrefs.get(0))); |
990 |
|
} |
991 |
|
else |
992 |
|
{ |
993 |
280 |
for (int idb = 0; idb < seq.getDBRefs().size(); idb++) |
994 |
|
{ |
995 |
280 |
DBRefEntry dbref = seq.getDBRefs().get(idb); |
996 |
280 |
dataRef.put(tmp, dbref_to_ac_record(dbref)); |
997 |
|
|
998 |
280 |
if (isAA && DBRefSource.UNIPROT |
999 |
|
.equals(DBRefUtils.getCanonicalName(dbref.getSource()))) |
1000 |
|
{ |
1001 |
206 |
break; |
1002 |
|
} |
1003 |
74 |
if (!isAA && DBRefSource.EMBL |
1004 |
|
.equals(DBRefUtils.getCanonicalName(dbref.getSource()))) |
1005 |
|
{ |
1006 |
61 |
break; |
1007 |
|
} |
1008 |
|
} |
1009 |
|
} |
1010 |
|
} |
1011 |
344 |
in++; |
1012 |
|
} |
1013 |
60 |
maxid += 9; |
1014 |
60 |
int i = 0; |
1015 |
|
|
1016 |
|
|
1017 |
60 |
if (al.getProperties() != null) |
1018 |
|
{ |
1019 |
3 |
if (!al.getProperties().isEmpty()) |
1020 |
|
{ |
1021 |
3 |
Enumeration key = al.getProperties().keys(); |
1022 |
3 |
Enumeration val = al.getProperties().elements(); |
1023 |
41 |
while (key.hasMoreElements()) |
1024 |
|
{ |
1025 |
38 |
out.append("#=GF " + key.nextElement() + " " + val.nextElement()); |
1026 |
38 |
out.append(newline); |
1027 |
|
} |
1028 |
|
} |
1029 |
|
} |
1030 |
|
|
1031 |
|
|
1032 |
60 |
if (dataRef != null) |
1033 |
|
{ |
1034 |
3 |
Enumeration<String> en = dataRef.keys(); |
1035 |
271 |
while (en.hasMoreElements()) |
1036 |
|
{ |
1037 |
268 |
Object idd = en.nextElement(); |
1038 |
268 |
String type = dataRef.remove(idd); |
1039 |
268 |
out.append(new Format("%-" + (maxid - 2) + "s") |
1040 |
|
.form("#=GS " + idd.toString() + " ")); |
1041 |
268 |
if (isAA && type.contains("UNIPROT") |
1042 |
|
|| (!isAA && type.contains("EMBL"))) |
1043 |
|
{ |
1044 |
|
|
1045 |
268 |
out.append(" AC " + type.substring(type.indexOf(";") + 1)); |
1046 |
|
} |
1047 |
|
else |
1048 |
|
{ |
1049 |
0 |
out.append(" DR " + type + " "); |
1050 |
|
} |
1051 |
268 |
out.append(newline); |
1052 |
|
} |
1053 |
|
} |
1054 |
|
|
1055 |
|
|
1056 |
|
|
1057 |
? |
while (i < slen && (seq = s[i]) != null) |
1058 |
|
{ |
1059 |
344 |
if (seq.getDescription() != null) |
1060 |
|
{ |
1061 |
|
|
1062 |
16 |
out.append(new Format("%-" + maxid + "s").form("#=GS " |
1063 |
|
+ printId(seq, jvSuffix) + " DE " + seq.getDescription())); |
1064 |
16 |
out.append(newline); |
1065 |
|
} |
1066 |
|
|
1067 |
344 |
AlignmentAnnotation[] alAnot = seq.getAnnotation(); |
1068 |
344 |
if (alAnot != null) |
1069 |
|
{ |
1070 |
83 |
Annotation[] ann; |
1071 |
166 |
for (int j = 0, nj = alAnot.length; j < nj; j++) |
1072 |
|
{ |
1073 |
|
|
1074 |
83 |
String key = type2id(alAnot[j].label); |
1075 |
83 |
boolean isrna = alAnot[j].isValidStruc(); |
1076 |
|
|
1077 |
83 |
if (isrna) |
1078 |
|
{ |
1079 |
|
|
1080 |
|
|
1081 |
66 |
key = "SS"; |
1082 |
|
} |
1083 |
83 |
if (key == null) |
1084 |
|
{ |
1085 |
|
|
1086 |
4 |
continue; |
1087 |
|
} |
1088 |
|
|
1089 |
|
|
1090 |
79 |
out.append(new Format("%-" + maxid + "s").form( |
1091 |
|
"#=GR " + printId(seq, jvSuffix) + " " + key + " ")); |
1092 |
79 |
ann = alAnot[j].annotations; |
1093 |
79 |
String sseq = ""; |
1094 |
7982 |
for (int k = 0, nk = ann.length; k < nk; k++) |
1095 |
|
{ |
1096 |
7903 |
sseq += outputCharacter(key, k, isrna, ann, seq); |
1097 |
|
} |
1098 |
79 |
out.append(sseq); |
1099 |
79 |
out.append(newline); |
1100 |
|
} |
1101 |
|
} |
1102 |
|
|
1103 |
344 |
out.append(new Format("%-" + maxid + "s") |
1104 |
|
.form(printId(seq, jvSuffix) + " ")); |
1105 |
344 |
out.append(seq.getSequenceAsString()); |
1106 |
344 |
out.append(newline); |
1107 |
344 |
i++; |
1108 |
|
} |
1109 |
|
|
1110 |
|
|
1111 |
60 |
AlignmentAnnotation aa; |
1112 |
60 |
AlignmentAnnotation[] an = al.getAlignmentAnnotation(); |
1113 |
60 |
if (an != null) |
1114 |
|
{ |
1115 |
272 |
for (int ia = 0, na = an.length; ia < na; ia++) |
1116 |
|
{ |
1117 |
216 |
aa = an[ia]; |
1118 |
216 |
if (aa.autoCalculated || !aa.visible || aa.sequenceRef != null) |
1119 |
|
{ |
1120 |
211 |
continue; |
1121 |
|
} |
1122 |
5 |
String sseq = ""; |
1123 |
5 |
String label; |
1124 |
5 |
String key = ""; |
1125 |
5 |
if (aa.label.equals("seq")) |
1126 |
|
{ |
1127 |
1 |
label = "seq_cons"; |
1128 |
|
} |
1129 |
|
else |
1130 |
|
{ |
1131 |
4 |
key = type2id(aa.label.toLowerCase(Locale.ROOT)); |
1132 |
4 |
if (key == null) |
1133 |
|
{ |
1134 |
0 |
label = aa.label; |
1135 |
|
} |
1136 |
|
else |
1137 |
|
{ |
1138 |
4 |
label = key + "_cons"; |
1139 |
|
} |
1140 |
|
} |
1141 |
5 |
if (label == null) |
1142 |
|
{ |
1143 |
0 |
label = aa.label; |
1144 |
|
} |
1145 |
5 |
label = label.replace(" ", "_"); |
1146 |
|
|
1147 |
5 |
out.append( |
1148 |
|
new Format("%-" + maxid + "s").form("#=GC " + label + " ")); |
1149 |
5 |
boolean isrna = aa.isValidStruc(); |
1150 |
453 |
for (int j = 0, nj = aa.annotations.length; j < nj; j++) |
1151 |
|
{ |
1152 |
448 |
sseq += outputCharacter(key, j, isrna, aa.annotations, null); |
1153 |
|
} |
1154 |
5 |
out.append(sseq); |
1155 |
5 |
out.append(newline); |
1156 |
|
} |
1157 |
|
} |
1158 |
|
|
1159 |
60 |
out.append("//"); |
1160 |
60 |
out.append(newline); |
1161 |
|
|
1162 |
60 |
return out.toString(); |
1163 |
|
} |
1164 |
|
|
1165 |
|
|
1166 |
|
|
1167 |
|
|
1168 |
|
@param |
1169 |
|
@param |
1170 |
|
@param |
1171 |
|
@param |
1172 |
|
@param |
1173 |
|
@param |
1174 |
|
|
|
|
| 87.8% |
Uncovered Elements: 6 (49) |
Complexity: 20 |
Complexity Density: 0.87 |
|
1175 |
8351 |
private char outputCharacter(String key, int k, boolean isrna,... |
1176 |
|
Annotation[] ann, SequenceI sequenceI) |
1177 |
|
{ |
1178 |
8351 |
char seq = ' '; |
1179 |
8351 |
Annotation annot = ann[k]; |
1180 |
8351 |
String ch = (annot == null) |
1181 |
2440 |
? ((sequenceI == null) ? "-" |
1182 |
|
: Character.toString(sequenceI.getCharAt(k))) |
1183 |
5911 |
: (annot.displayCharacter == null |
1184 |
|
? String.valueOf(annot.secondaryStructure) |
1185 |
|
: annot.displayCharacter); |
1186 |
8351 |
if (ch == null) |
1187 |
|
{ |
1188 |
0 |
ch = " "; |
1189 |
|
} |
1190 |
8351 |
if (key != null && key.equals("SS")) |
1191 |
|
{ |
1192 |
8134 |
char ssannotchar = ' '; |
1193 |
8134 |
boolean charset = false; |
1194 |
8134 |
if (annot == null) |
1195 |
|
{ |
1196 |
|
|
1197 |
2440 |
ssannotchar = ' '; |
1198 |
2440 |
charset = true; |
1199 |
|
} |
1200 |
|
else |
1201 |
|
{ |
1202 |
|
|
1203 |
5694 |
if (annot.secondaryStructure > ' ' && ch.length() < 2) |
1204 |
|
{ |
1205 |
3074 |
ssannotchar = annot.secondaryStructure; |
1206 |
3074 |
charset = true; |
1207 |
|
} |
1208 |
|
} |
1209 |
8134 |
if (charset) |
1210 |
|
{ |
1211 |
5514 |
return (ssannotchar == ' ' && isrna) ? '.' : ssannotchar; |
1212 |
|
} |
1213 |
|
} |
1214 |
|
|
1215 |
2837 |
if (ch.length() == 0) |
1216 |
|
{ |
1217 |
0 |
seq = '.'; |
1218 |
|
} |
1219 |
2837 |
else if (ch.length() == 1) |
1220 |
|
{ |
1221 |
454 |
seq = ch.charAt(0); |
1222 |
|
} |
1223 |
2383 |
else if (ch.length() > 1) |
1224 |
|
{ |
1225 |
2383 |
seq = ch.charAt(1); |
1226 |
|
} |
1227 |
|
|
1228 |
2837 |
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 |
|
|
|
|
| 94.7% |
Uncovered Elements: 1 (19) |
Complexity: 2 |
Complexity Density: 0.12 |
|
1246 |
1 |
static... |
1247 |
|
{ |
1248 |
1 |
if (typeIds == null) |
1249 |
|
{ |
1250 |
1 |
typeIds = new Hashtable(); |
1251 |
1 |
typeIds.put("SS", "Secondary Structure"); |
1252 |
1 |
typeIds.put("SA", "Surface Accessibility"); |
1253 |
1 |
typeIds.put("TM", "transmembrane"); |
1254 |
1 |
typeIds.put("PP", "Posterior Probability"); |
1255 |
1 |
typeIds.put("LI", "ligand binding"); |
1256 |
1 |
typeIds.put("AS", "active site"); |
1257 |
1 |
typeIds.put("IN", "intron"); |
1258 |
1 |
typeIds.put("IR", "interacting residue"); |
1259 |
1 |
typeIds.put("AC", "accession"); |
1260 |
1 |
typeIds.put("OS", "organism"); |
1261 |
1 |
typeIds.put("CL", "class"); |
1262 |
1 |
typeIds.put("DE", "description"); |
1263 |
1 |
typeIds.put("DR", "reference"); |
1264 |
1 |
typeIds.put("LO", "look"); |
1265 |
1 |
typeIds.put("RF", "Reference Positions"); |
1266 |
|
|
1267 |
|
} |
1268 |
|
} |
1269 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1270 |
973 |
protected static String id2type(String id)... |
1271 |
|
{ |
1272 |
973 |
if (typeIds.containsKey(id)) |
1273 |
|
{ |
1274 |
970 |
return (String) typeIds.get(id); |
1275 |
|
} |
1276 |
3 |
jalview.bin.Console.errPrintln( |
1277 |
|
"Warning : Unknown Stockholm annotation type code " + id); |
1278 |
3 |
return id; |
1279 |
|
} |
1280 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
1281 |
407 |
protected static String type2id(String type)... |
1282 |
|
{ |
1283 |
407 |
String key = null; |
1284 |
407 |
Enumeration e = typeIds.keys(); |
1285 |
4494 |
while (e.hasMoreElements()) |
1286 |
|
{ |
1287 |
4490 |
Object ll = e.nextElement(); |
1288 |
4490 |
if (typeIds.get(ll).toString().equalsIgnoreCase(type)) |
1289 |
|
{ |
1290 |
403 |
key = (String) ll; |
1291 |
403 |
break; |
1292 |
|
} |
1293 |
|
} |
1294 |
407 |
if (key != null) |
1295 |
|
{ |
1296 |
403 |
return key; |
1297 |
|
} |
1298 |
4 |
jalview.bin.Console.errPrintln( |
1299 |
|
"Warning : Unknown Stockholm annotation type: " + type); |
1300 |
4 |
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 |
|
} |