-/*\r
+ /*\r
* Jalview - A Sequence Alignment Editor and Viewer\r
* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
*\r
*/\r
public void updateConservation()\r
{\r
+ try{\r
Conservation cons = new jalview.analysis.Conservation("All",\r
- jalview.schemes.ResidueProperties.propHash, 3,\r
- alignment.getSequences(), 0, alignment.getWidth() - 1);\r
+ jalview.schemes.ResidueProperties.propHash, 3,\r
+ alignment.getSequences(), 0, alignment.getWidth() - 1);\r
cons.calculate();\r
cons.verdict(false, ConsPercGaps);\r
cons.findQuality();\r
\r
for (int i = 0; i < alWidth; i++)\r
{\r
- float value = 0;\r
-\r
- try\r
+ float value = 0;\r
+\r
+ try\r
+ {\r
+ value = Integer.parseInt(sequence.charAt(i) + "");\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ if (sequence.charAt(i) == '*')\r
{\r
- value = Integer.parseInt(sequence.charAt(i) + "");\r
+ value = 11;\r
}\r
- catch (Exception ex)\r
- {\r
- if (sequence.charAt(i) == '*')\r
- {\r
- value = 11;\r
- }\r
\r
- if (sequence.charAt(i) == '+')\r
- {\r
- value = 10;\r
- }\r
+ if (sequence.charAt(i) == '+')\r
+ {\r
+ value = 10;\r
}\r
-\r
- float vprop = value - min;\r
- vprop /= max;\r
- annotations[i] = new Annotation(sequence.charAt(i) + "",\r
- String.valueOf(value), ' ', value,\r
- new Color(minR + (maxR * vprop), minG + (maxG * vprop),\r
- minB + (maxB * vprop)));\r
-\r
- // Quality calc\r
- value = ((Double) cons.quality.get(i)).floatValue();\r
- vprop = value - qmin;\r
- vprop /= qmax;\r
- qannotations[i] = new Annotation(" ", String.valueOf(value), ' ',\r
- value,\r
- new Color(minR + (maxR * vprop), minG + (maxG * vprop),\r
- minB + (maxB * vprop)));\r
+ }\r
+\r
+ float vprop = value - min;\r
+ vprop /= max;\r
+ annotations[i] = new Annotation(sequence.charAt(i) + "",\r
+ String.valueOf(value), ' ', value,\r
+ new Color(minR + (maxR * vprop),\r
+ minG + (maxG * vprop),\r
+ minB + (maxB * vprop)));\r
+\r
+ // Quality calc\r
+ value = ( (Double) cons.quality.get(i)).floatValue();\r
+ vprop = value - qmin;\r
+ vprop /= qmax;\r
+ qannotations[i] = new Annotation(" ", String.valueOf(value), ' ',\r
+ value,\r
+ new Color(minR + (maxR * vprop),\r
+ minG + (maxG * vprop),\r
+ minB + (maxB * vprop)));\r
}\r
\r
if (conservation == null)\r
{\r
- conservation = new AlignmentAnnotation("Conservation",\r
- "Conservation of total alignment less than " +\r
- ConsPercGaps + "% gaps", annotations, 0f, // cons.qualityRange[0].floatValue(),\r
- 11f, // cons.qualityRange[1].floatValue()\r
- 1);\r
-\r
- if (showConservation)\r
- {\r
- alignment.addAnnotation(conservation);\r
- }\r
-\r
- quality = new AlignmentAnnotation("Quality",\r
- "Alignment Quality based on Blosum62 scores", qannotations,\r
- cons.qualityRange[0].floatValue(),\r
- cons.qualityRange[1].floatValue(), 1);\r
-\r
- if (showQuality)\r
- {\r
- alignment.addAnnotation(quality);\r
- }\r
+ conservation = new AlignmentAnnotation("Conservation",\r
+ "Conservation of total alignment less than " +\r
+ ConsPercGaps + "% gaps",\r
+ annotations, 0f, // cons.qualityRange[0].floatValue(),\r
+ 11f, // cons.qualityRange[1].floatValue()\r
+ 1);\r
+\r
+ if (showConservation)\r
+ {\r
+ alignment.addAnnotation(conservation);\r
+ }\r
+\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
+\r
+ if (showQuality)\r
+ {\r
+ alignment.addAnnotation(quality);\r
+ }\r
}\r
else\r
{\r
- conservation.annotations = annotations;\r
- quality.annotations = qannotations;\r
- quality.graphMax = cons.qualityRange[1].floatValue();\r
+ conservation.annotations = annotations;\r
+ quality.annotations = qannotations;\r
+ quality.graphMax = cons.qualityRange[1].floatValue();\r
}\r
+ }catch(OutOfMemoryError error)\r
+ {\r
+ System.out.println("Out of memory calculating conservation.");\r
+ }\r
}\r
\r
/**\r
*/\r
public void updateConsensus()\r
{\r
+ try{\r
Annotation[] annotations = new Annotation[alignment.getWidth()];\r
\r
// this routine prevents vconsensus becoming a new object each time\r
// and PID colouring of alignment\r
if (vconsensus == null)\r
{\r
- vconsensus = alignment.getAAFrequency();\r
+ vconsensus = alignment.getAAFrequency();\r
}\r
else\r
{\r
- Vector temp = alignment.getAAFrequency();\r
- vconsensus.clear();\r
+ Vector temp = alignment.getAAFrequency();\r
+ vconsensus.clear();\r
\r
- Enumeration e = temp.elements();\r
+ Enumeration e = temp.elements();\r
\r
- while (e.hasMoreElements())\r
- {\r
- vconsensus.add(e.nextElement());\r
- }\r
+ while (e.hasMoreElements())\r
+ {\r
+ vconsensus.add(e.nextElement());\r
+ }\r
}\r
\r
Hashtable hash = null;\r
\r
for (int i = 0; i < alignment.getWidth(); i++)\r
{\r
- hash = (Hashtable) vconsensus.elementAt(i);\r
+ hash = (Hashtable) vconsensus.elementAt(i);\r
\r
- float value = 0;\r
- if(ignoreGapsInConsensusCalculation)\r
- value = ((Float)hash.get("pid_nogaps")).floatValue();\r
- else\r
- value = ((Float)hash.get("pid_gaps")).floatValue();\r
+ float value = 0;\r
+ if (ignoreGapsInConsensusCalculation)\r
+ value = ( (Float) hash.get("pid_nogaps")).floatValue();\r
+ else\r
+ value = ( (Float) hash.get("pid_gaps")).floatValue();\r
\r
- String maxRes = hash.get("maxResidue").toString();\r
- String mouseOver = hash.get("maxResidue")+" ";\r
+ String maxRes = hash.get("maxResidue").toString();\r
+ String mouseOver = hash.get("maxResidue") + " ";\r
\r
- if (maxRes.length() > 1)\r
- {\r
- mouseOver = "[" + maxRes + "] ";\r
- maxRes = "+";\r
- }\r
+ if (maxRes.length() > 1)\r
+ {\r
+ mouseOver = "[" + maxRes + "] ";\r
+ maxRes = "+";\r
+ }\r
\r
- mouseOver += ((int) value + "%");\r
- annotations[i] = new Annotation(maxRes, mouseOver, ' ', value);\r
+ mouseOver += ( (int) value + "%");\r
+ annotations[i] = new Annotation(maxRes, mouseOver, ' ', value);\r
}\r
\r
if (consensus == null)\r
{\r
- consensus = new AlignmentAnnotation("Consensus", "PID",\r
- annotations, 0f, 100f, 1);\r
+ consensus = new AlignmentAnnotation("Consensus", "PID",\r
+ annotations, 0f, 100f, 1);\r
\r
- if (showIdentity)\r
- {\r
- alignment.addAnnotation(consensus);\r
- }\r
+ if (showIdentity)\r
+ {\r
+ alignment.addAnnotation(consensus);\r
+ }\r
}\r
else\r
{\r
- consensus.annotations = annotations;\r
+ consensus.annotations = annotations;\r
}\r
\r
- if(globalColourScheme!=null)\r
+ if (globalColourScheme != null)\r
globalColourScheme.setConsensus(vconsensus);\r
+\r
+ }catch(OutOfMemoryError error)\r
+ {\r
+ System.out.println("Out of memory calculating consensus.");\r
+ }\r
+\r
}\r
\r
/**\r