Merge branch 'develop' into bug/JAL-1841rnaSecStr
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 18 Aug 2016 15:33:06 +0000 (16:33 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 18 Aug 2016 15:33:06 +0000 (16:33 +0100)
1  2 
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/jalview/appletgui/AnnotationPanel.java
src/jalview/gui/AnnotationPanel.java

@@@ -393,7 -393,7 +393,7 @@@ label.ignore_unmatched_dropped_files = 
  label.view_name_original = Original
  label.enter_view_name = Enter View Name
  label.enter_label = Enter label
 -label.enter_label_for_the_structure = Enter a label for the structure?
 +label.enter_label_for_the_structure = Enter a label for the structure
  label.pdb_entry_is_already_displayed = {0} is already displayed.\nDo you want to re-use this viewer ?
  label.map_sequences_to_visible_window = Map Sequences to Visible Window: {0}
  label.add_pdbentry_to_view = Do you want to add {0} to the view called\n{1}\n
@@@ -1028,9 -1028,11 +1028,11 @@@ error.implementation_error_need_to_have
  error.dbrefsource_implementation_exception =DBRefSource Implementation Exception
  error.implementation_error_dbinstance_must_implement_interface = Implmentation Error - getDbInstances must be given a class that implements jalview.ws.seqfetcher.DbSourceProxy (was given{0})
  error.implementation_error_must_init_dbsources =Implementation error. Must initialise dbSources
- label.view_controller_toggled_marked = {0} {1} columns containing features of type {2}  across {3} sequence(s)
+ label.view_controller_toggled_marked = {0} {1} columns {2} features of type {3}  across {4} sequence(s)
  label.toggled = Toggled
  label.marked = Marked
+ label.containing = containing
+ label.not_containing = not containing
  label.not = not
  label.no_feature_of_type_found = No features of type {0} found.
  label.submission_params = Submission {0}
@@@ -1310,3 -1312,5 +1312,5 @@@ status.obtaining_mapping_with_nw_alignm
  status.exporting_alignment_as_x_file = Exporting alignment as {0} file
  label.column = Column
  label.sequence = Sequence
+ label.cant_map_cds = Unable to map CDS to protein\nCDS missing or incomplete
+ label.operation_failed = Operation failed
@@@ -361,9 -361,9 +361,9 @@@ label.automatically_associate_pdb_files
  label.automatically_associate_pdb_files_by_name = Asociar los ficheros PDB por nombre automáticamente
  label.ignore_unmatched_dropped_files_info = Quieres <em>ignorar</em> los {0} ficheros cuyos nombres no coincidan con ningún IDs de las secuencias ?
  label.ignore_unmatched_dropped_files = Ignorar los ficheros sin coincidencias?
 -label.enter_view_name = Introducir nombre visible (¿?)
 +label.enter_view_name = Introduzca un nombre para la vista
  label.enter_label = Introducir etiqueta
 -label.enter_label_for_the_structure = Introducir una etiqueta para la estructura?
 +label.enter_label_for_the_structure = Introducir una etiqueta para la estructura
  label.pdb_entry_is_already_displayed = {0} Ya est\u00E1 mostrado.\nQuieres volver a usar este visor?
  label.map_sequences_to_visible_window = Mapa de secuencias en ventana visible: {0}
  label.add_pdbentry_to_view = Quieres a\u00F1adir {0} a la vista llamada\n{1}\n
@@@ -962,9 -962,11 +962,11 @@@ error.implementation_error_need_to_have
  error.dbrefsource_implementation_exception = Excepción de implementación DBRefSource
  error.implementation_error_dbinstance_must_implement_interface = Error de Implementación- getDbInstances debe recibir una clase que implemente jalview.ws.seqfetcher.DbSourceProxy (recibió {0})
  error.implementation_error_must_init_dbsources =Error de implementación. Debe inicializar dbSources
- label.view_controller_toggled_marked = {0} {1} columnas conteniendo características del tipo {2} en {3} secuencia(s)
+ label.view_controller_toggled_marked = {0} {1} columnas {2} características del tipo {3} en {4} secuencia(s)
  label.toggled = Invertida
  label.marked = Marcada
+ label.containing = conteniendo
+ label.not_containing = no conteniendo
  label.not = no
  label.no_feature_of_type_found = No se han encontrado características del tipo {0}.
  label.submission_params = Envío {0}
@@@ -1317,3 -1319,5 +1319,5 @@@ status.obtaining_mapping_with_nw_alignm
  status.exporting_alignment_as_x_file = Exportando alineamiento como fichero tipo {0}
  label.column = Columna
  label.sequence = Secuencia
+ label.cant_map_cds = No se pudo mapear CDS a proteína\nDatos CDS faltantes o incompletos
+ label.operation_failed = Operación fallada
@@@ -25,9 -25,9 +25,10 @@@ 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;
 +import jalview.util.Platform;
  
  import java.awt.Color;
  import java.awt.Dimension;
@@@ -101,8 -101,7 +102,8 @@@ public class AnnotationPanel extends Pa
  
    public AnnotationPanel(AlignmentPanel ap)
    {
 -    MAC = new jalview.util.Platform().isAMac();
 +    new jalview.util.Platform();
 +    MAC = Platform.isAMac();
      this.ap = ap;
      av = ap.av;
      setLayout(null);
  
      if (evt.getActionCommand().equals(REMOVE))
      {
-       for (int sel : av.getColumnSelection().getSelected())
+       for (int index : av.getColumnSelection().getSelected())
        {
-         // TODO: JAL-2001 check if applet has faulty 'REMOVE' selected columns
-         // of
-         // annotation if selection includes hidden columns
-         anot[sel] = null;
+         if (av.getColumnSelection().isVisible(index))
+         {
+           anot[index] = null;
+         }
        }
      }
      else if (evt.getActionCommand().equals(LABEL))
        else if (evt.getActionCommand().equals(STEM))
        {
          type = 'S';
 -        symbol = "\u03C3";
 +        int column = av.getColumnSelection().getSelectedRanges().get(0)[0];
 +        symbol = aa[activeRow].getDefaultRnaHelixSymbol(column);
        }
  
        if (!aa[activeRow].hasIcons)
      if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK
              && activeRow != -1)
      {
 -      if (av.getColumnSelection() == null)
 +      if (av.getColumnSelection() == null
 +              || av.getColumnSelection().isEmpty())
        {
          return;
        }
        PopupMenu pop = new PopupMenu(
                MessageManager.getString("label.structure_type"));
        MenuItem item;
 -      /*
 -       * Just display the needed structure options
 -       */
 -      if (av.getAlignment().isNucleotide() == true)
 +
 +      if (av.getAlignment().isNucleotide())
        {
          item = new MenuItem(STEM);
          item.addActionListener(this);
        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);
        }
  
        /*
            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(")");
            }
          }
        }
@@@ -26,6 -26,7 +26,7 @@@ import jalview.datamodel.ColumnSelectio
  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 +49,8 @@@ import java.awt.event.MouseMotionListen
  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;
@@@ -287,15 -290,17 +290,18 @@@ public class AnnotationPanel extends JP
        aa[activeRow].annotations = anot;
      }
  
 -    if (evt.getActionCommand().equals(REMOVE))
 +    String action = evt.getActionCommand();
 +    if (action.equals(REMOVE))
      {
-       for (int sel : av.getColumnSelection().getSelected())
+       for (int index : av.getColumnSelection().getSelected())
        {
-         anot[sel] = null;
+         if (av.getColumnSelection().isVisible(index))
+         {
+           anot[index] = null;
+         }
        }
      }
 -    else if (evt.getActionCommand().equals(LABEL))
 +    else if (action.equals(LABEL))
      {
        String exMesg = collectAnnotVals(anot, LABEL);
        String label = JOptionPane.showInputDialog(this,
  
          if (anot[index] == null)
          {
 -          anot[index] = new Annotation(label, "", ' ', 0); // TODO: verify that
 -          // null exceptions
 -          // aren't raised
 -          // elsewhere.
 +          anot[index] = new Annotation(label, "", ' ', 0);
          }
          else
          {
          }
        }
      }
 -    else if (evt.getActionCommand().equals(COLOUR))
 +    else if (action.equals(COLOUR))
      {
        Color col = JColorChooser.showDialog(this,
                MessageManager.getString("label.select_foreground_colour"),
      // HELIX, SHEET or STEM
      {
        char type = 0;
 -      String symbol = "\u03B1";
 +      String symbol = "\u03B1"; // alpha
  
 -      if (evt.getActionCommand().equals(HELIX))
 +      if (action.equals(HELIX))
        {
          type = 'H';
        }
 -      else if (evt.getActionCommand().equals(SHEET))
 +      else if (action.equals(SHEET))
        {
          type = 'E';
 -        symbol = "\u03B2";
 +        symbol = "\u03B2"; // beta
        }
  
        // Added by LML to color stems
 -      else if (evt.getActionCommand().equals(STEM))
 +      else if (action.equals(STEM))
        {
          type = 'S';
 -        symbol = "\u03C3";
 +        int column = av.getColumnSelection().getSelectedRanges().get(0)[0];
 +        symbol = aa[activeRow].getDefaultRnaHelixSymbol(column);
        }
  
        if (!aa[activeRow].hasIcons)
        if ((label.length() > 0) && !aa[activeRow].hasText)
        {
          aa[activeRow].hasText = true;
 -        if (evt.getActionCommand().equals(STEM))
 +        if (action.equals(STEM))
          {
            aa[activeRow].showAllColLabels = true;
          }
      return;
    }
  
-   private String collectAnnotVals(Annotation[] anot, String label2)
+   /**
+    * Returns any existing annotation concatenated as a string. For each
+    * annotation, takes the description, if any, else the secondary structure
+    * character (if type is HELIX, SHEET or STEM), else the display character (if
+    * type is LABEL).
+    * 
+    * @param anots
+    * @param type
+    * @return
+    */
+   private String collectAnnotVals(Annotation[] anots, String type)
    {
-     String collatedInput = "";
+     // TODO is this method wanted? why? 'last' is not used
+     StringBuilder collatedInput = new StringBuilder(64);
      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))
          continue;
        }
        String tlabel = null;
