From c2dd443026847395d0c9dc824c6c90457de9a675 Mon Sep 17 00:00:00 2001 From: James Procter Date: Wed, 22 Feb 2023 12:05:22 +0000 Subject: [PATCH] JAL-4027 JAL-3858 rename CUSTOM_RENDERER to CONTACT_MATRIX annotation.graph type, with actual matrix type stored in calcId --- src/jalview/datamodel/AlignmentAnnotation.java | 2 +- src/jalview/datamodel/ColumnSelection.java | 2 +- src/jalview/datamodel/ContactMapHolder.java | 3 ++- src/jalview/datamodel/ContactMatrix.java | 2 +- src/jalview/datamodel/ContactMatrixI.java | 6 ++++++ src/jalview/datamodel/SeqDistanceContactMatrix.java | 7 +++++++ src/jalview/gui/AnnotationPanel.java | 6 +++--- src/jalview/io/PContactPredictionFile.java | 10 +++++++++- src/jalview/renderer/AnnotationRendererFactory.java | 2 +- src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java | 7 +++++++ test/jalview/ws/seqfetcher/DbRefFetcherTest.java | 2 +- 11 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/jalview/datamodel/AlignmentAnnotation.java b/src/jalview/datamodel/AlignmentAnnotation.java index 3f9c2d9..4861dfd 100755 --- a/src/jalview/datamodel/AlignmentAnnotation.java +++ b/src/jalview/datamodel/AlignmentAnnotation.java @@ -306,7 +306,7 @@ public class AlignmentAnnotation public static final int LINE_GRAPH = 2; - public static final int CUSTOMRENDERER = 4; + public static final int CONTACT_MAP = 4; public boolean belowAlignment = true; diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index db83e76..6ee324f 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -567,7 +567,7 @@ public class ColumnSelection // viewmodel package this.clear(); - if (ann_row.graph == AlignmentAnnotation.CUSTOMRENDERER && (filterParams + if (ann_row.graph == AlignmentAnnotation.CONTACT_MAP && (filterParams .getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD || filterParams .getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD)) diff --git a/src/jalview/datamodel/ContactMapHolder.java b/src/jalview/datamodel/ContactMapHolder.java index 2b5c853..f6ccc6a 100644 --- a/src/jalview/datamodel/ContactMapHolder.java +++ b/src/jalview/datamodel/ContactMapHolder.java @@ -40,10 +40,11 @@ public class ContactMapHolder implements ContactMapHolderI AlignmentAnnotation aa = new AlignmentAnnotation(cm.getAnnotLabel(), cm.getAnnotDescr(), new Annotation[0]); - aa.graph = AlignmentAnnotation.CUSTOMRENDERER; + aa.graph = AlignmentAnnotation.CONTACT_MAP; aa.graphMin = cm.getMin(); aa.graphMax = cm.getMax(); aa.editable = false; + aa.calcId=cm.getType(); contactmaps.put(aa.annotationId, cm); // TODO: contact matrices could be intra or inter - more than one refseq diff --git a/src/jalview/datamodel/ContactMatrix.java b/src/jalview/datamodel/ContactMatrix.java index 35ec87b..b4f7c07 100644 --- a/src/jalview/datamodel/ContactMatrix.java +++ b/src/jalview/datamodel/ContactMatrix.java @@ -3,7 +3,7 @@ package jalview.datamodel; import java.util.ArrayList; import java.util.List; -public class ContactMatrix implements ContactMatrixI +public abstract class ContactMatrix implements ContactMatrixI { /** * are contacts reflexive ? diff --git a/src/jalview/datamodel/ContactMatrixI.java b/src/jalview/datamodel/ContactMatrixI.java index 6860e82..d9afc7f 100644 --- a/src/jalview/datamodel/ContactMatrixI.java +++ b/src/jalview/datamodel/ContactMatrixI.java @@ -17,4 +17,10 @@ public interface ContactMatrixI String getAnnotLabel(); + /** + * string indicating how the contactMatrix should be rendered - stored in calcId + * @return + */ + String getType(); + } diff --git a/src/jalview/datamodel/SeqDistanceContactMatrix.java b/src/jalview/datamodel/SeqDistanceContactMatrix.java index 7dd9778..0773e12 100644 --- a/src/jalview/datamodel/SeqDistanceContactMatrix.java +++ b/src/jalview/datamodel/SeqDistanceContactMatrix.java @@ -8,6 +8,7 @@ package jalview.datamodel; */ public class SeqDistanceContactMatrix implements ContactMatrixI { + private static final String SEQUENCE_DISTANCE = "SEQUENCE_DISTANCE"; private int width = 0; public SeqDistanceContactMatrix(int width) @@ -99,4 +100,10 @@ public class SeqDistanceContactMatrix implements ContactMatrixI { return "Sequence Distance"; } + + @Override + public String getType() + { + return SEQUENCE_DISTANCE; + } } diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index e146754..a97e0e4 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -589,7 +589,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (graphStretch != -1) { - if (aa[graphStretch].graph == AlignmentAnnotation.CUSTOMRENDERER) + if (aa[graphStretch].graph == AlignmentAnnotation.CONTACT_MAP) { if (evt.isAltDown() || evt.isAltGraphDown()) { @@ -823,7 +823,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, * but could also be a matrix drag */ if ((evt.isAltDown() || evt.isAltGraphDown()) && (av.getAlignment() - .getAlignmentAnnotation()[graphStretch].graph == AlignmentAnnotation.CUSTOMRENDERER)) + .getAlignmentAnnotation()[graphStretch].graph == AlignmentAnnotation.CONTACT_MAP)) { /* * dragging in a matrix @@ -1146,7 +1146,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, tooltip = ann.annotations[column].description; } // TODO abstract tooltip generator so different implementations can be built - if (ann.graph == AlignmentAnnotation.CUSTOMRENDERER) + if (ann.graph == AlignmentAnnotation.CONTACT_MAP) { ContactListI clist = av.getContactList(ann, column); if (clist != null) diff --git a/src/jalview/io/PContactPredictionFile.java b/src/jalview/io/PContactPredictionFile.java index 92500c0..de02939 100644 --- a/src/jalview/io/PContactPredictionFile.java +++ b/src/jalview/io/PContactPredictionFile.java @@ -44,6 +44,8 @@ import java.util.Map; */ public class PContactPredictionFile extends AlignFile { + protected static final String CONTACT_PREDICTION = "CONTACT_PREDICTION"; + public PContactPredictionFile(String inFile, DataSourceType fileSourceType) throws IOException { @@ -106,7 +108,13 @@ public class PContactPredictionFile extends AlignFile if (cm == null) { - cm = new ContactMatrix(true); + cm = new ContactMatrix(true) { + @Override + public String getType() + { + return CONTACT_PREDICTION; + } + }; models.add(cm); } diff --git a/src/jalview/renderer/AnnotationRendererFactory.java b/src/jalview/renderer/AnnotationRendererFactory.java index 1bee418..92ea677 100644 --- a/src/jalview/renderer/AnnotationRendererFactory.java +++ b/src/jalview/renderer/AnnotationRendererFactory.java @@ -31,7 +31,7 @@ public class AnnotationRendererFactory implements @Override public AnnotationRowRendererI getRendererFor(AlignmentAnnotation row) { - if (row.graph == AlignmentAnnotation.CUSTOMRENDERER) + if (row.graph == AlignmentAnnotation.CONTACT_MAP) { return new ContactMapRenderer(); } diff --git a/src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java b/src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java index 272d21d..79ad458 100644 --- a/src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java +++ b/src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java @@ -186,4 +186,11 @@ public class PAEContactMatrix implements ContactMatrixI { return "pAE Matrix"; } + + public static final String PAEMATRIX="PAE_MATRIX"; + @Override + public String getType() + { + return PAEMATRIX; + } } diff --git a/test/jalview/ws/seqfetcher/DbRefFetcherTest.java b/test/jalview/ws/seqfetcher/DbRefFetcherTest.java index d2b5aec..8ba2585 100644 --- a/test/jalview/ws/seqfetcher/DbRefFetcherTest.java +++ b/test/jalview/ws/seqfetcher/DbRefFetcherTest.java @@ -245,7 +245,7 @@ public class DbRefFetcherTest assertEquals("One sequence only", resp.getHeight(), 1); for (AlignmentAnnotation aa : resp.getAlignmentAnnotation()) { - if (aa.graph == AlignmentAnnotation.CUSTOMRENDERER) + if (aa.graph == AlignmentAnnotation.CONTACT_MAP) { assertTrue("Contact map didn't provide valid contact", resp.getContactListFor(aa, 1).getContactAt(1) != -1d); -- 1.7.10.2