Merge branch 'develop' into features/JAL-2446NCList
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 3 May 2017 13:55:32 +0000 (14:55 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 3 May 2017 13:55:32 +0000 (14:55 +0100)
14 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/datamodel/AlignmentView.java
src/jalview/ext/ensembl/EnsemblRestClient.java
src/jalview/gui/AnnotationColumnChooser.java
src/jalview/gui/AnnotationRowFilter.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/ws/sifts/SiftsClient.java
test/jalview/datamodel/AlignmentViewTest.java
test/jalview/ws/dbsources/RemoteFormatTest.java [new file with mode: 0644]
test/jalview/ws/sifts/SiftsClientTest.java

index 915ef6f..922f482 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
@@ -1300,3 +1299,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 bdd61fe..e6e1872 100644 (file)
@@ -178,6 +178,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
@@ -834,6 +835,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 bbd01f6..77bb6bb 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 9db9f38..1e34036 100644 (file)
@@ -970,14 +970,14 @@ public class AlignmentView
       if (start < fwidth)
       {
         viscontigs[nvis] = start;
-        viscontigs[nvis + 1] = fwidth; // end is inclusive
+        viscontigs[nvis + 1] = fwidth - 1; // end is inclusive
         nvis += 2;
       }
       return viscontigs;
     }
     else
     {
-      return new int[] { 0, width };
+      return new int[] { 0, width - 1 };
     }
   }
 
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 c321e59..d5bc7d1 100644 (file)
@@ -110,20 +110,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
@@ -315,16 +318,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 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;
index c69581f..fe3a25b 100644 (file)
@@ -575,18 +575,8 @@ public class SiftsClient implements SiftsClientI
                   .equalsIgnoreCase(seqCoordSys.getName())
                   && isAccessionMatched(cRefDb.getDbAccessionId()))
           {
-            String resNumIndexString = cRefDb.getDbResNum()
-                    .equalsIgnoreCase("None") ? String.valueOf(UNASSIGNED)
-                    : cRefDb.getDbResNum();
-            try
-            {
-              currSeqIndex = Integer.valueOf(resNumIndexString);
-            } catch (NumberFormatException nfe)
-            {
-              currSeqIndex = Integer.valueOf(resNumIndexString
-                      .split("[a-zA-Z]")[0]);
-              continue;
-            }
+            currSeqIndex = getLeadingIntegerValue(
+                    cRefDb.getDbResNum(), UNASSIGNED);
             if (pdbRefDb != null)
             {
               break;// exit loop if pdb and uniprot are already found
@@ -599,23 +589,11 @@ public class SiftsClient implements SiftsClientI
         }
         if (currSeqIndex >= seq.getStart() && currSeqIndex <= seq.getEnd())
         {
-          int resNum;
-          try
-          {
-            resNum = (pdbRefDb == null) ? Integer.valueOf(residue
-                    .getDbResNum()) : Integer.valueOf(pdbRefDb
-                    .getDbResNum());
-          } catch (NumberFormatException nfe)
-          {
-            if (pdbRefDb == null || pdbRefDb.getDbResNum().equals("null"))
-            {
-              resNum = UNASSIGNED;
-              continue;
-            }
-            resNum = Integer.valueOf(pdbRefDb
-                    .getDbResNum().split("[a-zA-Z]")[0]);
-            continue;
-          }
+
+          int resNum = (pdbRefDb == null) ? getLeadingIntegerValue(
+                  residue.getDbResNum(), UNASSIGNED)
+                  : getLeadingIntegerValue(pdbRefDb.getDbResNum(),
+                          UNASSIGNED);
 
           if (isResidueObserved(residue)
                   || seqCoordSys == CoordinateSys.UNIPROT)
@@ -638,6 +616,30 @@ public class SiftsClient implements SiftsClientI
   }
 
   /**
+   * Get the leading integer part of a string that begins with an integer.
+   * 
+   * @param input
+   *          - the string input to process
+   * @param failValue
+   *          - value returned if unsuccessful
+   * @return
+   */
+  static int getLeadingIntegerValue(String input, int failValue)
+  {
+    if (input == null)
+    {
+      return failValue;
+    }
+    String[] parts = input.split("(?=\\D)(?<=\\d)");
+    if (parts != null && parts.length > 0 && parts[0].matches("[0-9]+"))
+    {
+      return Integer.valueOf(parts[0]);
+    }
+    return failValue;
+  }
+
+
+  /**
    * 
    * @param chainId
    *          Target chain to populate mapping of its atom positions.
index 594d6e6..b201c7e 100644 (file)
@@ -22,7 +22,11 @@ package jalview.datamodel;
 
 import static org.testng.Assert.assertEquals;
 
+import jalview.gui.AlignFrame;
+import jalview.gui.AlignViewport;
 import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
+import jalview.io.FileLoader;
 
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -50,4 +54,69 @@ public class AlignmentViewTest
     assertEquals(av.getVisibleAlignment('$').getSequenceAt(0)
             .getSequenceAsString(), "A$$CDE");
   }
+
+  @Test(groups = { "Functional" })
+  public void testGetVisibleContigs()
+  {
+    AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+            ">s1\n0123456789\n", DataSourceType.PASTE);
+    AlignViewport av = af.getViewport();
+    AlignmentView view = av.getAlignmentView(true);
+
+    /*
+     * verify getVisibleContigs returns inclusive [start, end] ranges
+     * 
+     * no columns hidden
+     */
+    int[] contigs = view.getVisibleContigs();
+    assertEquals(contigs, new int[] { 0, 9 });
+
+    /*
+     * hide 3 internal columns
+     */
+    av.hideColumns(5, 7);
+    // the old AlignmentView is now stale!
+    contigs = view.getVisibleContigs();
+    assertEquals(contigs, new int[] { 0, 9 });
+    // get a fresh AlignmentView
+    view = av.getAlignmentView(true);
+    contigs = view.getVisibleContigs();
+    assertEquals(contigs, new int[] { 0, 4, 8, 9 });
+
+    // hide first 2 columns
+    av.hideColumns(0, 1);
+    view = av.getAlignmentView(true);
+    contigs = view.getVisibleContigs();
+    assertEquals(contigs, new int[] { 2, 4, 8, 9 });
+
+    // hide last column
+    av.hideColumns(9, 9);
+    view = av.getAlignmentView(true);
+    contigs = view.getVisibleContigs();
+    assertEquals(contigs, new int[] { 2, 4, 8, 8 });
+
+    // unhide columns 5-7
+    av.showColumn(5);
+    view = av.getAlignmentView(true);
+    contigs = view.getVisibleContigs();
+    assertEquals(contigs, new int[] { 2, 8 });
+
+    // hide columns 2-7
+    av.hideColumns(2, 7);
+    view = av.getAlignmentView(true);
+    contigs = view.getVisibleContigs();
+    assertEquals(contigs, new int[] { 8, 8 });
+
+    // hide column 8
+    av.hideColumns(8, 8);
+    view = av.getAlignmentView(true);
+    contigs = view.getVisibleContigs();
+    assertEquals(contigs, new int[] {});
+
+    // unhide all
+    av.showAllHiddenColumns();
+    view = av.getAlignmentView(true);
+    contigs = view.getVisibleContigs();
+    assertEquals(contigs, new int[] { 0, 9 });
+  }
 }
