name update for group autoannotation and consensus display settings
authorjprocter <Jim Procter>
Tue, 30 Mar 2010 17:45:22 +0000 (17:45 +0000)
committerjprocter <Jim Procter>
Tue, 30 Mar 2010 17:45:22 +0000 (17:45 +0000)
src/jalview/datamodel/SequenceGroup.java

index 3bdb65f..871e4cf 100755 (executable)
@@ -86,14 +86,14 @@ public class SequenceGroup
   /**
    * consensus calculation property
    */
-  private boolean includeAllConsSymbols=false;
+  private boolean showConsensusProfile=false;
 
   /**
    * @return the includeAllConsSymbols
    */
   public boolean isIncludeAllConsSymbols()
   {
-    return includeAllConsSymbols;
+    return showConsensusProfile;
   }
 
 
@@ -454,6 +454,11 @@ public class SequenceGroup
   }
 
   /**
+   * Max Gaps Threshold for performing a conservation calculation
+   * TODO: make this a configurable property - or global to an alignment view 
+   */
+  private int consPercGaps=25;
+  /**
    * calculate residue conservation for group - but only if necessary.
    */
   public void recalcConservation()
@@ -465,7 +470,7 @@ public class SequenceGroup
     
     try
     {
-      Hashtable cnsns[] = AAFrequency.calculate(sequences, startRes, endRes + 1, includeAllConsSymbols);
+      Hashtable cnsns[] = AAFrequency.calculate(sequences, startRes, endRes + 1, showConsensusProfile);
       if (consensus != null)
       {
         _updateConsensusRow(cnsns);
@@ -486,7 +491,7 @@ public class SequenceGroup
                 ResidueProperties.propHash, 3, sequences, startRes,
                 endRes + 1);
         c.calculate();
-        c.verdict(false, 25);
+        c.verdict(false, consPercGaps);
         if (conservation!=null)
         {
           _updateConservationRow(c);
@@ -515,6 +520,10 @@ public class SequenceGroup
     {
       getConservation();
     }
+    // update Labels
+    conservation.label = "Conservation for "+getName();
+    conservation.description = "Conservation for group "+getName()+" less than " + consPercGaps
+            + "% gaps";
     // preserve width if already set
     int aWidth = (conservation.annotations!=null) ? (endRes<conservation.annotations.length ? conservation.annotations.length : endRes+1) : endRes+1;
     conservation.annotations = null;
@@ -528,13 +537,15 @@ public class SequenceGroup
     {
       getConsensus();
     }
+    consensus.label = "Consensus for "+getName();
+    consensus.description = "Percent Identity";
     consensusData = cnsns;
     // preserve width if already set
     int aWidth = (consensus.annotations!=null) ? (endRes<consensus.annotations.length ? consensus.annotations.length : endRes+1) : endRes+1;
     consensus.annotations = null;
     consensus.annotations = new Annotation[aWidth]; // should be alignment width
 
-    AAFrequency.completeConsensus(consensus,cnsns,startRes,endRes+1,ignoreGapsInConsensus, includeAllConsSymbols); // TODO: setting container for ignoreGapsInConsensusCalculation);
+    AAFrequency.completeConsensus(consensus,cnsns,startRes,endRes+1,ignoreGapsInConsensus, showConsensusProfile); // TODO: setting container for ignoreGapsInConsensusCalculation);
   }
 
   /**
@@ -916,6 +927,13 @@ public class SequenceGroup
     this.showUnconserved = displayNonconserved;
   }
   AlignmentAnnotation consensus=null,conservation=null;
+
+  /**
+   * flag indicating if consensus histogram should be rendered
+   */
+  private boolean showConsensusHistogram;
+
   /**
    * 
    * @return automatically calculated consensus row
@@ -933,12 +951,14 @@ public class SequenceGroup
     }
     if (consensus==null)
     {
-       consensus = new AlignmentAnnotation("Consensus for "+getName(), "PID",
+       consensus = new AlignmentAnnotation("","",
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       consensus.hasText = true;
       consensus.autoCalculated = true;
       consensus.groupRef = this;
     }
+    consensus.label = "Consensus for "+getName();
+    consensus.description = "Percent Identity";
     return consensus;
   }
     /**
@@ -946,17 +966,16 @@ public class SequenceGroup
    * @return autoCalculated annotation row
    */
   public AlignmentAnnotation getConservationRow() {
-    int ConsPercGaps = 25;
     if (conservation == null) {
-      conservation = new AlignmentAnnotation("Conservation for "+getName(),
-            "Conservation for group "+getName()+" less than " + ConsPercGaps
-                    + "% gaps", new Annotation[1], 0f, 11f,
+      conservation = new AlignmentAnnotation("","", new Annotation[1], 0f, 11f,
             AlignmentAnnotation.BAR_GRAPH);
     conservation.hasText = true;
     conservation.autoCalculated = true;
     conservation.groupRef = this;
-      }
-    
+    }
+    conservation.label = "Conservation for "+getName();
+    conservation.description = "Conservation for group "+getName()+" less than " + consPercGaps
+            + "% gaps";
     return conservation;
   }
 
@@ -1012,10 +1031,32 @@ public class SequenceGroup
    */
   public void setIncludeAllConsSymbols(boolean includeAllConsSymbols)
   {
-    if (this.includeAllConsSymbols!=includeAllConsSymbols && consensus!=null) {
-      this.includeAllConsSymbols = includeAllConsSymbols;
+    if (this.showConsensusProfile!=includeAllConsSymbols && consensus!=null) {
+      this.showConsensusProfile = includeAllConsSymbols;
+      recalcConservation();
+    }
+    this.showConsensusProfile = includeAllConsSymbols;
+  }
+
+
+  /**
+   * 
+   * @param showConsHist flag indicating if the consensus histogram for this group should be rendered
+   */
+  public void setShowConsensusHistogram(boolean showConsHist)
+  {
+    
+    if (showConsensusHistogram!=showConsHist && consensus!=null) {
+      this.showConsensusHistogram = showConsHist;
       recalcConservation();
     }
-    this.includeAllConsSymbols = includeAllConsSymbols;
+    this.showConsensusHistogram = showConsHist;
+  }
+  /**
+   * @return the showConsensusHistogram
+   */
+  public boolean isShowConsensusHistogram()
+  {
+    return showConsensusHistogram;
+  }
   }
-}