2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * This extension was written by Benjamin Schuster-Boeckler at sanger.ac.uk
26 import com.stevesoft.pat.*;
27 import jalview.datamodel.*;
28 import jalview.util.Format;
30 // import org.apache.log4j.*;
33 * This class is supposed to parse a Stockholm format file into Jalview There
34 * are TODOs in this class: we do not know what the database source and version
35 * is for the file when parsing the #GS= AC tag which associates accessions with
36 * sequences. Database references are also not parsed correctly: a separate
37 * reference string parser must be added to parse the database reference form
38 * into Jalview's local representation.
40 * @author bsb at sanger.ac.uk
41 * @version 0.3 + jalview mods
44 public class StockholmFile extends AlignFile
46 // static Logger logger = Logger.getLogger("jalview.io.StockholmFile");
47 StringBuffer out; // output buffer
51 public StockholmFile()
56 * Creates a new StockholmFile object for output.
58 public StockholmFile(AlignmentI al)
63 public StockholmFile(String inFile, String type) throws IOException
68 public StockholmFile(FileParse source) throws IOException
73 public void initData()
79 * Parse a file in Stockholm format into Jalview's data model. The file has to
80 * be passed at construction time
83 * If there is an error with the input file
85 public void parse() throws IOException
87 StringBuffer treeString = new StringBuffer();
88 String treeName = null;
89 // --------------- Variable Definitions -------------------
93 Hashtable seqAnn = new Hashtable(); // Sequence related annotations
94 Hashtable seqs = new Hashtable();
95 Regex p, r, rend, s, x;
97 // Temporary line for processing RNA annotation
98 // String RNAannot = "";
100 // ------------------ Parsing File ----------------------
101 // First, we have to check that this file has STOCKHOLM format, i.e. the
102 // first line must match
103 r = new Regex("# STOCKHOLM ([\\d\\.]+)");
104 if (!r.search(nextLine()))
106 throw new IOException(
107 "This file is not in valid STOCKHOLM format: First line does not contain '# STOCKHOLM'");
111 version = r.stringMatched(1);
112 // logger.debug("Stockholm version: " + version);
115 // We define some Regexes here that will be used regularily later
116 rend = new Regex("^\\s*\\/\\/"); // Find the end of an alignment
117 p = new Regex("(\\S+)\\/(\\d+)\\-(\\d+)"); // split sequence id in
119 s = new Regex("(\\S+)\\s+(\\S*)\\s+(.*)"); // Parses annotation subtype
120 r = new Regex("#=(G[FSRC]?)\\s+(.*)"); // Finds any annotation line
121 x = new Regex("(\\S+)\\s+(\\S+)"); // split id from sequence
123 // Convert all bracket types to parentheses (necessary for passing to VARNA)
124 Regex openparen = new Regex("(<|\\[)", "(");
125 Regex closeparen = new Regex("(>|\\])", ")");
127 // Detect if file is RNA by looking for bracket types
128 Regex detectbrackets = new Regex("(<|>|\\[|\\]|\\(|\\))");
135 openparen.optimize();
136 closeparen.optimize();
138 while ((line = nextLine()) != null)
140 if (line.length() == 0)
144 if (rend.search(line))
146 // End of the alignment, pass stuff back
147 this.noSeqs = seqs.size();
149 String seqdb,dbsource = null;
150 Regex pf = new Regex("PF[0-9]{5}(.*)"); // Finds AC for Pfam
151 Regex rf = new Regex("RF[0-9]{5}(.*)"); // Finds AC for Rfam
152 if (getAlignmentProperty("AC") != null)
154 String dbType = getAlignmentProperty("AC").toString();
155 if (pf.search(dbType))
157 // PFAM Alignment - so references are typically from Uniprot
160 else if (rf.search(dbType))
165 // logger.debug("Number of sequences: " + this.noSeqs);
166 Enumeration accs = seqs.keys();
167 while (accs.hasMoreElements())
169 String acc = (String) accs.nextElement();
170 // logger.debug("Processing sequence " + acc);
171 String seq = (String) seqs.remove(acc);
172 if (maxLength < seq.length())
174 maxLength = seq.length();
180 * Retrieve hash of annotations for this accession Associate
181 * Annotation with accession
183 Hashtable accAnnotations = null;
185 if (seqAnn != null && seqAnn.containsKey(acc))
187 accAnnotations = (Hashtable) seqAnn.remove(acc);
188 // TODO: add structures to sequence
191 // Split accession in id and from/to
194 sid = p.stringMatched(1);
195 start = Integer.parseInt(p.stringMatched(2));
196 end = Integer.parseInt(p.stringMatched(3));
198 // logger.debug(sid + ", " + start + ", " + end);
200 Sequence seqO = new Sequence(sid, seq, start, end);
201 // Add Description (if any)
202 if (accAnnotations != null && accAnnotations.containsKey("DE"))
204 String desc = (String) accAnnotations.get("DE");
205 seqO.setDescription((desc == null) ? "" : desc);
208 // Add DB References (if any)
209 if (accAnnotations != null && accAnnotations.containsKey("DR"))
211 String dbr = (String) accAnnotations.get("DR");
212 if (dbr != null && dbr.indexOf(";") > -1)
214 String src = dbr.substring(0, dbr.indexOf(";"));
215 String acn = dbr.substring(dbr.indexOf(";") + 1);
216 jalview.util.DBRefUtils.parseToDbRef(seqO, src, "0", acn);
220 if (accAnnotations != null && accAnnotations.containsKey("AC"))
222 if (dbsource != null)
224 String dbr = (String) accAnnotations.get("AC");
227 // we could get very clever here - but for now - just try to guess accession type from source of alignment plus structure of accession
228 guessDatabaseFor(seqO, dbr, dbsource);
232 // else - do what ? add the data anyway and prompt the user to specify what references these are ?
235 Hashtable features = null;
236 // We need to adjust the positions of all features to account for gaps
239 features = (Hashtable) accAnnotations.remove("features");
240 } catch (java.lang.NullPointerException e)
242 // loggerwarn("Getting Features for " + acc + ": " +
246 // if we have features
247 if (features != null)
249 int posmap[] = seqO.findPositionMap();
250 Enumeration i = features.keys();
251 while (i.hasMoreElements())
253 // TODO: parse out secondary structure annotation as annotation
255 // TODO: parse out scores as annotation row
256 // TODO: map coding region to core jalview feature types
257 String type = i.nextElement().toString();
258 Hashtable content = (Hashtable) features.remove(type);
260 // add alignment annotation for this feature
261 String key = type2id(type);
264 if (accAnnotations != null
265 && accAnnotations.containsKey(key))
267 Vector vv = (Vector) accAnnotations.get(key);
268 for (int ii = 0; ii < vv.size(); ii++)
270 AlignmentAnnotation an = (AlignmentAnnotation) vv
272 seqO.addAlignmentAnnotation(an);
277 Enumeration j = content.keys();
278 while (j.hasMoreElements())
280 String desc = j.nextElement().toString();
281 String ns = content.get(desc).toString();
282 char[] byChar = ns.toCharArray();
283 for (int k = 0; k < byChar.length; k++)
286 if (!(c == ' ' || c == '_' || c == '-' || c == '.')) // PFAM
293 int new_pos = posmap[k]; // look up nearest seqeunce
294 // position to this column
295 SequenceFeature feat = new SequenceFeature(type, desc,
296 new_pos, new_pos, 0f, null);
298 seqO.addSequenceFeature(feat);
308 // logger.debug("Adding seq " + acc + " from " + start + " to " + end
310 this.seqs.addElement(seqO);
312 return; // finished parsing this segment of source
314 else if (!r.search(line))
316 // System.err.println("Found sequence line: " + line);
318 // Split sequence in sequence and accession parts
321 // logger.error("Could not parse sequence line: " + line);
322 throw new IOException("Could not parse sequence line: " + line);
324 String ns = (String) seqs.get(x.stringMatched(1));
329 ns += x.stringMatched(2);
331 seqs.put(x.stringMatched(1), ns);
335 String annType = r.stringMatched(1);
336 String annContent = r.stringMatched(2);
338 // System.err.println("type:" + annType + " content: " + annContent);
340 if (annType.equals("GF"))
343 * Generic per-File annotation, free text Magic features: #=GF NH
344 * <tree in New Hampshire eXtended format> #=GF TN <Unique identifier
345 * for the next tree> Pfam descriptions: 7. DESCRIPTION OF FIELDS
347 * Compulsory fields: ------------------
349 * AC Accession number: Accession number in form PFxxxxx.version or
350 * PBxxxxxx. ID Identification: One word name for family. DE
351 * Definition: Short description of family. AU Author: Authors of the
352 * entry. SE Source of seed: The source suggesting the seed members
353 * belong to one family. GA Gathering method: Search threshold to
354 * build the full alignment. TC Trusted Cutoff: Lowest sequence score
355 * and domain score of match in the full alignment. NC Noise Cutoff:
356 * Highest sequence score and domain score of match not in full
357 * alignment. TP Type: Type of family -- presently Family, Domain,
358 * Motif or Repeat. SQ Sequence: Number of sequences in alignment. AM
359 * Alignment Method The order ls and fs hits are aligned to the model
360 * to build the full align. // End of alignment.
362 * Optional fields: ----------------
364 * DC Database Comment: Comment about database reference. DR Database
365 * Reference: Reference to external database. RC Reference Comment:
366 * Comment about literature reference. RN Reference Number: Reference
367 * Number. RM Reference Medline: Eight digit medline UI number. RT
368 * Reference Title: Reference Title. RA Reference Author: Reference
369 * Author RL Reference Location: Journal location. PI Previous
370 * identifier: Record of all previous ID lines. KW Keywords: Keywords.
371 * CC Comment: Comments. NE Pfam accession: Indicates a nested domain.
372 * NL Location: Location of nested domains - sequence ID, start and
375 * Obsolete fields: ----------- AL Alignment method of seed: The
376 * method used to align the seed members.
378 // Let's save the annotations, maybe we'll be able to do something
379 // with them later...
380 Regex an = new Regex("(\\w+)\\s*(.*)");
381 if (an.search(annContent))
383 if (an.stringMatched(1).equals("NH"))
385 treeString.append(an.stringMatched(2));
387 else if (an.stringMatched(1).equals("TN"))
389 if (treeString.length() > 0)
391 if (treeName == null)
393 treeName = "Tree " + (getTreeCount() + 1);
395 addNewickTree(treeName, treeString.toString());
397 treeName = an.stringMatched(2);
398 treeString = new StringBuffer();
400 setAlignmentProperty(an.stringMatched(1), an.stringMatched(2));
403 else if (annType.equals("GS"))
405 // Generic per-Sequence annotation, free text
407 * Pfam uses these features: Feature Description ---------------------
408 * ----------- AC <accession> ACcession number DE <freetext>
409 * DEscription DR <db>; <accession>; Database Reference OS <organism>
410 * OrganiSm (species) OC <clade> Organism Classification (clade, etc.)
411 * LO <look> Look (Color, etc.)
413 if (s.search(annContent))
415 String acc = s.stringMatched(1);
416 String type = s.stringMatched(2);
417 String content = s.stringMatched(3);
418 // TODO: store DR in a vector.
419 // TODO: store AC according to generic file db annotation.
421 if (seqAnn.containsKey(acc))
423 ann = (Hashtable) seqAnn.get(acc);
427 ann = new Hashtable();
429 ann.put(type, content);
430 seqAnn.put(acc, ann);
434 throw new IOException("Error parsing " + line);
437 else if (annType.equals("GC"))
439 // Generic per-Column annotation, exactly 1 char per column
440 // always need a label.
441 if (x.search(annContent))
443 // parse out and create alignment annotation directly.
444 parseAnnotationRow(annotations, x.stringMatched(1),
448 else if (annType.equals("GR"))
450 // Generic per-Sequence AND per-Column markup, exactly 1 char per
453 * Feature Description Markup letters ------- -----------
454 * -------------- SS Secondary Structure [HGIEBTSCX] SA Surface
455 * Accessibility [0-9X] (0=0%-10%; ...; 9=90%-100%) TM TransMembrane
456 * [Mio] PP Posterior Probability [0-9*] (0=0.00-0.05; 1=0.05-0.15;
457 * *=0.95-1.00) LI LIgand binding [*] AS Active Site [*] IN INtron (in
460 if (s.search(annContent))
462 String acc = s.stringMatched(1);
463 String type = s.stringMatched(2);
464 String seq = new String(s.stringMatched(3));
465 String description = null;
466 // Check for additional information about the current annotation
467 // We use a simple string tokenizer here for speed
468 StringTokenizer sep = new StringTokenizer(seq, " \t");
469 description = sep.nextToken();
470 if (sep.hasMoreTokens())
472 seq = sep.nextToken();
477 description = new String();
479 // sequence id with from-to fields
482 // Get an object with all the annotations for this sequence
483 if (seqAnn.containsKey(acc))
485 // logger.debug("Found annotations for " + acc);
486 ann = (Hashtable) seqAnn.get(acc);
490 // logger.debug("Creating new annotations holder for " + acc);
491 ann = new Hashtable();
492 seqAnn.put(acc, ann);
494 // TODO test structure, call parseAnnotationRow with vector from
495 // hashtable for specific sequence
497 // Get an object with all the content for an annotation
498 if (ann.containsKey("features"))
500 // logger.debug("Found features for " + acc);
501 features = (Hashtable) ann.get("features");
505 // logger.debug("Creating new features holder for " + acc);
506 features = new Hashtable();
507 ann.put("features", features);
511 if (features.containsKey(this.id2type(type)))
513 // logger.debug("Found content for " + this.id2type(type));
514 content = (Hashtable) features.get(this.id2type(type));
518 // logger.debug("Creating new content holder for " +
519 // this.id2type(type));
520 content = new Hashtable();
521 features.put(this.id2type(type), content);
523 String ns = (String) content.get(description);
529 content.put(description, ns);
531 if (seqAnn.containsKey(acc))
533 strucAnn = (Hashtable) seqAnn.get(acc);
537 strucAnn = new Hashtable();
540 Vector newStruc = new Vector();
541 parseAnnotationRow(newStruc, type, ns);
542 strucAnn.put(type, newStruc);
543 seqAnn.put(acc, strucAnn);
548 .println("Warning - couldn't parse sequence annotation row line:\n"
550 // throw new IOException("Error parsing " + line);
555 throw new IOException("Unknown annotation detected: " + annType
560 if (treeString.length() > 0)
562 if (treeName == null)
564 treeName = "Tree " + (1 + getTreeCount());
566 addNewickTree(treeName, treeString.toString());
571 * Demangle an accession string and guess the originating sequence database for a given sequence
572 * @param seqO sequence to be annotated
573 * @param dbr Accession string for sequence
574 * @param dbsource source database for alignment (PFAM or RFAM)
576 private void guessDatabaseFor(Sequence seqO, String dbr, String dbsource)
578 DBRefEntry dbrf=null;
579 List<DBRefEntry> dbrs=new ArrayList<DBRefEntry>();
580 String seqdb="Unknown",sdbac=""+dbr;
582 if ((st=sdbac.indexOf("/"))>-1)
584 String num,range=sdbac.substring(st+1);
585 sdbac = sdbac.substring(0,st);
586 if ((p=range.indexOf("-"))>-1)
589 if (p<range.length())
591 num = range.substring(p).trim();
593 en = Integer.parseInt(num);
594 } catch (NumberFormatException x)
596 // could warn here that index is invalid
603 num=range.substring(0,p).trim();
605 st = Integer.parseInt(num);
606 } catch (NumberFormatException x)
608 // could warn here that index is invalid
612 if (dbsource.equals("PFAM")) {
614 if (sdbac.indexOf(".")>-1)
616 // strip of last subdomain
617 sdbac = sdbac.substring(0,sdbac.indexOf("."));
618 dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, seqdb, dbsource, sdbac);
624 dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, dbsource, dbsource, dbr);
630 seqdb = "EMBL"; // total guess - could be ENA, or something else these days
631 if (sdbac.indexOf(".")>-1)
633 // strip off last subdomain
634 sdbac = sdbac.substring(0,sdbac.indexOf("."));
635 dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, seqdb, dbsource, sdbac);
642 dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, dbsource, dbsource, dbr);
648 if (st!=-1 && en!=-1)
650 for (DBRefEntry d:dbrs)
652 jalview.util.MapList mp = new jalview.util.MapList(new int[] { seqO.getStart(),seqO.getEnd()},new int[] { st,en},1,1);
653 jalview.datamodel.Mapping mping = new Mapping(mp);
659 protected static AlignmentAnnotation parseAnnotationRow(
660 Vector annotation, String label, String annots)
662 String convert1, convert2 = null;
664 // Convert all bracket types to parentheses
665 Regex openparen = new Regex("(<|\\[)", "(");
666 Regex closeparen = new Regex("(>|\\])", ")");
668 // Detect if file is RNA by looking for bracket types
669 Regex detectbrackets = new Regex("(<|>|\\[|\\]|\\(|\\))");
671 convert1 = openparen.replaceAll(annots);
672 convert2 = closeparen.replaceAll(convert1);
676 if (label.contains("_cons"))
678 type = (label.indexOf("_cons") == label.length() - 5) ? label
679 .substring(0, label.length() - 5) : label;
682 type = id2type(type);
683 if (type.equals("secondary structure"))
687 // decide on secondary structure or not.
688 Annotation[] els = new Annotation[annots.length()];
689 for (int i = 0; i < annots.length(); i++)
691 String pos = annots.substring(i, i + 1);
693 ann = new Annotation(pos, "", ' ', 0f); // 0f is 'valid' null - will not
697 if (detectbrackets.search(pos))
699 ann.secondaryStructure = jalview.schemes.ResidueProperties
700 .getRNASecStrucState(pos).charAt(0);
704 ann.secondaryStructure = jalview.schemes.ResidueProperties
705 .getDssp3state(pos).charAt(0);
708 if (ann.secondaryStructure == pos.charAt(0) || pos.charAt(0) == 'C')
710 ann.displayCharacter = ""; // null; // " ";
714 ann.displayCharacter = " " + ann.displayCharacter;
720 AlignmentAnnotation annot = null;
721 Enumeration e = annotation.elements();
722 while (e.hasMoreElements())
724 annot = (AlignmentAnnotation) e.nextElement();
725 if (annot.label.equals(type))
731 annot = new AlignmentAnnotation(type, type, els);
732 annotation.addElement(annot);
736 Annotation[] anns = new Annotation[annot.annotations.length
738 System.arraycopy(annot.annotations, 0, anns, 0,
739 annot.annotations.length);
740 System.arraycopy(els, 0, anns, annot.annotations.length, els.length);
741 annot.annotations = anns;
742 // System.out.println("else: ");
747 public String print(SequenceI[] s)
749 // find max length of id
753 Hashtable dataRef = null;
754 while ((in < s.length) && (s[in] != null))
756 String tmp = printId(s[in]);
757 if (s[in].getSequence().length > max)
759 max = s[in].getSequence().length;
762 if (tmp.length() > maxid)
764 maxid = tmp.length();
766 if (s[in].getDBRef() != null)
768 for (int idb = 0; idb < s[in].getDBRef().length; idb++)
771 dataRef = new Hashtable();
773 String datAs1 = s[in].getDBRef()[idb].getSource().toString()
775 + s[in].getDBRef()[idb].getAccessionId().toString();
776 dataRef.put(tmp, datAs1);
784 // output database type
785 if (al.getProperties() != null)
787 if (!al.getProperties().isEmpty())
789 Enumeration key = al.getProperties().keys();
790 Enumeration val = al.getProperties().elements();
791 while (key.hasMoreElements())
793 out.append("#=GF " + key.nextElement() + " " + val.nextElement());
799 // output database accessions
802 Enumeration en = dataRef.keys();
803 while (en.hasMoreElements())
805 Object idd = en.nextElement();
806 String type = (String) dataRef.remove(idd);
807 out.append(new Format("%-" + (maxid - 2) + "s").form("#=GS "
808 + idd.toString() + " "));
809 if (type.contains("PFAM") || type.contains("RFAM"))
812 out.append(" AC " + type.substring(type.indexOf(";") + 1));
816 out.append(" DR " + type + " ");
822 // output annotations
823 while (i < s.length && s[i] != null)
825 if (s[i].getDatasetSequence() != null)
827 SequenceI ds = s[i].getDatasetSequence();
828 AlignmentAnnotation[] alAnot;
831 alAnot = s[i].getAnnotation();
835 for (int j = 0; j < alAnot.length; j++)
837 if (ds.getSequenceFeatures() != null)
839 feature = ds.getSequenceFeatures()[0].type;
841 String key = type2id(feature);
846 // out.append("#=GR ");
847 out.append(new Format("%-" + maxid + "s").form("#=GR "
848 + printId(s[i]) + " " + key + " "));
849 ann = alAnot[j].annotations;
851 for (int k = 0; k < ann.length; k++)
854 String ch = (annot == null) ? Character.toString(s[i]
855 .getCharAt(k)) : annot.displayCharacter;
856 if (ch.length() == 0)
858 if (key.equals("SS"))
860 char ll = annot.secondaryStructure;
861 seq = (Character.toString(ll).equals(" ")) ? seq + "C"
869 else if (ch.length() == 1)
873 else if (ch.length() > 1)
884 out.append(new Format("%-" + maxid + "s").form(printId(s[i]) + " "));
885 out.append(s[i].getSequenceAsString());
890 // alignment annotation
891 AlignmentAnnotation aa;
892 if (al.getAlignmentAnnotation() != null)
894 for (int ia = 0; ia < al.getAlignmentAnnotation().length; ia++)
896 aa = al.getAlignmentAnnotation()[ia];
897 if (aa.autoCalculated || !aa.visible)
904 if (aa.label.equals("seq"))
907 label = type2id(aa.label.toLowerCase()) + "_cons";
912 out.append(new Format("%-" + maxid + "s").form("#=GC " + label
914 for (int j = 0; j < aa.annotations.length; j++)
916 String ch = (aa.annotations[j] == null) ? "-"
917 : aa.annotations[j].displayCharacter;
918 if (ch.length() == 0)
920 char ll = aa.annotations[j].secondaryStructure;
921 if (Character.toString(ll).equals(" "))
926 else if (ch.length() == 1)
930 else if (ch.length() > 1)
939 return out.toString();
942 public String print()
944 out = new StringBuffer();
945 out.append("# STOCKHOLM 1.0");
947 print(getSeqsAsArray());
951 return out.toString();
954 private static Hashtable typeIds = null;
959 typeIds = new Hashtable();
960 typeIds.put("SS", "secondary structure");
961 typeIds.put("SA", "surface accessibility");
962 typeIds.put("TM", "transmembrane");
963 typeIds.put("PP", "posterior probability");
964 typeIds.put("LI", "ligand binding");
965 typeIds.put("AS", "active site");
966 typeIds.put("IN", "intron");
967 typeIds.put("IR", "interacting residue");
968 typeIds.put("AC", "accession");
969 typeIds.put("OS", "organism");
970 typeIds.put("CL", "class");
971 typeIds.put("DE", "description");
972 typeIds.put("DR", "reference");
973 typeIds.put("LO", "look");
974 typeIds.put("RF", "reference positions");
979 protected static String id2type(String id)
981 if (typeIds.containsKey(id))
983 return (String) typeIds.get(id);
985 System.err.println("Warning : Unknown Stockholm annotation type code "
990 protected static String type2id(String type)
993 Enumeration e = typeIds.keys();
994 while (e.hasMoreElements())
996 Object ll = e.nextElement();
997 if (typeIds.get(ll).toString().equals(type))
1005 return (String) key;
1007 System.err.println("Warning : Unknown Stockholm annotation type: "
1012 * //ssline is complete secondary structure line private AlignmentAnnotation
1013 * addHelices(Vector annotation, String label, String ssline) {
1015 * // decide on secondary structure or not. Annotation[] els = new
1016 * Annotation[ssline.length()]; for (int i = 0; i < ssline.length(); i++) {
1017 * String pos = ssline.substring(i, i + 1); Annotation ann; ann = new
1018 * Annotation(pos, "", ' ', 0f); // 0f is 'valid' null - will not
1020 * ann.secondaryStructure =
1021 * jalview.schemes.ResidueProperties.getRNAssState(pos).charAt(0);
1023 * ann.displayCharacter = "x" + ann.displayCharacter;
1025 * System.out.println(ann.displayCharacter);
1027 * els[i] = ann; } AlignmentAnnotation helicesAnnot = null; Enumeration e =
1028 * annotation.elements(); while (e.hasMoreElements()) { helicesAnnot =
1029 * (AlignmentAnnotation) e.nextElement(); if (helicesAnnot.label.equals(type))
1030 * break; helicesAnnot = null; } if (helicesAnnot == null) { helicesAnnot =
1031 * new AlignmentAnnotation(type, type, els);
1032 * annotation.addElement(helicesAnnot); } else { Annotation[] anns = new
1033 * Annotation[helicesAnnot.annotations.length + els.length];
1034 * System.arraycopy(helicesAnnot.annotations, 0, anns, 0,
1035 * helicesAnnot.annotations.length); System.arraycopy(els, 0, anns,
1036 * helicesAnnot.annotations.length, els.length); helicesAnnot.annotations =
1039 * helicesAnnot.features = Rna.GetBasePairs(ssline);
1040 * Rna.HelixMap(helicesAnnot.features);
1043 * return helicesAnnot; }