X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fio%2FAnnotationFile.js;h=ed8daf2549806d5f3cacf4b07dfd656a940e4f20;hp=59a4df572064f236351d0d12f1e5da46c311741f;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6 diff --git a/site/j2s/jalview/io/AnnotationFile.js b/site/j2s/jalview/io/AnnotationFile.js index 59a4df5..ed8daf2 100644 --- a/site/j2s/jalview/io/AnnotationFile.js +++ b/site/j2s/jalview/io/AnnotationFile.js @@ -1,1003 +1,1003 @@ -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", - function () { -this.text = new StringBuffer ("JALVIEW_ANNOTATION" + this.newline + "# Created: " + new java.util.Date () + this.newline + this.newline); -this.refSeq = null; -this.refSeqId = null; -}); -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", - 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; -}, "jalview.datamodel.SequenceGroup,jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "writeSequence_Ref", - 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; -}, "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", - 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); -}}} -}, "jalview.datamodel.ColumnSelection,~S"); -Clazz.defineMethod (c$, "autoAnnotsKey", - function (annotation, refSeq, groupRef) { -return annotation.graph + "\t" + annotation.label + "\t" + annotation.description + "\t" + (refSeq != null ? refSeq.getDisplayId (true) : ""); -}, "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(self.c$); -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"); +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", + function () { +this.text = new StringBuffer ("JALVIEW_ANNOTATION" + this.newline + "# Created: " + new java.util.Date () + this.newline + this.newline); +this.refSeq = null; +this.refSeqId = null; +}); +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", + 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; +}, "jalview.datamodel.SequenceGroup,jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "writeSequence_Ref", + 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; +}, "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", + 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); +}}} +}, "jalview.datamodel.ColumnSelection,~S"); +Clazz.defineMethod (c$, "autoAnnotsKey", + function (annotation, refSeq, groupRef) { +return annotation.graph + "\t" + annotation.label + "\t" + annotation.description + "\t" + (refSeq != null ? refSeq.getDisplayId (true) : ""); +}, "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(self.c$); +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"); +});