\r
AlignmentAnnotation consensus;\r
AlignmentAnnotation conservation;\r
+ AlignmentAnnotation quality;\r
+\r
public void updateConservation()\r
{\r
- Annotation [] annotations = new Annotation[alignment.getWidth()];\r
-\r
+ int percGaps = 100; // JBPNote : This should be a scalable property!\r
Conservation cons = new jalview.analysis.Conservation("All",\r
- jalview.schemes.ResidueProperties.propHash, 3,\r
+ jalview.schemes.ResidueProperties.propHash, 1,\r
alignment.getSequences(), 0,\r
alignment.getWidth());\r
cons.calculate();\r
- cons.verdict(false, 100);\r
+ cons.verdict(false, percGaps);\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 = 0f;\r
+ minG = 0.0f;\r
minB = 0f;\r
- maxR = 1.0f-minR; maxG=0.9f-minG; maxB=0f-minB; // scalable range for colouring\r
- float min = cons.qualityRange[0].floatValue();\r
- float max = cons.qualityRange[1].floatValue();\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 < alignment.getWidth(); i++)\r
+ for (int i = 0; i < alWidth; i++)\r
{\r
float value = 0;\r
try\r
- {\r
- //value = Integer.parseInt(sequence.charAt(i) + "");\r
- value = ((Double) cons.quality.get(i)).floatValue();\r
- }\r
+ {\r
+ value = Integer.parseInt(sequence.charAt(i) + "");\r
+ }\r
catch (Exception ex)\r
- {\r
- if (sequence.charAt(i) == '*') value = 10;\r
- }\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
- "Conservation graph", ' ', value, new Color(minR+maxR*vprop, minB+maxB*vprop, minB+maxB*vprop));\r
+ "Conservation graph", ' ', 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(sequence.charAt(i) + "",\r
+ new 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("Quality",\r
- "Quality of total alignment",\r
+ conservation = new AlignmentAnnotation("Conservation",\r
+ "Conservation of total alignment less than "+percGaps+"% gaps",\r
annotations,\r
- cons.qualityRange[0].floatValue(),\r
- cons.qualityRange[1].floatValue(), 1);\r
+ 0f, // cons.qualityRange[0].floatValue(),\r
+ 11f, // cons.qualityRange[1].floatValue()\r
+ 1);\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
+ alignment.addAnnotation(quality);\r
}\r
- else\r
+ else {\r
conservation.annotations = annotations;\r
+ quality.annotations = qannotations;\r
+ }\r
+\r
\r
}\r
\r
\r
Vector cons = alignment.getAAFrequency();\r
Hashtable hash = null;\r
- for (int i = 0; i < alignment.getWidth(); i++)\r
+ for (int i = 0, alWidth=alignment.getWidth(); i<alWidth; i++)\r
{\r
hash = (Hashtable) cons.elementAt(i);\r
float value = Float.parseFloat(hash.get("maxCount").toString());\r
consensusV = alignment.getAAFrequency();\r
StringBuffer sb = new StringBuffer();\r
Hashtable hash = null;\r
- for (int i = 0; i < consensusV.size(); i++)\r
+ for (int i = 0, sz=consensusV.size(); i < sz; i++)\r
{\r
hash = (Hashtable) consensusV.elementAt(i);\r
sb.append(hash.get("maxResidue").toString().charAt(0));\r
public void setEndRes(int res) {\r
if (res > alignment.getWidth()-1) {\r
System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1));\r
- res = alignment.getWidth() -1;\r
+ res = alignment.getWidth()-1;\r
}\r
if (res < 0) {\r
res = 0;\r