X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fanalysis%2FConservation.js;h=aa95a7372fdd92fd189865943c3d9a9882633dd9;hp=1a43b1ac99f15e57286a0800853d62cadd3fd355;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/analysis/Conservation.js b/bin/jalview/analysis/Conservation.js index 1a43b1a..aa95a73 100644 --- a/bin/jalview/analysis/Conservation.js +++ b/bin/jalview/analysis/Conservation.js @@ -1,371 +1,370 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.Conservation", ["jalview.datamodel.Annotation", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.awt.Color", "java.lang.Character", "$.Double", "$.StringBuffer", "java.util.Hashtable", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.sequences = null; -this.start = 0; -this.end = 0; -this.seqNums = null; -this.maxLength = 0; -this.seqNumsChanged = false; -this.total = null; -this.canonicaliseAa = true; -this.quality = null; -this.qualityRange = null; -this.consString = ""; -this.consSequence = null; -this.propHash = null; -this.threshold = 0; -this.name = ""; -this.cons2 = null; -this.consSymbs = null; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "Conservation"); -Clazz.prepareFields (c$, function () { -this.qualityRange = new Array (2); -}); -Clazz.makeConstructor (c$, -function (name, propHash, threshold, sequences, start, end) { -this.name = name; -this.propHash = propHash; -this.threshold = threshold; -this.start = start; -this.end = end; -this.maxLength = end - start + 1; -var s; -var sSize = sequences.size (); -var sarray = new Array (sSize); -this.sequences = sarray; -try { -for (s = 0; s < sSize; s++) { -sarray[s] = sequences.get (s); -if (sarray[s].getLength () > this.maxLength) { -this.maxLength = sarray[s].getLength (); -}} -} catch (ex) { -if (Clazz.exceptionOf (ex, ArrayIndexOutOfBoundsException)) { -this.sequences = new Array (0); -this.maxLength = 0; -} else { -throw ex; -} -} -}, "~S,java.util.Hashtable,~N,java.util.List,~N,~N"); -Clazz.defineMethod (c$, "calcSeqNum", -($fz = function (i) { -var sq = null; -var sqnum = null; -var sSize = this.sequences.length; -if ((i > -1) && (i < sSize)) { -sq = this.sequences[i].getSequenceAsString (); -if (this.seqNums.size () <= i) { -this.seqNums.addElement ( Clazz.newIntArray (sq.length + 1, 0)); -}if (sq.hashCode () != (this.seqNums.elementAt (i))[0]) { -var j; -var len; -this.seqNumsChanged = true; -len = sq.length; -if (this.maxLength < len) { -this.maxLength = len; -}sqnum = Clazz.newIntArray (len + 1, 0); -sqnum[0] = sq.hashCode (); -for (j = 1; j <= len; j++) { -sqnum[j] = jalview.schemes.ResidueProperties.aaIndex[sq.charCodeAt (j - 1)]; -} -this.seqNums.setElementAt (sqnum, i); -} else { -System.out.println ("SEQUENCE HAS BEEN DELETED!!!"); -}} else { -System.err.println ("ERROR: calcSeqNum called with out of range sequence index for Alignment\n"); -}}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "calculate", -function () { -var resultHash; -var ht; -var thresh; -var j; -var jSize = this.sequences.length; -var values; -var type; -var res = null; -var c; -var enumeration2; -this.total = new Array (this.maxLength); -for (var i = this.start; i <= this.end; i++) { -values = Clazz.newIntArray (255, 0); -for (j = 0; j < jSize; j++) { -if (this.sequences[j].getLength () > i) { -c = this.sequences[j].getCharAt (i); -if (this.canonicaliseAa) { -c = String.fromCharCode (jalview.schemes.ResidueProperties.aaIndex[this.sequences[j].getCharAt (i).charCodeAt (0)]); -if (c.charCodeAt (0) > 20) { -c = '-'; -} else { -c = jalview.schemes.ResidueProperties.aa[c.charCodeAt (0)].charAt (0); -}} else { -if (c == '.' || c == ' ') { -c = '-'; -}if (!this.canonicaliseAa && 'a' <= c && c <= 'z') { -c = String.fromCharCode (c.charCodeAt (0) - (32)); -}}values[c.charCodeAt (0)]++; -} else { -values['-'.charCodeAt (0)]++; -}} -thresh = Clazz.doubleToInt ((this.threshold * (jSize)) / 100); -resultHash = new java.util.Hashtable (); -for (var v = '-'; v < 'Z'; v = String.fromCharCode (v.charCodeAt (0) + 1)) { -if (values[v.charCodeAt (0)] > thresh) { -res = String.valueOf (v); -enumeration2 = this.propHash.keys (); -while (enumeration2.hasMoreElements ()) { -type = enumeration2.nextElement (); -ht = this.propHash.get (type); -if (!resultHash.containsKey (type)) { -if (ht.containsKey (res)) { -resultHash.put (type, ht.get (res)); -} else { -resultHash.put (type, ht.get ("-")); -}} else if ((resultHash.get (type)).equals (ht.get (res)) == false) { -resultHash.put (type, new Integer (-1)); -}} -}} -if (this.total.length > 0) { -this.total[i - this.start] = resultHash; -}} -}); -Clazz.defineMethod (c$, "countConsNGaps", -function (j) { -var count = 0; -var cons = 0; -var nres = 0; -var r = Clazz.newIntArray (2, 0); -var f = '$'; -var i; -var iSize = this.sequences.length; -var c; -for (i = 0; i < iSize; i++) { -if (j >= this.sequences[i].getLength ()) { -count++; -continue; -}c = this.sequences[i].getCharAt (j); -if (jalview.util.Comparison.isGap ((c))) { -count++; -} else { -nres++; -if (nres == 1) { -f = c; -cons++; -} else if (f == c) { -cons++; -}}} -r[0] = (nres == cons) ? 1 : 0; -r[1] = count; -return r; -}, "~N"); -Clazz.defineMethod (c$, "verdict", -function (consflag, percentageGaps) { -var consString = new StringBuffer (); -var type; -var result; -var gapcons; -var totGaps; -var count; -var pgaps; -var resultHash; -var enumeration; -for (var i = 0; i < this.start; i++) { -consString.append ('-'); -} -this.consSymbs = new Array (this.end - this.start + 1); -for (var i = this.start; i <= this.end; i++) { -gapcons = this.countConsNGaps (i); -totGaps = gapcons[1]; -pgaps = (totGaps * 100) / this.sequences.length; -this.consSymbs[i - this.start] = String.instantialize (); -if (percentageGaps > pgaps) { -resultHash = this.total[i - this.start]; -count = 0; -enumeration = resultHash.keys (); -while (enumeration.hasMoreElements ()) { -type = enumeration.nextElement (); -result = resultHash.get (type); -if (consflag) { -if (result.intValue () == 1) { -this.consSymbs[i - this.start] = type + " " + this.consSymbs[i - this.start]; -count++; -}} else { -if (result.intValue () != -1) { -{ -if (result.intValue () == 0) { -this.consSymbs[i - this.start] = this.consSymbs[i - this.start] + " !" + type; -} else { -this.consSymbs[i - this.start] = type + " " + this.consSymbs[i - this.start]; -}}count++; -}}} -if (count < 10) { -{ -consString.append(""+count); -}} else { -consString.append ((gapcons[0] == 1) ? "*" : "+"); -}} else { -consString.append ('-'); -}} -this.consSequence = new jalview.datamodel.Sequence (this.name, consString.toString (), this.start, this.end); -}, "~B,~N"); -Clazz.defineMethod (c$, "getConsSequence", -function () { -return this.consSequence; -}); -Clazz.defineMethod (c$, "findQuality", -function () { -this.findQuality (0, this.maxLength - 1); -}); -Clazz.defineMethod (c$, "percentIdentity2", -($fz = function () { -this.seqNums = new java.util.Vector (); -var i = 0; -var iSize = this.sequences.length; -for (i = 0; i < iSize; i++) { -this.calcSeqNum (i); -} -if ((this.cons2 == null) || this.seqNumsChanged) { -this.cons2 = Clazz.newIntArray (this.maxLength, 24, 0); -for (var j = 0; j < 24; j++) { -for (i = 0; i < this.maxLength; i++) { -this.cons2[i][j] = 0; -} -} -var sqnum; -var j = 0; -while (j < this.sequences.length) { -sqnum = this.seqNums.elementAt (j); -for (i = 1; i < sqnum.length; i++) { -this.cons2[i - 1][sqnum[i]]++; -} -for (i = sqnum.length - 1; i < this.maxLength; i++) { -this.cons2[i][23]++; -} -j++; -} -}}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "findQuality", -function (start, end) { -this.quality = new java.util.Vector (); -var max = -10000; -var BLOSUM62 = jalview.schemes.ResidueProperties.getBLOSUM62 (); -this.percentIdentity2 (); -var size = this.seqNums.size (); -var lengths = Clazz.newIntArray (size, 0); -var tot; -var bigtot; -var sr; -var tmp; -var x; -var xx; -var l; -var j; -var i; -var ii; -var i2; -var k; -var seqNum; -for (l = 0; l < size; l++) { -lengths[l] = (this.seqNums.elementAt (l)).length - 1; -} -for (j = start; j <= end; j++) { -bigtot = 0; -x = Clazz.newDoubleArray (24, 0); -for (ii = 0; ii < 24; ii++) { -x[ii] = 0; -for (i2 = 0; i2 < 24; i2++) { -x[ii] += ((this.cons2[j][i2] * BLOSUM62[ii][i2]) + 4); -} -x[ii] /= size; -} -for (k = 0; k < size; k++) { -tot = 0; -xx = Clazz.newDoubleArray (24, 0); -seqNum = (j < lengths[k]) ? (this.seqNums.elementAt (k))[j + 1] : 23; -for (i = 0; i < 23; i++) { -sr = 0; -sr = BLOSUM62[i][seqNum] + 4; -xx[i] = x[i] - sr; -tot += (xx[i] * xx[i]); -} -bigtot += Math.sqrt (tot); -} -if (max < bigtot) { -max = bigtot; -}this.quality.addElement ( new Double (bigtot)); -} -var newmax = -10000; -for (j = start; j <= end; j++) { -tmp = (this.quality.elementAt (j)).doubleValue (); -tmp = ((max - tmp) * (size - this.cons2[j][23])) / size; -this.quality.setElementAt ( new Double (tmp), j); -if (tmp > newmax) { -newmax = tmp; -}} -this.qualityRange[0] = new Double (0); -this.qualityRange[1] = new Double (newmax); -}, "~N,~N"); -Clazz.defineMethod (c$, "completeAnnotations", -function (conservation, quality2, istart, alWidth) { -var sequence = this.getConsSequence ().getSequence (); -var minR; -var minG; -var minB; -var maxR; -var maxG; -var maxB; -minR = 0.3; -minG = 0.0; -minB = 0; -maxR = 1.0 - minR; -maxG = 0.9 - minG; -maxB = 0 - minB; -var min = 0; -var max = 11; -var qmin = 0; -var qmax = 0; -var c; -if (conservation.annotations != null && conservation.annotations.length < alWidth) { -conservation.annotations = new Array (alWidth); -}if (quality2 != null) { -quality2.graphMax = this.qualityRange[1].floatValue (); -if (quality2.annotations != null && quality2.annotations.length < alWidth) { -quality2.annotations = new Array (alWidth); -}qmin = this.qualityRange[0].floatValue (); -qmax = this.qualityRange[1].floatValue (); -}for (var i = 0; i < alWidth; i++) { -var value = 0; -c = sequence[i]; -if (Character.isDigit (c)) { -value = c.charCodeAt (0) - 48; -} else if (c == '*') { -value = 11; -} else if (c == '+') { -value = 10; -}var vprop = value - min; -vprop /= max; -conservation.annotations[i] = new jalview.datamodel.Annotation (String.valueOf (c), this.consSymbs[i - this.start], ' ', value, new java.awt.Color (minR + (maxR * vprop), minG + (maxG * vprop), minB + (maxB * vprop))); -if (quality2 != null) { -value = (this.quality.elementAt (i)).floatValue (); -vprop = value - qmin; -vprop /= qmax; -quality2.annotations[i] = new jalview.datamodel.Annotation (" ", String.valueOf (value), ' ', value, new java.awt.Color (minR + (maxR * vprop), minG + (maxG * vprop), minB + (maxB * vprop))); -}} -}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation,~N,~N"); -c$.calculateConservation = Clazz.defineMethod (c$, "calculateConservation", -function (name, consHash, threshold, seqs, start, end, posOrNeg, consPercGaps, calcQuality) { -var cons = new jalview.analysis.Conservation (name, consHash, threshold, seqs, start, end); -return jalview.analysis.Conservation.calculateConservation (cons, posOrNeg, consPercGaps, calcQuality); -}, "~S,java.util.Hashtable,~N,java.util.List,~N,~N,~B,~N,~B"); -c$.calculateConservation = Clazz.defineMethod (c$, "calculateConservation", -function (cons, b, consPercGaps, calcQuality) { -cons.calculate (); -cons.verdict (b, consPercGaps); -if (calcQuality) { -cons.findQuality (); -}return cons; -}, "jalview.analysis.Conservation,~B,~N,~B"); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.Conservation", ["jalview.datamodel.Annotation", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.awt.Color", "java.lang.Character", "$.Double", "$.StringBuffer", "java.util.Hashtable", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.sequences = null; +this.start = 0; +this.end = 0; +this.seqNums = null; +this.maxLength = 0; +this.seqNumsChanged = false; +this.total = null; +this.canonicaliseAa = true; +this.quality = null; +this.qualityRange = null; +this.consString = ""; +this.consSequence = null; +this.propHash = null; +this.threshold = 0; +this.name = ""; +this.cons2 = null; +this.consSymbs = null; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "Conservation"); +Clazz.prepareFields (c$, function () { +this.qualityRange = new Array (2); +}); +Clazz.makeConstructor (c$, +function (name, propHash, threshold, sequences, start, end) { +this.name = name; +this.propHash = propHash; +this.threshold = threshold; +this.start = start; +this.end = end; +this.maxLength = end - start + 1; +var s; +var sSize = sequences.size (); +var sarray = new Array (sSize); +this.sequences = sarray; +try { +for (s = 0; s < sSize; s++) { +sarray[s] = sequences.get (s); +if (sarray[s].getLength () > this.maxLength) { +this.maxLength = sarray[s].getLength (); +}} +} catch (ex) { +if (Clazz.exceptionOf (ex, ArrayIndexOutOfBoundsException)) { +this.sequences = new Array (0); +this.maxLength = 0; +} else { +throw ex; +} +} +}, "~S,java.util.Hashtable,~N,java.util.List,~N,~N"); +Clazz.defineMethod (c$, "calcSeqNum", +($fz = function (i) { +var sq = null; +var sqnum = null; +var sSize = this.sequences.length; +if ((i > -1) && (i < sSize)) { +sq = this.sequences[i].getSequenceAsString (); +if (this.seqNums.size () <= i) { +this.seqNums.addElement ( Clazz.newIntArray (sq.length + 1, 0)); +}if (sq.hashCode () != (this.seqNums.elementAt (i))[0]) { +var j; +var len; +this.seqNumsChanged = true; +len = sq.length; +if (this.maxLength < len) { +this.maxLength = len; +}sqnum = Clazz.newIntArray (len + 1, 0); +sqnum[0] = sq.hashCode (); +for (j = 1; j <= len; j++) { +sqnum[j] = jalview.schemes.ResidueProperties.aaIndex[sq.charCodeAt (j - 1)]; +} +this.seqNums.setElementAt (sqnum, i); +} else { +System.out.println ("SEQUENCE HAS BEEN DELETED!!!"); +}} else { +System.err.println ("ERROR: calcSeqNum called with out of range sequence index for Alignment\n"); +}}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "calculate", +function () { +var resultHash; +var ht; +var thresh; +var j; +var jSize = this.sequences.length; +var values; +var type; +var res = null; +var c; +var enumeration2; +this.total = new Array (this.maxLength); +for (var i = this.start; i <= this.end; i++) { +values = Clazz.newIntArray (255, 0); +for (j = 0; j < jSize; j++) { +if (this.sequences[j].getLength () > i) { +c = this.sequences[j].getCharAt (i); +if (this.canonicaliseAa) { +c = String.fromCharCode (jalview.schemes.ResidueProperties.aaIndex[this.sequences[j].getCharAt (i).charCodeAt (0)]); +if (c.charCodeAt (0) > 20) { +c = '-'; +} else { +c = jalview.schemes.ResidueProperties.aa[c.charCodeAt (0)].charAt (0); +}} else { +if (c == '.' || c == ' ') { +c = '-'; +}if (!this.canonicaliseAa && 'a' <= c && c <= 'z') { +c = String.fromCharCode (c.charCodeAt (0) - (32)); +}}values[c.charCodeAt (0)]++; +} else { +values['-'.charCodeAt (0)]++; +}} +thresh = Clazz.doubleToInt ((this.threshold * (jSize)) / 100); +resultHash = new java.util.Hashtable (); +for (var v = '-'; v < 'Z'; v = String.fromCharCode (v.charCodeAt (0) + 1)) { +if (values[v.charCodeAt (0)] > thresh) { +res = String.valueOf (v); +enumeration2 = this.propHash.keys (); +while (enumeration2.hasMoreElements ()) { +type = enumeration2.nextElement (); +ht = this.propHash.get (type); +if (!resultHash.containsKey (type)) { +if (ht.containsKey (res)) { +resultHash.put (type, ht.get (res)); +} else { +resultHash.put (type, ht.get ("-")); +}} else if ((resultHash.get (type)).equals (ht.get (res)) == false) { +resultHash.put (type, new Integer (-1)); +}} +}} +if (this.total.length > 0) { +this.total[i - this.start] = resultHash; +}} +}); +Clazz.defineMethod (c$, "countConsNGaps", +function (j) { +var count = 0; +var cons = 0; +var nres = 0; +var r = Clazz.newIntArray (2, 0); +var f = '$'; +var i; +var iSize = this.sequences.length; +var c; +for (i = 0; i < iSize; i++) { +if (j >= this.sequences[i].getLength ()) { +count++; +continue; +}c = this.sequences[i].getCharAt (j); +if (jalview.util.Comparison.isGap ((c))) { +count++; +} else { +nres++; +if (nres == 1) { +f = c; +cons++; +} else if (f == c) { +cons++; +}}} +r[0] = (nres == cons) ? 1 : 0; +r[1] = count; +return r; +}, "~N"); +Clazz.defineMethod (c$, "verdict", +function (consflag, percentageGaps) { +var consString = new StringBuffer (); +var type; +var result; +var gapcons; +var totGaps; +var count; +var pgaps; +var resultHash; +var enumeration; +for (var i = 0; i < this.start; i++) { +consString.append ('-'); +} +this.consSymbs = new Array (this.end - this.start + 1); +for (var i = this.start; i <= this.end; i++) { +gapcons = this.countConsNGaps (i); +totGaps = gapcons[1]; +pgaps = (totGaps * 100) / this.sequences.length; +this.consSymbs[i - this.start] = String.instantialize (); +if (percentageGaps > pgaps) { +resultHash = this.total[i - this.start]; +count = 0; +enumeration = resultHash.keys (); +while (enumeration.hasMoreElements ()) { +type = enumeration.nextElement (); +result = resultHash.get (type); +if (consflag) { +if (result.intValue () == 1) { +this.consSymbs[i - this.start] = type + " " + this.consSymbs[i - this.start]; +count++; +}} else { +if (result.intValue () != -1) { +{ +if (result.intValue () == 0) { +this.consSymbs[i - this.start] = this.consSymbs[i - this.start] + " !" + type; +} else { +this.consSymbs[i - this.start] = type + " " + this.consSymbs[i - this.start]; +}}count++; +}}} +if (count < 10) { +consString.append ("" + count); +} else { +consString.append ((gapcons[0] == 1) ? "*" : "+"); +}} else { +consString.append ('-'); +}} +this.consSequence = new jalview.datamodel.Sequence (this.name, consString.toString (), this.start, this.end); +}, "~B,~N"); +Clazz.defineMethod (c$, "getConsSequence", +function () { +return this.consSequence; +}); +Clazz.defineMethod (c$, "findQuality", +function () { +this.findQuality (0, this.maxLength - 1); +}); +Clazz.defineMethod (c$, "percentIdentity2", +($fz = function () { +this.seqNums = new java.util.Vector (); +var i = 0; +var iSize = this.sequences.length; +for (i = 0; i < iSize; i++) { +this.calcSeqNum (i); +} +if ((this.cons2 == null) || this.seqNumsChanged) { +this.cons2 = Clazz.newIntArray (this.maxLength, 24, 0); +for (var j = 0; j < 24; j++) { +for (i = 0; i < this.maxLength; i++) { +this.cons2[i][j] = 0; +} +} +var sqnum; +var j = 0; +while (j < this.sequences.length) { +sqnum = this.seqNums.elementAt (j); +for (i = 1; i < sqnum.length; i++) { +this.cons2[i - 1][sqnum[i]]++; +} +for (i = sqnum.length - 1; i < this.maxLength; i++) { +this.cons2[i][23]++; +} +j++; +} +}}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "findQuality", +function (start, end) { +this.quality = new java.util.Vector (); +var max = -10000; +var BLOSUM62 = jalview.schemes.ResidueProperties.getBLOSUM62 (); +this.percentIdentity2 (); +var size = this.seqNums.size (); +var lengths = Clazz.newIntArray (size, 0); +var tot; +var bigtot; +var sr; +var tmp; +var x; +var xx; +var l; +var j; +var i; +var ii; +var i2; +var k; +var seqNum; +for (l = 0; l < size; l++) { +lengths[l] = (this.seqNums.elementAt (l)).length - 1; +} +for (j = start; j <= end; j++) { +bigtot = 0; +x = Clazz.newDoubleArray (24, 0); +for (ii = 0; ii < 24; ii++) { +x[ii] = 0; +for (i2 = 0; i2 < 24; i2++) { +x[ii] += ((this.cons2[j][i2] * BLOSUM62[ii][i2]) + 4); +} +x[ii] /= size; +} +for (k = 0; k < size; k++) { +tot = 0; +xx = Clazz.newDoubleArray (24, 0); +seqNum = (j < lengths[k]) ? (this.seqNums.elementAt (k))[j + 1] : 23; +for (i = 0; i < 23; i++) { +sr = 0; +sr = BLOSUM62[i][seqNum] + 4; +xx[i] = x[i] - sr; +tot += (xx[i] * xx[i]); +} +bigtot += Math.sqrt (tot); +} +if (max < bigtot) { +max = bigtot; +}this.quality.addElement ( new Double (bigtot)); +} +var newmax = -10000; +for (j = start; j <= end; j++) { +tmp = (this.quality.elementAt (j)).doubleValue (); +tmp = ((max - tmp) * (size - this.cons2[j][23])) / size; +this.quality.setElementAt ( new Double (tmp), j); +if (tmp > newmax) { +newmax = tmp; +}} +this.qualityRange[0] = new Double (0); +this.qualityRange[1] = new Double (newmax); +}, "~N,~N"); +Clazz.defineMethod (c$, "completeAnnotations", +function (conservation, quality2, istart, alWidth) { +var sequence = this.getConsSequence ().getSequence (); +var minR; +var minG; +var minB; +var maxR; +var maxG; +var maxB; +minR = 0.3; +minG = 0.0; +minB = 0; +maxR = 1.0 - minR; +maxG = 0.9 - minG; +maxB = 0 - minB; +var min = 0; +var max = 11; +var qmin = 0; +var qmax = 0; +var c; +if (conservation.annotations != null && conservation.annotations.length < alWidth) { +conservation.annotations = new Array (alWidth); +}if (quality2 != null) { +quality2.graphMax = this.qualityRange[1].floatValue (); +if (quality2.annotations != null && quality2.annotations.length < alWidth) { +quality2.annotations = new Array (alWidth); +}qmin = this.qualityRange[0].floatValue (); +qmax = this.qualityRange[1].floatValue (); +}for (var i = 0; i < alWidth; i++) { +var value = 0; +c = sequence[i]; +if (Character.isDigit (c)) { +value = c.charCodeAt (0) - 48; +} else if (c == '*') { +value = 11; +} else if (c == '+') { +value = 10; +}var vprop = value - min; +vprop /= max; +conservation.annotations[i] = new jalview.datamodel.Annotation (String.valueOf (c), this.consSymbs[i - this.start], ' ', value, new java.awt.Color (minR + (maxR * vprop), minG + (maxG * vprop), minB + (maxB * vprop))); +if (quality2 != null) { +value = (this.quality.elementAt (i)).floatValue (); +vprop = value - qmin; +vprop /= qmax; +quality2.annotations[i] = new jalview.datamodel.Annotation (" ", String.valueOf (value), ' ', value, new java.awt.Color (minR + (maxR * vprop), minG + (maxG * vprop), minB + (maxB * vprop))); +}} +}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation,~N,~N"); +c$.calculateConservation = Clazz.defineMethod (c$, "calculateConservation", +function (name, consHash, threshold, seqs, start, end, posOrNeg, consPercGaps, calcQuality) { +var cons = new jalview.analysis.Conservation (name, consHash, threshold, seqs, start, end); +return jalview.analysis.Conservation.calculateConservation (cons, posOrNeg, consPercGaps, calcQuality); +}, "~S,java.util.Hashtable,~N,java.util.List,~N,~N,~B,~N,~B"); +c$.calculateConservation = Clazz.defineMethod (c$, "calculateConservation", +function (cons, b, consPercGaps, calcQuality) { +cons.calculate (); +cons.verdict (b, consPercGaps); +if (calcQuality) { +cons.findQuality (); +}return cons; +}, "jalview.analysis.Conservation,~B,~N,~B"); +});