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