Merge branch 'features/JAL-2503_filteronquantitativeannotation' into develop
authorJim Procter <jprocter@issues.jalview.org>
Thu, 4 May 2017 13:10:03 +0000 (14:10 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Thu, 4 May 2017 13:10:03 +0000 (14:10 +0100)
20 files changed:
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/jalview/analysis/AAFrequency.java
src/jalview/appletgui/AnnotationColumnChooser.java
src/jalview/appletgui/AnnotationRowFilter.java
src/jalview/ext/ensembl/EnsemblRestClient.java
src/jalview/fts/core/GFTSPanel.java
src/jalview/gui/AnnotationColourChooser.java
src/jalview/gui/AnnotationColumnChooser.java
src/jalview/gui/AnnotationRowFilter.java
src/jalview/gui/CalculationChooser.java
src/jalview/gui/Console.java
src/jalview/gui/Desktop.java
src/jalview/gui/FeatureSettings.java
src/jalview/gui/Finder.java
src/jalview/gui/JalviewDialog.java
src/jalview/gui/PCAPanel.java
src/jalview/gui/SequenceFetcher.java
src/jalview/viewmodel/AlignmentViewport.java
test/jalview/ws/dbsources/RemoteFormatTest.java [new file with mode: 0644]

index 5ac4269..e63752d 100644 (file)
@@ -68,7 +68,6 @@ action.user_defined = User Defined...
 action.by_conservation = By Conservation
 action.wrap = Wrap
 action.show_gaps = Show Gaps
-action.show_occupancy = Show Occupancy
 action.show_hidden_markers = Show Hidden Markers
 action.find = Find
 action.undefine_groups = Undefine Groups
@@ -1303,3 +1302,9 @@ warn.name_cannot_be_duplicate = User-defined URL names must be unique and cannot
 label.invalid_name = Invalid Name !
 label.output_seq_details = Output Sequence Details to list all database references
 label.urllinks = Links
+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.complement_consensus_descr = PID for cDNA
+label.strucconsensus_descr = PID for base pairs
+label.occupancy_descr = Number of aligned positions 
\ No newline at end of file
index e959afd..6ddbb44 100644 (file)
@@ -182,6 +182,7 @@ label.score_model_conservation = Conservaci
 label.score_model_enhconservation = Conservación de las propiedades físico-químicas
 label.status_bar = Barra de estado
 label.out_to_textbox = Generar cuadro de texto
+label.occupancy = Ocupación
 label.clustal = Clustal
 # label.colourScheme_<schemeName> as in JalviewColourScheme
 label.colourScheme_clustal = Clustalx
@@ -835,6 +836,7 @@ label.webservice_job_title_on = {0} usando {1} de {2}
 label.updating_vamsas_session = Actualizando sesión VAMSAS
 label.loading_file = Cargando fichero: {0}
 label.edit_params = Editar {0}
+label.as_percentage = Como Porcentaje
 error.not_implemented = No implementado
 error.no_such_method_as_clone1_for = No existe ese método como un clone1 de {0}
 error.null_from_clone1 = Nulo de clone1!
index 3636b5e..b806355 100755 (executable)
@@ -332,9 +332,9 @@ public class AAFrequency
 
       final int gapped = profile.getNonGapped();
 
-      String description = "";
+      String description = "" + gapped;
 
-      gaprow.annotations[i] = new Annotation(description, description,
+      gaprow.annotations[i] = new Annotation("", description,
               '\0', gapped, jalview.util.ColorUtils.bleachColour(
                       Color.DARK_GRAY, (float) scale * gapped));
     }
index 4b67bbf..25ff293 100644 (file)
@@ -167,20 +167,22 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
     }
 
     populateThresholdComboBox(threshold);
-
+    AnnotationColumnChooser lastChooser = av
+            .getAnnotationColumnSelectionState();
     // restore Object state from the previous session if one exists