-       if (anot[index] != null)
+       if (anots[index] != null)
        { // LML added stem code
-         if (label2.equals(HELIX) || label2.equals(SHEET)
-                 || label2.equals(STEM) || label2.equals(LABEL))
+         if (type.equals(HELIX) || type.equals(SHEET)
+                 || type.equals(STEM) || type.equals(LABEL))
          {
-           tlabel = anot[index].description;
+           tlabel = anots[index].description;
            if (tlabel == null || tlabel.length() < 1)
            {
-             if (label2.equals(HELIX) || label2.equals(SHEET)
-                     || label2.equals(STEM))
+             if (type.equals(HELIX) || type.equals(SHEET)
+                     || type.equals(STEM))
              {
-               tlabel = "" + anot[index].secondaryStructure;
+               tlabel = "" + anots[index].secondaryStructure;
              }
              else
              {
-               tlabel = "" + anot[index].displayCharacter;
+               tlabel = "" + anots[index].displayCharacter;
              }
            }
          }
          {
            if (last.length() > 0)
            {
-             collatedInput += " ";
+             collatedInput.append(" ");
            }
-           collatedInput += tlabel;
+           collatedInput.append(tlabel);
          }
        }
      }
-     return collatedInput;
+     return collatedInput.toString();
    }
  
    /**
  
      if (evt.isPopupTrigger() && activeRow != -1)
      {
 -      if (av.getColumnSelection() == null)
 +      if (av.getColumnSelection() == null
 +              || av.getColumnSelection().isEmpty())
        {
          return;
        }
        /*
         * Just display the needed structure options
         */
 -      if (av.getAlignment().isNucleotide() == true)
 +      if (av.getAlignment().isNucleotide())
        {
          item = new JMenuItem(STEM);
          item.addActionListener(this);
        return;
      }
  
 -    if (aa == null)
 -    {
 -      return;
 -    }
 -
      ap.getScalePanel().mousePressed(evt);
  
    }
          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(")");
          }
        }
      }