JAL-1807 still testing
[jalviewjs.git] / bin / jalview / io / AnnotationFile.js
index 4c4c01e..a707ee4 100644 (file)
-Clazz.declarePackage ("jalview.io");
-Clazz.load (null, "jalview.io.AnnotationFile", ["jalview.analysis.Conservation", "jalview.datamodel.AlignmentAnnotation", "$.Annotation", "$.ColumnSelection", "$.GraphLine", "$.SequenceGroup", "jalview.io.AppletFormatAdapter", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.ColourSchemeProperty", "$.ResidueProperties", "$.UserColourScheme", "jalview.util.Comparison", "$.Format", "java.awt.Color", "java.io.BufferedReader", "$.InputStreamReader", "$.StringReader", "java.lang.Boolean", "$.Float", "$.StringBuffer", "java.util.ArrayList", "$.BitSet", "$.Date", "$.Hashtable", "$.StringTokenizer", "$.Vector"], function () {
-c$ = Clazz.decorateAsClass (function () {
-this.newline = null;
-this.text = null;
-if (!Clazz.isClassDefined ("jalview.io.AnnotationFile.ViewDef")) {
-jalview.io.AnnotationFile.$AnnotationFile$ViewDef$ ();
-}
-this.refSeq = null;
-this.refSeqId = null;
-this.nlinesread = 0;
-this.lastread = "";
-Clazz.instantialize (this, arguments);
-}, jalview.io, "AnnotationFile");
-Clazz.prepareFields (c$, function () {
-this.newline = System.getProperty ("line.separator");
-});
-Clazz.makeConstructor (c$, 
-function () {
-this.init ();
-});
-Clazz.defineMethod (c$, "setNewlineString", 
-function (nl) {
-this.newline = nl;
-this.init ();
-}, "~S");
-Clazz.defineMethod (c$, "getNewlineString", 
-function () {
-return this.newline;
-});
-Clazz.defineMethod (c$, "init", 
-($fz = function () {
-this.text =  new StringBuffer ("JALVIEW_ANNOTATION" + this.newline + "# Created: " +  new java.util.Date () + this.newline + this.newline);
-this.refSeq = null;
-this.refSeqId = null;
-}, $fz.isPrivate = true, $fz));
-Clazz.defineMethod (c$, "printAnnotations", 
-function (annotations, list, properties) {
-return this.printAnnotations (annotations, list, properties, null, null, null);
-}, "~A,java.util.List,java.util.Hashtable");
-Clazz.defineMethod (c$, "printAnnotations", 
-function (annotations, list, properties, cs, al, view) {
-if (view != null) {
-if (view.viewname != null) {
-this.text.append ("VIEW_DEF\t" + view.viewname + "\n");
-}if (list == null) {
-list = view.visibleGroups;
-}if (cs == null) {
-cs = view.hiddencols;
-}if (al == null) {
-}}if (al != null && al.hasSeqrep ()) {
-this.text.append ("VIEW_SETREF\t" + al.getSeqrep ().getName () + "\n");
-}if (cs != null && cs.hasHiddenColumns ()) {
-this.text.append ("VIEW_HIDECOLS\t");
-var hc = cs.getHiddenColumns ();
-var comma = false;
-for (var r, $r = hc.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) {
-if (!comma) {
-comma = true;
-} else {
-this.text.append (",");
-}this.text.append ("" + r[0]);
-this.text.append ("-");
-this.text.append ("" + r[1]);
-}
-this.text.append ("\n");
-}if (annotations != null) {
-var oneColour = true;
-var row;
-var comma;
-var refSeq = null;
-var refGroup = null;
-var colours =  new StringBuffer ();
-var graphLine =  new StringBuffer ();
-var rowprops =  new StringBuffer ();
-var graphGroup =  new java.util.Hashtable ();
-var graphGroup_refs =  new java.util.Hashtable ();
-var graphGroupSeen =  new java.util.BitSet ();
-var color;
-for (var i = 0; i < annotations.length; i++) {
-row = annotations[i];
-if (!row.visible && !row.hasScore () && !(row.graphGroup > -1 && graphGroupSeen.get (row.graphGroup))) {
-continue;
-}color = null;
-oneColour = true;
-this.writeSequence_Ref (refSeq, row.sequenceRef);
-refSeq = row.sequenceRef;
-this.writeGroup_Ref (refGroup, row.groupRef);
-refGroup = row.groupRef;
-var hasGlyphs = row.hasIcons;
-var hasLabels = row.hasText;
-var hasValues = row.$hasScore;
-var hasText = false;
-for (var j = 0; row.annotations != null && j < row.annotations.length && (!hasGlyphs || !hasLabels || !hasValues); j++) {
-if (row.annotations[j] != null) {
-hasLabels = new Boolean (hasLabels | (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length > 0 && !row.annotations[j].displayCharacter.equals (" "))).valueOf ();
-hasGlyphs = new Boolean (hasGlyphs | ((row.annotations[j].secondaryStructure).charCodeAt (0) != 0 && row.annotations[j].secondaryStructure != ' ')).valueOf ();
-hasValues = new Boolean (hasValues | (!Float.isNaN (row.annotations[j].value))).valueOf ();
-hasText = new Boolean (hasText | (row.annotations[j].description != null && row.annotations[j].description.length > 0)).valueOf ();
-}}
-if (row.graph == 0) {
-this.text.append ("NO_GRAPH\t");
-hasValues = false;
-} else {
-if (row.graph == 1) {
-this.text.append ("BAR_GRAPH\t");
-hasGlyphs = false;
-} else if (row.graph == 2) {
-hasGlyphs = false;
-this.text.append ("LINE_GRAPH\t");
-}if (row.getThreshold () != null) {
-graphLine.append ("GRAPHLINE\t");
-graphLine.append (row.label);
-graphLine.append ("\t");
-graphLine.append (row.getThreshold ().value);
-graphLine.append ("\t");
-graphLine.append (row.getThreshold ().label);
-graphLine.append ("\t");
-graphLine.append (jalview.util.Format.getHexString (row.getThreshold ().colour));
-graphLine.append (this.newline);
-}if (row.graphGroup > -1) {
-graphGroupSeen.set (row.graphGroup);
-var key =  new Integer (row.graphGroup);
-if (graphGroup.containsKey (key)) {
-graphGroup.put (key, graphGroup.get (key) + "\t" + row.label);
-} else {
-graphGroup_refs.put (key,  Clazz.newArray (-1, [refSeq, refGroup]));
-graphGroup.put (key, row.label);
-}}}this.text.append (row.label + "\t");
-if (row.description != null) {
-this.text.append (row.description + "\t");
-}for (var j = 0; row.annotations != null && j < row.annotations.length; j++) {
-if (refSeq != null && jalview.util.Comparison.isGap (refSeq.getCharAt (j))) {
-continue;
-}if (row.annotations[j] != null) {
-comma = "";
-if (hasGlyphs) {
-this.text.append (comma);
-if (row.annotations[j].secondaryStructure != ' ') {
-this.text.append (row.annotations[j].secondaryStructure);
-}comma = ",";
-}if (hasValues) {
-if (!Float.isNaN (row.annotations[j].value)) {
-this.text.append (comma + row.annotations[j].value);
-} else {
-System.err.println ("Skipping NaN - not valid value.");
-this.text.append (comma + 0);
-}comma = ",";
-}if (hasLabels) {
-if (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length > 0 && !row.annotations[j].displayCharacter.equals (" ")) {
-this.text.append (comma + row.annotations[j].displayCharacter);
-comma = ",";
-}}if (hasText) {
-if (row.annotations[j].description != null && row.annotations[j].description.length > 0 && !row.annotations[j].description.equals (row.annotations[j].displayCharacter)) {
-this.text.append (comma + row.annotations[j].description);
-comma = ",";
-}}if (color != null && !color.equals (row.annotations[j].colour)) {
-oneColour = false;
-}color = row.annotations[j].colour;
-if (row.annotations[j].colour != null && row.annotations[j].colour !== java.awt.Color.black) {
-this.text.append (comma + "[" + jalview.util.Format.getHexString (row.annotations[j].colour) + "]");
-comma = ",";
-}}this.text.append ("|");
-}
-if (row.hasScore ()) {
-this.text.append ("\t" + row.score);
-}this.text.append (this.newline);
-if (color != null && color !== java.awt.Color.black && oneColour) {
-colours.append ("COLOUR\t");
-colours.append (row.label);
-colours.append ("\t");
-colours.append (jalview.util.Format.getHexString (color));
-colours.append (this.newline);
-}if (row.scaleColLabel || row.showAllColLabels || row.centreColLabels) {
-rowprops.append ("ROWPROPERTIES\t");
-rowprops.append (row.label);
-rowprops.append ("\tscaletofit=");
-rowprops.append (row.scaleColLabel);
-rowprops.append ("\tshowalllabs=");
-rowprops.append (row.showAllColLabels);
-rowprops.append ("\tcentrelabs=");
-rowprops.append (row.centreColLabels);
-rowprops.append (this.newline);
-}if (graphLine.length () > 0) {
-this.text.append (graphLine.toString ());
-graphLine.setLength (0);
-}}
-this.text.append (this.newline);
-this.text.append (colours.toString ());
-if (graphGroup.size () > 0) {
-var oldRefSeq = refSeq;
-var oldRefGroup = refGroup;
-for (var combine_statement, $combine_statement = graphGroup.entrySet ().iterator (); $combine_statement.hasNext () && ((combine_statement = $combine_statement.next ()) || true);) {
-var seqRefAndGroup = graphGroup_refs.get (combine_statement.getKey ());
-this.writeSequence_Ref (refSeq, seqRefAndGroup[0]);
-refSeq = seqRefAndGroup[0];
-this.writeGroup_Ref (refGroup, seqRefAndGroup[1]);
-refGroup = seqRefAndGroup[1];
-this.text.append ("COMBINE\t");
-this.text.append (combine_statement.getValue ());
-this.text.append (this.newline);
-}
-this.writeSequence_Ref (refSeq, oldRefSeq);
-refSeq = oldRefSeq;
-this.writeGroup_Ref (refGroup, oldRefGroup);
-refGroup = oldRefGroup;
-}this.text.append (rowprops.toString ());
-}if (list != null) {
-this.printGroups (list);
-}if (properties != null) {
-this.text.append (this.newline);
-this.text.append (this.newline);
-this.text.append ("ALIGNMENT");
-var en = properties.keys ();
-while (en.hasMoreElements ()) {
-var key = en.nextElement ().toString ();
-this.text.append ("\t");
-this.text.append (key);
-this.text.append ("=");
-this.text.append (properties.get (key));
-}
-}return this.text.toString ();
-}, "~A,java.util.List,java.util.Hashtable,jalview.datamodel.ColumnSelection,jalview.datamodel.AlignmentI,jalview.io.AnnotationFile.ViewDef");
-Clazz.defineMethod (c$, "writeGroup_Ref", 
-($fz = function (refGroup, next_refGroup) {
-if (next_refGroup == null) {
-if (refGroup != null) {
-this.text.append (this.newline);
-this.text.append ("GROUP_REF\t");
-this.text.append ("ALIGNMENT");
-this.text.append (this.newline);
-}return true;
-} else {
-if (refGroup == null || refGroup !== next_refGroup) {
-this.text.append (this.newline);
-this.text.append ("GROUP_REF\t");
-this.text.append (next_refGroup.getName ());
-this.text.append (this.newline);
-return true;
-}}return false;
-}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceGroup,jalview.datamodel.SequenceGroup");
-Clazz.defineMethod (c$, "writeSequence_Ref", 
-($fz = function (refSeq, next_refSeq) {
-if (next_refSeq == null) {
-if (refSeq != null) {
-this.text.append (this.newline);
-this.text.append ("SEQUENCE_REF\t");
-this.text.append ("ALIGNMENT");
-this.text.append (this.newline);
-return true;
-}} else {
-if (refSeq == null || refSeq !== next_refSeq) {
-this.text.append (this.newline);
-this.text.append ("SEQUENCE_REF\t");
-this.text.append (next_refSeq.getName ());
-this.text.append (this.newline);
-return true;
-}}return false;
-}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI");
-Clazz.defineMethod (c$, "printGroups", 
-function (list) {
-var seqrep = null;
-for (var sg, $sg = list.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) {
-if (!sg.hasSeqrep ()) {
-this.text.append ("SEQUENCE_GROUP\t" + sg.getName () + "\t" + (sg.getStartRes () + 1) + "\t" + (sg.getEndRes () + 1) + "\t" + "-1\t");
-seqrep = null;
-} else {
-seqrep = sg.getSeqrep ();
-this.text.append ("SEQUENCE_REF\t");
-this.text.append (seqrep.getName ());
-this.text.append (this.newline);
-this.text.append ("SEQUENCE_GROUP\t");
-this.text.append (sg.getName ());
-this.text.append ("\t");
-this.text.append ("" + (seqrep.findPosition (sg.getStartRes ())));
-this.text.append ("\t");
-this.text.append ((seqrep.findPosition (sg.getEndRes ())));
-this.text.append ("\t");
-this.text.append ("-1\t");
-}for (var s = 0; s < sg.getSize (); s++) {
-this.text.append (sg.getSequenceAt (s).getName ());
-this.text.append ("\t");
-}
-this.text.append (this.newline);
-this.text.append ("PROPERTIES\t");
-this.text.append (sg.getName ());
-this.text.append ("\t");
-if (sg.getDescription () != null) {
-this.text.append ("description=");
-this.text.append (sg.getDescription ());
-this.text.append ("\t");
-}if (sg.cs != null) {
-this.text.append ("colour=");
-this.text.append (jalview.schemes.ColourSchemeProperty.getColourName (sg.cs));
-this.text.append ("\t");
-if (sg.cs.getThreshold () != 0) {
-this.text.append ("pidThreshold=");
-this.text.append (sg.cs.getThreshold ());
-}if (sg.cs.conservationApplied ()) {
-this.text.append ("consThreshold=");
-this.text.append (sg.cs.getConservationInc ());
-this.text.append ("\t");
-}}this.text.append ("outlineColour=");
-this.text.append (jalview.util.Format.getHexString (sg.getOutlineColour ()));
-this.text.append ("\t");
-this.text.append ("displayBoxes=");
-this.text.append (sg.getDisplayBoxes ());
-this.text.append ("\t");
-this.text.append ("displayText=");
-this.text.append (sg.getDisplayText ());
-this.text.append ("\t");
-this.text.append ("colourText=");
-this.text.append (sg.getColourText ());
-this.text.append ("\t");
-this.text.append ("showUnconserved=");
-this.text.append (sg.getShowNonconserved ());
-this.text.append ("\t");
-if (sg.textColour !== java.awt.Color.black) {
-this.text.append ("textCol1=");
-this.text.append (jalview.util.Format.getHexString (sg.textColour));
-this.text.append ("\t");
-}if (sg.textColour2 !== java.awt.Color.white) {
-this.text.append ("textCol2=");
-this.text.append (jalview.util.Format.getHexString (sg.textColour2));
-this.text.append ("\t");
-}if (sg.thresholdTextColour != 0) {
-this.text.append ("textColThreshold=");
-this.text.append (sg.thresholdTextColour);
-this.text.append ("\t");
-}if (sg.idColour != null) {
-this.text.append ("idColour=");
-this.text.append (jalview.util.Format.getHexString (sg.idColour));
-this.text.append ("\t");
-}if (sg.isHidereps ()) {
-this.text.append ("hide=true\t");
-}if (sg.isHideCols ()) {
-this.text.append ("hidecols=true\t");
-}if (seqrep != null) {
-this.text.append (this.newline);
-this.text.append ("SEQUENCE_REF");
-}this.text.append (this.newline);
-this.text.append (this.newline);
-}
-}, "java.util.List");
-Clazz.defineMethod (c$, "annotateAlignmentView", 
-function (viewport, file, protocol) {
-var colSel = viewport.getColumnSelection ();
-if (colSel == null) {
-colSel =  new jalview.datamodel.ColumnSelection ();
-}var rslt = this.readAnnotationFile (viewport.getAlignment (), colSel, file, protocol);
-if (rslt && (colSel.hasSelectedColumns () || colSel.hasHiddenColumns ())) {
-viewport.setColumnSelection (colSel);
-}return rslt;
-}, "jalview.api.AlignViewportI,~S,~S");
-Clazz.defineMethod (c$, "readAnnotationFile", 
-function (al, file, protocol) {
-return this.readAnnotationFile (al, null, file, protocol);
-}, "jalview.datamodel.AlignmentI,~S,~S");
-Clazz.defineMethod (c$, "readAnnotationFile", 
-function (al, colSel, file, protocol) {
-var $in = null;
-try {
-if (protocol.equals (jalview.io.AppletFormatAdapter.FILE)) {
-$in = jalview.jsdev.GenericFileAdapter.getReader (file, false);
-} else if (protocol.equals (jalview.io.AppletFormatAdapter.URL)) {
-$in = jalview.jsdev.GenericFileAdapter.getReader (file, true);
-} else if (protocol.equals (jalview.io.AppletFormatAdapter.PASTE)) {
-$in =  new java.io.BufferedReader ( new java.io.StringReader (file));
-} else if (protocol.equals (jalview.io.AppletFormatAdapter.CLASSLOADER)) {
-var is = this.getClass ().getResourceAsStream ("/" + file);
-if (is != null) {
-$in =  new java.io.BufferedReader ( new java.io.InputStreamReader (is));
-}}if ($in != null) {
-return this.parseAnnotationFrom (al, colSel, $in);
-}} catch (ex) {
-if (Clazz.exceptionOf (ex, Exception)) {
-ex.printStackTrace ();
-System.out.println ("Problem reading annotation file: " + ex);
-if (this.nlinesread > 0) {
-System.out.println ("Last read line " + this.nlinesread + ": '" + this.lastread + "' (first 80 chars) ...");
-}return false;
-} else {
-throw ex;
-}
-}
-return false;
-}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,~S,~S");
-Clazz.defineMethod (c$, "parseAnnotationFrom", 
-function (al, colSel, $in) {
-this.nlinesread = 0;
-var combineAnnotation_calls =  new java.util.ArrayList ();
-var deferredAnnotation_calls =  new java.util.ArrayList ();
-var modified = false;
-var groupRef = null;
-var groupRefRows =  new java.util.Hashtable ();
-var autoAnnots =  new java.util.Hashtable ();
-{
-var line;
-var label;
-var description;
-var token;
-var graphStyle;
-var index;
-var refSeqIndex = 1;
-var existingAnnotations = 0;
-var overrideAutoAnnot = false;
-if (al.getAlignmentAnnotation () != null) {
-existingAnnotations = al.getAlignmentAnnotation ().length;
-if (existingAnnotations > 0) {
-var aa = al.getAlignmentAnnotation ();
-for (var aai = 0; aai < aa.length; aai++) {
-if (aa[aai].autoCalculated) {
-autoAnnots.put (this.autoAnnotsKey (aa[aai], aa[aai].sequenceRef, (aa[aai].groupRef == null ? null : aa[aai].groupRef.getName ())),  new Integer (1));
-}}
-}}var alWidth = al.getWidth ();
-var st;
-var annotations;
-var annotation = null;
-var jvAnnotationFile = false;
-while ((line = $in.readLine ()) != null) {
-this.nlinesread++;
-this.lastread =  String.instantialize (line);
-if (line.indexOf ("#") == 0) {
-continue;
-}if (line.indexOf ("JALVIEW_ANNOTATION") > -1) {
-jvAnnotationFile = true;
-break;
-}}
-if (!jvAnnotationFile) {
-$in.close ();
-return false;
-}while ((line = $in.readLine ()) != null) {
-this.nlinesread++;
-this.lastread =  String.instantialize (line);
-if (line.indexOf ("#") == 0 || line.indexOf ("JALVIEW_ANNOTATION") > -1 || line.length == 0) {
-continue;
-}st =  new java.util.StringTokenizer (line, "\t");
-token = st.nextToken ();
-if (token.equalsIgnoreCase ("COLOUR")) {
-this.colourAnnotations (al, st.nextToken (), st.nextToken ());
-modified = true;
-continue;
-} else if (token.equalsIgnoreCase (jalview.io.AnnotationFile.COMBINE)) {
-combineAnnotation_calls.add ( Clazz.newArray (-1, [st, this.refSeq, groupRef]));
-modified = true;
-continue;
-} else if (token.equalsIgnoreCase ("ROWPROPERTIES")) {
-this.addRowProperties (al, st);
-modified = true;
-continue;
-} else if (token.equalsIgnoreCase (jalview.io.AnnotationFile.GRAPHLINE)) {
-deferredAnnotation_calls.add ( Clazz.newArray (-1, [jalview.io.AnnotationFile.GRAPHLINE, st, this.refSeq, groupRef]));
-modified = true;
-continue;
-} else if (token.equalsIgnoreCase ("SEQUENCE_REF")) {
-if (st.hasMoreTokens ()) {
-this.refSeq = al.findName (this.refSeqId = st.nextToken ());
-if (this.refSeq == null) {
-this.refSeqId = null;
-}try {
-refSeqIndex = Integer.parseInt (st.nextToken ());
-if (refSeqIndex < 1) {
-refSeqIndex = 1;
-System.out.println ("WARNING: SEQUENCE_REF index must be > 0 in AnnotationFile");
-}} catch (ex) {
-if (Clazz.exceptionOf (ex, Exception)) {
-refSeqIndex = 1;
-} else {
-throw ex;
-}
-}
-} else {
-this.refSeq = null;
-this.refSeqId = null;
-}continue;
-} else if (token.equalsIgnoreCase ("GROUP_REF")) {
-groupRef = null;
-if (st.hasMoreTokens ()) {
-groupRef = st.nextToken ();
-if (groupRef.length < 1) {
-groupRef = null;
-} else {
-if (groupRefRows.get (groupRef) == null) {
-groupRefRows.put (groupRef,  new java.util.Vector ());
-}}}continue;
-} else if (token.equalsIgnoreCase ("SEQUENCE_GROUP")) {
-this.addGroup (al, st);
-modified = true;
-continue;
-} else if (token.equalsIgnoreCase ("PROPERTIES")) {
-this.addProperties (al, st);
-modified = true;
-continue;
-} else if (token.equalsIgnoreCase ("BELOW_ALIGNMENT")) {
-this.setBelowAlignment (al, st);
-modified = true;
-continue;
-} else if (token.equalsIgnoreCase ("ALIGNMENT")) {
-this.addAlignmentDetails (al, st);
-modified = true;
-continue;
-} else if (token.equalsIgnoreCase ("VIEW_SETREF")) {
-if (this.refSeq != null) {
-al.setSeqrep (this.refSeq);
-}modified = true;
-continue;
-} else if (token.equalsIgnoreCase ("VIEW_HIDECOLS")) {
-if (st.hasMoreTokens ()) {
-if (colSel == null) {
-colSel =  new jalview.datamodel.ColumnSelection ();
-}this.parseHideCols (colSel, st.nextToken ());
-}modified = true;
-continue;
-} else if (token.equalsIgnoreCase ("HIDE_INSERTIONS")) {
-var sr = this.refSeq == null ? al.getSeqrep () : this.refSeq;
-if (sr == null) {
-sr = al.getSequenceAt (0);
-}if (sr != null) {
-if (colSel == null) {
-System.err.println ("Cannot process HIDE_INSERTIONS without an alignment view: Ignoring line: " + line);
-} else {
-colSel.hideInsertionsFor (sr);
-}}modified = true;
-continue;
-}graphStyle = jalview.datamodel.AlignmentAnnotation.getGraphValueFromString (token);
-label = st.nextToken ();
-index = 0;
-annotations =  new Array (alWidth);
-description = null;
-var score = NaN;
-if (st.hasMoreTokens ()) {
-line = st.nextToken ();
-if (line.indexOf ("|") == -1) {
-description = line;
-if (st.hasMoreTokens ()) {
-line = st.nextToken ();
-}}if (st.hasMoreTokens ()) {
-score = Float.$valueOf (st.nextToken ()).floatValue ();
-}st =  new java.util.StringTokenizer (line, "|", true);
-var emptyColumn = true;
-var onlyOneElement = (st.countTokens () == 1);
-while (st.hasMoreElements () && index < alWidth) {
-token = st.nextToken ().trim ();
-if (onlyOneElement) {
-try {
-score = Float.$valueOf (token).floatValue ();
-break;
-} catch (ex) {
-if (Clazz.exceptionOf (ex, NumberFormatException)) {
-} else {
-throw ex;
-}
-}
-}if (token.equals ("|")) {
-if (emptyColumn) {
-index++;
-}emptyColumn = true;
-} else {
-annotations[index++] = this.parseAnnotation (token, graphStyle);
-emptyColumn = false;
-}}
-}annotation =  new jalview.datamodel.AlignmentAnnotation (label, description, (index == 0) ? null : annotations, 0, 0, graphStyle);
-annotation.score = score;
-if (!overrideAutoAnnot && autoAnnots.containsKey (this.autoAnnotsKey (annotation, this.refSeq, groupRef))) {
-continue;
-}if (this.refSeq != null) {
-annotation.belowAlignment = false;
-var referedSeq = this.refSeq;
-do {
-var ann =  new jalview.datamodel.AlignmentAnnotation (annotation);
-annotation.createSequenceMapping (referedSeq, refSeqIndex, false);
-annotation.adjustForAlignment ();
-referedSeq.addAlignmentAnnotation (annotation);
-al.addAnnotation (annotation);
-al.setAnnotationIndex (annotation, al.getAlignmentAnnotation ().length - existingAnnotations - 1);
-if (groupRef != null) {
-(groupRefRows.get (groupRef)).addElement (annotation);
-}annotation = ann;
-} while (this.refSeqId != null && (referedSeq = al.findName (referedSeq, this.refSeqId, true)) != null);
-} else {
-al.addAnnotation (annotation);
-al.setAnnotationIndex (annotation, al.getAlignmentAnnotation ().length - existingAnnotations - 1);
-if (groupRef != null) {
-(groupRefRows.get (groupRef)).addElement (annotation);
-}}modified = true;
-}
-var groupRefLookup =  new java.util.Hashtable ();
-var en = groupRefRows.keys ();
-while (en.hasMoreElements ()) {
-groupRef = en.nextElement ();
-var matched = false;
-for (var theGroup, $theGroup = al.getGroups ().iterator (); $theGroup.hasNext () && ((theGroup = $theGroup.next ()) || true);) {
-if (theGroup.getName ().equals (groupRef)) {
-if (matched) {
-System.err.println ("Ignoring 1:many group reference mappings for group name '" + groupRef + "'");
-} else {
-matched = true;
-var rowset = groupRefRows.get (groupRef);
-groupRefLookup.put (groupRef, theGroup);
-if (rowset != null && rowset.size () > 0) {
-var alan = null;
-for (var elm = 0, elmSize = rowset.size (); elm < elmSize; elm++) {
-alan = rowset.elementAt (elm);
-alan.groupRef = theGroup;
-}
-}}}}
-(groupRefRows.get (groupRef)).removeAllElements ();
-}
-for (var _deferred_args, $_deferred_args = deferredAnnotation_calls.iterator (); $_deferred_args.hasNext () && ((_deferred_args = $_deferred_args.next ()) || true);) {
-if (_deferred_args[0] === jalview.io.AnnotationFile.GRAPHLINE) {
-this.addLine (al, _deferred_args[1], _deferred_args[2], (_deferred_args[3] == null) ? null : groupRefLookup.get (_deferred_args[3]));
-}}
-var combinecount = 0;
-for (var _combine_args, $_combine_args = combineAnnotation_calls.iterator (); $_combine_args.hasNext () && ((_combine_args = $_combine_args.next ()) || true);) {
-this.combineAnnotations (al, ++combinecount, _combine_args[0], _combine_args[1], (_combine_args[2] == null) ? null : groupRefLookup.get (_combine_args[2]));
-}
-}return modified;
-}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,java.io.BufferedReader");
-Clazz.defineMethod (c$, "parseHideCols", 
-($fz = function (colSel, nextToken) {
-var inval =  new java.util.StringTokenizer (nextToken, ",");
-while (inval.hasMoreTokens ()) {
-var range = inval.nextToken ().trim ();
-var from;
-var to = range.indexOf ("-");
-if (to == -1) {
-from = to = Integer.parseInt (range);
-if (from >= 0) {
-colSel.hideColumns (from, to);
-}} else {
-from = Integer.parseInt (range.substring (0, to));
-if (to < range.length - 1) {
-to = Integer.parseInt (range.substring (to + 1));
-} else {
-to = from;
-}if (from > 0 && to >= from) {
-colSel.hideColumns (from, to);
-}}}
-}, $fz.isPrivate = true, $fz), "jalview.datamodel.ColumnSelection,~S");
-Clazz.defineMethod (c$, "autoAnnotsKey", 
-($fz = function (annotation, refSeq, groupRef) {
-return annotation.graph + "\t" + annotation.label + "\t" + annotation.description + "\t" + (refSeq != null ? refSeq.getDisplayId (true) : "");
-}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.SequenceI,~S");
-Clazz.defineMethod (c$, "parseAnnotation", 
-function (string, graphStyle) {
-var hasSymbols = (graphStyle == 0);
-var desc = null;
-var displayChar = null;
-var ss = ' ';
-var value = 0;
-var parsedValue = false;
-var dcset = false;
-var colour = null;
-var i = string.indexOf ("[");
-var j = string.indexOf ("]");
-if (i > -1 && j > -1) {
-var ucs =  new jalview.schemes.UserColourScheme ();
-colour = ucs.getColourFromString (string.substring (i + 1, j));
-if (i > 0 && string.charAt (i - 1) == ',') {
-i--;
-}string = string.substring (0, i) + string.substring (j + 1);
-}var st =  new java.util.StringTokenizer (string, ",", true);
-var token;
-var seenContent = false;
-var pass = 0;
-while (st.hasMoreTokens ()) {
-pass++;
-token = st.nextToken ().trim ();
-if (token.equals (",")) {
-if (!seenContent && parsedValue && !dcset) {
-dcset = true;
-displayChar = " ";
-}seenContent = false;
-continue;
-} else {
-seenContent = true;
-}if (!parsedValue) {
-try {
-displayChar = token;
-value =  new Float (token).floatValue ();
-parsedValue = true;
-continue;
-} catch (ex) {
-if (Clazz.exceptionOf (ex, NumberFormatException)) {
-} else {
-throw ex;
-}
-}
-} else {
-if (token.length == 1) {
-displayChar = token;
-}}if (hasSymbols && (token.equals ("H") || token.equals ("E") || token.equals ("S") || token.equals (" "))) {
-ss = token.charAt (0);
-if (displayChar.equals (token.substring (0, 1))) {
-displayChar = "";
-}} else if (desc == null || (parsedValue && pass > 2)) {
-desc = token;
-}}
-if (displayChar != null && desc != null && desc.length == 1) {
-if (displayChar.length > 1) {
-var tmp = displayChar;
-displayChar = desc;
-desc = tmp;
-} else {
-if (displayChar.equals (desc)) {
-desc = null;
-}}}var anot =  new jalview.datamodel.Annotation (displayChar, desc, ss, value);
-anot.colour = colour;
-return anot;
-}, "~S,~N");
-Clazz.defineMethod (c$, "colourAnnotations", 
-function (al, label, colour) {
-var ucs =  new jalview.schemes.UserColourScheme (colour);
-var annotations;
-for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {
-if (al.getAlignmentAnnotation ()[i].label.equalsIgnoreCase (label)) {
-annotations = al.getAlignmentAnnotation ()[i].annotations;
-for (var j = 0; j < annotations.length; j++) {
-if (annotations[j] != null) {
-annotations[j].colour = ucs.findColour ('A');
-}}
-}}
-}, "jalview.datamodel.AlignmentI,~S,~S");
-Clazz.defineMethod (c$, "combineAnnotations", 
-function (al, combineCount, st, seqRef, groupRef) {
-var group = st.nextToken ();
-var graphGroup = 0;
-if (al.getAlignmentAnnotation () != null) {
-for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {
-var aa = al.getAlignmentAnnotation ()[i];
-if (aa.graphGroup > graphGroup) {
-graphGroup = aa.graphGroup + 1;
-}if (aa.sequenceRef === seqRef && aa.groupRef === groupRef && aa.label.equalsIgnoreCase (group)) {
-if (aa.graphGroup > -1) {
-graphGroup = aa.graphGroup;
-} else {
-if (graphGroup <= combineCount) {
-graphGroup = combineCount + 1;
-}aa.graphGroup = graphGroup;
-}break;
-}}
-while (st.hasMoreTokens ()) {
-group = st.nextToken ();
-for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {
-var aa = al.getAlignmentAnnotation ()[i];
-if (aa.sequenceRef === seqRef && aa.groupRef === groupRef && aa.label.equalsIgnoreCase (group)) {
-aa.graphGroup = graphGroup;
-break;
-}}
-}
-} else {
-System.err.println ("Couldn't combine annotations. None are added to alignment yet!");
-}}, "jalview.datamodel.AlignmentI,~N,java.util.StringTokenizer,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup");
-Clazz.defineMethod (c$, "addLine", 
-function (al, st, seqRef, groupRef) {
-var group = st.nextToken ();
-var annotation = null;
-var alannot = al.getAlignmentAnnotation ();
-var value =  new Float (st.nextToken ()).floatValue ();
-var label = st.hasMoreTokens () ? st.nextToken () : null;
-var colour = null;
-if (st.hasMoreTokens ()) {
-var ucs =  new jalview.schemes.UserColourScheme (st.nextToken ());
-colour = ucs.findColour ('A');
-}if (alannot != null) {
-for (var i = 0; i < alannot.length; i++) {
-if (alannot[i].label.equalsIgnoreCase (group) && (seqRef == null || alannot[i].sequenceRef === seqRef) && (groupRef == null || alannot[i].groupRef === groupRef)) {
-alannot[i].setThreshold ( new jalview.datamodel.GraphLine (value, label, colour));
-}}
-}if (annotation == null) {
-return;
-}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup");
-Clazz.defineMethod (c$, "addGroup", 
-function (al, st) {
-var sg =  new jalview.datamodel.SequenceGroup ();
-sg.setName (st.nextToken ());
-var rng = "";
-try {
-rng = st.nextToken ();
-if (rng.length > 0 && !rng.startsWith ("*")) {
-sg.setStartRes (Integer.parseInt (rng) - 1);
-} else {
-sg.setStartRes (0);
-}rng = st.nextToken ();
-if (rng.length > 0 && !rng.startsWith ("*")) {
-sg.setEndRes (Integer.parseInt (rng) - 1);
-} else {
-sg.setEndRes (al.getWidth () - 1);
-}} catch (e) {
-if (Clazz.exceptionOf (e, Exception)) {
-System.err.println ("Couldn't parse Group Start or End Field as '*' or a valid column or sequence index: '" + rng + "' - assuming alignment width for group.");
-sg.setStartRes (0);
-sg.setEndRes (al.getWidth () - 1);
-} else {
-throw e;
-}
-}
-var index = st.nextToken ();
-if (index.equals ("-1")) {
-while (st.hasMoreElements ()) {
-sg.addSequence (al.findName (st.nextToken ()), false);
-}
-} else {
-var st2 =  new java.util.StringTokenizer (index, ",");
-while (st2.hasMoreTokens ()) {
-var tmp = st2.nextToken ();
-if (tmp.equals ("*")) {
-for (var i = 0; i < al.getHeight (); i++) {
-sg.addSequence (al.getSequenceAt (i), false);
-}
-} else if (tmp.indexOf ("-") >= 0) {
-var st3 =  new java.util.StringTokenizer (tmp, "-");
-var start = (Integer.parseInt (st3.nextToken ()));
-var end = (Integer.parseInt (st3.nextToken ()));
-if (end > start) {
-for (var i = start; i <= end; i++) {
-sg.addSequence (al.getSequenceAt (i - 1), false);
-}
-}} else {
-sg.addSequence (al.getSequenceAt (Integer.parseInt (tmp) - 1), false);
-}}
-}if (this.refSeq != null) {
-sg.setStartRes (this.refSeq.findIndex (sg.getStartRes () + 1) - 1);
-sg.setEndRes (this.refSeq.findIndex (sg.getEndRes () + 1) - 1);
-sg.setSeqrep (this.refSeq);
-}if (sg.getSize () > 0) {
-al.addGroup (sg);
-}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");
-Clazz.defineMethod (c$, "addRowProperties", 
-function (al, st) {
-var label = st.nextToken ();
-var keyValue;
-var key;
-var value;
-var scaletofit = false;
-var centerlab = false;
-var showalllabs = false;
-while (st.hasMoreTokens ()) {
-keyValue = st.nextToken ();
-key = keyValue.substring (0, keyValue.indexOf ("="));
-value = keyValue.substring (keyValue.indexOf ("=") + 1);
-if (key.equalsIgnoreCase ("scaletofit")) {
-scaletofit = Boolean.$valueOf (value).booleanValue ();
-}if (key.equalsIgnoreCase ("showalllabs")) {
-showalllabs = Boolean.$valueOf (value).booleanValue ();
-}if (key.equalsIgnoreCase ("centrelabs")) {
-centerlab = Boolean.$valueOf (value).booleanValue ();
-}var alr = al.getAlignmentAnnotation ();
-if (alr != null) {
-for (var i = 0; i < alr.length; i++) {
-if (alr[i].label.equalsIgnoreCase (label)) {
-alr[i].centreColLabels = centerlab;
-alr[i].scaleColLabel = scaletofit;
-alr[i].showAllColLabels = showalllabs;
-}}
-}}
-}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");
-Clazz.defineMethod (c$, "addProperties", 
-function (al, st) {
-if (al.getGroups () == null) {
-return;
-}var name = st.nextToken ();
-var sg = null;
-for (var _sg, $_sg = al.getGroups ().iterator (); $_sg.hasNext () && ((_sg = $_sg.next ()) || true);) {
-if ((sg = _sg).getName ().equals (name)) {
-break;
-} else {
-sg = null;
-}}
-if (sg != null) {
-var keyValue;
-var key;
-var value;
-var def = sg.cs;
-sg.cs = null;
-while (st.hasMoreTokens ()) {
-keyValue = st.nextToken ();
-key = keyValue.substring (0, keyValue.indexOf ("="));
-value = keyValue.substring (keyValue.indexOf ("=") + 1);
-if (key.equalsIgnoreCase ("description")) {
-sg.setDescription (value);
-} else if (key.equalsIgnoreCase ("colour")) {
-sg.cs = jalview.schemes.ColourSchemeProperty.getColour (al, value);
-} else if (key.equalsIgnoreCase ("pidThreshold")) {
-sg.cs.setThreshold (Integer.parseInt (value), true);
-} else if (key.equalsIgnoreCase ("consThreshold")) {
-sg.cs.setConservationInc (Integer.parseInt (value));
-var c =  new jalview.analysis.Conservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (null), sg.getStartRes (), sg.getEndRes () + 1);
-c.calculate ();
-c.verdict (false, 25);
-sg.cs.setConservation (c);
-} else if (key.equalsIgnoreCase ("outlineColour")) {
-sg.setOutlineColour ( new jalview.schemes.UserColourScheme (value).findColour ('A'));
-} else if (key.equalsIgnoreCase ("displayBoxes")) {
-sg.setDisplayBoxes (Boolean.$valueOf (value).booleanValue ());
-} else if (key.equalsIgnoreCase ("showUnconserved")) {
-sg.setShowNonconserved (Boolean.$valueOf (value).booleanValue ());
-} else if (key.equalsIgnoreCase ("displayText")) {
-sg.setDisplayText (Boolean.$valueOf (value).booleanValue ());
-} else if (key.equalsIgnoreCase ("colourText")) {
-sg.setColourText (Boolean.$valueOf (value).booleanValue ());
-} else if (key.equalsIgnoreCase ("textCol1")) {
-sg.textColour =  new jalview.schemes.UserColourScheme (value).findColour ('A');
-} else if (key.equalsIgnoreCase ("textCol2")) {
-sg.textColour2 =  new jalview.schemes.UserColourScheme (value).findColour ('A');
-} else if (key.equalsIgnoreCase ("textColThreshold")) {
-sg.thresholdTextColour = Integer.parseInt (value);
-} else if (key.equalsIgnoreCase ("idColour")) {
-sg.setIdColour ((def =  new jalview.schemes.UserColourScheme (value)).findColour ('A'));
-} else if (key.equalsIgnoreCase ("hide")) {
-sg.setHidereps (true);
-} else if (key.equalsIgnoreCase ("hidecols")) {
-sg.setHideCols (true);
-}sg.recalcConservation ();
-}
-if (sg.cs == null) {
-sg.cs = def;
-}}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");
-Clazz.defineMethod (c$, "setBelowAlignment", 
-function (al, st) {
-var token;
-var aa;
-var ala = al.getAlignmentAnnotation ();
-if (ala == null) {
-System.err.print ("Warning - no annotation to set below for sequence associated annotation:");
-}while (st.hasMoreTokens ()) {
-token = st.nextToken ();
-if (ala == null) {
-System.err.print (" " + token);
-} else {
-for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {
-aa = al.getAlignmentAnnotation ()[i];
-if (aa.sequenceRef === this.refSeq && aa.label.equals (token)) {
-aa.belowAlignment = true;
-}}
-}}
-if (ala == null) {
-System.err.print ("\n");
-}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");
-Clazz.defineMethod (c$, "addAlignmentDetails", 
-function (al, st) {
-var keyValue;
-var key;
-var value;
-while (st.hasMoreTokens ()) {
-keyValue = st.nextToken ();
-key = keyValue.substring (0, keyValue.indexOf ("="));
-value = keyValue.substring (keyValue.indexOf ("=") + 1);
-al.setProperty (key, value);
-}
-}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");
-Clazz.defineMethod (c$, "printCSVAnnotations", 
-function (annotations) {
-var sp =  new StringBuffer ();
-for (var i = 0; i < annotations.length; i++) {
-var atos = annotations[i].toString ();
-var p = 0;
-do {
-var cp = atos.indexOf ("\n", p);
-sp.append (annotations[i].label);
-sp.append (",");
-if (cp > p) {
-sp.append (atos.substring (p, cp + 1));
-} else {
-sp.append (atos.substring (p));
-sp.append (this.newline);
-}p = cp + 1;
-} while (p > 0);
-}
-return sp.toString ();
-}, "~A");
-Clazz.defineMethod (c$, "printAnnotationsForView", 
-function (viewport) {
-return this.printAnnotations (viewport.isShowAnnotation () ? viewport.getAlignment ().getAlignmentAnnotation () : null, viewport.getAlignment ().getGroups (), viewport.getAlignment ().getProperties (), viewport.getColumnSelection (), viewport.getAlignment (), null);
-}, "jalview.api.AlignViewportI");
-Clazz.defineMethod (c$, "printAnnotationsForAlignment", 
-function (al) {
-return this.printAnnotations (al.getAlignmentAnnotation (), al.getGroups (), al.getProperties (), null, al, null);
-}, "jalview.datamodel.AlignmentI");
-c$.$AnnotationFile$ViewDef$ = function () {
-Clazz.pu$h ();
-c$ = Clazz.decorateAsClass (function () {
-Clazz.prepareCallback (this, arguments);
-this.viewname = null;
-this.hidseqs = null;
-this.hiddencols = null;
-this.visibleGroups = null;
-this.hiddenRepSeqs = null;
-Clazz.instantialize (this, arguments);
-}, jalview.io.AnnotationFile, "ViewDef");
-Clazz.makeConstructor (c$, 
-function (a, b, c, d) {
-this.viewname = a;
-this.hidseqs = b;
-this.hiddencols = c;
-this.hiddenRepSeqs = d;
-}, "~S,jalview.datamodel.HiddenSequences,jalview.datamodel.ColumnSelection,java.util.Hashtable");
-c$ = Clazz.p0p ();
-};
-Clazz.defineStatics (c$,
-"GRAPHLINE", "GRAPHLINE",
-"COMBINE", "COMBINE");
-});
+Clazz.declarePackage ("jalview.io");\r
+Clazz.load (null, "jalview.io.AnnotationFile", ["jalview.analysis.Conservation", "jalview.datamodel.AlignmentAnnotation", "$.Annotation", "$.ColumnSelection", "$.GraphLine", "$.SequenceGroup", "jalview.io.AppletFormatAdapter", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.ColourSchemeProperty", "$.ResidueProperties", "$.UserColourScheme", "jalview.util.Comparison", "$.Format", "java.awt.Color", "java.io.BufferedReader", "$.InputStreamReader", "$.StringReader", "java.lang.Boolean", "$.Float", "$.StringBuffer", "java.util.ArrayList", "$.BitSet", "$.Date", "$.Hashtable", "$.StringTokenizer", "$.Vector"], function () {\r
+c$ = Clazz.decorateAsClass (function () {\r
+this.newline = null;\r
+this.text = null;\r
+if (!Clazz.isClassDefined ("jalview.io.AnnotationFile.ViewDef")) {\r
+jalview.io.AnnotationFile.$AnnotationFile$ViewDef$ ();\r
+}\r
+this.refSeq = null;\r
+this.refSeqId = null;\r
+this.nlinesread = 0;\r
+this.lastread = "";\r
+Clazz.instantialize (this, arguments);\r
+}, jalview.io, "AnnotationFile");\r
+Clazz.prepareFields (c$, function () {\r
+this.newline = System.getProperty ("line.separator");\r
+});\r
+Clazz.makeConstructor (c$, \r
+function () {\r
+this.init ();\r
+});\r
+Clazz.defineMethod (c$, "setNewlineString", \r
+function (nl) {\r
+this.newline = nl;\r
+this.init ();\r
+}, "~S");\r
+Clazz.defineMethod (c$, "getNewlineString", \r
+function () {\r
+return this.newline;\r
+});\r
+Clazz.defineMethod (c$, "init", \r
+($fz = function () {\r
+this.text =  new StringBuffer ("JALVIEW_ANNOTATION" + this.newline + "# Created: " +  new java.util.Date () + this.newline + this.newline);\r
+this.refSeq = null;\r
+this.refSeqId = null;\r
+}, $fz.isPrivate = true, $fz));\r
+Clazz.defineMethod (c$, "printAnnotations", \r
+function (annotations, list, properties) {\r
+return this.printAnnotations (annotations, list, properties, null, null, null);\r
+}, "~A,java.util.List,java.util.Hashtable");\r
+Clazz.defineMethod (c$, "printAnnotations", \r
+function (annotations, list, properties, cs, al, view) {\r
+if (view != null) {\r
+if (view.viewname != null) {\r
+this.text.append ("VIEW_DEF\t" + view.viewname + "\n");\r
+}if (list == null) {\r
+list = view.visibleGroups;\r
+}if (cs == null) {\r
+cs = view.hiddencols;\r
+}if (al == null) {\r
+}}if (al != null && al.hasSeqrep ()) {\r
+this.text.append ("VIEW_SETREF\t" + al.getSeqrep ().getName () + "\n");\r
+}if (cs != null && cs.hasHiddenColumns ()) {\r
+this.text.append ("VIEW_HIDECOLS\t");\r
+var hc = cs.getHiddenColumns ();\r
+var comma = false;\r
+for (var r, $r = hc.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) {\r
+if (!comma) {\r
+comma = true;\r
+} else {\r
+this.text.append (",");\r
+}this.text.append ("" + r[0]);\r
+this.text.append ("-");\r
+this.text.append ("" + r[1]);\r
+}\r
+this.text.append ("\n");\r
+}if (annotations != null) {\r
+var oneColour = true;\r
+var row;\r
+var comma;\r
+var refSeq = null;\r
+var refGroup = null;\r
+var colours =  new StringBuffer ();\r
+var graphLine =  new StringBuffer ();\r
+var rowprops =  new StringBuffer ();\r
+var graphGroup =  new java.util.Hashtable ();\r
+var graphGroup_refs =  new java.util.Hashtable ();\r
+var graphGroupSeen =  new java.util.BitSet ();\r
+var color;\r
+for (var i = 0; i < annotations.length; i++) {\r
+row = annotations[i];\r
+if (!row.visible && !row.hasScore () && !(row.graphGroup > -1 && graphGroupSeen.get (row.graphGroup))) {\r
+continue;\r
+}color = null;\r
+oneColour = true;\r
+this.writeSequence_Ref (refSeq, row.sequenceRef);\r
+refSeq = row.sequenceRef;\r
+this.writeGroup_Ref (refGroup, row.groupRef);\r
+refGroup = row.groupRef;\r
+var hasGlyphs = row.hasIcons;\r
+var hasLabels = row.hasText;\r
+var hasValues = row.$hasScore;\r
+var hasText = false;\r
+for (var j = 0; row.annotations != null && j < row.annotations.length && (!hasGlyphs || !hasLabels || !hasValues); j++) {\r
+if (row.annotations[j] != null) {\r
+hasLabels = new Boolean (hasLabels | (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length > 0 && !row.annotations[j].displayCharacter.equals (" "))).valueOf ();\r
+hasGlyphs = new Boolean (hasGlyphs | ((row.annotations[j].secondaryStructure).charCodeAt (0) != 0 && row.annotations[j].secondaryStructure != ' ')).valueOf ();\r
+hasValues = new Boolean (hasValues | (!Float.isNaN (row.annotations[j].value))).valueOf ();\r
+hasText = new Boolean (hasText | (row.annotations[j].description != null && row.annotations[j].description.length > 0)).valueOf ();\r
+}}\r
+if (row.graph == 0) {\r
+this.text.append ("NO_GRAPH\t");\r
+hasValues = false;\r
+} else {\r
+if (row.graph == 1) {\r
+this.text.append ("BAR_GRAPH\t");\r
+hasGlyphs = false;\r
+} else if (row.graph == 2) {\r
+hasGlyphs = false;\r
+this.text.append ("LINE_GRAPH\t");\r
+}if (row.getThreshold () != null) {\r
+graphLine.append ("GRAPHLINE\t");\r
+graphLine.append (row.label);\r
+graphLine.append ("\t");\r
+graphLine.append (row.getThreshold ().value);\r
+graphLine.append ("\t");\r
+graphLine.append (row.getThreshold ().label);\r
+graphLine.append ("\t");\r
+graphLine.append (jalview.util.Format.getHexString (row.getThreshold ().colour));\r
+graphLine.append (this.newline);\r
+}if (row.graphGroup > -1) {\r
+graphGroupSeen.set (row.graphGroup);\r
+var key =  new Integer (row.graphGroup);\r
+if (graphGroup.containsKey (key)) {\r
+graphGroup.put (key, graphGroup.get (key) + "\t" + row.label);\r
+} else {\r
+graphGroup_refs.put (key,  Clazz.newArray (-1, [refSeq, refGroup]));\r
+graphGroup.put (key, row.label);\r
+}}}this.text.append (row.label + "\t");\r
+if (row.description != null) {\r
+this.text.append (row.description + "\t");\r
+}for (var j = 0; row.annotations != null && j < row.annotations.length; j++) {\r
+if (refSeq != null && jalview.util.Comparison.isGap (refSeq.getCharAt (j))) {\r
+continue;\r
+}if (row.annotations[j] != null) {\r
+comma = "";\r
+if (hasGlyphs) {\r
+this.text.append (comma);\r
+if (row.annotations[j].secondaryStructure != ' ') {\r
+this.text.append (row.annotations[j].secondaryStructure);\r
+}comma = ",";\r
+}if (hasValues) {\r
+if (!Float.isNaN (row.annotations[j].value)) {\r
+this.text.append (comma + row.annotations[j].value);\r
+} else {\r
+System.err.println ("Skipping NaN - not valid value.");\r
+this.text.append (comma + 0);\r
+}comma = ",";\r
+}if (hasLabels) {\r
+if (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length > 0 && !row.annotations[j].displayCharacter.equals (" ")) {\r
+this.text.append (comma + row.annotations[j].displayCharacter);\r
+comma = ",";\r
+}}if (hasText) {\r
+if (row.annotations[j].description != null && row.annotations[j].description.length > 0 && !row.annotations[j].description.equals (row.annotations[j].displayCharacter)) {\r
+this.text.append (comma + row.annotations[j].description);\r
+comma = ",";\r
+}}if (color != null && !color.equals (row.annotations[j].colour)) {\r
+oneColour = false;\r
+}color = row.annotations[j].colour;\r
+if (row.annotations[j].colour != null && row.annotations[j].colour !== java.awt.Color.black) {\r
+this.text.append (comma + "[" + jalview.util.Format.getHexString (row.annotations[j].colour) + "]");\r
+comma = ",";\r
+}}this.text.append ("|");\r
+}\r
+if (row.hasScore ()) {\r
+this.text.append ("\t" + row.score);\r
+}this.text.append (this.newline);\r
+if (color != null && color !== java.awt.Color.black && oneColour) {\r
+colours.append ("COLOUR\t");\r
+colours.append (row.label);\r
+colours.append ("\t");\r
+colours.append (jalview.util.Format.getHexString (color));\r
+colours.append (this.newline);\r
+}if (row.scaleColLabel || row.showAllColLabels || row.centreColLabels) {\r
+rowprops.append ("ROWPROPERTIES\t");\r
+rowprops.append (row.label);\r
+rowprops.append ("\tscaletofit=");\r
+rowprops.append (row.scaleColLabel);\r
+rowprops.append ("\tshowalllabs=");\r
+rowprops.append (row.showAllColLabels);\r
+rowprops.append ("\tcentrelabs=");\r
+rowprops.append (row.centreColLabels);\r
+rowprops.append (this.newline);\r
+}if (graphLine.length () > 0) {\r
+this.text.append (graphLine.toString ());\r
+graphLine.setLength (0);\r
+}}\r
+this.text.append (this.newline);\r
+this.text.append (colours.toString ());\r
+if (graphGroup.size () > 0) {\r
+var oldRefSeq = refSeq;\r
+var oldRefGroup = refGroup;\r
+for (var combine_statement, $combine_statement = graphGroup.entrySet ().iterator (); $combine_statement.hasNext () && ((combine_statement = $combine_statement.next ()) || true);) {\r
+var seqRefAndGroup = graphGroup_refs.get (combine_statement.getKey ());\r
+this.writeSequence_Ref (refSeq, seqRefAndGroup[0]);\r
+refSeq = seqRefAndGroup[0];\r
+this.writeGroup_Ref (refGroup, seqRefAndGroup[1]);\r
+refGroup = seqRefAndGroup[1];\r
+this.text.append ("COMBINE\t");\r
+this.text.append (combine_statement.getValue ());\r
+this.text.append (this.newline);\r
+}\r
+this.writeSequence_Ref (refSeq, oldRefSeq);\r
+refSeq = oldRefSeq;\r
+this.writeGroup_Ref (refGroup, oldRefGroup);\r
+refGroup = oldRefGroup;\r
+}this.text.append (rowprops.toString ());\r
+}if (list != null) {\r
+this.printGroups (list);\r
+}if (properties != null) {\r
+this.text.append (this.newline);\r
+this.text.append (this.newline);\r
+this.text.append ("ALIGNMENT");\r
+var en = properties.keys ();\r
+while (en.hasMoreElements ()) {\r
+var key = en.nextElement ().toString ();\r
+this.text.append ("\t");\r
+this.text.append (key);\r
+this.text.append ("=");\r
+this.text.append (properties.get (key));\r
+}\r
+}return this.text.toString ();\r
+}, "~A,java.util.List,java.util.Hashtable,jalview.datamodel.ColumnSelection,jalview.datamodel.AlignmentI,jalview.io.AnnotationFile.ViewDef");\r
+Clazz.defineMethod (c$, "writeGroup_Ref", \r
+($fz = function (refGroup, next_refGroup) {\r
+if (next_refGroup == null) {\r
+if (refGroup != null) {\r
+this.text.append (this.newline);\r
+this.text.append ("GROUP_REF\t");\r
+this.text.append ("ALIGNMENT");\r
+this.text.append (this.newline);\r
+}return true;\r
+} else {\r
+if (refGroup == null || refGroup !== next_refGroup) {\r
+this.text.append (this.newline);\r
+this.text.append ("GROUP_REF\t");\r
+this.text.append (next_refGroup.getName ());\r
+this.text.append (this.newline);\r
+return true;\r
+}}return false;\r
+}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceGroup,jalview.datamodel.SequenceGroup");\r
+Clazz.defineMethod (c$, "writeSequence_Ref", \r
+($fz = function (refSeq, next_refSeq) {\r
+if (next_refSeq == null) {\r
+if (refSeq != null) {\r
+this.text.append (this.newline);\r
+this.text.append ("SEQUENCE_REF\t");\r
+this.text.append ("ALIGNMENT");\r
+this.text.append (this.newline);\r
+return true;\r
+}} else {\r
+if (refSeq == null || refSeq !== next_refSeq) {\r
+this.text.append (this.newline);\r
+this.text.append ("SEQUENCE_REF\t");\r
+this.text.append (next_refSeq.getName ());\r
+this.text.append (this.newline);\r
+return true;\r
+}}return false;\r
+}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI");\r
+Clazz.defineMethod (c$, "printGroups", \r
+function (list) {\r
+var seqrep = null;\r
+for (var sg, $sg = list.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) {\r
+if (!sg.hasSeqrep ()) {\r
+this.text.append ("SEQUENCE_GROUP\t" + sg.getName () + "\t" + (sg.getStartRes () + 1) + "\t" + (sg.getEndRes () + 1) + "\t" + "-1\t");\r
+seqrep = null;\r
+} else {\r
+seqrep = sg.getSeqrep ();\r
+this.text.append ("SEQUENCE_REF\t");\r
+this.text.append (seqrep.getName ());\r
+this.text.append (this.newline);\r
+this.text.append ("SEQUENCE_GROUP\t");\r
+this.text.append (sg.getName ());\r
+this.text.append ("\t");\r
+this.text.append ("" + (seqrep.findPosition (sg.getStartRes ())));\r
+this.text.append ("\t");\r
+this.text.append ((seqrep.findPosition (sg.getEndRes ())));\r
+this.text.append ("\t");\r
+this.text.append ("-1\t");\r
+}for (var s = 0; s < sg.getSize (); s++) {\r
+this.text.append (sg.getSequenceAt (s).getName ());\r
+this.text.append ("\t");\r
+}\r
+this.text.append (this.newline);\r
+this.text.append ("PROPERTIES\t");\r
+this.text.append (sg.getName ());\r
+this.text.append ("\t");\r
+if (sg.getDescription () != null) {\r
+this.text.append ("description=");\r
+this.text.append (sg.getDescription ());\r
+this.text.append ("\t");\r
+}if (sg.cs != null) {\r
+this.text.append ("colour=");\r
+this.text.append (jalview.schemes.ColourSchemeProperty.getColourName (sg.cs));\r
+this.text.append ("\t");\r
+if (sg.cs.getThreshold () != 0) {\r
+this.text.append ("pidThreshold=");\r
+this.text.append (sg.cs.getThreshold ());\r
+}if (sg.cs.conservationApplied ()) {\r
+this.text.append ("consThreshold=");\r
+this.text.append (sg.cs.getConservationInc ());\r
+this.text.append ("\t");\r
+}}this.text.append ("outlineColour=");\r
+this.text.append (jalview.util.Format.getHexString (sg.getOutlineColour ()));\r
+this.text.append ("\t");\r
+this.text.append ("displayBoxes=");\r
+this.text.append (sg.getDisplayBoxes ());\r
+this.text.append ("\t");\r
+this.text.append ("displayText=");\r
+this.text.append (sg.getDisplayText ());\r
+this.text.append ("\t");\r
+this.text.append ("colourText=");\r
+this.text.append (sg.getColourText ());\r
+this.text.append ("\t");\r
+this.text.append ("showUnconserved=");\r
+this.text.append (sg.getShowNonconserved ());\r
+this.text.append ("\t");\r
+if (sg.textColour !== java.awt.Color.black) {\r
+this.text.append ("textCol1=");\r
+this.text.append (jalview.util.Format.getHexString (sg.textColour));\r
+this.text.append ("\t");\r
+}if (sg.textColour2 !== java.awt.Color.white) {\r
+this.text.append ("textCol2=");\r
+this.text.append (jalview.util.Format.getHexString (sg.textColour2));\r
+this.text.append ("\t");\r
+}if (sg.thresholdTextColour != 0) {\r
+this.text.append ("textColThreshold=");\r
+this.text.append (sg.thresholdTextColour);\r
+this.text.append ("\t");\r
+}if (sg.idColour != null) {\r
+this.text.append ("idColour=");\r
+this.text.append (jalview.util.Format.getHexString (sg.idColour));\r
+this.text.append ("\t");\r
+}if (sg.isHidereps ()) {\r
+this.text.append ("hide=true\t");\r
+}if (sg.isHideCols ()) {\r
+this.text.append ("hidecols=true\t");\r
+}if (seqrep != null) {\r
+this.text.append (this.newline);\r
+this.text.append ("SEQUENCE_REF");\r
+}this.text.append (this.newline);\r
+this.text.append (this.newline);\r
+}\r
+}, "java.util.List");\r
+Clazz.defineMethod (c$, "annotateAlignmentView", \r
+function (viewport, file, protocol) {\r
+var colSel = viewport.getColumnSelection ();\r
+if (colSel == null) {\r
+colSel =  new jalview.datamodel.ColumnSelection ();\r
+}var rslt = this.readAnnotationFile (viewport.getAlignment (), colSel, file, protocol);\r
+if (rslt && (colSel.hasSelectedColumns () || colSel.hasHiddenColumns ())) {\r
+viewport.setColumnSelection (colSel);\r
+}return rslt;\r
+}, "jalview.api.AlignViewportI,~S,~S");\r
+Clazz.defineMethod (c$, "readAnnotationFile", \r
+function (al, file, protocol) {\r
+return this.readAnnotationFile (al, null, file, protocol);\r
+}, "jalview.datamodel.AlignmentI,~S,~S");\r
+Clazz.defineMethod (c$, "readAnnotationFile", \r
+function (al, colSel, file, protocol) {\r
+var $in = null;\r
+try {\r
+if (protocol.equals (jalview.io.AppletFormatAdapter.FILE)) {\r
+$in = jalview.jsdev.GenericFileAdapter.getReader (file, false);\r
+} else if (protocol.equals (jalview.io.AppletFormatAdapter.URL)) {\r
+$in = jalview.jsdev.GenericFileAdapter.getReader (file, true);\r
+} else if (protocol.equals (jalview.io.AppletFormatAdapter.PASTE)) {\r
+$in =  new java.io.BufferedReader ( new java.io.StringReader (file));\r
+} else if (protocol.equals (jalview.io.AppletFormatAdapter.CLASSLOADER)) {\r
+var is = this.getClass ().getResourceAsStream ("/" + file);\r
+if (is != null) {\r
+$in =  new java.io.BufferedReader ( new java.io.InputStreamReader (is));\r
+}}if ($in != null) {\r
+return this.parseAnnotationFrom (al, colSel, $in);\r
+}} catch (ex) {\r
+if (Clazz.exceptionOf (ex, Exception)) {\r
+ex.printStackTrace ();\r
+System.out.println ("Problem reading annotation file: " + ex);\r
+if (this.nlinesread > 0) {\r
+System.out.println ("Last read line " + this.nlinesread + ": '" + this.lastread + "' (first 80 chars) ...");\r
+}return false;\r
+} else {\r
+throw ex;\r
+}\r
+}\r
+return false;\r
+}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,~S,~S");\r
+Clazz.defineMethod (c$, "parseAnnotationFrom", \r
+function (al, colSel, $in) {\r
+this.nlinesread = 0;\r
+var combineAnnotation_calls =  new java.util.ArrayList ();\r
+var deferredAnnotation_calls =  new java.util.ArrayList ();\r
+var modified = false;\r
+var groupRef = null;\r
+var groupRefRows =  new java.util.Hashtable ();\r
+var autoAnnots =  new java.util.Hashtable ();\r
+{\r
+var line;\r
+var label;\r
+var description;\r
+var token;\r
+var graphStyle;\r
+var index;\r
+var refSeqIndex = 1;\r
+var existingAnnotations = 0;\r
+var overrideAutoAnnot = false;\r
+if (al.getAlignmentAnnotation () != null) {\r
+existingAnnotations = al.getAlignmentAnnotation ().length;\r
+if (existingAnnotations > 0) {\r
+var aa = al.getAlignmentAnnotation ();\r
+for (var aai = 0; aai < aa.length; aai++) {\r
+if (aa[aai].autoCalculated) {\r
+autoAnnots.put (this.autoAnnotsKey (aa[aai], aa[aai].sequenceRef, (aa[aai].groupRef == null ? null : aa[aai].groupRef.getName ())),  new Integer (1));\r
+}}\r
+}}var alWidth = al.getWidth ();\r
+var st;\r
+var annotations;\r
+var annotation = null;\r
+var jvAnnotationFile = false;\r
+while ((line = $in.readLine ()) != null) {\r
+this.nlinesread++;\r
+this.lastread =  String.instantialize (line);\r
+if (line.indexOf ("#") == 0) {\r
+continue;\r
+}if (line.indexOf ("JALVIEW_ANNOTATION") > -1) {\r
+jvAnnotationFile = true;\r
+break;\r
+}}\r
+if (!jvAnnotationFile) {\r
+$in.close ();\r
+return false;\r
+}while ((line = $in.readLine ()) != null) {\r
+this.nlinesread++;\r
+this.lastread =  String.instantialize (line);\r
+if (line.indexOf ("#") == 0 || line.indexOf ("JALVIEW_ANNOTATION") > -1 || line.length == 0) {\r
+continue;\r
+}st =  new java.util.StringTokenizer (line, "\t");\r
+token = st.nextToken ();\r
+if (token.equalsIgnoreCase ("COLOUR")) {\r
+this.colourAnnotations (al, st.nextToken (), st.nextToken ());\r
+modified = true;\r
+continue;\r
+} else if (token.equalsIgnoreCase (jalview.io.AnnotationFile.COMBINE)) {\r
+combineAnnotation_calls.add ( Clazz.newArray (-1, [st, this.refSeq, groupRef]));\r
+modified = true;\r
+continue;\r
+} else if (token.equalsIgnoreCase ("ROWPROPERTIES")) {\r
+this.addRowProperties (al, st);\r
+modified = true;\r
+continue;\r
+} else if (token.equalsIgnoreCase (jalview.io.AnnotationFile.GRAPHLINE)) {\r
+deferredAnnotation_calls.add ( Clazz.newArray (-1, [jalview.io.AnnotationFile.GRAPHLINE, st, this.refSeq, groupRef]));\r
+modified = true;\r
+continue;\r
+} else if (token.equalsIgnoreCase ("SEQUENCE_REF")) {\r
+if (st.hasMoreTokens ()) {\r
+this.refSeq = al.findName (this.refSeqId = st.nextToken ());\r
+if (this.refSeq == null) {\r
+this.refSeqId = null;\r
+}try {\r
+refSeqIndex = Integer.parseInt (st.nextToken ());\r
+if (refSeqIndex < 1) {\r
+refSeqIndex = 1;\r
+System.out.println ("WARNING: SEQUENCE_REF index must be > 0 in AnnotationFile");\r
+}} catch (ex) {\r
+if (Clazz.exceptionOf (ex, Exception)) {\r
+refSeqIndex = 1;\r
+} else {\r
+throw ex;\r
+}\r
+}\r
+} else {\r
+this.refSeq = null;\r
+this.refSeqId = null;\r
+}continue;\r
+} else if (token.equalsIgnoreCase ("GROUP_REF")) {\r
+groupRef = null;\r
+if (st.hasMoreTokens ()) {\r
+groupRef = st.nextToken ();\r
+if (groupRef.length < 1) {\r
+groupRef = null;\r
+} else {\r
+if (groupRefRows.get (groupRef) == null) {\r
+groupRefRows.put (groupRef,  new java.util.Vector ());\r
+}}}continue;\r
+} else if (token.equalsIgnoreCase ("SEQUENCE_GROUP")) {\r
+this.addGroup (al, st);\r
+modified = true;\r
+continue;\r
+} else if (token.equalsIgnoreCase ("PROPERTIES")) {\r
+this.addProperties (al, st);\r
+modified = true;\r
+continue;\r
+} else if (token.equalsIgnoreCase ("BELOW_ALIGNMENT")) {\r
+this.setBelowAlignment (al, st);\r
+modified = true;\r
+continue;\r
+} else if (token.equalsIgnoreCase ("ALIGNMENT")) {\r
+this.addAlignmentDetails (al, st);\r
+modified = true;\r
+continue;\r
+} else if (token.equalsIgnoreCase ("VIEW_SETREF")) {\r
+if (this.refSeq != null) {\r
+al.setSeqrep (this.refSeq);\r
+}modified = true;\r
+continue;\r
+} else if (token.equalsIgnoreCase ("VIEW_HIDECOLS")) {\r
+if (st.hasMoreTokens ()) {\r
+if (colSel == null) {\r
+colSel =  new jalview.datamodel.ColumnSelection ();\r
+}this.parseHideCols (colSel, st.nextToken ());\r
+}modified = true;\r
+continue;\r
+} else if (token.equalsIgnoreCase ("HIDE_INSERTIONS")) {\r
+var sr = this.refSeq == null ? al.getSeqrep () : this.refSeq;\r
+if (sr == null) {\r
+sr = al.getSequenceAt (0);\r
+}if (sr != null) {\r
+if (colSel == null) {\r
+System.err.println ("Cannot process HIDE_INSERTIONS without an alignment view: Ignoring line: " + line);\r
+} else {\r
+colSel.hideInsertionsFor (sr);\r
+}}modified = true;\r
+continue;\r
+}graphStyle = jalview.datamodel.AlignmentAnnotation.getGraphValueFromString (token);\r
+label = st.nextToken ();\r
+index = 0;\r
+annotations =  new Array (alWidth);\r
+description = null;\r
+var score = NaN;\r
+if (st.hasMoreTokens ()) {\r
+line = st.nextToken ();\r
+if (line.indexOf ("|") == -1) {\r
+description = line;\r
+if (st.hasMoreTokens ()) {\r
+line = st.nextToken ();\r
+}}if (st.hasMoreTokens ()) {\r
+score = Float.$valueOf (st.nextToken ()).floatValue ();\r
+}st =  new java.util.StringTokenizer (line, "|", true);\r
+var emptyColumn = true;\r
+var onlyOneElement = (st.countTokens () == 1);\r
+while (st.hasMoreElements () && index < alWidth) {\r
+token = st.nextToken ().trim ();\r
+if (onlyOneElement) {\r
+try {\r
+score = Float.$valueOf (token).floatValue ();\r
+break;\r
+} catch (ex) {\r
+if (Clazz.exceptionOf (ex, NumberFormatException)) {\r
+} else {\r
+throw ex;\r
+}\r
+}\r
+}if (token.equals ("|")) {\r
+if (emptyColumn) {\r
+index++;\r
+}emptyColumn = true;\r
+} else {\r
+annotations[index++] = this.parseAnnotation (token, graphStyle);\r
+emptyColumn = false;\r
+}}\r
+}annotation =  new jalview.datamodel.AlignmentAnnotation (label, description, (index == 0) ? null : annotations, 0, 0, graphStyle);\r
+annotation.score = score;\r
+if (!overrideAutoAnnot && autoAnnots.containsKey (this.autoAnnotsKey (annotation, this.refSeq, groupRef))) {\r
+continue;\r
+}if (this.refSeq != null) {\r
+annotation.belowAlignment = false;\r
+var referedSeq = this.refSeq;\r
+do {\r
+var ann =  new jalview.datamodel.AlignmentAnnotation (annotation);\r
+annotation.createSequenceMapping (referedSeq, refSeqIndex, false);\r
+annotation.adjustForAlignment ();\r
+referedSeq.addAlignmentAnnotation (annotation);\r
+al.addAnnotation (annotation);\r
+al.setAnnotationIndex (annotation, al.getAlignmentAnnotation ().length - existingAnnotations - 1);\r
+if (groupRef != null) {\r
+(groupRefRows.get (groupRef)).addElement (annotation);\r
+}annotation = ann;\r
+} while (this.refSeqId != null && (referedSeq = al.findName (referedSeq, this.refSeqId, true)) != null);\r
+} else {\r
+al.addAnnotation (annotation);\r
+al.setAnnotationIndex (annotation, al.getAlignmentAnnotation ().length - existingAnnotations - 1);\r
+if (groupRef != null) {\r
+(groupRefRows.get (groupRef)).addElement (annotation);\r
+}}modified = true;\r
+}\r
+var groupRefLookup =  new java.util.Hashtable ();\r
+var en = groupRefRows.keys ();\r
+while (en.hasMoreElements ()) {\r
+groupRef = en.nextElement ();\r
+var matched = false;\r
+for (var theGroup, $theGroup = al.getGroups ().iterator (); $theGroup.hasNext () && ((theGroup = $theGroup.next ()) || true);) {\r
+if (theGroup.getName ().equals (groupRef)) {\r
+if (matched) {\r
+System.err.println ("Ignoring 1:many group reference mappings for group name '" + groupRef + "'");\r
+} else {\r
+matched = true;\r
+var rowset = groupRefRows.get (groupRef);\r
+groupRefLookup.put (groupRef, theGroup);\r
+if (rowset != null && rowset.size () > 0) {\r
+var alan = null;\r
+for (var elm = 0, elmSize = rowset.size (); elm < elmSize; elm++) {\r
+alan = rowset.elementAt (elm);\r
+alan.groupRef = theGroup;\r
+}\r
+}}}}\r
+(groupRefRows.get (groupRef)).removeAllElements ();\r
+}\r
+for (var _deferred_args, $_deferred_args = deferredAnnotation_calls.iterator (); $_deferred_args.hasNext () && ((_deferred_args = $_deferred_args.next ()) || true);) {\r
+if (_deferred_args[0] === jalview.io.AnnotationFile.GRAPHLINE) {\r
+this.addLine (al, _deferred_args[1], _deferred_args[2], (_deferred_args[3] == null) ? null : groupRefLookup.get (_deferred_args[3]));\r
+}}\r
+var combinecount = 0;\r
+for (var _combine_args, $_combine_args = combineAnnotation_calls.iterator (); $_combine_args.hasNext () && ((_combine_args = $_combine_args.next ()) || true);) {\r
+this.combineAnnotations (al, ++combinecount, _combine_args[0], _combine_args[1], (_combine_args[2] == null) ? null : groupRefLookup.get (_combine_args[2]));\r
+}\r
+}return modified;\r
+}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,java.io.BufferedReader");\r
+Clazz.defineMethod (c$, "parseHideCols", \r
+($fz = function (colSel, nextToken) {\r
+var inval =  new java.util.StringTokenizer (nextToken, ",");\r
+while (inval.hasMoreTokens ()) {\r
+var range = inval.nextToken ().trim ();\r
+var from;\r
+var to = range.indexOf ("-");\r
+if (to == -1) {\r
+from = to = Integer.parseInt (range);\r
+if (from >= 0) {\r
+colSel.hideColumns (from, to);\r
+}} else {\r
+from = Integer.parseInt (range.substring (0, to));\r
+if (to < range.length - 1) {\r
+to = Integer.parseInt (range.substring (to + 1));\r
+} else {\r
+to = from;\r
+}if (from > 0 && to >= from) {\r
+colSel.hideColumns (from, to);\r
+}}}\r
+}, $fz.isPrivate = true, $fz), "jalview.datamodel.ColumnSelection,~S");\r
+Clazz.defineMethod (c$, "autoAnnotsKey", \r
+($fz = function (annotation, refSeq, groupRef) {\r
+return annotation.graph + "\t" + annotation.label + "\t" + annotation.description + "\t" + (refSeq != null ? refSeq.getDisplayId (true) : "");\r
+}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.SequenceI,~S");\r
+Clazz.defineMethod (c$, "parseAnnotation", \r
+function (string, graphStyle) {\r
+var hasSymbols = (graphStyle == 0);\r
+var desc = null;\r
+var displayChar = null;\r
+var ss = ' ';\r
+var value = 0;\r
+var parsedValue = false;\r
+var dcset = false;\r
+var colour = null;\r
+var i = string.indexOf ("[");\r
+var j = string.indexOf ("]");\r
+if (i > -1 && j > -1) {\r
+var ucs =  new jalview.schemes.UserColourScheme ();\r
+colour = ucs.getColourFromString (string.substring (i + 1, j));\r
+if (i > 0 && string.charAt (i - 1) == ',') {\r
+i--;\r
+}string = string.substring (0, i) + string.substring (j + 1);\r
+}var st =  new java.util.StringTokenizer (string, ",", true);\r
+var token;\r
+var seenContent = false;\r
+var pass = 0;\r
+while (st.hasMoreTokens ()) {\r
+pass++;\r
+token = st.nextToken ().trim ();\r
+if (token.equals (",")) {\r
+if (!seenContent && parsedValue && !dcset) {\r
+dcset = true;\r
+displayChar = " ";\r
+}seenContent = false;\r
+continue;\r
+} else {\r
+seenContent = true;\r
+}if (!parsedValue) {\r
+try {\r
+displayChar = token;\r
+value =  new Float (token).floatValue ();\r
+parsedValue = true;\r
+continue;\r
+} catch (ex) {\r
+if (Clazz.exceptionOf (ex, NumberFormatException)) {\r
+} else {\r
+throw ex;\r
+}\r
+}\r
+} else {\r
+if (token.length == 1) {\r
+displayChar = token;\r
+}}if (hasSymbols && (token.equals ("H") || token.equals ("E") || token.equals ("S") || token.equals (" "))) {\r
+ss = token.charAt (0);\r
+if (displayChar.equals (token.substring (0, 1))) {\r
+displayChar = "";\r
+}} else if (desc == null || (parsedValue && pass > 2)) {\r
+desc = token;\r
+}}\r
+if (displayChar != null && desc != null && desc.length == 1) {\r
+if (displayChar.length > 1) {\r
+var tmp = displayChar;\r
+displayChar = desc;\r
+desc = tmp;\r
+} else {\r
+if (displayChar.equals (desc)) {\r
+desc = null;\r
+}}}var anot =  new jalview.datamodel.Annotation (displayChar, desc, ss, value);\r
+anot.colour = colour;\r
+return anot;\r
+}, "~S,~N");\r
+Clazz.defineMethod (c$, "colourAnnotations", \r
+function (al, label, colour) {\r
+var ucs =  new jalview.schemes.UserColourScheme (colour);\r
+var annotations;\r
+for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {\r
+if (al.getAlignmentAnnotation ()[i].label.equalsIgnoreCase (label)) {\r
+annotations = al.getAlignmentAnnotation ()[i].annotations;\r
+for (var j = 0; j < annotations.length; j++) {\r
+if (annotations[j] != null) {\r
+annotations[j].colour = ucs.findColour ('A');\r
+}}\r
+}}\r
+}, "jalview.datamodel.AlignmentI,~S,~S");\r
+Clazz.defineMethod (c$, "combineAnnotations", \r
+function (al, combineCount, st, seqRef, groupRef) {\r
+var group = st.nextToken ();\r
+var graphGroup = 0;\r
+if (al.getAlignmentAnnotation () != null) {\r
+for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {\r
+var aa = al.getAlignmentAnnotation ()[i];\r
+if (aa.graphGroup > graphGroup) {\r
+graphGroup = aa.graphGroup + 1;\r
+}if (aa.sequenceRef === seqRef && aa.groupRef === groupRef && aa.label.equalsIgnoreCase (group)) {\r
+if (aa.graphGroup > -1) {\r
+graphGroup = aa.graphGroup;\r
+} else {\r
+if (graphGroup <= combineCount) {\r
+graphGroup = combineCount + 1;\r
+}aa.graphGroup = graphGroup;\r
+}break;\r
+}}\r
+while (st.hasMoreTokens ()) {\r
+group = st.nextToken ();\r
+for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {\r
+var aa = al.getAlignmentAnnotation ()[i];\r
+if (aa.sequenceRef === seqRef && aa.groupRef === groupRef && aa.label.equalsIgnoreCase (group)) {\r
+aa.graphGroup = graphGroup;\r
+break;\r
+}}\r
+}\r
+} else {\r
+System.err.println ("Couldn't combine annotations. None are added to alignment yet!");\r
+}}, "jalview.datamodel.AlignmentI,~N,java.util.StringTokenizer,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup");\r
+Clazz.defineMethod (c$, "addLine", \r
+function (al, st, seqRef, groupRef) {\r
+var group = st.nextToken ();\r
+var annotation = null;\r
+var alannot = al.getAlignmentAnnotation ();\r
+var value =  new Float (st.nextToken ()).floatValue ();\r
+var label = st.hasMoreTokens () ? st.nextToken () : null;\r
+var colour = null;\r
+if (st.hasMoreTokens ()) {\r
+var ucs =  new jalview.schemes.UserColourScheme (st.nextToken ());\r
+colour = ucs.findColour ('A');\r
+}if (alannot != null) {\r
+for (var i = 0; i < alannot.length; i++) {\r
+if (alannot[i].label.equalsIgnoreCase (group) && (seqRef == null || alannot[i].sequenceRef === seqRef) && (groupRef == null || alannot[i].groupRef === groupRef)) {\r
+alannot[i].setThreshold ( new jalview.datamodel.GraphLine (value, label, colour));\r
+}}\r
+}if (annotation == null) {\r
+return;\r
+}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup");\r
+Clazz.defineMethod (c$, "addGroup", \r
+function (al, st) {\r
+var sg =  new jalview.datamodel.SequenceGroup ();\r
+sg.setName (st.nextToken ());\r
+var rng = "";\r
+try {\r
+rng = st.nextToken ();\r
+if (rng.length > 0 && !rng.startsWith ("*")) {\r
+sg.setStartRes (Integer.parseInt (rng) - 1);\r
+} else {\r
+sg.setStartRes (0);\r
+}rng = st.nextToken ();\r
+if (rng.length > 0 && !rng.startsWith ("*")) {\r
+sg.setEndRes (Integer.parseInt (rng) - 1);\r
+} else {\r
+sg.setEndRes (al.getWidth () - 1);\r
+}} catch (e) {\r
+if (Clazz.exceptionOf (e, Exception)) {\r
+System.err.println ("Couldn't parse Group Start or End Field as '*' or a valid column or sequence index: '" + rng + "' - assuming alignment width for group.");\r
+sg.setStartRes (0);\r
+sg.setEndRes (al.getWidth () - 1);\r
+} else {\r
+throw e;\r
+}\r
+}\r
+var index = st.nextToken ();\r
+if (index.equals ("-1")) {\r
+while (st.hasMoreElements ()) {\r
+sg.addSequence (al.findName (st.nextToken ()), false);\r
+}\r
+} else {\r
+var st2 =  new java.util.StringTokenizer (index, ",");\r
+while (st2.hasMoreTokens ()) {\r
+var tmp = st2.nextToken ();\r
+if (tmp.equals ("*")) {\r
+for (var i = 0; i < al.getHeight (); i++) {\r
+sg.addSequence (al.getSequenceAt (i), false);\r
+}\r
+} else if (tmp.indexOf ("-") >= 0) {\r
+var st3 =  new java.util.StringTokenizer (tmp, "-");\r
+var start = (Integer.parseInt (st3.nextToken ()));\r
+var end = (Integer.parseInt (st3.nextToken ()));\r
+if (end > start) {\r
+for (var i = start; i <= end; i++) {\r
+sg.addSequence (al.getSequenceAt (i - 1), false);\r
+}\r
+}} else {\r
+sg.addSequence (al.getSequenceAt (Integer.parseInt (tmp) - 1), false);\r
+}}\r
+}if (this.refSeq != null) {\r
+sg.setStartRes (this.refSeq.findIndex (sg.getStartRes () + 1) - 1);\r
+sg.setEndRes (this.refSeq.findIndex (sg.getEndRes () + 1) - 1);\r
+sg.setSeqrep (this.refSeq);\r
+}if (sg.getSize () > 0) {\r
+al.addGroup (sg);\r
+}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");\r
+Clazz.defineMethod (c$, "addRowProperties", \r
+function (al, st) {\r
+var label = st.nextToken ();\r
+var keyValue;\r
+var key;\r
+var value;\r
+var scaletofit = false;\r
+var centerlab = false;\r
+var showalllabs = false;\r
+while (st.hasMoreTokens ()) {\r
+keyValue = st.nextToken ();\r
+key = keyValue.substring (0, keyValue.indexOf ("="));\r
+value = keyValue.substring (keyValue.indexOf ("=") + 1);\r
+if (key.equalsIgnoreCase ("scaletofit")) {\r
+scaletofit = Boolean.$valueOf (value).booleanValue ();\r
+}if (key.equalsIgnoreCase ("showalllabs")) {\r
+showalllabs = Boolean.$valueOf (value).booleanValue ();\r
+}if (key.equalsIgnoreCase ("centrelabs")) {\r
+centerlab = Boolean.$valueOf (value).booleanValue ();\r
+}var alr = al.getAlignmentAnnotation ();\r
+if (alr != null) {\r
+for (var i = 0; i < alr.length; i++) {\r
+if (alr[i].label.equalsIgnoreCase (label)) {\r
+alr[i].centreColLabels = centerlab;\r
+alr[i].scaleColLabel = scaletofit;\r
+alr[i].showAllColLabels = showalllabs;\r
+}}\r
+}}\r
+}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");\r
+Clazz.defineMethod (c$, "addProperties", \r
+function (al, st) {\r
+if (al.getGroups () == null) {\r
+return;\r
+}var name = st.nextToken ();\r
+var sg = null;\r
+for (var _sg, $_sg = al.getGroups ().iterator (); $_sg.hasNext () && ((_sg = $_sg.next ()) || true);) {\r
+if ((sg = _sg).getName ().equals (name)) {\r
+break;\r
+} else {\r
+sg = null;\r
+}}\r
+if (sg != null) {\r
+var keyValue;\r
+var key;\r
+var value;\r
+var def = sg.cs;\r
+sg.cs = null;\r
+while (st.hasMoreTokens ()) {\r
+keyValue = st.nextToken ();\r
+key = keyValue.substring (0, keyValue.indexOf ("="));\r
+value = keyValue.substring (keyValue.indexOf ("=") + 1);\r
+if (key.equalsIgnoreCase ("description")) {\r
+sg.setDescription (value);\r
+} else if (key.equalsIgnoreCase ("colour")) {\r
+sg.cs = jalview.schemes.ColourSchemeProperty.getColour (al, value);\r
+} else if (key.equalsIgnoreCase ("pidThreshold")) {\r
+sg.cs.setThreshold (Integer.parseInt (value), true);\r
+} else if (key.equalsIgnoreCase ("consThreshold")) {\r
+sg.cs.setConservationInc (Integer.parseInt (value));\r
+var c =  new jalview.analysis.Conservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (null), sg.getStartRes (), sg.getEndRes () + 1);\r
+c.calculate ();\r
+c.verdict (false, 25);\r
+sg.cs.setConservation (c);\r
+} else if (key.equalsIgnoreCase ("outlineColour")) {\r
+sg.setOutlineColour ( new jalview.schemes.UserColourScheme (value).findColour ('A'));\r
+} else if (key.equalsIgnoreCase ("displayBoxes")) {\r
+sg.setDisplayBoxes (Boolean.$valueOf (value).booleanValue ());\r
+} else if (key.equalsIgnoreCase ("showUnconserved")) {\r
+sg.setShowNonconserved (Boolean.$valueOf (value).booleanValue ());\r
+} else if (key.equalsIgnoreCase ("displayText")) {\r
+sg.setDisplayText (Boolean.$valueOf (value).booleanValue ());\r
+} else if (key.equalsIgnoreCase ("colourText")) {\r
+sg.setColourText (Boolean.$valueOf (value).booleanValue ());\r
+} else if (key.equalsIgnoreCase ("textCol1")) {\r
+sg.textColour =  new jalview.schemes.UserColourScheme (value).findColour ('A');\r
+} else if (key.equalsIgnoreCase ("textCol2")) {\r
+sg.textColour2 =  new jalview.schemes.UserColourScheme (value).findColour ('A');\r
+} else if (key.equalsIgnoreCase ("textColThreshold")) {\r
+sg.thresholdTextColour = Integer.parseInt (value);\r
+} else if (key.equalsIgnoreCase ("idColour")) {\r
+sg.setIdColour ((def =  new jalview.schemes.UserColourScheme (value)).findColour ('A'));\r
+} else if (key.equalsIgnoreCase ("hide")) {\r
+sg.setHidereps (true);\r
+} else if (key.equalsIgnoreCase ("hidecols")) {\r
+sg.setHideCols (true);\r
+}sg.recalcConservation ();\r
+}\r
+if (sg.cs == null) {\r
+sg.cs = def;\r
+}}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");\r
+Clazz.defineMethod (c$, "setBelowAlignment", \r
+function (al, st) {\r
+var token;\r
+var aa;\r
+var ala = al.getAlignmentAnnotation ();\r
+if (ala == null) {\r
+System.err.print ("Warning - no annotation to set below for sequence associated annotation:");\r
+}while (st.hasMoreTokens ()) {\r
+token = st.nextToken ();\r
+if (ala == null) {\r
+System.err.print (" " + token);\r
+} else {\r
+for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {\r
+aa = al.getAlignmentAnnotation ()[i];\r
+if (aa.sequenceRef === this.refSeq && aa.label.equals (token)) {\r
+aa.belowAlignment = true;\r
+}}\r
+}}\r
+if (ala == null) {\r
+System.err.print ("\n");\r
+}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");\r
+Clazz.defineMethod (c$, "addAlignmentDetails", \r
+function (al, st) {\r
+var keyValue;\r
+var key;\r
+var value;\r
+while (st.hasMoreTokens ()) {\r
+keyValue = st.nextToken ();\r
+key = keyValue.substring (0, keyValue.indexOf ("="));\r
+value = keyValue.substring (keyValue.indexOf ("=") + 1);\r
+al.setProperty (key, value);\r
+}\r
+}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");\r
+Clazz.defineMethod (c$, "printCSVAnnotations", \r
+function (annotations) {\r
+var sp =  new StringBuffer ();\r
+for (var i = 0; i < annotations.length; i++) {\r
+var atos = annotations[i].toString ();\r
+var p = 0;\r
+do {\r
+var cp = atos.indexOf ("\n", p);\r
+sp.append (annotations[i].label);\r
+sp.append (",");\r
+if (cp > p) {\r
+sp.append (atos.substring (p, cp + 1));\r
+} else {\r
+sp.append (atos.substring (p));\r
+sp.append (this.newline);\r
+}p = cp + 1;\r
+} while (p > 0);\r
+}\r
+return sp.toString ();\r
+}, "~A");\r
+Clazz.defineMethod (c$, "printAnnotationsForView", \r
+function (viewport) {\r
+return this.printAnnotations (viewport.isShowAnnotation () ? viewport.getAlignment ().getAlignmentAnnotation () : null, viewport.getAlignment ().getGroups (), viewport.getAlignment ().getProperties (), viewport.getColumnSelection (), viewport.getAlignment (), null);\r
+}, "jalview.api.AlignViewportI");\r
+Clazz.defineMethod (c$, "printAnnotationsForAlignment", \r
+function (al) {\r
+return this.printAnnotations (al.getAlignmentAnnotation (), al.getGroups (), al.getProperties (), null, al, null);\r
+}, "jalview.datamodel.AlignmentI");\r
+c$.$AnnotationFile$ViewDef$ = function () {\r
+Clazz.pu$h ();\r
+c$ = Clazz.decorateAsClass (function () {\r
+Clazz.prepareCallback (this, arguments);\r
+this.viewname = null;\r
+this.hidseqs = null;\r
+this.hiddencols = null;\r
+this.visibleGroups = null;\r
+this.hiddenRepSeqs = null;\r
+Clazz.instantialize (this, arguments);\r
+}, jalview.io.AnnotationFile, "ViewDef");\r
+Clazz.makeConstructor (c$, \r
+function (a, b, c, d) {\r
+this.viewname = a;\r
+this.hidseqs = b;\r
+this.hiddencols = c;\r
+this.hiddenRepSeqs = d;\r
+}, "~S,jalview.datamodel.HiddenSequences,jalview.datamodel.ColumnSelection,java.util.Hashtable");\r
+c$ = Clazz.p0p ();\r
+};\r
+Clazz.defineStatics (c$,\r
+"GRAPHLINE", "GRAPHLINE",\r
+"COMBINE", "COMBINE");\r
+});\r