-    if (av.getAnnotationColumnSelectionState() != null)
+    if (lastChooser != null)
     {
-      currentSearchPanel = av.getAnnotationColumnSelectionState()
+      currentSearchPanel = lastChooser
               .getCurrentSearchPanel();
-      currentStructureFilterPanel = av.getAnnotationColumnSelectionState()
+      currentStructureFilterPanel = lastChooser
               .getCurrentStructureFilterPanel();
-      annotations.select(av.getAnnotationColumnSelectionState()
+      annotations.select(lastChooser
               .getAnnotations().getSelectedIndex());
-      threshold.select(av.getAnnotationColumnSelectionState()
+      threshold.select(lastChooser
               .getThreshold().getSelectedIndex());
-      actionOption = av.getAnnotationColumnSelectionState()
+      actionOption = lastChooser
               .getActionOption();
+      percentThreshold.setState(lastChooser.percentThreshold.getState());
     }
 
     try
@@ -243,10 +245,10 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
     ngStructureFilterPanel = new StructureFilterPanel(this);
 
     thresholdPanel.setTitle("Threshold Filter");
-    thresholdPanel.add(percentThreshold);
     thresholdPanel.add(getThreshold());
     thresholdPanel.add(slider);
     thresholdPanel.add(thresholdValue);
+    thresholdPanel.add(percentThreshold);
 
     actionPanel.add(ok);
     actionPanel.add(cancel);
@@ -318,7 +320,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
   {
     if (!adjusting)
     {
-      thresholdValue.setText((slider.getValue() / 1000f) + "");
+      setThresholdValueText();
       valueChanged(!sliderDragging);
     }
   }
@@ -404,12 +406,14 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
 
     slider.setEnabled(true);
     thresholdValue.setEnabled(true);
+    percentThreshold.setEnabled(true);
 
     if (selectedThresholdItem == AnnotationColourGradient.NO_THRESHOLD)
     {
       slider.setEnabled(false);
       thresholdValue.setEnabled(false);
       thresholdValue.setText("");
+      percentThreshold.setEnabled(false);
       // build filter params
     }
     else if (selectedThresholdItem != AnnotationColourGradient.NO_THRESHOLD)
@@ -434,6 +438,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
       // slider.setMajorTickSpacing((int) (range / 10f));
       slider.setEnabled(true);
       thresholdValue.setEnabled(true);
+      percentThreshold.setEnabled(true);
       adjusting = false;
 
       // build filter params
@@ -890,19 +895,8 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
   @Override
   public void actionPerformed(ActionEvent evt)
   {
-    if (evt.getSource() == thresholdValue)
-    {
-      try
-      {
-        float f = new Float(thresholdValue.getText()).floatValue();
-        slider.setValue((int) (f * 1000));
-        adjustmentValueChanged(null);
-      } catch (NumberFormatException ex)
-      {
-      }
-    }
 
-    else if (evt.getSource() == ok)
+    if (evt.getSource() == ok)
     {
       ok_actionPerformed(null);
     }
index 6ea0fed..315ce3b 100644 (file)
@@ -133,21 +133,26 @@ public abstract class AnnotationRowFilter extends Panel
     updateView();
   }
 
+  /**
+   * update the text field from the threshold slider. preserves state of
+   * 'adjusting' so safe to call in init.
+   */
   protected void setThresholdValueText()
   {
+    boolean oldadj = adjusting;
     adjusting = true;
     if (percentThreshold.getState())
     {
       double scl = slider.getMaximum() - slider.getMinimum();
       scl = (slider.getValue() - slider.getMinimum()) / scl;
-      thresholdValue.setText(100 * scl + "");
+      thresholdValue.setText(100f * scl + "");
     }
     else
     {
       thresholdValue.setText((slider.getValue() / 1000f) + "");
     }
     thresholdValue.setCaretPosition(0);
-    adjusting = false;
+    adjusting = oldadj;
   }
   
   public void thresholdValue_actionPerformed(ActionEvent e)
@@ -157,15 +162,15 @@ public abstract class AnnotationRowFilter extends Panel
       float f = Float.parseFloat(thresholdValue.getText());
       if (percentThreshold.getState())
       {
-        slider.setValue(slider.getMinimum()
-                + ((int) ((f / 100f) * (slider.getMaximum() - slider
-                        .getMinimum()))));
+        int pos = slider.getMinimum()
+                + (int) ((slider.getMaximum() - slider.getMinimum()) * f / 100f);
+        slider.setValue(pos);
       }
       else
       {
         slider.setValue((int) (f * 1000));
       }
-      updateView();
+      valueChanged(false);
     } catch (NumberFormatException ex)
     {
     }
index ab3b197..5960f81 100644 (file)
@@ -57,13 +57,13 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher
 
   /*
    * update these constants when Jalview has been checked / updated for
-   * changes to Ensembl REST API
+   * changes to Ensembl REST API (ref JAL-2105)
    * @see https://github.com/Ensembl/ensembl-rest/wiki/Change-log
    * @see http://rest.ensembl.org/info/rest?content-type=application/json
    */
-  private static final String LATEST_ENSEMBLGENOMES_REST_VERSION = "4.8";
+  private static final String LATEST_ENSEMBLGENOMES_REST_VERSION = "5.0";
 
-  private static final String LATEST_ENSEMBL_REST_VERSION = "4.8";
+  private static final String LATEST_ENSEMBL_REST_VERSION = "5.0";
 
   private static final String REST_CHANGE_LOG = "https://github.com/Ensembl/ensembl-rest/wiki/Change-log";
 
@@ -513,9 +513,11 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher
       boolean laterVersion = StringUtils.compareVersions(version, expected) == 1;
       if (laterVersion)
       {
-        System.err.println(String.format(
-                "Expected %s REST version %s but found %s, see %s",
-                getDbSource(), expected, version, REST_CHANGE_LOG));
+        System.err
+                .println(String
+                        .format("EnsemblRestClient expected %s REST version %s but found %s, see %s",
+                                getDbSource(), expected, version,
+                                REST_CHANGE_LOG));
       }
       info.restVersion = version;
     } catch (Throwable t)
