From: Jim Procter Date: Mon, 6 Sep 2021 13:47:03 +0000 (+0100) Subject: JAL-3829 mocking for PDBFTS for related query to UniprotFTS mock. X-Git-Tag: Release_2_11_2_0~39^2~18 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=bb3748fd2cc3ee8e8e0409599569e24e88974a17;p=jalview.git JAL-3829 mocking for PDBFTS for related query to UniprotFTS mock. --- diff --git a/src/jalview/fts/core/FTSRestClient.java b/src/jalview/fts/core/FTSRestClient.java index f651707..b262f64 100644 --- a/src/jalview/fts/core/FTSRestClient.java +++ b/src/jalview/fts/core/FTSRestClient.java @@ -31,6 +31,7 @@ import java.util.Objects; import jalview.fts.api.FTSDataColumnI; import jalview.fts.api.FTSDataColumnI.FTSDataColumnGroupI; import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource; +import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient; import jalview.fts.api.FTSRestClientI; /** @@ -57,6 +58,10 @@ public abstract class FTSRestClient implements FTSRestClientI private int defaultResponsePageSize = 100; + protected String mockQuery = null; + + protected String mockResponse = null; + protected FTSRestClient() { @@ -428,6 +433,12 @@ public abstract class FTSRestClient implements FTSRestClientI "Couldn't find data column with name : " + nameOrCode); } + public static void createMockFTSRestClient(FTSRestClient instance,String workingQuery, + String jsonResponse) + { + instance.setMock(workingQuery,jsonResponse); + } + @Override public FTSDataColumnGroupI getDataColumnGroupById(String id) throws Exception @@ -481,6 +492,12 @@ public abstract class FTSRestClient implements FTSRestClientI return String.valueOf(code) + " " + message; } + public static void unMock(FTSRestClient instance) + { + instance.mockQuery =null; + instance.mockResponse =null; + } + protected String getResourceFile(String fileName) { String result = ""; @@ -505,6 +522,17 @@ public abstract class FTSRestClient implements FTSRestClientI return defaultResponsePageSize; } + protected void setMock(String workingQuery, String jsonResponse) + { + mockQuery=workingQuery; + mockResponse = jsonResponse; + } + + protected boolean isMocked() + { + return mockQuery != null && mockResponse!=null; + } + @Override public String[] getPreferencesColumnsFor(PreferenceSource source) { diff --git a/src/jalview/fts/service/pdb/PDBFTSRestClient.java b/src/jalview/fts/service/pdb/PDBFTSRestClient.java index a315300..483bb2f 100644 --- a/src/jalview/fts/service/pdb/PDBFTSRestClient.java +++ b/src/jalview/fts/service/pdb/PDBFTSRestClient.java @@ -170,11 +170,8 @@ public class PDBFTSRestClient extends FTSRestClient implements StructureFTSRestC URI uri = webResource.getURI(); System.out.println(uri); - - // Execute the REST request - ClientResponse clientResponse = webResource - .accept(MediaType.APPLICATION_JSON).get(clientResponseClass ); - + ClientResponse clientResponse =null; + int responseStatus = -1; // Get the JSON string from the response object or directly from the // client (JavaScript) Map jsonObj = null; @@ -182,18 +179,46 @@ public class PDBFTSRestClient extends FTSRestClient implements StructureFTSRestC System.out.println("query >>>>>>> " + pdbRestRequest.toString()); + if (!isMocked()) + { + // Execute the REST request + clientResponse = webResource.accept(MediaType.APPLICATION_JSON) + .get(clientResponseClass); + responseStatus = clientResponse.getStatus(); + } + else + { + // mock response + if (uri.toString().equals(mockQuery)) + { + responseStatus = 200; + } + else + { + // FIXME - may cause unexpected exceptions for callers when mocked + responseStatus = 400; + } + } + // Check the response status and report exception if one occurs - int responseStatus = clientResponse.getStatus(); switch (responseStatus) { case 200: - if (Platform.isJS()) + + if (isMocked()) { - jsonObj = clientResponse.getEntity(Map.class); + responseString = mockResponse; } else { - responseString = clientResponse.getEntity(String.class); + if (Platform.isJS()) + { + jsonObj = clientResponse.getEntity(Map.class); + } + else + { + responseString = clientResponse.getEntity(String.class); + } } break; case 400: @@ -513,4 +538,340 @@ public static String parseJsonExceptionString(String jsonErrorResponse) } return columnNames; } + + public static void setMock() + { + String mockReq = "https://www.ebi.ac.uk/pdbe/search/pdb/select?wt=json&fl=pdb_id,title,experimental_method,resolution&rows=500&start=0&q=(4igk+OR+1t15+OR+4ifi+OR+1t29+OR+3pxb+OR+4y2g+OR+1y98+OR+1jnx+OR+3pxa+OR+3k0h+OR+3k0k+OR+1n5o+OR+3pxc+OR+3pxd+OR+1t2u+OR+3k15+OR+3pxe+OR+3k16+OR+4ofb+OR+3coj+OR+7lyb+OR+1t2v+OR+4y18+OR+4jlu+OR+4u4a+OR+2ing+OR+7jzv+OR+6g2i+OR+1jm7+OR+1oqa)+AND+molecule_sequence:%5B''+TO+*%5D+AND+status:REL&sort="; + String mockResp = "{\n" + + " \"responseHeader\":{\n" + + " \"status\":0,\n" + + " \"QTime\":0,\n" + + " \"params\":{\n" + + " \"q\":\"(4igk OR 1t15 OR 4ifi OR 1t29 OR 3pxb OR 4y2g OR 1y98 OR 1jnx OR 3pxa OR 3k0h OR 3k0k OR 1n5o OR 3pxc OR 3pxd OR 1t2u OR 3k15 OR 3pxe OR 3k16 OR 4ofb OR 3coj OR 7lyb OR 1t2v OR 4y18 OR 4jlu OR 4u4a OR 2ing OR 7jzv OR 6g2i OR 1jm7 OR 1oqa) AND molecule_sequence:['' TO *] AND status:REL\",\n" + + " \"fl\":\"pdb_id,title,experimental_method,resolution\",\n" + + " \"start\":\"0\",\n" + + " \"sort\":\"\",\n" + + " \"rows\":\"500\",\n" + + " \"wt\":\"json\"}},\n" + + " \"response\":{\"numFound\":64,\"start\":0,\"docs\":[\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4ofb\",\n" + + " \"resolution\":3.05,\n" + + " \"title\":\"Crystal structure of human BRCA1 BRCT in complex with nonphosphopeptide inhibitor\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3pxe\",\n" + + " \"resolution\":2.85,\n" + + " \"title\":\"Impact of BRCA1 BRCT domain missense substitutions on phospho-peptide recognition: E1836K\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4jlu\",\n" + + " \"resolution\":3.5,\n" + + " \"title\":\"Crystal structure of BRCA1 BRCT with doubly phosphorylated Abraxas\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4y2g\",\n" + + " \"resolution\":2.5,\n" + + " \"title\":\"Structure of BRCA1 BRCT domains in complex with Abraxas single phosphorylated peptide\"},\n" + + " {\n" + + " \"experimental_method\":[\"Solution NMR\"],\n" + + " \"pdb_id\":\"1oqa\",\n" + + " \"title\":\"Solution structure of the BRCT-c domain from human BRCA1\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4u4a\",\n" + + " \"resolution\":3.51,\n" + + " \"title\":\"Complex Structure of BRCA1 BRCT with singly phospho Abraxas\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"1t2v\",\n" + + " \"resolution\":3.3,\n" + + " \"title\":\"Structural basis of phospho-peptide recognition by the BRCT domain of BRCA1, structure with phosphopeptide\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3k15\",\n" + + " \"resolution\":2.8,\n" + + " \"title\":\"Crystal Structure of BRCA1 BRCT D1840T in complex with a minimal recognition tetrapeptide with an amidated C-terminus\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"1t15\",\n" + + " \"resolution\":1.85,\n" + + " \"title\":\"Crystal Structure of the Brca1 BRCT Domains in Complex with the Phosphorylated Interacting Region from Bach1 Helicase\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3k16\",\n" + + " \"resolution\":3.0,\n" + + " \"title\":\"Crystal Structure of BRCA1 BRCT D1840T in complex with a minimal recognition tetrapeptide with a free carboxy C-terminus\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"1t29\",\n" + + " \"resolution\":2.3,\n" + + " \"title\":\"Crystal structure of the BRCA1 BRCT repeats bound to a phosphorylated BACH1 peptide\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"1y98\",\n" + + " \"resolution\":2.5,\n" + + " \"title\":\"Structure of the BRCT repeats of BRCA1 bound to a CtIP phosphopeptide.\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4ifi\",\n" + + " \"resolution\":2.2,\n" + + " \"title\":\"Structure of human BRCA1 BRCT in complex with BAAT peptide\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3k0k\",\n" + + " \"resolution\":2.7,\n" + + " \"title\":\"Crystal Structure of BRCA1 BRCT in complex with a minimal recognition tetrapeptide with a free carboxy C-terminus.\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3k0h\",\n" + + " \"resolution\":2.7,\n" + + " \"title\":\"The crystal structure of BRCA1 BRCT in complex with a minimal recognition tetrapeptide with an amidated C-terminus\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3pxd\",\n" + + " \"resolution\":2.8,\n" + + " \"title\":\"Impact of BRCA1 BRCT domain missense substitutions on phospho-peptide recognition: R1835P\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3pxc\",\n" + + " \"resolution\":2.8,\n" + + " \"title\":\"Impact of BRCA1 BRCT domain missense substitutions on phospho-peptide recognition: R1699Q\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3pxa\",\n" + + " \"resolution\":2.55,\n" + + " \"title\":\"Impact of BRCA1 BRCT domain missense substitutions on phospho-peptide recognition: G1656D\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"1jnx\",\n" + + " \"resolution\":2.5,\n" + + " \"title\":\"Crystal structure of the BRCT repeat region from the breast cancer associated protein, BRCA1\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4igk\",\n" + + " \"resolution\":1.75,\n" + + " \"title\":\"Structure of human BRCA1 BRCT in complex with ATRIP peptide\"},\n" + + " {\n" + + " \"experimental_method\":[\"Solution NMR\"],\n" + + " \"pdb_id\":\"1jm7\",\n" + + " \"title\":\"Solution structure of the BRCA1/BARD1 RING-domain heterodimer\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4jlu\",\n" + + " \"resolution\":3.5,\n" + + " \"title\":\"Crystal structure of BRCA1 BRCT with doubly phosphorylated Abraxas\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"6g2i\",\n" + + " \"resolution\":5.9,\n" + + " \"title\":\"Filament of acetyl-CoA carboxylase and BRCT domains of BRCA1 (ACC-BRCT) at 5.9 A resolution\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3coj\",\n" + + " \"resolution\":3.21,\n" + + " \"title\":\"Crystal Structure of the BRCT Domains of Human BRCA1 in Complex with a Phosphorylated Peptide from Human Acetyl-CoA Carboxylase 1\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3pxb\",\n" + + " \"resolution\":2.5,\n" + + " \"title\":\"Impact of BRCA1 BRCT domain missense substitutions on phospho-peptide recognition: T1700A\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"1t2u\",\n" + + " \"resolution\":2.8,\n" + + " \"title\":\"Structural basis of phosphopeptide recognition by the BRCT domain of BRCA1: structure of BRCA1 missense variant V1809F\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"1n5o\",\n" + + " \"resolution\":2.8,\n" + + " \"title\":\"Structural consequences of a cancer-causing BRCA1-BRCT missense mutation\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4u4a\",\n" + + " \"resolution\":3.51,\n" + + " \"title\":\"Complex Structure of BRCA1 BRCT with singly phospho Abraxas\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4y2g\",\n" + + " \"resolution\":2.5,\n" + + " \"title\":\"Structure of BRCA1 BRCT domains in complex with Abraxas single phosphorylated peptide\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3pxe\",\n" + + " \"resolution\":2.85,\n" + + " \"title\":\"Impact of BRCA1 BRCT domain missense substitutions on phospho-peptide recognition: E1836K\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4ofb\",\n" + + " \"resolution\":3.05,\n" + + " \"title\":\"Crystal structure of human BRCA1 BRCT in complex with nonphosphopeptide inhibitor\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4y18\",\n" + + " \"resolution\":3.5,\n" + + " \"title\":\"Structure of BRCA1 BRCT domains in complex with Abraxas double phosphorylated peptide\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"2ing\",\n" + + " \"resolution\":3.6,\n" + + " \"title\":\"X-ray Structure of the BRCA1 BRCT mutant M1775K\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"1t29\",\n" + + " \"resolution\":2.3,\n" + + " \"title\":\"Crystal structure of the BRCA1 BRCT repeats bound to a phosphorylated BACH1 peptide\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"1t2v\",\n" + + " \"resolution\":3.3,\n" + + " \"title\":\"Structural basis of phospho-peptide recognition by the BRCT domain of BRCA1, structure with phosphopeptide\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"1t15\",\n" + + " \"resolution\":1.85,\n" + + " \"title\":\"Crystal Structure of the Brca1 BRCT Domains in Complex with the Phosphorylated Interacting Region from Bach1 Helicase\"},\n" + + " {\n" + + " \"experimental_method\":[\"Solution NMR\"],\n" + + " \"pdb_id\":\"1jm7\",\n" + + " \"title\":\"Solution structure of the BRCA1/BARD1 RING-domain heterodimer\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4ifi\",\n" + + " \"resolution\":2.2,\n" + + " \"title\":\"Structure of human BRCA1 BRCT in complex with BAAT peptide\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4igk\",\n" + + " \"resolution\":1.75,\n" + + " \"title\":\"Structure of human BRCA1 BRCT in complex with ATRIP peptide\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"1y98\",\n" + + " \"resolution\":2.5,\n" + + " \"title\":\"Structure of the BRCT repeats of BRCA1 bound to a CtIP phosphopeptide.\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3k15\",\n" + + " \"resolution\":2.8,\n" + + " \"title\":\"Crystal Structure of BRCA1 BRCT D1840T in complex with a minimal recognition tetrapeptide with an amidated C-terminus\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3k0k\",\n" + + " \"resolution\":2.7,\n" + + " \"title\":\"Crystal Structure of BRCA1 BRCT in complex with a minimal recognition tetrapeptide with a free carboxy C-terminus.\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3k16\",\n" + + " \"resolution\":3.0,\n" + + " \"title\":\"Crystal Structure of BRCA1 BRCT D1840T in complex with a minimal recognition tetrapeptide with a free carboxy C-terminus\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3k0h\",\n" + + " \"resolution\":2.7,\n" + + " \"title\":\"The crystal structure of BRCA1 BRCT in complex with a minimal recognition tetrapeptide with an amidated C-terminus\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"4y18\",\n" + + " \"resolution\":3.5,\n" + + " \"title\":\"Structure of BRCA1 BRCT domains in complex with Abraxas double phosphorylated peptide\"},\n" + + " {\n" + + " \"experimental_method\":[\"X-ray diffraction\"],\n" + + " \"pdb_id\":\"3coj\",\n" + + " \"resolution\":3.21,\n" + + " \"title\":\"Crystal Structure of the BRCT Domains of Human BRCA1 in Complex with a Phosphorylated Peptide from Human Acetyl-CoA Carboxylase 1\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7jzv\",\n" + + " \"resolution\":3.9,\n" + + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7jzv\",\n" + + " \"resolution\":3.9,\n" + + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7lyb\",\n" + + " \"resolution\":3.28,\n" + + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7lyb\",\n" + + " \"resolution\":3.28,\n" + + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7lyb\",\n" + + " \"resolution\":3.28,\n" + + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7jzv\",\n" + + " \"resolution\":3.9,\n" + + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7lyb\",\n" + + " \"resolution\":3.28,\n" + + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7jzv\",\n" + + " \"resolution\":3.9,\n" + + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7lyb\",\n" + + " \"resolution\":3.28,\n" + + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7jzv\",\n" + + " \"resolution\":3.9,\n" + + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7lyb\",\n" + + " \"resolution\":3.28,\n" + + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7lyb\",\n" + + " \"resolution\":3.28,\n" + + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7lyb\",\n" + + " \"resolution\":3.28,\n" + + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7jzv\",\n" + + " \"resolution\":3.9,\n" + + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"6g2i\",\n" + + " \"resolution\":5.9,\n" + + " \"title\":\"Filament of acetyl-CoA carboxylase and BRCT domains of BRCA1 (ACC-BRCT) at 5.9 A resolution\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7jzv\",\n" + + " \"resolution\":3.9,\n" + + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7lyb\",\n" + + " \"resolution\":3.28,\n" + + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n" + + " {\n" + + " \"experimental_method\":[\"Electron Microscopy\"],\n" + + " \"pdb_id\":\"7jzv\",\n" + + " \"resolution\":3.9,\n" + + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"}]\n" + + " }}"; + createMockFTSRestClient((FTSRestClient)getInstance(), mockReq, mockResp); + } } diff --git a/src/jalview/fts/service/threedbeacons/TDBeaconsFTSRestClient.java b/src/jalview/fts/service/threedbeacons/TDBeaconsFTSRestClient.java index 9ca42e5..73939c3 100644 --- a/src/jalview/fts/service/threedbeacons/TDBeaconsFTSRestClient.java +++ b/src/jalview/fts/service/threedbeacons/TDBeaconsFTSRestClient.java @@ -36,26 +36,11 @@ public class TDBeaconsFTSRestClient extends FTSRestClient { private static final String DEFAULT_THREEDBEACONS_DOMAIN = "https://wwwdev.ebi.ac.uk/pdbe/pdbe-kb/3dbeacons/api/uniprot/summary/"; - private static FTSRestClientI instance = null; + public static FTSRestClientI instance = null; protected TDBeaconsFTSRestClient() { } - public static void createMockTDBeaconsFSRestClient(String workingQuery, String jsonResponse) { - instance = new TDBeaconsFTSRestClient(); - ((TDBeaconsFTSRestClient) instance).setMock(workingQuery,jsonResponse); - } - private String mockQuery = null; - - private String mockResponse = null; - protected void setMock(String workingQuery,String jsonResponse) { - mockQuery=workingQuery; - mockResponse = jsonResponse; - } - private boolean isMocked() - { - return mockQuery != null && mockResponse!=null; - } @SuppressWarnings("unchecked") @Override public FTSRestResponse executeRequest(FTSRestRequest tdbRestRequest) diff --git a/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java b/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java index ea3756c..84d6b4c 100644 --- a/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java +++ b/test/jalview/fts/threedbeacons/TDBeaconsFTSRestClientTest.java @@ -274,7 +274,7 @@ public class TDBeaconsFTSRestClientTest private static String mockResponse = "{\"uniprot_entry\":{\"sequence_length\":1863,\"ac\":\"P38398\",\"id\":\"BRCA1_HUMAN\"},\"structures\":[{\"model_identifier\":\"4igk\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2012-12-17\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":1.75,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/4igk_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"1t15\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2004-04-15\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":1.85,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/1t15_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"4ifi\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2012-12-14\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.2,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/4ifi_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"1t29\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2004-04-20\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.3,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/1t29_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"3pxb\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2010-12-09\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.5,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/3pxb_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"4y2g\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2015-02-09\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.5,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/4y2g_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"1y98\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2004-12-14\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.5,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/1y98_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"1jnx\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2001-07-26\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.5,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/1jnx_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"3pxa\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2010-12-09\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.55,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/3pxa_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"3k0h\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2009-09-24\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.7,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/3k0h_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"3k0k\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2009-09-24\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.7,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/3k0k_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"1n5o\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2002-11-06\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.8,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/1n5o_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"3pxc\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2010-12-09\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.8,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/3pxc_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"3pxd\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2010-12-09\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.8,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/3pxd_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"1t2u\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2004-04-22\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.8,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/1t2u_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"3k15\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2009-09-25\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.8,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/3k15_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"3pxe\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2010-12-09\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":2.85,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/3pxe_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"3k16\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2009-09-25\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":3.0,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/3k16_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"4ofb\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2014-01-14\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":3.05,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/4ofb_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"3coj\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2008-03-28\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":3.21,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/3coj_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"7lyb\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2021-03-06\",\"sequence_identity\":100.0,\"uniprot_start\":1,\"uniprot_end\":100,\"resolution\":3.28,\"coverage\":5.37,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/7lyb_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"1t2v\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2004-04-22\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":3.3,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/1t2v_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"4y18\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2015-02-06\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":3.5,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/4y18_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"4jlu\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2013-03-13\",\"sequence_identity\":100.0,\"uniprot_start\":1649,\"uniprot_end\":1859,\"resolution\":3.5,\"coverage\":11.33,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/4jlu_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"4u4a\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2014-07-23\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":3.51,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/4u4a_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"2ing\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2006-10-07\",\"sequence_identity\":100.0,\"uniprot_start\":1649,\"uniprot_end\":1859,\"resolution\":3.6,\"coverage\":11.33,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/2ing_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"7jzv\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2020-09-02\",\"sequence_identity\":99.0,\"uniprot_start\":2,\"uniprot_end\":104,\"resolution\":3.9,\"coverage\":5.53,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/7jzv_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"6g2i\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2018-03-23\",\"sequence_identity\":100.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"resolution\":5.9,\"coverage\":11.49,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/6g2i_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"1jm7\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2001-07-17\",\"sequence_identity\":100.0,\"uniprot_start\":1,\"uniprot_end\":110,\"resolution\":null,\"coverage\":5.9,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/1jm7_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"1oqa\",\"model_category\":\"EXPERIMENTALLY DETERMINED\",\"provider\":\"PDBE\",\"created\":\"2003-03-07\",\"sequence_identity\":100.0,\"uniprot_start\":1755,\"uniprot_end\":1863,\"resolution\":null,\"coverage\":5.85,\"model_url\":\"https://www.ebi.ac.uk/pdbe/static/entry/1oqa_updated.cif\",\"model_format\":\"MMCIF\"},{\"model_identifier\":\"612f67c86ba77a10ab6f34ec\",\"model_category\":\"TEMPLATE-BASED\",\"provider\":\"SWISSMODEL\",\"created\":\"2021-09-01\",\"sequence_identity\":1.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"coverage\":0.115,\"qmean_version\":\"4.2.0\",\"qmean_avg_local_score\":0.776,\"model_url\":\"https://beta.swissmodel.expasy.org/3d-beacons/uniprot/P38398.pdb?range=1646-1859&template=6g2i.1.K&provider=swissmodel\",\"model_format\":\"PDB\"},{\"model_identifier\":\"612f67c86ba77a10ab6f34f0\",\"model_category\":\"TEMPLATE-BASED\",\"provider\":\"SWISSMODEL\",\"created\":\"2021-09-01\",\"sequence_identity\":1.0,\"uniprot_start\":1,\"uniprot_end\":103,\"coverage\":0.055,\"qmean_version\":\"4.2.0\",\"qmean_avg_local_score\":0.655,\"model_url\":\"https://beta.swissmodel.expasy.org/3d-beacons/uniprot/P38398.pdb?range=1-103&template=1jm7.1.A&provider=swissmodel\",\"model_format\":\"PDB\"},{\"model_identifier\":\"AF-P38398-F1\",\"model_category\":\"Deep learning\",\"provider\":\"AlphaFold DB\",\"created\":\"2021-07-01\",\"sequence_identity\":1.0,\"uniprot_start\":1,\"uniprot_end\":1863,\"coverage\":100.0,\"model_url\":\"https://alphafold.ebi.ac.uk/files/AF-P38398-F1-model_v1.cif\",\"model_format\":\"MMCIF\"}]}"; public static void setMock() { - TDBeaconsFTSRestClient.createMockTDBeaconsFSRestClient("P38398.json", mockResponse); + FTSRestClient.createMockFTSRestClient((FTSRestClient)TDBeaconsFTSRestClient.getInstance(),"P38398.json", mockResponse); } @Test(groups= {"Functional"}) public void testMockTDBRequest()