2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 The Jalview Authors
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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
20 * This extension was written by Benjamin Schuster-Boeckler at sanger.ac.uk
27 import com.stevesoft.pat.*;
28 import jalview.datamodel.*;
29 import jalview.util.Format;
31 // import org.apache.log4j.*;
34 * This class is supposed to parse a Stockholm format file into Jalview There
35 * are TODOs in this class: we do not know what the database source and version
36 * is for the file when parsing the #GS= AC tag which associates accessions with
37 * sequences. Database references are also not parsed correctly: a separate
38 * reference string parser must be added to parse the database reference form
39 * into Jalview's local representation.
41 * @author bsb at sanger.ac.uk
42 * @version 0.3 + jalview mods
45 public class StockholmFile extends AlignFile
47 // static Logger logger = Logger.getLogger("jalview.io.StockholmFile");
48 StringBuffer out; // output buffer
52 public StockholmFile()
57 * Creates a new StockholmFile object for output.
59 public StockholmFile(AlignmentI al)
64 public StockholmFile(String inFile, String type) throws IOException
69 public StockholmFile(FileParse source) throws IOException
74 public void initData()
80 * Parse a file in Stockholm format into Jalview's data model. The file has to
81 * be passed at construction time
84 * If there is an error with the input file
86 public void parse() throws IOException
88 StringBuffer treeString = new StringBuffer();
89 String treeName = null;
90 // --------------- Variable Definitions -------------------
94 Hashtable seqAnn = new Hashtable(); // Sequence related annotations
95 Hashtable seqs = new Hashtable();
96 Regex p, r, rend, s, x;
98 // Temporary line for processing RNA annotation
99 // String RNAannot = "";
101 // ------------------ Parsing File ----------------------
102 // First, we have to check that this file has STOCKHOLM format, i.e. the
103 // first line must match
104 r = new Regex("# STOCKHOLM ([\\d\\.]+)");
105 if (!r.search(nextLine()))
107 throw new IOException(
108 "This file is not in valid STOCKHOLM format: First line does not contain '# STOCKHOLM'");
112 version = r.stringMatched(1);
113 // logger.debug("Stockholm version: " + version);
116 // We define some Regexes here that will be used regularily later
117 rend = new Regex("^\\s*\\/\\/"); // Find the end of an alignment
118 p = new Regex("(\\S+)\\/(\\d+)\\-(\\d+)"); // split sequence id in
120 s = new Regex("(\\S+)\\s+(\\S*)\\s+(.*)"); // Parses annotation subtype
121 r = new Regex("#=(G[FSRC]?)\\s+(.*)"); // Finds any annotation line
122 x = new Regex("(\\S+)\\s+(\\S+)"); // split id from sequence
124 // Convert all bracket types to parentheses (necessary for passing to VARNA)
125 Regex openparen = new Regex("(<|\\[)", "(");
126 Regex closeparen = new Regex("(>|\\])", ")");
128 // Detect if file is RNA by looking for bracket types
129 Regex detectbrackets = new Regex("(<|>|\\[|\\]|\\(|\\))");
136 openparen.optimize();
137 closeparen.optimize();
139 while ((line = nextLine()) != null)
141 if (line.length() == 0)
145 if (rend.search(line))
147 // End of the alignment, pass stuff back
148 this.noSeqs = seqs.size();
150 String seqdb,dbsource = null;
151 Regex pf = new Regex("PF[0-9]{5}(.*)"); // Finds AC for Pfam
152 Regex rf = new Regex("RF[0-9]{5}(.*)"); // Finds AC for Rfam
153 if (getAlignmentProperty("AC") != null)
155 String dbType = getAlignmentProperty("AC").toString();
156 if (pf.search(dbType))
158 // PFAM Alignment - so references are typically from Uniprot
161 else if (rf.search(dbType))
166 // logger.debug("Number of sequences: " + this.noSeqs);
167 Enumeration accs = seqs.keys();
168 while (accs.hasMoreElements())
170 String acc = (String) accs.nextElement();
171 // logger.debug("Processing sequence " + acc);
172 String seq = (String) seqs.remove(acc);
173 if (maxLength < seq.length())
175 maxLength = seq.length();
181 * Retrieve hash of annotations for this accession Associate
182 * Annotation with accession
184 Hashtable accAnnotations = null;
186 if (seqAnn != null && seqAnn.containsKey(acc))
188 accAnnotations = (Hashtable) seqAnn.remove(acc);
189 // TODO: add structures to sequence
192 // Split accession in id and from/to
195 sid = p.stringMatched(1);
196 start = Integer.parseInt(p.stringMatched(2));
197 end = Integer.parseInt(p.stringMatched(3));
199 // logger.debug(sid + ", " + start + ", " + end);
201 Sequence seqO = new Sequence(sid, seq, start, end);
202 // Add Description (if any)
203 if (accAnnotations != null && accAnnotations.containsKey("DE"))
205 String desc = (String) accAnnotations.get("DE");
206 seqO.setDescription((desc == null) ? "" : desc);
209 // Add DB References (if any)
210 if (accAnnotations != null && accAnnotations.containsKey("DR"))
212 String dbr = (String) accAnnotations.get("DR");
213 if (dbr != null && dbr.indexOf(";") > -1)
215 String src = dbr.substring(0, dbr.indexOf(";"));
216 String acn = dbr.substring(dbr.indexOf(";") + 1);
217 jalview.util.DBRefUtils.parseToDbRef(seqO, src, "0", acn);
221 if (accAnnotations != null && accAnnotations.containsKey("AC"))
223 if (dbsource != null)
225 String dbr = (String) accAnnotations.get("AC");
228 // we could get very clever here - but for now - just try to guess accession type from source of alignment plus structure of accession
229 guessDatabaseFor(seqO, dbr, dbsource);
233 // else - do what ? add the data anyway and prompt the user to specify what references these are ?
236 Hashtable features = null;
237 // We need to adjust the positions of all features to account for gaps
240 features = (Hashtable) accAnnotations.remove("features");
241 } catch (java.lang.NullPointerException e)
243 // loggerwarn("Getting Features for " + acc + ": " +
247 // if we have features
248 if (features != null)
250 int posmap[] = seqO.findPositionMap();
251 Enumeration i = features.keys();
252 while (i.hasMoreElements())
254 // TODO: parse out secondary structure annotation as annotation
256 // TODO: parse out scores as annotation row
257 // TODO: map coding region to core jalview feature types
258 String type = i.nextElement().toString();
259 Hashtable content = (Hashtable) features.remove(type);
261 // add alignment annotation for this feature
262 String key = type2id(type);
265 if (accAnnotations != null
266 && accAnnotations.containsKey(key))
268 Vector vv = (Vector) accAnnotations.get(key);
269 for (int ii = 0; ii < vv.size(); ii++)
271 AlignmentAnnotation an = (AlignmentAnnotation) vv
273 seqO.addAlignmentAnnotation(an);
278 Enumeration j = content.keys();
279 while (j.hasMoreElements())
281 String desc = j.nextElement().toString();
282 String ns = content.get(desc).toString();
283 char[] byChar = ns.toCharArray();
284 for (int k = 0; k < byChar.length; k++)
287 if (!(c == ' ' || c == '_' || c == '-' || c == '.')) // PFAM
294 int new_pos = posmap[k]; // look up nearest seqeunce
295 // position to this column
296 SequenceFeature feat = new SequenceFeature(type, desc,
297 new_pos, new_pos, 0f, null);
299 seqO.addSequenceFeature(feat);
309 // logger.debug("Adding seq " + acc + " from " + start + " to " + end
311 this.seqs.addElement(seqO);
313 return; // finished parsing this segment of source
315 else if (!r.search(line))
317 // System.err.println("Found sequence line: " + line);
319 // Split sequence in sequence and accession parts
322 // logger.error("Could not parse sequence line: " + line);
323 throw new IOException("Could not parse sequence line: " + line);
325 String ns = (String) seqs.get(x.stringMatched(1));
330 ns += x.stringMatched(2);
332 seqs.put(x.stringMatched(1), ns);
336 String annType = r.stringMatched(1);
337 String annContent = r.stringMatched(2);
339 // System.err.println("type:" + annType + " content: " + annContent);
341 if (annType.equals("GF"))
344 * Generic per-File annotation, free text Magic features: #=GF NH
345 * <tree in New Hampshire eXtended format> #=GF TN <Unique identifier
346 * for the next tree> Pfam descriptions: 7. DESCRIPTION OF FIELDS
348 * Compulsory fields: ------------------
350 * AC Accession number: Accession number in form PFxxxxx.version or
351 * PBxxxxxx. ID Identification: One word name for family. DE
352 * Definition: Short description of family. AU Author: Authors of the
353 * entry. SE Source of seed: The source suggesting the seed members
354 * belong to one family. GA Gathering method: Search threshold to
355 * build the full alignment. TC Trusted Cutoff: Lowest sequence score
356 * and domain score of match in the full alignment. NC Noise Cutoff:
357 * Highest sequence score and domain score of match not in full
358 * alignment. TP Type: Type of family -- presently Family, Domain,
359 * Motif or Repeat. SQ Sequence: Number of sequences in alignment. AM
360 * Alignment Method The order ls and fs hits are aligned to the model
361 * to build the full align. // End of alignment.
363 * Optional fields: ----------------
365 * DC Database Comment: Comment about database reference. DR Database
366 * Reference: Reference to external database. RC Reference Comment:
367 * Comment about literature reference. RN Reference Number: Reference
368 * Number. RM Reference Medline: Eight digit medline UI number. RT
369 * Reference Title: Reference Title. RA Reference Author: Reference
370 * Author RL Reference Location: Journal location. PI Previous
371 * identifier: Record of all previous ID lines. KW Keywords: Keywords.
372 * CC Comment: Comments. NE Pfam accession: Indicates a nested domain.
373 * NL Location: Location of nested domains - sequence ID, start and
376 * Obsolete fields: ----------- AL Alignment method of seed: The
377 * method used to align the seed members.
379 // Let's save the annotations, maybe we'll be able to do something
380 // with them later...
381 Regex an = new Regex("(\\w+)\\s*(.*)");
382 if (an.search(annContent))
384 if (an.stringMatched(1).equals("NH"))
386 treeString.append(an.stringMatched(2));
388 else if (an.stringMatched(1).equals("TN"))
390 if (treeString.length() > 0)
392 if (treeName == null)
394 treeName = "Tree " + (getTreeCount() + 1);
396 addNewickTree(treeName, treeString.toString());
398 treeName = an.stringMatched(2);
399 treeString = new StringBuffer();
401 setAlignmentProperty(an.stringMatched(1), an.stringMatched(2));
404 else if (annType.equals("GS"))
406 // Generic per-Sequence annotation, free text
408 * Pfam uses these features: Feature Description ---------------------
409 * ----------- AC <accession> ACcession number DE <freetext>
410 * DEscription DR <db>; <accession>; Database Reference OS <organism>
411 * OrganiSm (species) OC <clade> Organism Classification (clade, etc.)
412 * LO <look> Look (Color, etc.)
414 if (s.search(annContent))
416 String acc = s.stringMatched(1);
417 String type = s.stringMatched(2);
418 String content = s.stringMatched(3);
419 // TODO: store DR in a vector.
420 // TODO: store AC according to generic file db annotation.
422 if (seqAnn.containsKey(acc))
424 ann = (Hashtable) seqAnn.get(acc);
428 ann = new Hashtable();
430 ann.put(type, content);
431 seqAnn.put(acc, ann);
435 throw new IOException("Error parsing " + line);
438 else if (annType.equals("GC"))
440 // Generic per-Column annotation, exactly 1 char per column
441 // always need a label.
442 if (x.search(annContent))
444 // parse out and create alignment annotation directly.
445 parseAnnotationRow(annotations, x.stringMatched(1),
449 else if (annType.equals("GR"))
451 // Generic per-Sequence AND per-Column markup, exactly 1 char per
454 * Feature Description Markup letters ------- -----------
455 * -------------- SS Secondary Structure [HGIEBTSCX] SA Surface
456 * Accessibility [0-9X] (0=0%-10%; ...; 9=90%-100%) TM TransMembrane
457 * [Mio] PP Posterior Probability [0-9*] (0=0.00-0.05; 1=0.05-0.15;
458 * *=0.95-1.00) LI LIgand binding [*] AS Active Site [*] IN INtron (in
461 if (s.search(annContent))
463 String acc = s.stringMatched(1);
464 String type = s.stringMatched(2);
465 String seq = new String(s.stringMatched(3));
466 String description = null;
467 // Check for additional information about the current annotation
468 // We use a simple string tokenizer here for speed
469 StringTokenizer sep = new StringTokenizer(seq, " \t");
470 description = sep.nextToken();
471 if (sep.hasMoreTokens())
473 seq = sep.nextToken();
478 description = new String();
480 // sequence id with from-to fields
483 // Get an object with all the annotations for this sequence
484 if (seqAnn.containsKey(acc))
486 // logger.debug("Found annotations for " + acc);
487 ann = (Hashtable) seqAnn.get(acc);
491 // logger.debug("Creating new annotations holder for " + acc);
492 ann = new Hashtable();
493 seqAnn.put(acc, ann);
495 // TODO test structure, call parseAnnotationRow with vector from
496 // hashtable for specific sequence
498 // Get an object with all the content for an annotation
499 if (ann.containsKey("features"))
501 // logger.debug("Found features for " + acc);
502 features = (Hashtable) ann.get("features");
506 // logger.debug("Creating new features holder for " + acc);
507 features = new Hashtable();
508 ann.put("features", features);
512 if (features.containsKey(this.id2type(type)))
514 // logger.debug("Found content for " + this.id2type(type));
515 content = (Hashtable) features.get(this.id2type(type));
519 // logger.debug("Creating new content holder for " +
520 // this.id2type(type));
521 content = new Hashtable();
522 features.put(this.id2type(type), content);
524 String ns = (String) content.get(description);
530 content.put(description, ns);
532 if (seqAnn.containsKey(acc))
534 strucAnn = (Hashtable) seqAnn.get(acc);
538 strucAnn = new Hashtable();
541 Vector newStruc = new Vector();
542 parseAnnotationRow(newStruc, type, ns);
543 strucAnn.put(type, newStruc);
544 seqAnn.put(acc, strucAnn);
549 .println("Warning - couldn't parse sequence annotation row line:\n"
551 // throw new IOException("Error parsing " + line);
556 throw new IOException("Unknown annotation detected: " + annType
561 if (treeString.length() > 0)
563 if (treeName == null)
565 treeName = "Tree " + (1 + getTreeCount());
567 addNewickTree(treeName, treeString.toString());
572 * Demangle an accession string and guess the originating sequence database for a given sequence
573 * @param seqO sequence to be annotated
574 * @param dbr Accession string for sequence
575 * @param dbsource source database for alignment (PFAM or RFAM)
577 private void guessDatabaseFor(Sequence seqO, String dbr, String dbsource)
579 DBRefEntry dbrf=null;
580 List<DBRefEntry> dbrs=new ArrayList<DBRefEntry>();
581 String seqdb="Unknown",sdbac=""+dbr;
583 if ((st=sdbac.indexOf("/"))>-1)
585 String num,range=sdbac.substring(st+1);
586 sdbac = sdbac.substring(0,st);
587 if ((p=range.indexOf("-"))>-1)
590 if (p<range.length())
592 num = range.substring(p).trim();
594 en = Integer.parseInt(num);
595 } catch (NumberFormatException x)
597 // could warn here that index is invalid
604 num=range.substring(0,p).trim();
606 st = Integer.parseInt(num);
607 } catch (NumberFormatException x)
609 // could warn here that index is invalid
613 if (dbsource.equals("PFAM")) {
615 if (sdbac.indexOf(".")>-1)
617 // strip of last subdomain
618 sdbac = sdbac.substring(0,sdbac.indexOf("."));
619 dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, seqdb, dbsource, sdbac);
625 dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, dbsource, dbsource, dbr);
631 seqdb = "EMBL"; // total guess - could be ENA, or something else these days
632 if (sdbac.indexOf(".")>-1)
634 // strip off last subdomain
635 sdbac = sdbac.substring(0,sdbac.indexOf("."));
636 dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, seqdb, dbsource, sdbac);
643 dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, dbsource, dbsource, dbr);
649 if (st!=-1 && en!=-1)
651 for (DBRefEntry d:dbrs)
653 jalview.util.MapList mp = new jalview.util.MapList(new int[] { seqO.getStart(),seqO.getEnd()},new int[] { st,en},1,1);
654 jalview.datamodel.Mapping mping = new Mapping(mp);
660 protected static AlignmentAnnotation parseAnnotationRow(
661 Vector annotation, String label, String annots)
663 String convert1, convert2 = null;
665 // Convert all bracket types to parentheses
666 Regex openparen = new Regex("(<|\\[)", "(");
667 Regex closeparen = new Regex("(>|\\])", ")");
669 // Detect if file is RNA by looking for bracket types
670 Regex detectbrackets = new Regex("(<|>|\\[|\\]|\\(|\\))");
672 convert1 = openparen.replaceAll(annots);
673 convert2 = closeparen.replaceAll(convert1);
677 if (label.contains("_cons"))
679 type = (label.indexOf("_cons") == label.length() - 5) ? label
680 .substring(0, label.length() - 5) : label;
683 type = id2type(type);
684 if (type.equals("secondary structure"))
688 // decide on secondary structure or not.
689 Annotation[] els = new Annotation[annots.length()];
690 for (int i = 0; i < annots.length(); i++)
692 String pos = annots.substring(i, i + 1);
694 ann = new Annotation(pos, "", ' ', 0f); // 0f is 'valid' null - will not
698 if (detectbrackets.search(pos))
700 ann.secondaryStructure = jalview.schemes.ResidueProperties
701 .getRNASecStrucState(pos).charAt(0);
705 ann.secondaryStructure = jalview.schemes.ResidueProperties
706 .getDssp3state(pos).charAt(0);
709 if (ann.secondaryStructure == pos.charAt(0) || pos.charAt(0) == 'C')
711 ann.displayCharacter = ""; // null; // " ";
715 ann.displayCharacter = " " + ann.displayCharacter;
721 AlignmentAnnotation annot = null;
722 Enumeration e = annotation.elements();
723 while (e.hasMoreElements())
725 annot = (AlignmentAnnotation) e.nextElement();
726 if (annot.label.equals(type))
732 annot = new AlignmentAnnotation(type, type, els);
733 annotation.addElement(annot);
737 Annotation[] anns = new Annotation[annot.annotations.length
739 System.arraycopy(annot.annotations, 0, anns, 0,
740 annot.annotations.length);
741 System.arraycopy(els, 0, anns, annot.annotations.length, els.length);
742 annot.annotations = anns;
743 // System.out.println("else: ");
748 public String print(SequenceI[] s)
750 // find max length of id
754 Hashtable dataRef = null;
755 while ((in < s.length) && (s[in] != null))
757 String tmp = printId(s[in]);
758 if (s[in].getSequence().length > max)
760 max = s[in].getSequence().length;
763 if (tmp.length() > maxid)
765 maxid = tmp.length();
767 if (s[in].getDBRef() != null)
769 for (int idb = 0; idb < s[in].getDBRef().length; idb++)
772 dataRef = new Hashtable();
774 String datAs1 = s[in].getDBRef()[idb].getSource().toString()
776 + s[in].getDBRef()[idb].getAccessionId().toString();
777 dataRef.put(tmp, datAs1);
785 // output database type
786 if (al.getProperties() != null)
788 if (!al.getProperties().isEmpty())
790 Enumeration key = al.getProperties().keys();
791 Enumeration val = al.getProperties().elements();
792 while (key.hasMoreElements())
794 out.append("#=GF " + key.nextElement() + " " + val.nextElement());
800 // output database accessions
803 Enumeration en = dataRef.keys();
804 while (en.hasMoreElements())
806 Object idd = en.nextElement();
807 String type = (String) dataRef.remove(idd);
808 out.append(new Format("%-" + (maxid - 2) + "s").form("#=GS "
809 + idd.toString() + " "));
810 if (type.contains("PFAM") || type.contains("RFAM"))
813 out.append(" AC " + type.substring(type.indexOf(";") + 1));
817 out.append(" DR " + type + " ");
823 // output annotations
824 while (i < s.length && s[i] != null)
826 if (s[i].getDatasetSequence() != null)
828 SequenceI ds = s[i].getDatasetSequence();
829 AlignmentAnnotation[] alAnot;
832 alAnot = s[i].getAnnotation();
836 for (int j = 0; j < alAnot.length; j++)
838 if (ds.getSequenceFeatures() != null)
840 feature = ds.getSequenceFeatures()[0].type;
842 String key = type2id(feature);
847 // out.append("#=GR ");
848 out.append(new Format("%-" + maxid + "s").form("#=GR "
849 + printId(s[i]) + " " + key + " "));
850 ann = alAnot[j].annotations;
852 for (int k = 0; k < ann.length; k++)
855 String ch = (annot == null) ? Character.toString(s[i]
856 .getCharAt(k)) : annot.displayCharacter;
857 if (ch.length() == 0)
859 if (key.equals("SS"))
861 char ll = annot.secondaryStructure;
862 seq = (Character.toString(ll).equals(" ")) ? seq + "C"
870 else if (ch.length() == 1)
874 else if (ch.length() > 1)
885 out.append(new Format("%-" + maxid + "s").form(printId(s[i]) + " "));
886 out.append(s[i].getSequenceAsString());
891 // alignment annotation
892 AlignmentAnnotation aa;
893 if (al.getAlignmentAnnotation() != null)
895 for (int ia = 0; ia < al.getAlignmentAnnotation().length; ia++)
897 aa = al.getAlignmentAnnotation()[ia];
898 if (aa.autoCalculated || !aa.visible)
905 if (aa.label.equals("seq"))
908 label = type2id(aa.label.toLowerCase()) + "_cons";
913 out.append(new Format("%-" + maxid + "s").form("#=GC " + label
915 for (int j = 0; j < aa.annotations.length; j++)
917 String ch = (aa.annotations[j] == null) ? "-"
918 : aa.annotations[j].displayCharacter;
919 if (ch.length() == 0)
921 char ll = aa.annotations[j].secondaryStructure;
922 if (Character.toString(ll).equals(" "))
927 else if (ch.length() == 1)
931 else if (ch.length() > 1)
940 return out.toString();
943 public String print()
945 out = new StringBuffer();
946 out.append("# STOCKHOLM 1.0");
948 print(getSeqsAsArray());
952 return out.toString();
955 private static Hashtable typeIds = null;
960 typeIds = new Hashtable();
961 typeIds.put("SS", "secondary structure");
962 typeIds.put("SA", "surface accessibility");
963 typeIds.put("TM", "transmembrane");
964 typeIds.put("PP", "posterior probability");
965 typeIds.put("LI", "ligand binding");
966 typeIds.put("AS", "active site");
967 typeIds.put("IN", "intron");
968 typeIds.put("IR", "interacting residue");
969 typeIds.put("AC", "accession");
970 typeIds.put("OS", "organism");
971 typeIds.put("CL", "class");
972 typeIds.put("DE", "description");
973 typeIds.put("DR", "reference");
974 typeIds.put("LO", "look");
975 typeIds.put("RF", "reference positions");
980 protected static String id2type(String id)
982 if (typeIds.containsKey(id))
984 return (String) typeIds.get(id);
986 System.err.println("Warning : Unknown Stockholm annotation type code "
991 protected static String type2id(String type)
994 Enumeration e = typeIds.keys();
995 while (e.hasMoreElements())
997 Object ll = e.nextElement();
998 if (typeIds.get(ll).toString().equals(type))
1006 return (String) key;
1008 System.err.println("Warning : Unknown Stockholm annotation type: "
1013 * //ssline is complete secondary structure line private AlignmentAnnotation
1014 * addHelices(Vector annotation, String label, String ssline) {
1016 * // decide on secondary structure or not. Annotation[] els = new
1017 * Annotation[ssline.length()]; for (int i = 0; i < ssline.length(); i++) {
1018 * String pos = ssline.substring(i, i + 1); Annotation ann; ann = new
1019 * Annotation(pos, "", ' ', 0f); // 0f is 'valid' null - will not
1021 * ann.secondaryStructure =
1022 * jalview.schemes.ResidueProperties.getRNAssState(pos).charAt(0);
1024 * ann.displayCharacter = "x" + ann.displayCharacter;
1026 * System.out.println(ann.displayCharacter);
1028 * els[i] = ann; } AlignmentAnnotation helicesAnnot = null; Enumeration e =
1029 * annotation.elements(); while (e.hasMoreElements()) { helicesAnnot =
1030 * (AlignmentAnnotation) e.nextElement(); if (helicesAnnot.label.equals(type))
1031 * break; helicesAnnot = null; } if (helicesAnnot == null) { helicesAnnot =
1032 * new AlignmentAnnotation(type, type, els);
1033 * annotation.addElement(helicesAnnot); } else { Annotation[] anns = new
1034 * Annotation[helicesAnnot.annotations.length + els.length];
1035 * System.arraycopy(helicesAnnot.annotations, 0, anns, 0,
1036 * helicesAnnot.annotations.length); System.arraycopy(els, 0, anns,
1037 * helicesAnnot.annotations.length, els.length); helicesAnnot.annotations =
1040 * helicesAnnot.features = Rna.GetBasePairs(ssline);
1041 * Rna.HelixMap(helicesAnnot.features);
1044 * return helicesAnnot; }