index a69d9f8..6000526 100644 (file)
@@ -146,6 +146,10 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
 
   protected HashSet<String> paginatorCart = new HashSet<String>();
 
+  private static final int MIN_WIDTH = 670;
+
+  private static final int MIN_HEIGHT = 300;
+
   protected static final DecimalFormat totalNumberformatter = new DecimalFormat(
           "###,###");
 
@@ -234,6 +238,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
     try
     {
       jbInit();
+      mainFrame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
       mainFrame.addFocusListener(new FocusAdapter()
       {
         @Override
index 8500888..253a7ec 100644 (file)
@@ -69,6 +69,10 @@ public class AnnotationColourChooser extends AnnotationRowFilter
 
   private JCheckBox thresholdIsMin = new JCheckBox();
 
+  protected static final int MIN_WIDTH = 500;
+
+  protected static final int MIN_HEIGHT = 240;
+
   public AnnotationColourChooser(AlignViewport av, final AlignmentPanel ap)
   {
     super(av, ap);
@@ -90,7 +94,7 @@ public class AnnotationColourChooser extends AnnotationRowFilter
     Desktop.addInternalFrame(frame,
             MessageManager.getString("label.colour_by_annotation"), 520,
             215);
-
+    frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
     addSliderChangeListener();
     addSliderMouseListeners();
 
index 1efc569..999d217 100644 (file)
@@ -29,6 +29,7 @@ import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
 import java.awt.BorderLayout;
 import java.awt.CardLayout;
 import java.awt.Color;
+import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
@@ -87,6 +88,10 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
 
   private ColumnSelection oldColumnSelection;
 
+  protected int MIN_WIDTH = 420;
+
+  protected int MIN_HEIGHT = 430;
+
   public AnnotationColumnChooser(AlignViewport av, final AlignmentPanel ap)
   {
     super(av, ap);
@@ -96,6 +101,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
     Desktop.addInternalFrame(frame,
             MessageManager.getString("label.select_by_annotation"), 520,
             215);
+    frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
 
     addSliderChangeListener();
     addSliderMouseListeners();
@@ -109,20 +115,23 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
 
     setAnnotations(new JComboBox<String>(getAnnotationItems(false)));
     populateThresholdComboBox(threshold);
-
+    AnnotationColumnChooser lastChooser = av
+            .getAnnotationColumnSelectionState();
     // restore Object state from the previous session if one exists
-    if (av.getAnnotationColumnSelectionState() != null)
+    if (lastChooser != null)
     {
-      currentSearchPanel = av.getAnnotationColumnSelectionState()
+      currentSearchPanel = lastChooser
               .getCurrentSearchPanel();
-      currentStructureFilterPanel = av.getAnnotationColumnSelectionState()
+      currentStructureFilterPanel = lastChooser
               .getCurrentStructureFilterPanel();
-      annotations.setSelectedIndex(av.getAnnotationColumnSelectionState()
+      annotations.setSelectedIndex(lastChooser
               .getAnnotations().getSelectedIndex());
-      threshold.setSelectedIndex(av.getAnnotationColumnSelectionState()
+      threshold.setSelectedIndex(lastChooser
               .getThreshold().getSelectedIndex());
-      actionOption = av.getAnnotationColumnSelectionState()
+      actionOption = lastChooser
               .getActionOption();
+      percentThreshold.setSelected(lastChooser.percentThreshold
+              .isSelected());
     }
 
     try
@@ -314,16 +323,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
       slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000));
       slider.setValue((int) (getCurrentAnnotation().threshold.value * 1000));
       
-      if (percentThreshold.isSelected())
-      {
-        thresholdValue
-                .setText(""
-                        + ((getCurrentAnnotation().threshold.value - getCurrentAnnotation().graphMin) * 100f / (getCurrentAnnotation().graphMax - getCurrentAnnotation().graphMin)));
-      }
-      else
-      {
-        thresholdValue.setText(getCurrentAnnotation().threshold.value + "");
-      }
+      setThresholdValueText();
 
       slider.setMajorTickSpacing((int) (range / 10f));
       slider.setEnabled(true);
index 1035a6c..a3ce528 100644 (file)
@@ -129,8 +129,13 @@ public abstract class AnnotationRowFilter extends JPanel
     });
   }
 
+  /**
+   * update the text field from the threshold slider. preserves state of
+   * 'adjusting' so safe to call in init.
+   */
   protected void setThresholdValueText()
   {
+    boolean oldadj = adjusting;
     adjusting = true;
     if (percentThreshold.isSelected())
     {
@@ -141,7 +146,7 @@ public abstract class AnnotationRowFilter extends JPanel
     {
       thresholdValue.setText((slider.getValue() / 1000f) + "");
     }
-    adjusting = false;
+    adjusting = oldadj;
   }
   protected void addSliderMouseListeners()
   {
@@ -291,7 +296,7 @@ public abstract class AnnotationRowFilter extends JPanel
     try
     {
       float f = Float.parseFloat(thresholdValue.getText());
-      if (percentThreshold.isEnabled())
+      if (percentThreshold.isSelected())
       {
         slider.setValue(slider.getMinimum()
                 + ((int) ((f / 100f) * (slider.getMaximum() - slider
index fe6336e..05f1fba 100644 (file)
@@ -47,6 +47,7 @@ import java.util.List;
 
 import javax.swing.BorderFactory;
 import javax.swing.ButtonGroup;
+import javax.swing.DefaultComboBoxModel;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
@@ -300,6 +301,7 @@ public class CalculationChooser extends JPanel
     {
       ok.setEnabled(false);
     }
+    updateScoreModels(comboBox, tips);
   }
 
   /**
@@ -340,6 +342,13 @@ public class CalculationChooser extends JPanel
     }
     return false;
   }
+
+  final JComboBox<String> comboBox = new JComboBox<String>();
+
+  final ComboBoxTooltipRenderer renderer = new ComboBoxTooltipRenderer();
+
+  List<String> tips = new ArrayList<String>();
+
   /**
    * A rather elaborate helper method (blame Swing, not me) that builds a
    * drop-down list of score models (by name) with descriptions as tooltips.
@@ -348,17 +357,14 @@ public class CalculationChooser extends JPanel
    */
   protected JComboBox<String> buildModelOptionsList()
   {
-    final JComboBox<String> comboBox = new JComboBox<String>();
-    ComboBoxTooltipRenderer renderer = new ComboBoxTooltipRenderer();
     comboBox.setRenderer(renderer);
-    final List<String> tips = new ArrayList<String>();
 
     /*
      * show tooltip on mouse over the combobox
      * note the listener has to be on the components that make up
      * the combobox, doesn't work if just on the combobox
      */
-    MouseAdapter mouseListener = new MouseAdapter()
+    final MouseAdapter mouseListener = new MouseAdapter()
     {
       @Override
       public void mouseEntered(MouseEvent e)
@@ -377,17 +383,39 @@ public class CalculationChooser extends JPanel
       c.addMouseListener(mouseListener);
     }
 
+    updateScoreModels(comboBox, tips);
+
+    /*
+     * set the list of tooltips on the combobox's renderer
+     */
+    renderer.setTooltips(tips);
+
+    return comboBox;
+  }
+
+  private void updateScoreModels(JComboBox comboBox, List<String> tips)
+  {
+    Object curSel = comboBox.getSelectedItem();
+    tips.clear();
+    DefaultComboBoxModel model = new DefaultComboBoxModel();
+
     /*
      * now we can actually add entries to the combobox,
      * remembering their descriptions for tooltips
      */
     ScoreModels scoreModels = ScoreModels.getInstance();
+    boolean selectedIsPresent = false;
     for (ScoreModelI sm : scoreModels.getModels())
     {
       boolean nucleotide = af.getViewport().getAlignment().isNucleotide();
       if (sm.isDNA() && nucleotide || sm.isProtein() && !nucleotide)
       {
-        comboBox.addItem(sm.getName());
+        if (curSel != null && sm.getName().equals(curSel))
+        {
+          selectedIsPresent = true;
+          curSel = sm.getName();
+        }
+        model.addElement(sm.getName());
 
         /*
          * tooltip is description if provided, else text lookup with
@@ -401,14 +429,13 @@ public class CalculationChooser extends JPanel
         }
         tips.add(tooltip);
       }
-
-      /*
-       * set the list of tooltips on the combobox's renderer
-       */
-      renderer.setTooltips(tips);
     }
-
-    return comboBox;
+    if (selectedIsPresent)
+    {
+      model.setSelectedItem(curSel);
+    }
+    // finally, update the model
+    comboBox.setModel(model);
   }
 
   /**
index 280b4c0..de7574c 100644 (file)
@@ -84,6 +84,10 @@ public class Console extends WindowAdapter implements WindowListener,
   // are we attached to some parent Desktop
   Desktop parent = null;
 
+  private int MIN_WIDTH = 300;
+
+  private int MIN_HEIGHT = 250;
+
   public Console()
   {
     // create all components and add them
@@ -243,7 +247,9 @@ public class Console extends WindowAdapter implements WindowListener,
             .getLocalGraphicsEnvironment();
     String[] fontNames = ge.getAvailableFontFamilyNames();
     for (int n = 0; n < fontNames.length; n++)
+    {
       System.out.println(fontNames[n]);
+    }
     // Testing part: simple an error thrown anywhere in this JVM will be printed
     // on the Console
     // We do it with a seperate Thread becasue we don't wan't to break a Thread
@@ -259,9 +265,13 @@ public class Console extends WindowAdapter implements WindowListener,
     JFrame frame = new JFrame(string);
     frame.setName(string);
     if (x == -1)
-      x = (int) (i / 2);
+    {
+      x = i / 2;
+    }
     if (y == -1)
-      y = (int) (j / 2);
+    {
+      y = j / 2;
+    }
     frame.setBounds(x, y, i, j);
     return frame;
   }
@@ -298,6 +308,7 @@ public class Console extends WindowAdapter implements WindowListener,
       frame = initFrame("Jalview Java Console", bounds.width,
               bounds.height, bounds.x, bounds.y);
     }
+    frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
     // desktop.add(frame);
     initConsole(false);
     JalviewAppender jappender = new JalviewAppender();
@@ -345,6 +356,7 @@ public class Console extends WindowAdapter implements WindowListener,
     // System.exit(0);
   }
 
+  @Override
   public synchronized void windowClosed(WindowEvent evt)
   {
     frame.setVisible(false);
@@ -365,6 +377,7 @@ public class Console extends WindowAdapter implements WindowListener,
     }
   }
 
+  @Override
   public synchronized void windowClosing(WindowEvent evt)
   {
     frame.setVisible(false); // default behaviour of JFrame
@@ -373,12 +386,14 @@ public class Console extends WindowAdapter implements WindowListener,
     // frame.dispose();
   }
 
+  @Override
   public synchronized void actionPerformed(ActionEvent evt)
   {
     trimBuffer(true);
     // textArea.setText("");
   }
 
+  @Override
   public synchronized void run()
   {
     try
@@ -410,7 +425,9 @@ public class Console extends WindowAdapter implements WindowListener,
           // lines++;
         }
         if (quit)
+        {
           return;
+        }
       }
 
       while (Thread.currentThread() == reader2)
@@ -439,7 +456,9 @@ public class Console extends WindowAdapter implements WindowListener,
           // lines++;
         }
         if (quit)
+        {
           return;
+        }
       }
       while (Thread.currentThread() == textAppender)
       {
@@ -531,6 +550,7 @@ public class Console extends WindowAdapter implements WindowListener,
     long time = System.nanoTime();
     javax.swing.SwingUtilities.invokeLater(new Runnable()
     {
+      @Override
       public void run()
       {
         displayPipe.append(input); // change to stringBuffer
@@ -598,7 +618,9 @@ public class Console extends WindowAdapter implements WindowListener,
     {
       int available = in.available();
       if (available == 0)
+      {
         break;
+      }
       byte b[] = new byte[available];
       in.read(b);
       input = input + new String(b, 0, b.length);
index 7d0eb7f..d6c25a8 100644 (file)
@@ -129,6 +129,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         DropTargetListener, ClipboardOwner, IProgressIndicator,
         jalview.api.StructureSelectionManagerProvider
 {
+  private static int DEFAULT_MIN_WIDTH = 300;
+
+  private static int DEFAULT_MIN_HEIGHT = 250;
 
   private JalviewChangeSupport changeSupport = new JalviewChangeSupport();
 
@@ -833,6 +836,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
     openFrameCount++;
 
+    frame.setMinimumSize(new Dimension(DEFAULT_MIN_WIDTH,
+            DEFAULT_MIN_HEIGHT));
     frame.setVisible(makeVisible);
     frame.setClosable(true);
     frame.setResizable(resizable);
index 26f9964..feb09fc 100644 (file)
@@ -40,6 +40,7 @@ import jalview.ws.dbsources.das.api.jalviewSourceI;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Component;
+import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.Graphics;
 import java.awt.GridLayout;
@@ -126,6 +127,10 @@ public class FeatureSettings extends JPanel implements
 
   JPanel transPanel = new JPanel(new GridLayout(1, 2));
 
+  private static final int MIN_WIDTH = 400;
+
+  private static final int MIN_HEIGHT = 400;
+
   public FeatureSettings(AlignFrame af)
   {
     this.af = af;
@@ -278,6 +283,7 @@ public class FeatureSettings extends JPanel implements
               MessageManager.getString("label.sequence_feature_settings"),
               400, 450);
     }
+    frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
 
     frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
     {
index af23ceb..e44c956 100755 (executable)
@@ -28,6 +28,7 @@ import jalview.jbgui.GFinder;
 import jalview.util.MessageManager;
 import jalview.viewmodel.AlignmentViewport;
 
+import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 import java.util.Vector;
@@ -38,7 +39,6 @@ import javax.swing.AbstractAction;
 import javax.swing.JComponent;
 import javax.swing.JInternalFrame;
 import javax.swing.JLayeredPane;
-import javax.swing.JOptionPane;
 import javax.swing.KeyStroke;
 
 /**
@@ -54,14 +54,18 @@ import javax.swing.KeyStroke;
  */
 public class Finder extends GFinder
 {
-  private static final int HEIGHT = 110;
+  private static final int HEIGHT = 120;
 
-  private static final int WIDTH = 340;
+  private static final int WIDTH = 400;
 
   AlignmentViewport av;
 
   AlignmentPanel ap;
 
+  private static final int MIN_WIDTH = 350;
+
+  private static final int MIN_HEIGHT = 120;
+
   JInternalFrame frame;
 
   int seqIndex = 0;
@@ -97,7 +101,7 @@ public class Finder extends GFinder
     addEscapeHandler();
     Desktop.addInternalFrame(frame, MessageManager.getString("label.find"),
             WIDTH, HEIGHT);
-
+    frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
     textfield.requestFocus();
   }
 
index 8742253..05f5ffc 100644 (file)
@@ -23,6 +23,7 @@ package jalview.gui;
 import jalview.util.MessageManager;
 
 import java.awt.Container;
+import java.awt.Dimension;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -89,6 +90,9 @@ public abstract class JalviewDialog extends JPanel
     {
       frame.setSize(width, height);
     }
+    int minWidth = width - 100;
+    int minHeight = height - 100;
+    frame.setMinimumSize(new Dimension(minWidth, minHeight));
     frame.setContentPane(content);
     this.block = block;
 
index 0675cdf..e9ba1e7 100644 (file)
@@ -36,6 +36,7 @@ import jalview.viewmodel.PCAModel;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
+import java.awt.Dimension;
 import java.awt.Graphics;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -72,6 +73,10 @@ public class PCAPanel extends GPCAPanel implements Runnable,
 
   PCAModel pcaModel;
 
+  private static final int MIN_WIDTH = 470;
+
+  private static final int MIN_HEIGHT = 250;
+
   int top = 0;
 
   /**
@@ -256,6 +261,7 @@ public class PCAPanel extends GPCAPanel implements Runnable,
       addKeyListener(rc);
       Desktop.addInternalFrame(this, MessageManager
               .getString("label.principal_component_analysis"), 475, 450);
+      this.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
     }
   }
 
index 8e1d549..bf0ab70 100755 (executable)
@@ -52,7 +52,6 @@ import javax.swing.JButton;
 import javax.swing.JCheckBox;
 import javax.swing.JInternalFrame;
 import javax.swing.JLabel;
-import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTextArea;
index 0015299..fa3a8a7 100644 (file)
@@ -62,6 +62,7 @@ import jalview.structure.VamsasSource;
 import jalview.util.Comparison;
 import jalview.util.MapList;
 import jalview.util.MappingUtils;
+import jalview.util.MessageManager;
 import jalview.viewmodel.styles.ViewStyle;
 import jalview.workers.AlignCalcManager;
 import jalview.workers.ComplementConsensusThread;
@@ -1892,7 +1893,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
       {
         initRNAStructure();
       }
-      consensus = new AlignmentAnnotation("Consensus", "PID",
+      consensus = new AlignmentAnnotation("Consensus",
+              MessageManager.getString("label.consensus_descr"),
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       initConsensus(consensus);
       initGapCounts();
@@ -1929,7 +1931,9 @@ public abstract class AlignmentViewport implements AlignViewportI,
         if (doConsensus)
         {
           complementConsensus = new AlignmentAnnotation("cDNA Consensus",
-                  "PID for cDNA", new Annotation[1], 0f, 100f,
+                  MessageManager
+                          .getString("label.complement_consensus_descr"),
+                  new Annotation[1], 0f, 100f,
                   AlignmentAnnotation.BAR_GRAPH);
           initConsensus(complementConsensus);
           return true;
@@ -1957,7 +1961,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
     if (showOccupancy)
     {
       gapcounts = new AlignmentAnnotation("Occupancy",
-              "Number of aligned positions", new Annotation[1], 0f,
+              MessageManager.getString("label.occupancy_descr"),
+              new Annotation[1], 0f,
               alignment.getHeight(), AlignmentAnnotation.BAR_GRAPH);
       gapcounts.hasText = true;
       gapcounts.autoCalculated = true;
@@ -1975,8 +1980,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
       if (conservation == null)
       {
         conservation = new AlignmentAnnotation("Conservation",
-                "Conservation of total alignment less than "
-                        + getConsPercGaps() + "% gaps", new Annotation[1],
+                MessageManager.formatMessage("label.conservation_descr",
+                        getConsPercGaps()), new Annotation[1],
                 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
         conservation.hasText = true;
         conservation.autoCalculated = true;
@@ -1992,7 +1997,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
       if (quality == null)
       {
         quality = new AlignmentAnnotation("Quality",
-                "Alignment Quality based on Blosum62 scores",
+                MessageManager.getString("label.quality_descr"),
                 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
         quality.hasText = true;
         quality.autoCalculated = true;
@@ -2005,7 +2010,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
   {
     if (alignment.hasRNAStructure() && strucConsensus == null)
     {
-      strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
+      strucConsensus = new AlignmentAnnotation("StrucConsensus",
+              MessageManager.getString("label.strucconsensus_descr"),
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       strucConsensus.hasText = true;
       strucConsensus.autoCalculated = true;
diff --git a/test/jalview/ws/dbsources/RemoteFormatTest.java b/test/jalview/ws/dbsources/RemoteFormatTest.java
new file mode 100644 (file)
index 0000000..90d4472
--- /dev/null
@@ -0,0 +1,121 @@
+package jalview.ws.dbsources;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import jalview.analysis.AlignSeq;
+import jalview.bin.Cache;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.DBRefSource;
+import jalview.datamodel.SequenceI;
+import jalview.ext.ensembl.EnsemblGenomes;
+import jalview.fts.api.FTSData;
+import jalview.fts.api.FTSDataColumnI;
+import jalview.fts.api.FTSRestClientI;
+import jalview.fts.core.FTSRestRequest;
+import jalview.fts.core.FTSRestResponse;
+import jalview.fts.service.uniprot.UniProtFTSRestClient;
+import jalview.ws.SequenceFetcher;
+import jalview.ws.seqfetcher.DbSourceProxy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * A class to verify that remotely fetched data has an expected format and can
+ * be successfully processed by Jalview. This is intended as a first line of
+ * defence and early warning of service affecting changes to data fetched
+ * externally.
+ * <p>
+ * This is class is not intended to cover remote services e.g. alignment. Nor
+ * should it duplicate tests already provided by other classes (such as
+ * PDBFTSRestClientTest). Or maybe we will relocate those tests here...
+ */
+public class RemoteFormatTest
+{
+  SequenceFetcher sf;
+
+  @BeforeTest(alwaysRun = true)
+  public void setUp() throws Exception
+  {
+    Cache.loadProperties("test/jalview/io/testProps.jvprops");
+    // ensure 'add annotation from structure' is selected
+    Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
+            Boolean.TRUE.toString());
+    Cache.applicationProperties.setProperty("ADD_SS_ANN",
+            Boolean.TRUE.toString());
+
+    sf = new SequenceFetcher(false);
+  }
+
+  @DataProvider(name = "AccessionData")
+  protected Object[][] getAccessions()
+  {
+    return new Object[][] { { DBRefSource.UNIPROT, "P30419" },
+        { DBRefSource.PDB, "1QIP" }, { DBRefSource.EMBL, "X53828" },
+        { DBRefSource.EMBLCDS, "CAA37824" },
+        { DBRefSource.ENSEMBL, "ENSG00000157764" },
+        { new EnsemblGenomes().getDbSource(), "DDB_G0283883" },
+        { new PfamFull().getDbSource(), "PF03760" },
+        { new PfamSeed().getDbSource(), "PF03760" },
+        { new RfamSeed().getDbSource(), "RF00014" } };
+  }
+
+  @Test(groups = "Network", dataProvider = "AccessionData")
+  public void testFetchAccession(String dbSource, String accessionId)
+          throws Exception
+  {
+    System.out.println("Fetching " + accessionId + " from " + dbSource);
+    List<DbSourceProxy> sps = sf.getSourceProxy(dbSource);
+    assertFalse(sps.isEmpty());
+    AlignmentI al = sps.get(0).getSequenceRecords(accessionId);
+    assertNotNull(al);
+    assertTrue(al.getHeight() > 0);
+    SequenceI sq = al.getSequenceAt(0);
+    // suppress this check as only Uniprot and PDB acquire PDB refs
+    // assertTrue(sq.getAllPDBEntries().size() > 0, "No PDBEntry on sequence.");
+    assertTrue(sq.getDBRefs().length > 0, "No DBRef on sequence.");
+    // suppress this test as only certain databases provide 'primary' dbrefs
+    // assertFalse(sq.getPrimaryDBRefs().isEmpty());
+    int length = AlignSeq.extractGaps("-. ", sq.getSequenceAsString())
+            .length();
+    assertEquals(sq.getEnd() - sq.getStart() + 1, length,
+            "Sequence start/end doesn't match number of residues in sequence");
+  }
+
+  @Test(groups = { "Network" })
+  public void testUniprotFreeTextSearch() throws Exception
+  {
+    List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
+    FTSRestClientI client = UniProtFTSRestClient.getInstance();
+    wantedFields.add(client.getDataColumnByNameOrCode("id"));
+    wantedFields.add(client.getDataColumnByNameOrCode("entry name"));
+    wantedFields.add(client.getDataColumnByNameOrCode("organism"));
+    wantedFields.add(client.getDataColumnByNameOrCode("reviewed")); // Status
+    wantedFields.add(client.getDataColumnByNameOrCode("length"));
+  
+    FTSRestRequest request = new FTSRestRequest();
+    request.setAllowEmptySeq(false);
+    request.setResponseSize(100);
+    request.setFieldToSearchBy("Search All");
+    request.setSearchTerm("metanephrops"); // lobster!
+    request.setWantedFields(wantedFields);
+  
+    FTSRestResponse response;
+    response = client.executeRequest(request);
+    assertTrue(response.getNumberOfItemsFound() > 20);
+    assertTrue(response.getSearchSummary() != null);
+    assertTrue(response.getSearchSummary().size() > 20);
+    // verify we successfully filtered out the header row (JAL-2485)
+    FTSData header = response.getSearchSummary().iterator().next();
+    assertFalse(
+            header.getSummaryData()[0].toString().equalsIgnoreCase("Entry"),
+            "Failed to filter out summary header row");
+  }
+}