git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b197088
)
JAL-2349 JAL-3855 experimenting with filtering columns based on mean of contact map...
author
Jim Procter
<j.procter@dundee.ac.uk>
Thu, 20 Oct 2022 14:45:51 +0000
(15:45 +0100)
committer
Jim Procter
<j.procter@dundee.ac.uk>
Thu, 20 Oct 2022 15:08:53 +0000
(16:08 +0100)
src/jalview/appletgui/AnnotationColumnChooser.java
patch
|
blob
|
history
src/jalview/datamodel/ColumnSelection.java
patch
|
blob
|
history
src/jalview/gui/AnnotationColumnChooser.java
patch
|
blob
|
history
test/jalview/datamodel/ColumnSelectionTest.java
patch
|
blob
|
history
diff --git
a/src/jalview/appletgui/AnnotationColumnChooser.java
b/src/jalview/appletgui/AnnotationColumnChooser.java
index
206b132
..
37b45f9
100644
(file)
--- a/
src/jalview/appletgui/AnnotationColumnChooser.java
+++ b/
src/jalview/appletgui/AnnotationColumnChooser.java
@@
-20,12
+20,6
@@
*/
package jalview.appletgui;
*/
package jalview.appletgui;
-import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.HiddenColumns;
-import jalview.schemes.AnnotationColourGradient;
-import jalview.util.MessageManager;
-import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
-
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Checkbox;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Checkbox;
@@
-48,6
+42,12
@@
import java.awt.event.TextEvent;
import java.awt.event.TextListener;
import java.util.Vector;
import java.awt.event.TextListener;
import java.util.Vector;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.HiddenColumns;
+import jalview.schemes.AnnotationColourGradient;
+import jalview.util.MessageManager;
+import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
+
//import javax.swing.JPanel;
//import net.miginfocom.swing.MigLayout;
//import javax.swing.JPanel;
//import net.miginfocom.swing.MigLayout;
@@
-492,8
+492,8
@@
public class AnnotationColumnChooser extends AnnotationRowFilter implements
// filterAnnotations, because showing hidden columns has the side effect of
// adding them to the selection
av.showAllHiddenColumns();
// filterAnnotations, because showing hidden columns has the side effect of
// adding them to the selection
av.showAllHiddenColumns();
- av.getColumnSelection().filterAnnotations(
- getCurrentAnnotation().annotations, filterParams);
+ av.getColumnSelection().filterAnnotations(getCurrentAnnotation(),
+ filterParams);
if (getActionOption() == ACTION_OPTION_HIDE)
{
if (getActionOption() == ACTION_OPTION_HIDE)
{
diff --git
a/src/jalview/datamodel/ColumnSelection.java
b/src/jalview/datamodel/ColumnSelection.java
index
140a366
..
309aabf
100644
(file)
--- a/
src/jalview/datamodel/ColumnSelection.java
+++ b/
src/jalview/datamodel/ColumnSelection.java
@@
-559,9
+559,10
@@
public class ColumnSelection
* @param filterParams
* @return
*/
* @param filterParams
* @return
*/
- public int filterAnnotations(Annotation[] annotations,
+ public int filterAnnotations(AlignmentAnnotation ann_row,
AnnotationFilterParameter filterParams)
{
AnnotationFilterParameter filterParams)
{
+ Annotation[] annotations = ann_row.annotations;
// JBPNote - this method needs to be refactored to become independent of
// viewmodel package
this.clear();
// 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)
{
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
*/
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
if (filterParams
.getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD
- && ann.value > filterParams.getThresholdValue())
+ && value > filterParams.getThresholdValue())
{
matched = true;
}
if (!matched && filterParams
.getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD
{
matched = true;
}
if (!matched && filterParams
.getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD
- && ann.value < filterParams.getThresholdValue())
+ && value < filterParams.getThresholdValue())
{
matched = true;
}
{
matched = true;
}
diff --git
a/src/jalview/gui/AnnotationColumnChooser.java
b/src/jalview/gui/AnnotationColumnChooser.java
index
c0d4708
..
0b1ad93
100644
(file)
--- a/
src/jalview/gui/AnnotationColumnChooser.java
+++ b/
src/jalview/gui/AnnotationColumnChooser.java
@@
-21,14
+21,6
@@
package jalview.gui;
package jalview.gui;
-import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.HiddenColumns;
-import jalview.io.cache.JvCacheableInputBox;
-import jalview.schemes.AnnotationColourGradient;
-import jalview.util.MessageManager;
-import jalview.util.Platform;
-import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
-
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
@@
-50,6
+42,13
@@
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.TitledBorder;
import javax.swing.JRadioButton;
import javax.swing.border.TitledBorder;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.HiddenColumns;
+import jalview.io.cache.JvCacheableInputBox;
+import jalview.schemes.AnnotationColourGradient;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
+import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
import net.miginfocom.swing.MigLayout;
@SuppressWarnings("serial")
import net.miginfocom.swing.MigLayout;
@SuppressWarnings("serial")
@@
-376,7
+375,7
@@
public class AnnotationColumnChooser extends AnnotationRowFilter
// filterAnnotations, because showing hidden columns has the side effect of
// adding them to the selection
av.showAllHiddenColumns();
// filterAnnotations, because showing hidden columns has the side effect of
// adding them to the selection
av.showAllHiddenColumns();
- av.getColumnSelection().filterAnnotations(currentAnnotation.annotations,
+ av.getColumnSelection().filterAnnotations(currentAnnotation,
filterParams);
boolean hideCols = getActionOption() == ACTION_OPTION_HIDE;
filterParams);
boolean hideCols = getActionOption() == ACTION_OPTION_HIDE;
diff --git
a/test/jalview/datamodel/ColumnSelectionTest.java
b/test/jalview/datamodel/ColumnSelectionTest.java
index
d581345
..
5cb8cf5
100644
(file)
--- a/
test/jalview/datamodel/ColumnSelectionTest.java
+++ b/
test/jalview/datamodel/ColumnSelectionTest.java
@@
-25,12
+25,6
@@
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail;
-import jalview.analysis.AlignmentGenerator;
-import jalview.gui.JvOptionPane;
-import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
-import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField;
-import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType;
-
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
@@
-41,6
+35,12
@@
import java.util.List;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import jalview.analysis.AlignmentGenerator;
+import jalview.gui.JvOptionPane;
+import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
+import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField;
+import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType;
+
public class ColumnSelectionTest
{
public class ColumnSelectionTest
{
@@
-606,6
+606,8
@@
public class ColumnSelectionTest
public void testFilterAnnotations()
{
ColumnSelection cs = new ColumnSelection();
public void testFilterAnnotations()
{
ColumnSelection cs = new ColumnSelection();
+ AlignmentAnnotation alann = new AlignmentAnnotation("dummy",
+ "dummyDesc", null);
/*
* filter with no conditions clears the selection
/*
* filter with no conditions clears the selection
@@
-613,7
+615,8
@@
public class ColumnSelectionTest
Annotation[] anns = new Annotation[] { null };
AnnotationFilterParameter filter = new AnnotationFilterParameter();
cs.addElement(3);
Annotation[] anns = new Annotation[] { null };
AnnotationFilterParameter filter = new AnnotationFilterParameter();
cs.addElement(3);
- int added = cs.filterAnnotations(anns, filter);
+ alann.annotations = anns;
+ int added = cs.filterAnnotations(alann, filter);
assertEquals(0, added);
assertTrue(cs.isEmpty());
assertEquals(0, added);
assertTrue(cs.isEmpty());
@@
-624,8
+627,8
@@
public class ColumnSelectionTest
filter.addRegexSearchField(SearchableAnnotationField.DESCRIPTION);
Annotation helix = new Annotation("(", "hello", '<', 2f);
Annotation sheet = new Annotation("(", "world", '<', 2f);
filter.addRegexSearchField(SearchableAnnotationField.DESCRIPTION);
Annotation helix = new Annotation("(", "hello", '<', 2f);
Annotation sheet = new Annotation("(", "world", '<', 2f);
- added = cs.filterAnnotations(new Annotation[] { null, helix, sheet },
- filter);
+ alann.annotations = new Annotation[] { null, helix, sheet };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(1, added);
assertTrue(cs.contains(2));
assertEquals(1, added);
assertTrue(cs.contains(2));
@@
-635,8
+638,8
@@
public class ColumnSelectionTest
filter = new AnnotationFilterParameter();
filter.setRegexString("(");
filter.addRegexSearchField(SearchableAnnotationField.DISPLAY_STRING);
filter = new AnnotationFilterParameter();
filter.setRegexString("(");
filter.addRegexSearchField(SearchableAnnotationField.DISPLAY_STRING);
- added = cs.filterAnnotations(new Annotation[] { null, helix, sheet },
- filter);
+ alann.annotations = new Annotation[] { null, helix, sheet };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(2, added);
assertTrue(cs.contains(1));
assertTrue(cs.contains(2));
assertEquals(2, added);
assertTrue(cs.contains(1));
assertTrue(cs.contains(2));
@@
-650,9
+653,8
@@
public class ColumnSelectionTest
sheet = new Annotation("x", "desc", 'E', 1f);
Annotation turn = new Annotation("x", "desc", 'S', 2f);
Annotation ann4 = new Annotation("x", "desc", 'Y', 3f);
sheet = new Annotation("x", "desc", 'E', 1f);
Annotation turn = new Annotation("x", "desc", 'S', 2f);
Annotation ann4 = new Annotation("x", "desc", 'Y', 3f);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(1, added);
assertTrue(cs.contains(1));
assertEquals(1, added);
assertTrue(cs.contains(1));
@@
-660,9
+662,8
@@
public class ColumnSelectionTest
* select Helix and Sheet (E)
*/
filter.setFilterBetaSheet(true);
* select Helix and Sheet (E)
*/
filter.setFilterBetaSheet(true);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(2, added);
assertTrue(cs.contains(1));
assertTrue(cs.contains(2));
assertEquals(2, added);
assertTrue(cs.contains(1));
assertTrue(cs.contains(2));
@@
-672,9
+673,8
@@
public class ColumnSelectionTest
*/
filter.setFilterAlphaHelix(false);
filter.setFilterTurn(true);
*/
filter.setFilterAlphaHelix(false);
filter.setFilterTurn(true);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(2, added);
assertTrue(cs.contains(2));
assertTrue(cs.contains(3));
assertEquals(2, added);
assertTrue(cs.contains(2));
assertTrue(cs.contains(3));
@@
-685,9
+685,8
@@
public class ColumnSelectionTest
filter = new AnnotationFilterParameter();
filter.setThresholdType(ThresholdType.BELOW_THRESHOLD);
filter.setThresholdValue(2f);
filter = new AnnotationFilterParameter();
filter.setThresholdType(ThresholdType.BELOW_THRESHOLD);
filter.setThresholdValue(2f);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(2, added);
assertTrue(cs.contains(1));
assertTrue(cs.contains(2));
assertEquals(2, added);
assertTrue(cs.contains(1));
assertTrue(cs.contains(2));
@@
-696,9
+695,8
@@
public class ColumnSelectionTest
* select value > 2f (ann4 only)
*/
filter.setThresholdType(ThresholdType.ABOVE_THRESHOLD);
* select value > 2f (ann4 only)
*/
filter.setThresholdType(ThresholdType.ABOVE_THRESHOLD);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(1, added);
assertTrue(cs.contains(4));
assertEquals(1, added);
assertTrue(cs.contains(4));
@@
-706,9
+704,8
@@
public class ColumnSelectionTest
* select >2f or Helix
*/
filter.setFilterAlphaHelix(true);
* select >2f or Helix
*/
filter.setFilterAlphaHelix(true);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(2, added);
assertTrue(cs.contains(1));
assertTrue(cs.contains(4));
assertEquals(2, added);
assertTrue(cs.contains(1));
assertTrue(cs.contains(4));
@@
-719,9
+716,8
@@
public class ColumnSelectionTest
*/
filter.setThresholdType(ThresholdType.BELOW_THRESHOLD);
filter.setThresholdValue(1f);
*/
filter.setThresholdType(ThresholdType.BELOW_THRESHOLD);
filter.setThresholdValue(1f);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(1, added);
assertTrue(cs.contains(1));
}
assertEquals(1, added);
assertTrue(cs.contains(1));
}