JAL-2246 test a Uniprot fetch
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 3 May 2017 10:52:24 +0000 (11:52 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 3 May 2017 10:52:24 +0000 (11:52 +0100)
test/jalview/ws/dbsources/RemoteFormatTest.java

index a9cad80..c390efc 100644 (file)
@@ -1,18 +1,28 @@
 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;
 
 /**
@@ -27,10 +37,24 @@ import org.testng.annotations.Test;
  */
 public class RemoteFormatTest
 {
+  SequenceFetcher sf;
+
   @Test(groups = "Network")
-  public void testFetchUniprot()
+  public void testFetchUniprot() throws Exception
   {
-    // P00340
+    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")
@@ -109,4 +133,17 @@ public class RemoteFormatTest
     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);
+  }
 }