conservation & consensus recalc if group changed
authoramwaterhouse <Andrew Waterhouse>
Fri, 15 Apr 2005 14:56:12 +0000 (14:56 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 15 Apr 2005 14:56:12 +0000 (14:56 +0000)
src/jalview/datamodel/SequenceGroup.java

index 0cf954b..7aae434 100755 (executable)
@@ -14,7 +14,6 @@ public class SequenceGroup
   boolean displayBoxes;\r
   boolean displayText;\r
   boolean colourText;\r
-  boolean aaFrequencyValid = false;\r
   public Vector sequences = new Vector();\r
   int width = -1;\r
   public ColourSchemeI cs;\r
@@ -79,7 +78,6 @@ public class SequenceGroup
     if(endRes>=col)\r
       endRes = col;\r
 \r
-\r
     return true;\r
   }\r
 \r
@@ -108,6 +106,24 @@ public class SequenceGroup
   {\r
     if(!sequences.contains(s))\r
       sequences.addElement(s);\r
+\r
+\r
+    if(cs!=null)\r
+      cs.setConsensus( AAFrequency.calculate(sequences, 0, getWidth()) );\r
+\r
+    if(cs instanceof ConservationColourScheme)\r
+      recalcConservation();\r
+  }\r
+\r
+  void recalcConservation()\r
+  {\r
+      Conservation c = new Conservation(groupName,\r
+                                        ResidueProperties.propHash, 3,\r
+                                        sequences, 0, getWidth());\r
+      c.calculate();\r
+      c.verdict(false, 25);\r
+      ConservationColourScheme ccs = (ConservationColourScheme)cs;\r
+      ccs.conserve = c;\r
   }\r
 \r
   public void addOrRemove(SequenceI s)\r
@@ -121,6 +137,12 @@ public class SequenceGroup
   public void deleteSequence(SequenceI s)\r
   {\r
     sequences.removeElement(s);\r
+\r
+    if(cs!=null)\r
+      cs.setConsensus( AAFrequency.calculate(sequences, 0, getWidth()) );\r
+\r
+    if(cs instanceof ConservationColourScheme)\r
+      recalcConservation();\r
   }\r
 \r
 \r
@@ -184,19 +206,8 @@ public class SequenceGroup
     return displayBoxes;\r
   }\r
 \r
-  public Vector getAAFrequency()\r
-  {\r
-    if (aaFrequency == null || aaFrequencyValid == false)\r
-    {\r
-      aaFrequency = AAFrequency.calculate(sequences, 0, getWidth());\r
-      aaFrequencyValid = true;\r
-    }\r
-    return aaFrequency;\r
-  }\r
-\r
   public int getWidth()\r
   {\r
-    System.out.println("it is called");\r
     // MC This needs to get reset when characters are inserted and deleted\r
     for (int i = 0; i < sequences.size(); i++)\r
     {\r