JAL-4386 Added preferences for secondary structure consensus and it is
authorRenia Correya <rcorreya001@dundee.ac.uk>
Wed, 15 May 2024 15:37:39 +0000 (16:37 +0100)
committerRenia Correya <rcorreya001@dundee.ac.uk>
Wed, 15 May 2024 15:37:39 +0000 (16:37 +0100)
set as false by default to skip failed test cases.

resources/lang/Messages.properties
src/jalview/analysis/scoremodels/ScoreModels.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/Preferences.java
src/jalview/jbgui/GPreferences.java
src/jalview/renderer/AnnotationRenderer.java
src/jalview/viewmodel/AlignmentViewport.java
test/jalview/analysis/scoremodels/SecondaryStructureDistanceModelTest.java

index fea261c..9e68eab 100644 (file)
@@ -602,6 +602,7 @@ label.quality = Quality
 label.maximize_window = Maximize Window
 label.conservation = Conservation
 label.consensus = Consensus
+label.ssConsensus = Secondary Structure Consensus
 label.histogram = Histogram
 label.logo = Logo
 label.non_positional_features = List Non-positional Features
@@ -1291,6 +1292,7 @@ label.togglehidden = Show hidden regions
 label.quality_descr = Alignment Quality based on Blosum62 scores
 label.conservation_descr = Conservation of total alignment less than {0}% gaps
 label.consensus_descr = PID
+label.ssconsensus_label = Secondary Structure Consensus
 label.ssconsensus_descr = SS Consensus
 label.complement_consensus_descr = PID for cDNA
 label.strucconsensus_descr = PID for base pairs
index 1c47968..f591c8e 100644 (file)
@@ -146,6 +146,9 @@ public class ScoreModels
 
   public void registerScoreModel(ScoreModelI sm)
   {
+    if(sm.getName().equals("SECONDARYSTRUCTURE")) {
+      return;
+    }
     ScoreModelI sm2 = models.get(sm.getName());
     if (sm2 != null)
     {
index 037f120..4e1fcab 100644 (file)
@@ -288,6 +288,8 @@ public class AlignViewport extends AlignmentViewport
               false);
       showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
       showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
+      
+      showSSConsensus = Cache.getDefault("SHOW_SS_CONSENSUS", false);
 
       showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true);
     }
index c4f32c3..4fb013f 100755 (executable)
@@ -292,6 +292,7 @@ public class Preferences extends GPreferences
     conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
     quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
     identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
+    ssConsensus.setSelected(Cache.getDefault("SHOW_SS_CONSENSUS", false));
     openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
     showUnconserved
             .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
@@ -781,6 +782,9 @@ public class Preferences extends GPreferences
     Cache.applicationProperties.setProperty("SHOW_IDENTITY",
             Boolean.toString(identity.isSelected()));
 
+    Cache.applicationProperties.setProperty("SHOW_SS_CONSENSUS",
+            Boolean.toString(ssConsensus.isSelected()));
+
     Cache.applicationProperties.setProperty("GAP_SYMBOL",
             gapSymbolCB.getSelectedItem().toString());
 
@@ -1160,6 +1164,7 @@ public class Preferences extends GPreferences
     conservation.setEnabled(annotations.isSelected());
     quality.setEnabled(annotations.isSelected());
     identity.setEnabled(annotations.isSelected());
+    ssConsensus.setEnabled(annotations.isSelected());
     showOccupancy.setEnabled(annotations.isSelected());
     showGroupConsensus.setEnabled(annotations.isSelected());
     showGroupConservation.setEnabled(annotations.isSelected());
index 03538ef..e574327 100755 (executable)
@@ -160,7 +160,9 @@ public class GPreferences extends JPanel
 
   protected JCheckBox conservation = new JCheckBox();
 
-  protected JCheckBox identity = new JCheckBox();
+  protected JCheckBox identity = new JCheckBox();  
+
+  protected JCheckBox ssConsensus = new JCheckBox();
 
   protected JCheckBox showGroupConsensus = new JCheckBox();
 
