+ Conservation cons = new jalview.analysis.Conservation("All",\r
+ jalview.schemes.ResidueProperties.propHash, 3,\r
+ alignment.getSequences(), 0,\r
+ alignment.getWidth()-1);\r
+ cons.calculate();\r
+ cons.verdict(false, ConsPercGaps);\r
+ cons.findQuality();\r
+ int alWidth = alignment.getWidth();\r
+ Annotation [] annotations = new Annotation[alWidth];\r
+ Annotation [] qannotations = new Annotation[alWidth];\r
+ String sequence = cons.getConsSequence().getSequence();\r
+ float minR,minG,minB, maxR,maxG,maxB;\r
+ minR = 0.3f;\r
+ minG = 0.0f;\r
+ minB = 0f;\r
+ maxR = 1.0f-minR; maxG=0.9f-minG; maxB=0f-minB; // scalable range for colouring both Conservation and Quality\r
+ float min = 0f;\r
+ float max = 11f;\r
+ float qmin = cons.qualityRange[0].floatValue();\r
+ float qmax = cons.qualityRange[1].floatValue();\r
+\r
+ for (int i = 0; i < alWidth; i++)\r
+ {\r
+ float value = 0;\r
+ try\r
+ {\r
+ value = Integer.parseInt(sequence.charAt(i) + "");\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ if (sequence.charAt(i) == '*') value = 11;\r
+ if (sequence.charAt(i) == '+') value = 10;\r
+ }\r
+ float vprop = value-min;\r
+ vprop/=max;\r
+ annotations[i] = new Annotation(sequence.charAt(i) + "",\r
+ "", ' ', value, new Color(minR+maxR*vprop, minG+maxG*vprop, minB+maxB*vprop));\r
+ // Quality calc\r
+ value = ((Double) cons.quality.get(i)).floatValue();\r
+ vprop = value - qmin;\r
+ vprop/=qmax;\r
+ qannotations[i] = new Annotation(" ",\r
+ String.valueOf(value), ' ', value, new Color(minR+maxR*vprop, minG+maxG*vprop, minB+maxB*vprop));\r
+ }\r
+\r
+ if(conservation==null)\r
+ {\r
+ conservation = new AlignmentAnnotation("Conservation",\r
+ "Conservation of total alignment less than "+ConsPercGaps+"% gaps",\r
+ annotations,\r
+ 0f, // cons.qualityRange[0].floatValue(),\r
+ 11f, // cons.qualityRange[1].floatValue()\r
+ 1);\r
+ if(showConservation)\r
+ alignment.addAnnotation(conservation);\r
+ quality = new AlignmentAnnotation("Quality",\r
+ "Alignment Quality based on Blosum62 scores",\r
+ qannotations,\r
+ cons.qualityRange[0].floatValue(),\r
+ cons.qualityRange[1].floatValue(),\r
+ 1);\r
+ if(showQuality)\r
+ alignment.addAnnotation(quality);\r
+ }\r
+ else {\r
+ conservation.annotations = annotations;\r
+ quality.annotations = qannotations;\r
+ quality.graphMax = cons.qualityRange[1].floatValue();\r
+ }\r
+\r
+\r