import jalview.api.AnnotationRowFilterI;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
+import jalview.datamodel.AnnotationFilterParameter;
+import jalview.datamodel.AnnotationFilterParameter.SearchableAnnotationField;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.GraphLine;
import jalview.datamodel.SequenceGroup;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.util.List;
import java.util.Vector;
import javax.swing.JCheckBox;
}
}
}
- // seqAssociated.setEnabled(enableSeqAss);
this.annmap = new int[list.size()];
System.arraycopy(anmap, 0, this.annmap, 0, this.annmap.length);
return list;
return false;
}
- protected boolean markColumnsContaining(
- AlignmentAnnotation currentAnnotation, int thresholdComparisonType)
+ protected boolean filterAnnotations(Annotation[] annotations,
+ AnnotationFilterParameter filterParams, ColumnSelection cs)
{
- try
+ av.showAllHiddenColumns();
+ cs.clear();
+ int count = 0;
+ do
{
- if (currentAnnotation != null)
+ if (annotations[count] != null)
{
- Annotation[] annotations = currentAnnotation.annotations;
- ColumnSelection cs = av.getColumnSelection();
- cs.clear();
- if (thresholdComparisonType == AnnotationColourGradient.NO_THRESHOLD)
+
+ boolean itemMatched = false;
+
+ if (filterParams.getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD
+ && annotations[count].value > currentAnnotation.threshold.value)
{
- int count = 0;
- do
- {
- if (annotations[count] != null)
- {
- if (currentAnnotation.label.equals("Secondary Structure")
- && annotations[count].secondaryStructure != ' ')
- {
- cs.addElement(count);
- }
- else if (currentAnnotation.label
- .equals("Iron Sulphur Contacts"))
- {
- cs.addElement(count);
- }
- else if (annotations[count].value != 0.0)
- {
- cs.addElement(count);
- }
+ itemMatched = true;
+ }
+ if (filterParams.getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD
+ && annotations[count].value < currentAnnotation.threshold.value)
+ {
+ itemMatched = true;
+ }
- }
- count++;
- } while (count < annotations.length);
+ if (filterParams.isFilterAlphaHelix()
+ && annotations[count].secondaryStructure == 'H')
+ {
+ itemMatched = true;
}
- else
+
+ if (filterParams.isFilterBetaSheet()
+ && annotations[count].secondaryStructure == 'E')
+ {
+ itemMatched = true;
+ }
+
+ if (filterParams.isFilterTurn()
+ && annotations[count].secondaryStructure == 'S')
{
- int count = 0;
- do
+ itemMatched = true;
+ }
+
+ String regexSearchString = filterParams.getRegexString();
+ if (regexSearchString != null
+ && !filterParams.getRegexSearchFields().isEmpty())
+ {
+ List<SearchableAnnotationField> fields = filterParams
+ .getRegexSearchFields();
+ try
{
- if (annotations[count] != null)
+ if (fields.contains(SearchableAnnotationField.DISPLAY_STRING)
+ && annotations[count].displayCharacter
+ .matches(regexSearchString))
{
- if (thresholdComparisonType == AnnotationColourGradient.ABOVE_THRESHOLD)
- {
- if (annotations[count].value > currentAnnotation.threshold.value)
- {
- cs.addElement(count);
- }
- }
- else if (thresholdComparisonType == AnnotationColourGradient.BELOW_THRESHOLD)
- {
- if (annotations[count].value < currentAnnotation.threshold.value)
- {
- cs.addElement(count);
- }
- }
-
+ itemMatched = true;
}
- count++;
- } while (count < annotations.length);
+ } catch (java.util.regex.PatternSyntaxException pse)
+ {
+ if (annotations[count].displayCharacter
+ .equals(regexSearchString))
+ {
+ itemMatched = true;
+ }
+ }
+ if (fields.contains(SearchableAnnotationField.DESCRIPTION)
+ && annotations[count].description != null
+ && annotations[count].description
+ .matches(regexSearchString))
+ {
+ itemMatched = true;
+ }
}
- }
- return true;
- } catch (Exception e)
- {
- e.printStackTrace();
- return false;
- }
+ if (itemMatched)
+ {
+ cs.addElement(count);
+ }
+ }
+ count++;
+ } while (count < annotations.length);
+ return false;
}
public jalview.datamodel.AlignmentAnnotation getCurrentAnnotation()