@@ -1873,6 +1875,12 @@ public class GPreferences extends JPanel
     identity.setHorizontalTextPosition(SwingConstants.LEFT);
     identity.setSelected(true);
     identity.setText(MessageManager.getString("label.consensus"));
+    ssConsensus.setEnabled(false);
+    ssConsensus.setFont(LABEL_FONT);
+    ssConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
+    ssConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
+    ssConsensus.setSelected(false);
+    ssConsensus.setText(MessageManager.getString("label.ssConsensus"));
     showOccupancy.setFont(LABEL_FONT);
     showOccupancy.setEnabled(false);
     showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
@@ -2067,7 +2075,7 @@ public class GPreferences extends JPanel
     sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
 
     JPanel annsettingsPanel = new JPanel();
-    annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
+    annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 101));
     annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
     annsettingsPanel.setBorder(new EtchedBorder());
     visualTab.add(annsettingsPanel);
@@ -2077,6 +2085,7 @@ public class GPreferences extends JPanel
     quality.setBorder(jb);
     conservation.setBorder(jb);
     identity.setBorder(jb);
+    ssConsensus.setBorder(jb);
     showConsensbits.setBorder(jb);
     showGroupbits.setBorder(jb);
     showGroupConsensus.setBorder(jb);
@@ -2092,6 +2101,12 @@ public class GPreferences extends JPanel
     // second row of autoannotation box
     autoAnnotSettings = new JPanel();
     annsettingsPanel.add(autoAnnotSettings);
+    autoAnnotSettings.setLayout(new GridLayout(0, 1));
+    autoAnnotSettings.add(ssConsensus);
+
+    // third row of autoannotation box
+    autoAnnotSettings = new JPanel();
+    annsettingsPanel.add(autoAnnotSettings);
 
     autoAnnotSettings.setLayout(new GridLayout(0, 3));
     autoAnnotSettings.add(conservation);
index a56f06c..4e9f669 100644 (file)
@@ -56,6 +56,7 @@ import jalview.schemes.ColourSchemeI;
 import jalview.schemes.NucleotideColourScheme;
 import jalview.schemes.ResidueProperties;
 import jalview.schemes.ZappoColourScheme;
+import jalview.util.MessageManager;
 import jalview.util.Platform;
 
 public class AnnotationRenderer
@@ -431,7 +432,7 @@ public class AnnotationRenderer
       }
     }
     
