JAL-2146 status message now with formatted residue name / code
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 17 Aug 2016 13:55:26 +0000 (14:55 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 17 Aug 2016 13:55:26 +0000 (14:55 +0100)
src/jalview/appletgui/AnnotationPanel.java
src/jalview/gui/AnnotationPanel.java

index 1a5dc05..e5475f8 100755 (executable)
@@ -25,6 +25,7 @@ import jalview.datamodel.Annotation;
 import jalview.datamodel.SequenceI;
 import jalview.renderer.AnnotationRenderer;
 import jalview.renderer.AwtRenderPanelI;
+import jalview.schemes.ResidueProperties;
 import jalview.util.Comparison;
 import jalview.util.MessageManager;
 
@@ -472,9 +473,10 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI,
       StringBuilder text = new StringBuilder();
       text.append(MessageManager.getString("label.column")).append(" ")
               .append(column + 1);
-      if (aa[row].annotations[column].description != null)
+      String description = aa[row].annotations[column].description;
+      if (description != null && description.length() > 0)
       {
-        text.append("  ").append(aa[row].annotations[column].description);
+        text.append("  ").append(description);
       }
 
       /*
@@ -493,9 +495,28 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI,
           char residue = seqref.getCharAt(column);
           if (!Comparison.isGap(residue))
           {
+            text.append(" ");
+            String name;
+            if (av.getAlignment().isNucleotide())
+            {
+              name = ResidueProperties.nucleotideName.get(String
+                      .valueOf(residue));
+              text.append(" Nucleotide: ").append(
+                      name != null ? name : residue);
+            }
+            else
+            {
+              name = 'X' == residue ? "X" : ('*' == residue ? "STOP"
+                      : ResidueProperties.aa2Triplet.get(String
+                              .valueOf(residue)));
+              text.append(" Residue: ").append(
+                      name != null ? name : residue);
+            }
             int residuePos = seqref.findPosition(column);
-            text.append(": ").append(residue).append(" (")
-                    .append(residuePos).append(")");
+            text.append(" (").append(residuePos).append(")");
+            // int residuePos = seqref.findPosition(column);
+            // text.append(residue).append(" (")
+            // .append(residuePos).append(")");
           }
         }
       }
index eec1881..3c9a13e 100755 (executable)
@@ -26,6 +26,7 @@ import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.SequenceI;
 import jalview.renderer.AnnotationRenderer;
 import jalview.renderer.AwtRenderPanelI;
+import jalview.schemes.ResidueProperties;
 import jalview.util.Comparison;
 import jalview.util.MessageManager;
 
@@ -48,6 +49,8 @@ import java.awt.event.MouseMotionListener;
 import java.awt.event.MouseWheelEvent;
 import java.awt.event.MouseWheelListener;
 import java.awt.image.BufferedImage;
+import java.util.Collections;
+import java.util.List;
 
 import javax.swing.JColorChooser;
 import javax.swing.JMenuItem;
@@ -444,7 +447,9 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
     String last = "";
     ColumnSelection viscols = av.getColumnSelection();
     // TODO: refactor and save av.getColumnSelection for efficiency
-    for (int index : viscols.getSelected())
+    List<Integer> selected = viscols.getSelected();
+    Collections.sort(selected);
+    for (int index : selected)
     {
       // always check for current display state - just in case
       if (!viscols.isVisible(index))
@@ -795,9 +800,24 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
         char residue = seqref.getCharAt(column);
         if (!Comparison.isGap(residue))
         {
+          text.append(" ");
+          String name;
+          if (av.getAlignment().isNucleotide())
+          {
+            name = ResidueProperties.nucleotideName.get(String
+                    .valueOf(residue));
+            text.append(" Nucleotide: ").append(
+                    name != null ? name : residue);
+          }
+          else
+          {
+            name = 'X' == residue ? "X" : ('*' == residue ? "STOP"
+                    : ResidueProperties.aa2Triplet.get(String
+                            .valueOf(residue)));
+            text.append(" Residue: ").append(name != null ? name : residue);
+          }
           int residuePos = seqref.findPosition(column);
-          text.append(": ").append(residue).append(" (")
-                  .append(residuePos).append(")");
+          text.append(" (").append(residuePos).append(")");
         }
       }
     }