Clover icon

Coverage Report

  1. Project Clover database Fri Jun 19 2026 11:35:32 BST
  2. Package jalview.fts.service.pdb

File PDBFTSRestClientTest.java

 

Code metrics

12
150
12
1
847
765
29
0.19
12.5
12
2.42

Classes

Class Line # Actions
PDBFTSRestClientTest 58 150 29
0.4425287244.3%
 

Contributing tests

This file is covered by 13 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.fts.service.pdb;
22   
23    import static org.testng.Assert.fail;
24    import static org.testng.AssertJUnit.assertEquals;
25    import static org.testng.AssertJUnit.assertTrue;
26   
27    import java.io.BufferedReader;
28    import java.io.FileReader;
29    import java.io.IOException;
30    import java.util.ArrayList;
31    import java.util.Iterator;
32    import java.util.List;
33   
34    import javax.ws.rs.core.MediaType;
35   
36    import org.json.simple.JSONArray;
37    import org.json.simple.JSONObject;
38    import org.json.simple.parser.JSONParser;
39    import org.json.simple.parser.ParseException;
40    import org.testng.Assert;
41    import org.testng.annotations.AfterMethod;
42    import org.testng.annotations.BeforeClass;
43    import org.testng.annotations.BeforeMethod;
44    import org.testng.annotations.Test;
45   
46    import com.sun.jersey.api.client.Client;
47    import com.sun.jersey.api.client.ClientResponse;
48    import com.sun.jersey.api.client.WebResource;
49    import com.sun.jersey.api.client.config.ClientConfig;
50    import com.sun.jersey.api.client.config.DefaultClientConfig;
51   
52    import jalview.fts.api.FTSDataColumnI;
53    import jalview.fts.core.FTSRestClient;
54    import jalview.fts.core.FTSRestRequest;
55    import jalview.fts.core.FTSRestResponse;
56    import jalview.gui.JvOptionPane;
57   
 