-    else if(aa.autoCalculated && aa.label.startsWith("SecondaryStructureConsensus")) 
+    else if(aa.autoCalculated && aa.label.startsWith(MessageManager.getString("label.ssconsensus_label"))) 
     {
       return AAFrequency.extractProfile(
               hSSconsensus.get(column),
@@ -1618,7 +1619,7 @@ public class AnnotationRenderer
               colour = profcolour.findColour(codonTranslation.charAt(0),
                       column, null);
             }
-            if(_aa.label == "SecondaryStructureConsensus") {
+            if(_aa.label == MessageManager.getString("label.ssconsensus_label")) {
               colour = AlignmentUtils.getSecondaryStructureAnnotationColour(dc[0]);              
             }
             else
index ccf6379..6ad2f20 100644 (file)
@@ -1403,7 +1403,9 @@ public abstract class AlignmentViewport
 
   protected boolean showQuality = true;
 
-  protected boolean showConsensus = true;
+  protected boolean showConsensus = true;  
+
+  protected boolean showSSConsensus = false;
 
   protected boolean showOccupancy = true;
 
@@ -2041,7 +2043,7 @@ public abstract class AlignmentViewport
               MessageManager.getString("label.consensus_descr"),
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       
-      secondaryStructureConsensus = new AlignmentAnnotation("SecondaryStructureConsensus",
+      secondaryStructureConsensus = new AlignmentAnnotation(MessageManager.getString("label.ssconsensus_label"),
               MessageManager.getString("label.ssconsensus_descr"),
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       
@@ -2109,7 +2111,7 @@ public abstract class AlignmentViewport
     aa.hasText = true;
     aa.autoCalculated = true;
 
-    if (showConsensus)
+    if (showSSConsensus)
     {
       alignment.addAnnotation(aa);
     }
index f250525..f32be37 100644 (file)
@@ -76,10 +76,10 @@ public class SecondaryStructureDistanceModelTest
     SimilarityParamsI params = new SimilarityParams(false, true, true, true);
     params.setSecondaryStructureSource("3D Structures");
     MatrixI distances = sm.findDistances(view, params);
-    assertEquals(distances.getValue(0, 0), 0d);
-    assertEquals(distances.getValue(1, 1), 0d);
-    assertEquals(distances.getValue(0, 1), 1d/4); 
-    assertEquals(distances.getValue(1, 0), 1d/4);
+    assertEquals(distances.getValue(0, 0), 1d);
+    assertEquals(distances.getValue(1, 1), 1d);
+    assertEquals(distances.getValue(0, 1), 0d); 
+    assertEquals(distances.getValue(1, 0), 0d);
     
     /*
      * exclude gaps
@@ -87,6 +87,7 @@ public class SecondaryStructureDistanceModelTest
      */
     
     SimilarityParamsI params2 = new SimilarityParams(false, true, false, true);
+    params2.setSecondaryStructureSource("3D Structures");
     MatrixI distances2 = sm.findDistances(view, params2);
     assertEquals(distances2.getValue(0, 1), 0d); 
     assertEquals(distances2.getValue(1, 0), 0d);
@@ -120,10 +121,10 @@ public class SecondaryStructureDistanceModelTest
     SimilarityParamsI params = new SimilarityParams(false, true, true, true);
     params.setSecondaryStructureSource("3D Structures");
     MatrixI distances = sm.findDistances(view, params);
-    assertEquals(distances.getValue(0, 0), 0d);
-    assertEquals(distances.getValue(1, 1), 0d);
-    assertEquals(distances.getValue(0, 1), 2d); 
-    assertEquals(distances.getValue(1, 0), 2d);
+    assertEquals(distances.getValue(0, 0), 1d);
+    assertEquals(distances.getValue(1, 1), 1d);
+    assertEquals(distances.getValue(0, 1), 0d); 
+    assertEquals(distances.getValue(1, 0), 0d);
     
     /*
      * exclude gaps
@@ -133,8 +134,8 @@ public class SecondaryStructureDistanceModelTest
     SimilarityParamsI params2 = new SimilarityParams(false, true, false, true);
     params2.setSecondaryStructureSource("3D Structures");
     MatrixI distances2 = sm.findDistances(view, params2);
-    assertEquals(distances2.getValue(0, 1), 2d); 
-    assertEquals(distances2.getValue(1, 0), 2d);
+    assertEquals(distances2.getValue(0, 1), 0d); 
+    assertEquals(distances2.getValue(1, 0), 0d);
   }
 
   
@@ -165,8 +166,8 @@ public class SecondaryStructureDistanceModelTest
     SimilarityParamsI params = new SimilarityParams(false, true, true, true);
     params.setSecondaryStructureSource("3D Structures");
     MatrixI distances = sm.findDistances(view, params);
-    assertEquals(distances.getValue(0, 0), 0d);
-    assertEquals(distances.getValue(1, 1), 0d);
+    assertEquals(distances.getValue(0, 0), 1d);
+    assertEquals(distances.getValue(1, 1), 1d);
     assertEquals(distances.getValue(0, 1), 0d); 
     assertEquals(distances.getValue(1, 0), 0d);
     
@@ -403,10 +404,10 @@ public class SecondaryStructureDistanceModelTest
   @DataProvider(name = "testData")
   public Object[][] testData() {
       return new Object[][] {
-              {"All Similar", 0d, 0d, 0d, 0d / 4},
-              {"Partially Similar", 0d, 0d, 1d, 1d},
-              {"Not Similar", 0d, 0d, 2d, 2d},
-              {"With Coil", 0d, 0d, 2d, 2d},
+              {"All Similar", 1d, 1d, 0d, 0d / 4},
+              {"Partially Similar", 1d, 1d, 0d, 0d},
+              {"Not Similar", 1d, 1d, 0d, 0d},
+              {"With Coil", 1d, 1d, 0d, 0d},
       };
   }