X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FColumnSelection.java;h=4a38ec0f5b76a4263457fdc980ecce2daf33d83d;hb=6c36212c1e16557e6afb1b4dba9c28864d52ad4a;hp=140a3661033f9a46d496415654aa98bf3d3cb549;hpb=47a6e772d30202cfb73fe296fea6c8474bc2b8bb;p=jalview.git diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index 140a366..4a38ec0 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -278,6 +278,27 @@ public class ColumnSelection } /** + * add a series of start,end (inclusive) ranges to the column selection + * + * @param rng + * [start_0, end_0, start_1, end_1, ... ] + * @param baseOne + * - when true, ranges are base 1 and will be mapped to base 0 + */ + public void addRangeOfElements(int[] rng, boolean baseOne) + { + int base = baseOne ? -1 : 0; + for (int c = 0; c < rng.length; c += 2) + { + for (int p = rng[c]; p <= rng[c + 1]; p++) + { + selection.add(base + p); + } + } + + } + + /** * clears column selection */ public void clear() @@ -559,12 +580,52 @@ 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(); + + if (ann_row.graph == AlignmentAnnotation.CONTACT_MAP && (filterParams + .getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD + || filterParams + .getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD)) + { + float tVal = filterParams.getThresholdValue(); + if (ann_row.sequenceRef != null) + { + // TODO - get ContactList from AlignmentView for non-seq-ref associatd + for (int column = 0; column < annotations.length; column++) + { + if (ann_row.annotations[column] == null) + { + continue; + } + + int cpos = ann_row.sequenceRef.findPosition(column) - 1; + ContactListI clist = ann_row.sequenceRef + .getContactListFor(ann_row, cpos); + for (int row = column + 8, rowEnd = clist + .getContactHeight(); row < rowEnd; row++) + { + if (filterParams + .getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD + ? (clist.getContactAt(row) > tVal) + : (clist.getContactAt(row) < tVal)) + { + addElement(column); + break; + // int column_forrowpos = ann_row.sequenceRef.findIndex(row + 1); + // addElement(column_forrowpos); + } + } + } + } + return selection.size(); + } + int addedCount = 0; int column = 0; do @@ -572,6 +633,7 @@ public class ColumnSelection Annotation ann = annotations[column]; if (ann != null) { + float value = ann.value; boolean matched = false; /* @@ -580,14 +642,14 @@ public class ColumnSelection */ 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; }