diff --git a/test/jalview/ws/dbsources/RemoteFormatTest.java b/test/jalview/ws/dbsources/RemoteFormatTest.java
new file mode 100644 (file)
index 0000000..c390efc
--- /dev/null
@@ -0,0 +1,149 @@
+package jalview.ws.dbsources;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
+
+import jalview.bin.Cache;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.DBRefSource;
+import jalview.datamodel.SequenceI;
+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.BeforeMethod;
+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;
+
+  @Test(groups = "Network")
+  public void testFetchUniprot() throws Exception
+  {
+    List<DbSourceProxy> sps = sf.getSourceProxy(DBRefSource.UNIPROT);
+    assertFalse(sps.isEmpty());
+    AlignmentI response = sps.get(0).getSequenceRecords("P30419");
+    assertNotNull(response);
+    assertEquals(response.getHeight(), 1);
+    SequenceI sq = response.getSequenceAt(0);
+    assertTrue("No PDBEntry on sequence.", sq.getAllPDBEntries().size() > 0);
+    assertTrue("No DBRef on sequence.", sq.getDBRefs().length > 0);
+    List<DBRefEntry> dbr = sq.getPrimaryDBRefs();
+    assertFalse(dbr.isEmpty());
+    assertEquals(
+            "Sequence start/end doesn't match number of residues in sequence",
+            sq.getEnd() - sq.getStart() + 1, sq.getLength());
+  }
+
+  @Test(groups = "Network")
+  public void testFetchPdb()
+  {
+    // 1QIP
+  }
+
+  @Test(groups = "Network")
+  public void testFetchEmbl()
+  {
+    // X53828
+  }
+
+  @Test(groups = "Network")
+  public void testFetchEmblCDS()
+  {
+    // CAA37824
+  }
+
+  @Test(groups = "Network")
+  public void testFetchEnsembl()
+  {
+    // ENSG00000157764
+  }
+
+  @Test(groups = "Network")
+  public void testFetchEnsemblGenomes()
+  {
+    // DDB_G0283883
+  }
+
+  @Test(groups = "Network")
+  public void testFetchPfamSeed()
+  {
+    // PF03760
+  }
+
+  @Test(groups = "Network")
+  public void testFetchPfamFull()
+  {
+    // PF03760
+  }
+
+  @Test(groups = "Network")
+  public void testFetchRfamSeed()
+  {
+    // RF00014
+  }
+
+  @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("Failed to filter out summary header row",
+            header.getSummaryData()[0].toString().equalsIgnoreCase("Entry"));
+  }
+
+  @BeforeMethod(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);
+  }
+}
index 7f8adc9..b92766e 100644 (file)
@@ -514,4 +514,22 @@ groups = { "Network" },
     Assert.assertNull(entityP);
 
   }
+
+  @Test(groups = { "Network" })
+  public void getLeadingIntegerFromString()
+  {
+    Assert.assertEquals(
+            SiftsClient.getLeadingIntegerValue("1234abcd", -1), 1234);
+    Assert.assertEquals(
+            SiftsClient.getLeadingIntegerValue("1234", -1),
+            1234);
+    Assert.assertEquals(
+            SiftsClient.getLeadingIntegerValue("abcd", -1), -1);
+    Assert.assertEquals(
+            SiftsClient.getLeadingIntegerValue("abcd1234", -1), -1);
+    Assert.assertEquals(
+            SiftsClient.getLeadingIntegerValue("None", -1), -1);
+    Assert.assertEquals(
+            SiftsClient.getLeadingIntegerValue("Null", -1), -1);
+  }
 }