58    public class PDBFTSRestClientTest
59    {
60   
 
61  1 toggle @BeforeClass(alwaysRun = true)
62    public void setUpJvOptionPane()
63    {
64  1 JvOptionPane.setInteractiveMode(false);
65  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
66    }
67   
 
68  3 toggle @BeforeMethod(alwaysRun = true)
69    public void setUp() throws Exception
70    {
71    }
72   
 
73  3 toggle @AfterMethod(alwaysRun = true)
74    public void tearDown() throws Exception
75    {
76    }
77   
 
78  0 toggle @Test(groups = { "External", "Network" })
79    public void executeRequestTest()
80    {
81  0 List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
82  0 try
83    {
84  0 wantedFields.add(PDBFTSRestClient.getInstance()
85    .getDataColumnByNameOrCode("molecule_type"));
86  0 wantedFields.add(PDBFTSRestClient.getInstance()
87    .getDataColumnByNameOrCode("pdb_id"));
88  0 wantedFields.add(PDBFTSRestClient.getInstance()
89    .getDataColumnByNameOrCode("genus"));
90  0 wantedFields.add(PDBFTSRestClient.getInstance()
91    .getDataColumnByNameOrCode("gene_name"));
92  0 wantedFields.add(PDBFTSRestClient.getInstance()
93    .getDataColumnByNameOrCode("title"));
94    } catch (Exception e1)
95    {
96  0 e1.printStackTrace();
97    }
98  0 System.out.println("wantedFields >>" + wantedFields);
99   
100  0 FTSRestRequest request = new FTSRestRequest();
101  0 request.setAllowEmptySeq(false);
102  0 request.setResponseSize(100);
103  0 request.setFieldToSearchBy("text:");
104  0 request.setSearchTerm("abc");
105  0 request.setWantedFields(wantedFields);
106   
107  0 FTSRestResponse response;
108  0 try
109    {
110  0 response = PDBFTSRestClient.getInstance().executeRequest(request);
111    } catch (Exception e)
112    {
113  0 e.printStackTrace();
114  0 Assert.fail("Couldn't execute webservice call!");
115  0 return;
116    }
117  0 assertTrue(response.getNumberOfItemsFound() > 99);
118  0 assertTrue(response.getSearchSummary() != null);
119  0 assertTrue(response.getSearchSummary().size() > 99);
120    }
121   
 
122  1 toggle @Test(groups = { "Functional" })
123    public void getPDBDocFieldsAsCommaDelimitedStringTest()
124    {
125  1 List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
126  1 try
127    {
128  1 wantedFields.add(PDBFTSRestClient.getInstance()
129    .getDataColumnByNameOrCode("molecule_type"));
130  1 wantedFields.add(PDBFTSRestClient.getInstance()
131    .getDataColumnByNameOrCode("pdb_id"));
132  1 wantedFields.add(PDBFTSRestClient.getInstance()
133    .getDataColumnByNameOrCode("genus"));
134  1 wantedFields.add(PDBFTSRestClient.getInstance()
135    .getDataColumnByNameOrCode("gene_name"));
136  1 wantedFields.add(PDBFTSRestClient.getInstance()
137    .getDataColumnByNameOrCode("title"));
138    } catch (Exception e)
139    {
140  0 e.printStackTrace();
141    }
142   
143  1 String expectedResult = "molecule_type,pdb_id,genus,gene_name,title";
144  1 String actualResult = PDBFTSRestClient.getInstance()
145    .getDataColumnsFieldsAsCommaDelimitedString(wantedFields);
146   
147  1 assertEquals("", expectedResult, actualResult);
148    }
149   
 
150  1 toggle @Test(groups = { "Functional" })
151    public void parsePDBJsonExceptionStringTest()
152    {
153  1 List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
154  1 try
155    {
156  1 wantedFields.add(PDBFTSRestClient.getInstance()
157    .getDataColumnByNameOrCode("molecule_type"));
158  1 wantedFields.add(PDBFTSRestClient.getInstance()
159    .getDataColumnByNameOrCode("pdb_id"));
160  1 wantedFields.add(PDBFTSRestClient.getInstance()
161    .getDataColumnByNameOrCode("genus"));
162  1 wantedFields.add(PDBFTSRestClient.getInstance()
163    .getDataColumnByNameOrCode("gene_name"));
164  1 wantedFields.add(PDBFTSRestClient.getInstance()
165    .getDataColumnByNameOrCode("title"));
166    } catch (Exception e1)
167    {
168  0 e1.printStackTrace();
169    }
170   
171  1 FTSRestRequest request = new FTSRestRequest();
172  1 request.setAllowEmptySeq(false);
173  1 request.setResponseSize(100);
174  1 request.setFieldToSearchBy("text:");
175  1 request.setSearchTerm("abc");
176  1 request.setWantedFields(wantedFields);
177   
178  1 String jsonErrorResponse = "";
179  1 try
180    {
181  1 jsonErrorResponse = readJsonStringFromFile(
182    "test/jalview/io/pdb_request_json_error.txt");
183    } catch (IOException e)
184    {
185  0 e.printStackTrace();
186    }
187   
188  1 String parsedErrorResponse = PDBFTSRestClient
189    .parseJsonExceptionString(jsonErrorResponse);
190   
191  1 String expectedErrorMsg = "\n============= PDB Rest Client RunTime error =============\n"
192    + "Status: 400\n"
193    + "Message: org.apache.solr.search.SyntaxError: Cannot parse 'text:abc OR text:go:abc AND molecule_sequence_length:[1 TO *]': Encountered \" \":\" \": \"\" at line 1, column 19.\n"
194    + "query: text:abc OR text:go:abc AND molecule_sequence_length:[1 TO *]\n"
195    + "fl: pdb_id\n";
196   
197  1 assertEquals(expectedErrorMsg, parsedErrorResponse);
198    }
199   
 
200  0 toggle @Test(
201    groups =
202    { "External" },
203    enabled = false,
204    expectedExceptions = Exception.class)
205    public void testForExpectedRuntimeException() throws Exception
206    {
207    // FIXME JBPNote: looks like this test fails for no good reason - what
208    // exception was supposed to be raised ?
209  0 List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
210  0 wantedFields.add(PDBFTSRestClient.getInstance()
211    .getDataColumnByNameOrCode("pdb_id"));
212   
213  0 FTSRestRequest request = new FTSRestRequest();
214  0 request.setFieldToSearchBy("text:");
215  0 request.setSearchTerm("abc OR text:go:abc");
216  0 request.setWantedFields(wantedFields);
217  0 PDBFTSRestClient.getInstance().executeRequest(request);
218  0 fail("Expected an exception for incorrect search term syntax");
219    }
220   
221    // JBP: Is this actually external ? Looks like it is mocked
222    // JBP looks like the mock is not up to date for this test
 
223  0 toggle @Test(groups = { "External" })
224    public void parsePDBJsonResponseTest()
225    {
226  0 List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
227  0 try
228    {
229  0 wantedFields.add(PDBFTSRestClient.getInstance()
230    .getDataColumnByNameOrCode("molecule_type"));
231  0 wantedFields.add(PDBFTSRestClient.getInstance()
232    .getDataColumnByNameOrCode("pdb_id"));
233  0 wantedFields.add(PDBFTSRestClient.getInstance()
234    .getDataColumnByNameOrCode("genus"));
235  0 wantedFields.add(PDBFTSRestClient.getInstance()
236    .getDataColumnByNameOrCode("gene_name"));
237  0 wantedFields.add(PDBFTSRestClient.getInstance()
238    .getDataColumnByNameOrCode("title"));
239    } catch (Exception e1)
240    {
241  0 e1.printStackTrace();
242    }
243   
244  0 FTSRestRequest request = new FTSRestRequest();
245  0 request.setAllowEmptySeq(false);
246  0 request.setWantedFields(wantedFields);
247   
248  0 String jsonString = "";
249  0 try
250    {
251  0 jsonString = readJsonStringFromFile(
252    "test/jalview/io/pdb_response_json.txt");
253    } catch (IOException e)
254    {
255  0 e.printStackTrace();
256    }
257  0 FTSRestResponse response = PDBFTSRestClient
258    .parsePDBJsonResponse(jsonString, request);
259  0 assertTrue(response.getSearchSummary() != null);
260  0 assertTrue(response.getNumberOfItemsFound() == 931);
261  0 assertTrue(response.getSearchSummary().size() == 14);
262  0 System.out.println("Search summary : " + response.getSearchSummary());
263    }
264   
 
265  1 toggle @Test(groups = { "Functional" })
266    public void getPDBIdColumIndexTest()
267    {
268  1 List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
269  1 try
270    {
271  1 wantedFields.add(PDBFTSRestClient.getInstance()
272    .getDataColumnByNameOrCode("molecule_type"));
273  1 wantedFields.add(PDBFTSRestClient.getInstance()
274    .getDataColumnByNameOrCode("genus"));
275  1 wantedFields.add(PDBFTSRestClient.getInstance()
276    .getDataColumnByNameOrCode("gene_name"));
277  1 wantedFields.add(PDBFTSRestClient.getInstance()
278    .getDataColumnByNameOrCode("title"));
279  1 wantedFields.add(PDBFTSRestClient.getInstance()
280    .getDataColumnByNameOrCode("pdb_id"));
281    } catch (Exception e)
282    {
283  0 e.printStackTrace();
284    }
285  1 try
286    {
287  1 assertEquals(5, PDBFTSRestClient.getInstance()
288    .getPrimaryKeyColumIndex(wantedFields, true));
289  1 assertEquals(4, PDBFTSRestClient.getInstance()
290    .getPrimaryKeyColumIndex(wantedFields, false));
291    } catch (Exception e)
292    {
293    // TODO Auto-generated catch block
294  0 e.printStackTrace();
295    }
296    }
297   
 
298  0 toggle @Test(groups = { "External", "Network" })
299    public void externalServiceIntegrationTest()
300    {
301  0 ClientConfig clientConfig = new DefaultClientConfig();
302  0 Client client = Client.create(clientConfig);
303   
304    // Build request parameters for the REST Request
305  0 WebResource webResource = client
306    .resource(PDBFTSRestClient.PDB_SEARCH_ENDPOINT)
307    .queryParam("wt", "json").queryParam("rows", String.valueOf(1))
308    .queryParam("q", "text:abc AND molecule_sequence_length:[1 TO *]");
309  0 System.out.println(">>>> Query PDbe: "+webResource.getURI());
310    // Execute the REST request
311  0 ClientResponse clientResponse = webResource
312    .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
313   
314    // Get the JSON string from the response object
315  0 String pdbJsonResponseString = clientResponse.getEntity(String.class);
316   
317    // Check the response status and report exception if one occurs
318  0 if (clientResponse.getStatus() != 200)
319    {
320  0 Assert.fail("Webservice call failed!!!");
321    }
322    else
323    {
324  0 try
325    {
326  0 JSONParser jsonParser = new JSONParser();
327  0 JSONObject jsonObj = (JSONObject) jsonParser
328    .parse(pdbJsonResponseString);
329  0 JSONObject pdbResponse = (JSONObject) jsonObj.get("response");
330  0 String queryTime = ((JSONObject) jsonObj.get("responseHeader"))
331    .get("QTime").toString();
332  0 String numFound = pdbResponse.get("numFound").toString();
333  0 assertTrue("Couldn't Retrieve 'numFound' value", numFound != null);
334  0 assertTrue("Expected 1 result (or more)", Integer.valueOf(numFound)>0);
335  0 JSONArray docs = (JSONArray) pdbResponse.get("docs");
336  0 Iterator<JSONObject> docIter = docs.iterator();
337   
338  0 assertTrue("Couldn't Retrieve 'response' object",
339    pdbResponse != null);
340  0 assertTrue("Couldn't Retrieve 'QTime' value", queryTime != null);
341  0 assertTrue("Couldn't Retrieve 'docs' object",
342    docs != null || !docIter.hasNext());
343   
344  0 JSONObject pdbJsonDoc = docIter.next();
345   
346  0 for (FTSDataColumnI field : PDBFTSRestClient.getInstance()
347    .getAllFTSDataColumns())
348    {
349  0 if (field.getName().equalsIgnoreCase("ALL"))
350    {
351  0 continue;
352    }
353  0 if (pdbJsonDoc.get(field.getCode()) == null)
354    {
355    // System.out.println(">>>\t" + field.getCode());
356  0 assertTrue(
357    field.getCode()
358    + " has been removed from PDB doc Entity",
359    !pdbJsonResponseString.contains(field.getCode()));
360    }
361    }
362    } catch (ParseException e)
363    {
364  0 Assert.fail(
365    ">>> Test failed due to exception while parsing pdb response json !!!");
366  0 e.printStackTrace();
367    }
368    }
369    }
370   
371    /**
372    * reads any string from filePath
373    *
374    * @param filePath
375    * @return
376    * @throws IOException
377    */
 
378  186 toggle public static String readJsonStringFromFile(String filePath)
379    throws IOException
380    {
381  186 String fileContent;
382  186 BufferedReader br = new BufferedReader(new FileReader(filePath));
383  186 try
384    {
385  186 StringBuilder sb = new StringBuilder();
386  186 String line = br.readLine();
387   
388  118396 while (line != null)
389    {
390  118210 sb.append(line);
391  118210 sb.append(System.lineSeparator());
392  118210 line = br.readLine();
393    }
394  186 fileContent = sb.toString();
395    } finally
396    {
397  186 br.close();
398    }
399  186 return fileContent;
400    }
401   
 
402  9 toggle public static void setMock()
403    {
404  9 List<String[]> mocks = new ArrayList<String[]>();
405  9 mocks.add(
406    new String[]
407    { "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+7lyb+OR+3k0h+OR+3k0k+OR+1t15+OR+3pxc+OR+3pxd+OR+3pxe+OR+1jm7+OR+7jzv+OR+3pxa+OR+3pxb+OR+1y98+OR+1n5o+OR+4ifi+OR+4y2g+OR+3k15+OR+3k16+OR+4jlu+OR+2ing+OR+4ofb+OR+6g2i+OR+3coj+OR+1jnx+OR+4y18+OR+4u4a+OR+1oqa+OR+1t29+OR+1t2u+OR+1t2v)+AND+molecule_sequence_length:%5B1+TO+*%5D+AND+status:REL&sort=",
408    "{\n" + " \"responseHeader\":{\n" + " \"status\":0,\n"
409    + " \"QTime\":0,\n" + " \"params\":{\n"
410    + " \"q\":\"(4igk OR 7lyb OR 3k0h OR 3k0k OR 1t15 OR 3pxc OR 3pxd OR 3pxe OR 1jm7 OR 7jzv OR 3pxa OR 3pxb OR 1y98 OR 1n5o OR 4ifi OR 4y2g OR 3k15 OR 3k16 OR 4jlu OR 2ing OR 4ofb OR 6g2i OR 3coj OR 1jnx OR 4y18 OR 4u4a OR 1oqa OR 1t29 OR 1t2u OR 1t2v) AND molecule_sequence_length:[1 TO *] AND status:REL\",\n"
411    + " \"fl\":\"pdb_id,title,experimental_method,resolution\",\n"
412    + " \"start\":\"0\",\n"
413    + " \"sort\":\"\",\n"
414    + " \"rows\":\"500\",\n"
415    + " \"wt\":\"json\"}},\n"
416    + " \"response\":{\"numFound\":64,\"start\":0,\"docs\":[\n"
417    + " {\n"
418    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
419    + " \"pdb_id\":\"4ofb\",\n"
420    + " \"resolution\":3.05,\n"
421    + " \"title\":\"Crystal structure of human BRCA1 BRCT in complex with nonphosphopeptide inhibitor\"},\n"
422    + " {\n"
423    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
424    + " \"pdb_id\":\"3pxe\",\n"
425    + " \"resolution\":2.85,\n"
426    + " \"title\":\"Impact of BRCA1 BRCT domain missense substitutions on phospho-peptide recognition: E1836K\"},\n"
427    + " {\n"
428    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
429    + " \"pdb_id\":\"4jlu\",\n"
430    + " \"resolution\":3.5,\n"
431    + " \"title\":\"Crystal structure of BRCA1 BRCT with doubly phosphorylated Abraxas\"},\n"
432    + " {\n"
433    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
434    + " \"pdb_id\":\"4y2g\",\n"
435    + " \"resolution\":2.5,\n"
436    + " \"title\":\"Structure of BRCA1 BRCT domains in complex with Abraxas single phosphorylated peptide\"},\n"
437    + " {\n"
438    + " \"experimental_method\":[\"Solution NMR\"],\n"
439    + " \"pdb_id\":\"1oqa\",\n"
440    + " \"title\":\"Solution structure of the BRCT-c domain from human BRCA1\"},\n"
441    + " {\n"
442    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
443    + " \"pdb_id\":\"4u4a\",\n"
444    + " \"resolution\":3.51,\n"
445    + " \"title\":\"Complex Structure of BRCA1 BRCT with singly phospho Abraxas\"},\n"
446    + " {\n"
447    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
448    + " \"pdb_id\":\"3k16\",\n"
449    + " \"resolution\":3.0,\n"
450    + " \"title\":\"Crystal Structure of BRCA1 BRCT D1840T in complex with a minimal recognition tetrapeptide with a free carboxy C-terminus\"},\n"
451    + " {\n"
452    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
453    + " \"pdb_id\":\"1t15\",\n"
454    + " \"resolution\":1.85,\n"
455    + " \"title\":\"Crystal Structure of the Brca1 BRCT Domains in Complex with the Phosphorylated Interacting Region from Bach1 Helicase\"},\n"
456    + " {\n"
457    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
458    + " \"pdb_id\":\"3k15\",\n"
459    + " \"resolution\":2.8,\n"
460    + " \"title\":\"Crystal Structure of BRCA1 BRCT D1840T in complex with a minimal recognition tetrapeptide with an amidated C-terminus\"},\n"
461    + " {\n"
462    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
463    + " \"pdb_id\":\"1t2v\",\n"
464    + " \"resolution\":3.3,\n"
465    + " \"title\":\"Structural basis of phospho-peptide recognition by the BRCT domain of BRCA1, structure with phosphopeptide\"},\n"
466    + " {\n"
467    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
468    + " \"pdb_id\":\"1y98\",\n"
469    + " \"resolution\":2.5,\n"
470    + " \"title\":\"Structure of the BRCT repeats of BRCA1 bound to a CtIP phosphopeptide.\"},\n"
471    + " {\n"
472    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
473    + " \"pdb_id\":\"1t29\",\n"
474    + " \"resolution\":2.3,\n"
475    + " \"title\":\"Crystal structure of the BRCA1 BRCT repeats bound to a phosphorylated BACH1 peptide\"},\n"
476    + " {\n"
477    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
478    + " \"pdb_id\":\"3k0k\",\n"
479    + " \"resolution\":2.7,\n"
480    + " \"title\":\"Crystal Structure of BRCA1 BRCT in complex with a minimal recognition tetrapeptide with a free carboxy C-terminus.\"},\n"
481    + " {\n"
482    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
483    + " \"pdb_id\":\"3k0h\",\n"
484    + " \"resolution\":2.7,\n"
485    + " \"title\":\"The crystal structure of BRCA1 BRCT in complex with a minimal recognition tetrapeptide with an amidated C-terminus\"},\n"
486    + " {\n"
487    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
488    + " \"pdb_id\":\"4ifi\",\n"
489    + " \"resolution\":2.2,\n"
490    + " \"title\":\"Structure of human BRCA1 BRCT in complex with BAAT peptide\"},\n"
491    + " {\n"
492    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
493    + " \"pdb_id\":\"3pxd\",\n"
494    + " \"resolution\":2.8,\n"
495    + " \"title\":\"Impact of BRCA1 BRCT domain missense substitutions on phospho-peptide recognition: R1835P\"},\n"
496    + " {\n"
497    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
498    + " \"pdb_id\":\"3pxc\",\n"
499    + " \"resolution\":2.8,\n"
500    + " \"title\":\"Impact of BRCA1 BRCT domain missense substitutions on phospho-peptide recognition: R1699Q\"},\n"
501    + " {\n"
502    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
503    + " \"pdb_id\":\"1jnx\",\n"
504    + " \"resolution\":2.5,\n"
505    + " \"title\":\"Crystal structure of the BRCT repeat region from the breast cancer associated protein, BRCA1\"},\n"
506    + " {\n"
507    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
508    + " \"pdb_id\":\"3pxa\",\n"
509    + " \"resolution\":2.55,\n"
510    + " \"title\":\"Impact of BRCA1 BRCT domain missense substitutions on phospho-peptide recognition: G1656D\"},\n"
511    + " {\n"
512    + " \"experimental_method\":[\"Solution NMR\"],\n"
513    + " \"pdb_id\":\"1jm7\",\n"
514    + " \"title\":\"Solution structure of the BRCA1/BARD1 RING-domain heterodimer\"},\n"
515    + " {\n"
516    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
517    + " \"pdb_id\":\"4igk\",\n"
518    + " \"resolution\":1.75,\n"
519    + " \"title\":\"Structure of human BRCA1 BRCT in complex with ATRIP peptide\"},\n"
520    + " {\n"
521    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
522    + " \"pdb_id\":\"1t2u\",\n"
523    + " \"resolution\":2.8,\n"
524    + " \"title\":\"Structural basis of phosphopeptide recognition by the BRCT domain of BRCA1: structure of BRCA1 missense variant V1809F\"},\n"
525    + " {\n"
526    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
527    + " \"pdb_id\":\"3pxb\",\n"
528    + " \"resolution\":2.5,\n"
529    + " \"title\":\"Impact of BRCA1 BRCT domain missense substitutions on phospho-peptide recognition: T1700A\"},\n"
530    + " {\n"
531    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
532    + " \"pdb_id\":\"1n5o\",\n"
533    + " \"resolution\":2.8,\n"
534    + " \"title\":\"Structural consequences of a cancer-causing BRCA1-BRCT missense mutation\"},\n"
535    + " {\n"
536    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
537    + " \"pdb_id\":\"3coj\",\n"
538    + " \"resolution\":3.21,\n"
539    + " \"title\":\"Crystal Structure of the BRCT Domains of Human BRCA1 in Complex with a Phosphorylated Peptide from Human Acetyl-CoA Carboxylase 1\"},\n"
540    + " {\n"
541    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
542    + " \"pdb_id\":\"6g2i\",\n"
543    + " \"resolution\":5.9,\n"
544    + " \"title\":\"Filament of acetyl-CoA carboxylase and BRCT domains of BRCA1 (ACC-BRCT) at 5.9 A resolution\"},\n"
545    + " {\n"
546    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
547    + " \"pdb_id\":\"4jlu\",\n"
548    + " \"resolution\":3.5,\n"
549    + " \"title\":\"Crystal structure of BRCA1 BRCT with doubly phosphorylated Abraxas\"},\n"
550    + " {\n"
551    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
552    + " \"pdb_id\":\"4ofb\",\n"
553    + " \"resolution\":3.05,\n"
554    + " \"title\":\"Crystal structure of human BRCA1 BRCT in complex with nonphosphopeptide inhibitor\"},\n"
555    + " {\n"
556    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
557    + " \"pdb_id\":\"3pxe\",\n"
558    + " \"resolution\":2.85,\n"
559    + " \"title\":\"Impact of BRCA1 BRCT domain missense substitutions on phospho-peptide recognition: E1836K\"},\n"
560    + " {\n"
561    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
562    + " \"pdb_id\":\"4u4a\",\n"
563    + " \"resolution\":3.51,\n"
564    + " \"title\":\"Complex Structure of BRCA1 BRCT with singly phospho Abraxas\"},\n"
565    + " {\n"
566    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
567    + " \"pdb_id\":\"4y2g\",\n"
568    + " \"resolution\":2.5,\n"
569    + " \"title\":\"Structure of BRCA1 BRCT domains in complex with Abraxas single phosphorylated peptide\"},\n"
570    + " {\n"
571    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
572    + " \"pdb_id\":\"4y18\",\n"
573    + " \"resolution\":3.5,\n"
574    + " \"title\":\"Structure of BRCA1 BRCT domains in complex with Abraxas double phosphorylated peptide\"},\n"
575    + " {\n"
576    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
577    + " \"pdb_id\":\"2ing\",\n"
578    + " \"resolution\":3.6,\n"
579    + " \"title\":\"X-ray Structure of the BRCA1 BRCT mutant M1775K\"},\n"
580    + " {\n"
581    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
582    + " \"pdb_id\":\"1t15\",\n"
583    + " \"resolution\":1.85,\n"
584    + " \"title\":\"Crystal Structure of the Brca1 BRCT Domains in Complex with the Phosphorylated Interacting Region from Bach1 Helicase\"},\n"
585    + " {\n"
586    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
587    + " \"pdb_id\":\"1t29\",\n"
588    + " \"resolution\":2.3,\n"
589    + " \"title\":\"Crystal structure of the BRCA1 BRCT repeats bound to a phosphorylated BACH1 peptide\"},\n"
590    + " {\n"
591    + " \"experimental_method\":[\"Solution NMR\"],\n"
592    + " \"pdb_id\":\"1jm7\",\n"
593    + " \"title\":\"Solution structure of the BRCA1/BARD1 RING-domain heterodimer\"},\n"
594    + " {\n"
595    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
596    + " \"pdb_id\":\"1t2v\",\n"
597    + " \"resolution\":3.3,\n"
598    + " \"title\":\"Structural basis of phospho-peptide recognition by the BRCT domain of BRCA1, structure with phosphopeptide\"},\n"
599    + " {\n"
600    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
601    + " \"pdb_id\":\"4ifi\",\n"
602    + " \"resolution\":2.2,\n"
603    + " \"title\":\"Structure of human BRCA1 BRCT in complex with BAAT peptide\"},\n"
604    + " {\n"
605    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
606    + " \"pdb_id\":\"4igk\",\n"
607    + " \"resolution\":1.75,\n"
608    + " \"title\":\"Structure of human BRCA1 BRCT in complex with ATRIP peptide\"},\n"
609    + " {\n"
610    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
611    + " \"pdb_id\":\"3k0k\",\n"
612    + " \"resolution\":2.7,\n"
613    + " \"title\":\"Crystal Structure of BRCA1 BRCT in complex with a minimal recognition tetrapeptide with a free carboxy C-terminus.\"},\n"
614    + " {\n"
615    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
616    + " \"pdb_id\":\"3k16\",\n"
617    + " \"resolution\":3.0,\n"
618    + " \"title\":\"Crystal Structure of BRCA1 BRCT D1840T in complex with a minimal recognition tetrapeptide with a free carboxy C-terminus\"},\n"
619    + " {\n"
620    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
621    + " \"pdb_id\":\"3k15\",\n"
622    + " \"resolution\":2.8,\n"
623    + " \"title\":\"Crystal Structure of BRCA1 BRCT D1840T in complex with a minimal recognition tetrapeptide with an amidated C-terminus\"},\n"
624    + " {\n"
625    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
626    + " \"pdb_id\":\"3k0h\",\n"
627    + " \"resolution\":2.7,\n"
628    + " \"title\":\"The crystal structure of BRCA1 BRCT in complex with a minimal recognition tetrapeptide with an amidated C-terminus\"},\n"
629    + " {\n"
630    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
631    + " \"pdb_id\":\"1y98\",\n"
632    + " \"resolution\":2.5,\n"
633    + " \"title\":\"Structure of the BRCT repeats of BRCA1 bound to a CtIP phosphopeptide.\"},\n"
634    + " {\n"
635    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
636    + " \"pdb_id\":\"3coj\",\n"
637    + " \"resolution\":3.21,\n"
638    + " \"title\":\"Crystal Structure of the BRCT Domains of Human BRCA1 in Complex with a Phosphorylated Peptide from Human Acetyl-CoA Carboxylase 1\"},\n"
639    + " {\n"
640    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
641    + " \"pdb_id\":\"4y18\",\n"
642    + " \"resolution\":3.5,\n"
643    + " \"title\":\"Structure of BRCA1 BRCT domains in complex with Abraxas double phosphorylated peptide\"},\n"
644    + " {\n"
645    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
646    + " \"pdb_id\":\"7jzv\",\n"
647    + " \"resolution\":3.9,\n"
648    + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n"
649    + " {\n"
650    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
651    + " \"pdb_id\":\"7jzv\",\n"
652    + " \"resolution\":3.9,\n"
653    + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n"
654    + " {\n"
655    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
656    + " \"pdb_id\":\"7lyb\",\n"
657    + " \"resolution\":3.28,\n"
658    + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n"
659    + " {\n"
660    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
661    + " \"pdb_id\":\"7lyb\",\n"
662    + " \"resolution\":3.28,\n"
663    + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n"
664    + " {\n"
665    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
666    + " \"pdb_id\":\"7lyb\",\n"
667    + " \"resolution\":3.28,\n"
668    + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n"
669    + " {\n"
670    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
671    + " \"pdb_id\":\"7jzv\",\n"
672    + " \"resolution\":3.9,\n"
673    + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n"
674    + " {\n"
675    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
676    + " \"pdb_id\":\"7lyb\",\n"
677    + " \"resolution\":3.28,\n"
678    + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n"
679    + " {\n"
680    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
681    + " \"pdb_id\":\"7jzv\",\n"
682    + " \"resolution\":3.9,\n"
683    + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n"
684    + " {\n"
685    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
686    + " \"pdb_id\":\"7lyb\",\n"
687    + " \"resolution\":3.28,\n"
688    + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n"
689    + " {\n"
690    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
691    + " \"pdb_id\":\"7jzv\",\n"
692    + " \"resolution\":3.9,\n"
693    + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n"
694    + " {\n"
695    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
696    + " \"pdb_id\":\"7lyb\",\n"
697    + " \"resolution\":3.28,\n"
698    + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n"
699    + " {\n"
700    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
701    + " \"pdb_id\":\"7lyb\",\n"
702    + " \"resolution\":3.28,\n"
703    + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n"
704    + " {\n"
705    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
706    + " \"pdb_id\":\"7lyb\",\n"
707    + " \"resolution\":3.28,\n"
708    + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n"
709    + " {\n"
710    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
711    + " \"pdb_id\":\"7jzv\",\n"
712    + " \"resolution\":3.9,\n"
713    + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n"
714    + " {\n"
715    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
716    + " \"pdb_id\":\"6g2i\",\n"
717    + " \"resolution\":5.9,\n"
718    + " \"title\":\"Filament of acetyl-CoA carboxylase and BRCT domains of BRCA1 (ACC-BRCT) at 5.9 A resolution\"},\n"
719    + " {\n"
720    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
721    + " \"pdb_id\":\"7jzv\",\n"
722    + " \"resolution\":3.9,\n"
723    + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"},\n"
724    + " {\n"
725    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
726    + " \"pdb_id\":\"7lyb\",\n"
727    + " \"resolution\":3.28,\n"
728    + " \"title\":\"Cryo-EM structure of the human nucleosome core particle in complex with BRCA1-BARD1-UbcH5c\"},\n"
729    + " {\n"
730    + " \"experimental_method\":[\"Electron Microscopy\"],\n"
731    + " \"pdb_id\":\"7jzv\",\n"
732    + " \"resolution\":3.9,\n"
733    + " \"title\":\"Cryo-EM structure of the BRCA1-UbcH5c/BARD1 E3-E2 module bound to a nucleosome\"}]\n"
734    + " }}" });
735   
736  9 try
737    {
738  27 for (int i = 1; i < 3; i++)
739    {
740  18 mocks.add(
741    new String[]
742    { readJsonStringFromFile(
743    "test/jalview/fts/threedbeacons/p01308_pdbfts_query_pt"
744    + i + ".txt").trim(),
745    readJsonStringFromFile(
746    "test/jalview/fts/threedbeacons/p01308_pdbfts_query_pt"
747    + i + "_resp.txt").trim() });
748    }
749  54 for (int i = 1; i < 6; i++)
750    {
751  45 mocks.add(
752   
753    new String[]
754    { readJsonStringFromFile(
755    "test/jalview/fts/threedbeacons/p0dtd1_pdbfts_fts_query_pt"
756    + i + ".txt").trim(),
757    readJsonStringFromFile(
758    "test/jalview/fts/threedbeacons/p0dtd1_pdbfts_fts_query_pt"
759    + i + "_resp.txt").trim() });
760    }
761    // maize
762  9 mocks.add(
763    new String[]
764    { "https://www.ebi.ac.uk/pdbe/search/pdb/select?wt=json&fl=pdb_id,title,experimental_method,resolution&rows=500&start=0&q=(1gaq+OR+5h92+OR+3b2f+OR+3w5u+OR+5h8y+OR+3w5v)+AND+molecule_sequence_length:%5B1+TO+*%5D+AND+status:REL&sort=",
765    "{\n" + " \"responseHeader\":{\n" + " \"status\":0,\n"
766    + " \"QTime\":0,\n" + " \"params\":{\n"
767    + " \"q\":\"(1gaq OR 5h92 OR 3b2f OR 3w5u OR 5h8y OR 3w5v) AND molecule_sequence_length:[1 TO *] AND status:REL\",\n"
768    + " \"fl\":\"pdb_id,title,experimental_method,resolution\",\n"
769    + " \"start\":\"0\",\n"
770    + " \"sort\":\"\",\n"
771    + " \"rows\":\"500\",\n"
772    + " \"wt\":\"json\"}},\n"
773    + " \"response\":{\"numFound\":11,\"start\":0,\"docs\":[\n"
774    + " {\n"
775    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
776    + " \"pdb_id\":\"3b2f\",\n"
777    + " \"resolution\":1.7,\n"
778    + " \"title\":\"Maize Ferredoxin 1\"},\n"
779    + " {\n"
780    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
781    + " \"pdb_id\":\"5h92\",\n"
782    + " \"resolution\":2.08,\n"
783    + " \"title\":\"Crystal structure of the complex between maize Sulfite Reductase and ferredoxin in the form-3 crystal\"},\n"
784    + " {\n"
785    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
786    + " \"pdb_id\":\"5h8y\",\n"
787    + " \"resolution\":2.2,\n"
788    + " \"title\":\"Crystal structure of the complex between maize sulfite reductase and ferredoxin in the form-2 crystal\"},\n"
789    + " {\n"
790    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
791    + " \"pdb_id\":\"1gaq\",\n"
792    + " \"resolution\":2.59,\n"
793    + " \"title\":\"CRYSTAL STRUCTURE OF THE COMPLEX BETWEEN FERREDOXIN AND FERREDOXIN-NADP+ REDUCTASE\"},\n"
794    + " {\n"
795    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
796    + " \"pdb_id\":\"3w5u\",\n"
797    + " \"resolution\":2.7,\n"
798    + " \"title\":\"Cross-linked complex between Ferredoxin and Ferredoxin-NADP+ reductase\"},\n"
799    + " {\n"
800    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
801    + " \"pdb_id\":\"3w5v\",\n"
802    + " \"resolution\":3.81,\n"
803    + " \"title\":\"Cross-linked complex between Ferredoxin and Ferredoxin-NADP+ reductase\"},\n"
804    + " {\n"
805    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
806    + " \"pdb_id\":\"3w5u\",\n"
807    + " \"resolution\":2.7,\n"
808    + " \"title\":\"Cross-linked complex between Ferredoxin and Ferredoxin-NADP+ reductase\"},\n"
809    + " {\n"
810    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
811    + " \"pdb_id\":\"3w5v\",\n"
812    + " \"resolution\":3.81,\n"
813    + " \"title\":\"Cross-linked complex between Ferredoxin and Ferredoxin-NADP+ reductase\"},\n"
814    + " {\n"
815    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
816    + " \"pdb_id\":\"1gaq\",\n"
817    + " \"resolution\":2.59,\n"
818    + " \"title\":\"CRYSTAL STRUCTURE OF THE COMPLEX BETWEEN FERREDOXIN AND FERREDOXIN-NADP+ REDUCTASE\"},\n"
819    + " {\n"
820    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
821    + " \"pdb_id\":\"5h92\",\n"
822    + " \"resolution\":2.08,\n"
823    + " \"title\":\"Crystal structure of the complex between maize Sulfite Reductase and ferredoxin in the form-3 crystal\"},\n"
824    + " {\n"
825    + " \"experimental_method\":[\"X-ray diffraction\"],\n"
826    + " \"pdb_id\":\"5h8y\",\n"
827    + " \"resolution\":2.2,\n"
828    + " \"title\":\"Crystal structure of the complex between maize sulfite reductase and ferredoxin in the form-2 crystal\"}]\n"
829    + " }}" });
830  9 mocks.add(
831    new String[]
832    { "https://www.ebi.ac.uk/pdbe/search/pdb/select?wt=json&fl=pdb_id,title,experimental_method,resolution&rows=500&start=0&q=(4gs9+OR+6bvb+OR+8ck8+OR+8ck3+OR+6x3d+OR+8ck4+OR+6x28+OR+6i7r+OR+3h82+OR+6i7q+OR+6x21+OR+4xt2+OR+5kiz+OR+7q5v+OR+6x2h+OR+7q5x+OR+3f1n+OR+3f1o+OR+2a24+OR+3f1p+OR+1p97+OR+4ghi+OR+3h7w+OR+6d09+OR+6czw+OR+7ujv+OR+5tbm+OR+5ufp+OR+4pky+OR+6d0b+OR+6d0c+OR+6x37)+AND+molecule_sequence_length:%5B1+TO+*%5D+AND+status:REL&sort=",
833    readJsonStringFromFile(
834    "test/jalview/fts/threedbeacons/q99814_tdb_pdbfts_query_resp.txt") });
835    } catch (Throwable e)
836    {
837  0 Assert.fail("Couldn't read mock data.", e);
838    }
839    /*
840    * updating mocks for p0dtd1 require very long URLs to be queried
841    for i in test/jalview/fts/threedbeacons/p0dtd1_pdbfts_fts_query_pt?.txt; do wget -i $i -O ${i/.txt/_resp.txt}; done
842    */
843  9 FTSRestClient.createMockFTSRestClient(
844    (FTSRestClient) PDBFTSRestClient.getInstance(),
845    mocks.toArray(new String[0][2]));
846    }
847    }