JAL-2349 JAL-3855 experimenting with filtering columns based on mean of contact map...
[jalview.git] / src / jalview / datamodel / ColumnSelection.java
index 140a366..309aabf 100644 (file)
@@ -559,9 +559,10 @@ public class ColumnSelection
    * @param filterParams
    * @return
    */
-  public int filterAnnotations(Annotation[] annotations,
+  public int filterAnnotations(AlignmentAnnotation ann_row,
           AnnotationFilterParameter filterParams)
   {
+    Annotation[] annotations = ann_row.annotations;
     // JBPNote - this method needs to be refactored to become independent of
     // viewmodel package
     this.clear();
@@ -572,22 +573,36 @@ public class ColumnSelection
       Annotation ann = annotations[column];
       if (ann != null)
       {
+        float value = ann.value;
         boolean matched = false;
 
         /*
          * filter may have multiple conditions - 
          * these are or'd until a match is found
          */
+        if (ann_row.graph == AlignmentAnnotation.CUSTOMRENDERER)
+        {
+          if (ann_row.sequenceRef != null)
+          {
+            int cpos = ann_row.sequenceRef.findPosition(column) - 1;
+            ContactListI clist = ann_row.sequenceRef
+                    .getContactListFor(ann_row, cpos);
+            ContactRange crange = clist.getRangeFor(0,
+                    clist.getContactHeight());
+            value = (float) crange.getMean();
+          }
+        }
+
         if (filterParams
                 .getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD
-                && ann.value > filterParams.getThresholdValue())
+                && value > filterParams.getThresholdValue())
         {
           matched = true;
         }
 
         if (!matched && filterParams
                 .getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD
-                && ann.value < filterParams.getThresholdValue())
+                && value < filterParams.getThresholdValue())
         {
           matched = true;
         }