Request now parses the whole structures, need to fix the result
authorArnaldo <arnaud.gucciardi@gmail.com>
Mon, 29 Mar 2021 08:51:09 +0000 (10:51 +0200)
committerArnaldo <arnaud.gucciardi@gmail.com>
Mon, 29 Mar 2021 08:51:09 +0000 (10:51 +0200)
src/jalview/fts/service/threedbeacons/TDBeaconsFTSPanel.java
src/jalview/fts/service/threedbeacons/TDBeaconsFTSRestClient.java
test/jalview/fts/service/pdb/PDBFTSPanelTest.java
test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java

index 0d79d9b..c368e7b 100644 (file)
@@ -45,11 +45,11 @@ public class TDBeaconsFTSPanel extends GFTSPanel
             : fetcher.getProgressIndicator();
   }
   
-  public int TDBeaconsFTSPanel2(String result)
-  {
-    int seqlength = executeParse(result);
-    return seqlength;
-  }
+//  public int TDBeaconsFTSPanel2(String result)
+//  {
+//    int seqlength = executeParse(result);
+//    return seqlength;
+//  }
   
   public static int executeParse(String query) {
     BufferedReader reader;
@@ -102,7 +102,7 @@ public class TDBeaconsFTSPanel extends GFTSPanel
     JSONArray structures = entry.getJSONArray("structures");
     for (int i=0 ; i < structures.length() ; i++) {
             String id = structures.getJSONObject(i).getString("model_identifier");
-            System.out.println("identifier num " + i + " : " + id);
+            //System.out.println("identifier num " + i + " : " + id);
     }
     System.out.println("length : " + length + "; access name : " + ac);
     return length;
index b6be709..884dced 100644 (file)
@@ -47,14 +47,6 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
   {
     try
     {
-      // Removed wantedFields, sortParam & facetPivot from PDBFTSRClient
-      String wantedFields = getDataColumnsFieldsAsCommaDelimitedString(
-              tdbRestRequest.getWantedFields());
-      int responseSize = (tdbRestRequest.getResponseSize() == 0)
-              ? getDefaultResponsePageSize()
-              : tdbRestRequest.getResponseSize();
-      //int offSet = pdbRestRequest.getOffSet();
-      
       String query = tdbRestRequest.getFieldToSearchBy()
               + tdbRestRequest.getSearchTerm();
       Client client;
@@ -75,12 +67,9 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
         clientResponseClass = ClientResponse.class;
       }
       WebResource webResource;
-      webResource = client.resource(DEFAULT_THREEDBEACONS_DOMAIN).path(query);
+      webResource = client.resource(DEFAULT_THREEDBEACONS_DOMAIN)
+              .path(query);
       URI uri = webResource.getURI();
-//              .queryParam("P", query);
-//              .queryParam("rows", String.valueOf(responseSize))
-//              .queryParam("P",query);
-//      URI uri = webResource.getURI();
       System.out.println(uri.toString());
         
       // Execute the REST request
@@ -92,13 +81,11 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
       Map<String, Object> jsonObj = null;
       String responseString = null;
   
-      //System.out.println("query >>>>>>> " + tdbRestRequest.toString());
-        
       // Check the response status and report exception if one occurs
       int responseStatus = clientResponse.getStatus();
       switch (responseStatus)
       {
-      // if succesful
+      // if success
       case 200:
         if (Platform.isJS())
         {
@@ -165,13 +152,18 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
       {
         jsonObj = (Map<String, Object>) JSONUtils.parse(tdbJsonResponseString);
       }
+      System.out.println(jsonObj);
       //Map<String, Object> tdbResponse = (Map<String, Object>) jsonObj.get("structures");
-      //String seqLength = tdbEntry.get("sequence_length").toString();
-      //int seqLength = Integer.valueOf(tdbEntry.get("sequence_length").toString());
       
+      //System.out.println((Map<String, Object>) jsonObj.get("uniprot_entry")); 
       Long seqLength = (Long) ((Map<String, Object>) jsonObj.get("uniprot_entry")).get("sequence_length");
+      System.out.println(seqLength);
       result = new ArrayList<>();
       List<Object> structures = (List<Object>) jsonObj.get("structures");
+      //System.out.println(jsonObj.get("structures"));
+      //System.out.println(structures);
+      System.out.println("ZERO : " + structures.get(0));
+      System.out.println("1 : " + structures.get(1));
       int numFound = 0;
       for (Iterator<Object> strucIter = structures.iterator(); strucIter
               .hasNext();)
@@ -179,10 +171,13 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
         Map<String, Object> structure = (Map<String, Object>) strucIter.next();
         result.add(getFTSData(structure, tdbRestRequest));
         numFound++;
+        //System.out.println(structure);
       }
-        searchResult.setNumberOfItemsFound(numFound); 
-        searchResult.setSearchSummary(result);
-        searchResult.setSequenceLength(seqLength);
+      //System.out.println(structures);
+      System.out.println("1 : " + structures.get(1));
+      searchResult.setNumberOfItemsFound(numFound); 
+      searchResult.setSearchSummary(result);
+      searchResult.setSequenceLength(seqLength);
         
     } catch (ParseException e)
     {
index 187a30e..0b4dd92 100644 (file)
@@ -124,5 +124,13 @@ public class PDBFTSPanelTest
     assertTrue(!mainFrame.getTitle().equalsIgnoreCase(
             "PDB Sequence Fetcher"));
   }
+  
+  @Test
+  public void getFTSframeTitleTest() {
+    PDBFTSPanel searchPanel = new PDBFTSPanel(null);
+    String outcome = searchPanel.getFTSFrameTitle();
+    //System.out.println("FTS Frame title :" + outcome);
+    assertEquals(outcome, "PDB Sequence Fetcher");
+  }
 
 }
index fe1f3bc..f65fa84 100644 (file)
@@ -263,7 +263,6 @@ public class TDBeaconsFTSRestClientTest
 //              .getPrimaryKeyColumIndex(wantedFields, false));
     } catch (Exception e)
     {
-      // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
@@ -307,6 +306,7 @@ public class TDBeaconsFTSRestClientTest
     }
     assertTrue(response.getSearchSummary() != null);
     assertTrue(response.getNumberOfItemsFound() > 99);
+    System.out.println(response.getSearchSummary());
     System.out.println(response.getSearchSummary().size());
   }
 }