1 package jalview.fts.threedbeacons;
3 import static org.testng.Assert.assertNull;
4 import static org.testng.AssertJUnit.assertEquals;
5 import static org.testng.AssertJUnit.assertTrue;
7 import java.io.IOException;
9 import java.nio.charset.StandardCharsets;
10 import java.util.ArrayList;
11 import java.util.Collection;
12 import java.util.HashSet;
13 import java.util.List;
16 import org.testng.Assert;
17 import org.testng.annotations.AfterMethod;
18 import org.testng.annotations.BeforeClass;
19 import org.testng.annotations.BeforeMethod;
20 import org.testng.annotations.Test;
22 import jalview.fts.api.FTSDataColumnI;
23 import jalview.fts.api.FTSDataColumnI.FTSDataColumnGroupI;
24 import jalview.fts.core.FTSRestClient;
25 import jalview.fts.core.FTSRestRequest;
26 import jalview.fts.core.FTSRestResponse;
27 import jalview.fts.service.pdb.PDBFTSRestClientTest;
28 import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient;
29 import jalview.gui.JvOptionPane;
31 public class TDBeaconsFTSRestClientTest
33 @BeforeClass(alwaysRun = true)
34 public void setUpJvOptionPane()
36 JvOptionPane.setInteractiveMode(false);
37 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
40 private FTSRestClient ftsRestClient;
42 @BeforeMethod(alwaysRun = true)
43 public void setUp() throws Exception
45 ftsRestClient = new FTSRestClient()
49 public String getColumnDataConfigFileName()
51 return "/fts/tdbeacons_data_columns.txt";
55 public FTSRestResponse executeRequest(FTSRestRequest ftsRequest)
63 @AfterMethod(alwaysRun = true)
64 public void tearDown() throws Exception
69 public void getAllDefaulDisplayedDataColumns()
71 // to change when resources.tdbeacons_data_columns.txt is changed
73 ftsRestClient.getAllDefaultDisplayedFTSDataColumns());
75 .println(ftsRestClient.getAllDefaultDisplayedFTSDataColumns());
76 Assert.assertTrue(!ftsRestClient.getAllDefaultDisplayedFTSDataColumns()
79 ftsRestClient.getAllDefaultDisplayedFTSDataColumns().size(),
83 @Test(groups = { "Functional" })
84 public void getPrimaryKeyColumIndexTest()
86 Collection<FTSDataColumnI> wantedFields = ftsRestClient
87 .getAllDefaultDisplayedFTSDataColumns();
91 Assert.assertEquals(foundIndex, -1);
92 foundIndex = ftsRestClient.getPrimaryKeyColumIndex(wantedFields,
94 Assert.assertEquals(foundIndex, 12);
95 foundIndex = ftsRestClient.getPrimaryKeyColumIndex(wantedFields,
97 // 1+primary key index
98 Assert.assertEquals(foundIndex, 13);
102 Assert.fail("Exception thrown while testing...");
106 @Test(groups = { "Functional" })
107 public void getDataColumnsFieldsAsCommaDelimitedString()
109 // to change when resources.tdbeacons_data_columns.txt is changed
110 Collection<FTSDataColumnI> wantedFields = ftsRestClient
111 .getAllDefaultDisplayedFTSDataColumns();
112 String actual = ftsRestClient
113 .getDataColumnsFieldsAsCommaDelimitedString(wantedFields);
114 Assert.assertEquals(actual,
115 "uniprot_start,uniprot_end,provider,model_identifier,model_category,model_title,resolution,confidence_avg_local_score,confidence_type,confidence_version,coverage,created,model_url");
118 @Test(groups = { "Functional" })
119 public void getAllFTSDataColumns()
121 Collection<FTSDataColumnI> allFields = ftsRestClient
122 .getAllFTSDataColumns();
123 Assert.assertNotNull(allFields);
124 // System.out.println(allFields.size());
125 Assert.assertEquals(allFields.size(), 19);
128 @Test(groups = { "Functional" })
129 public void getSearchableDataColumns()
131 // to change when resources.tdbeacons_data_columns.txt is changed
132 Collection<FTSDataColumnI> searchableFields = ftsRestClient
133 .getSearchableDataColumns();
134 Assert.assertNotNull(searchableFields);
135 // System.out.println(searchableFields.size());
136 Assert.assertEquals(searchableFields.size(), 1); // only 1: uniprot
140 @Test(groups = { "Functional" })
141 public void getPrimaryKeyColumn()
143 // to change when resources.tdbeacons_data_columns.txt is changed
144 FTSDataColumnI expectedPKColumn;
147 expectedPKColumn = ftsRestClient.getDataColumnByNameOrCode("Url");
148 Assert.assertNotNull(ftsRestClient.getPrimaryKeyColumn());
149 Assert.assertEquals(ftsRestClient.getPrimaryKeyColumn(),
151 } catch (Exception e)
154 Assert.fail("Exception thrown while testing...");
158 @Test(groups = { "Functional" })
159 public void getDataColumnByNameOrCode()
163 FTSDataColumnI foundDataCol = ftsRestClient
164 .getDataColumnByNameOrCode("uniprot_accession");
165 Assert.assertNotNull(foundDataCol);
166 Assert.assertEquals(foundDataCol.getName(), "UniProt Accession");
167 } catch (Exception e)
170 Assert.fail("Exception thrown while testing...");
174 @Test(groups = { "Functional" })
175 public void getDataColumnGroupById()
177 FTSDataColumnGroupI foundDataColGroup;
180 foundDataColGroup = ftsRestClient.getDataColumnGroupById("g2");
181 Assert.assertNotNull(foundDataColGroup);
182 Assert.assertEquals(foundDataColGroup.getName(), "Quality");
183 } catch (Exception e)
189 @Test(groups = { "Functional" })
190 public void getDefaultResponsePageSize()
192 int defaultResSize = ftsRestClient.getDefaultResponsePageSize();
193 Assert.assertEquals(defaultResSize, 100); // why 100 or 500 ? pdb is 100,
197 @Test(groups = { "Functional" })
198 public void getColumnMinWidthTest()
202 FTSDataColumnI foundDataCol = ftsRestClient
203 .getDataColumnByNameOrCode("uniprot_accession");
204 Assert.assertNotNull(foundDataCol);
205 int actualColMinWidth = foundDataCol.getMinWidth();
206 Assert.assertEquals(actualColMinWidth, 50);
207 } catch (Exception e)
210 Assert.fail("Exception thrown while testing...");
213 // could add test for MaxWidth & PreferedWith
215 @Test(groups = { "Functional" })
216 public void getColumnClassTest()
220 FTSDataColumnI foundDataCol = ftsRestClient
221 .getDataColumnByNameOrCode("uniprot_accession");
222 Assert.assertNotNull(foundDataCol);
223 Assert.assertEquals(foundDataCol.getDataType().getDataTypeClass(),
225 foundDataCol = ftsRestClient.getDataColumnByNameOrCode("id");
226 Assert.assertNotNull(foundDataCol);
227 Assert.assertEquals(foundDataCol.getDataType().getDataTypeClass(),
229 } catch (Exception e)
232 Assert.fail("Exception thrown while testing...");
236 @Test(groups = { "Functional" })
237 public void coverageForEqualsAndHashFunction()
239 Set<FTSDataColumnI> uniqueSet = new HashSet<FTSDataColumnI>();
240 Collection<FTSDataColumnI> searchableCols = ftsRestClient
241 .getSearchableDataColumns();
242 System.out.println(searchableCols);
243 for (FTSDataColumnI foundCol : searchableCols)
245 System.out.println(foundCol.toString());
246 uniqueSet.add(foundCol);
247 uniqueSet.add(foundCol);
249 Assert.assertTrue(!uniqueSet.isEmpty());
250 // Assert.assertEquals(uniqueSet.size(), 22); -> 1 or 2 currently for 3DB
253 @Test(groups = { "Functional" })
254 public void getTDBIdColumIndexTest()
256 List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
259 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
260 .getDataColumnByNameOrCode("Model id"));
261 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
262 .getDataColumnByNameOrCode("uniprot_accession"));
263 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
264 .getDataColumnByNameOrCode("Title"));
265 } catch (Exception e)
271 assertEquals(4, TDBeaconsFTSRestClient.getInstance()
272 .getPrimaryKeyColumIndex(wantedFields, true));
273 // assertEquals(3, TDBeaconsFTSRestClient.getInstance()
274 // .getPrimaryKeyColumIndex(wantedFields, true));
275 } catch (Exception e)
281 private static String[][] mocks = { { "P38398.json",
282 "{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/4igk\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/1t15\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/4ifi\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/1t29\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/3pxb\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/4y2g\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/1y98\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/1jnx\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/3pxa\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/3k0h\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/3k0k\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/1n5o\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/3pxc\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/3pxd\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/1t2u\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/3k15\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/3pxe\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/3k16\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/4ofb\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/3coj\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/7lyb\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/1t2v\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/4y18\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/4jlu\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/4u4a\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/2ing\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/7jzv\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/6g2i\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/1jm7\"},{\"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_page_url\":\"https://www.ebi.ac.uk/pdbe/entry/pdb/1oqa\"},{\"model_identifier\":\"614057b7a2b5cc6a7fcb50bd\",\"model_category\":\"TEMPLATE-BASED\",\"provider\":\"SWISS-MODEL\",\"created\":\"2021-09-14\",\"sequence_identity\":1.0,\"uniprot_start\":1646,\"uniprot_end\":1859,\"coverage\":0.115,\"confidence_version\":\"4.2.0\",\"confidence_avg_local_score\":0.776,\"model_url\":\"https://swissmodel.expasy.org/3d-beacons/uniprot/P38398.pdb?range=1646-1859&template=6g2i.1.K&provider=swissmodel\",\"model_format\":\"PDB\",\"confidence_type\":\"QMEANDisCo\"},{\"model_identifier\":\"614057b7a2b5cc6a7fcb50c1\",\"model_category\":\"TEMPLATE-BASED\",\"provider\":\"SWISS-MODEL\",\"created\":\"2021-09-14\",\"sequence_identity\":1.0,\"uniprot_start\":1,\"uniprot_end\":103,\"coverage\":0.055,\"confidence_version\":\"4.2.0\",\"confidence_avg_local_score\":0.655,\"model_url\":\"https://swissmodel.expasy.org/3d-beacons/uniprot/P38398.pdb?range=1-103&template=1jm7.1.A&provider=swissmodel\",\"model_format\":\"PDB\",\"confidence_type\":\"QMEANDisCo\"},{\"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\",\"model_page_url\":\"https://alphafold.ebi.ac.uk/entry/P38398\"}]}" },
283 { "P01308.json",null}};
285 private static void setMockData()
289 mocks[1][1]= PDBFTSRestClientTest.readJsonStringFromFile("test/jalview/fts/threedbeacons/p01308_tdb_resp.txt");
290 } catch (IOException e)
292 Assert.fail("Couldn't read mock response data",e);
296 public static void setMock()
299 FTSRestClient.createMockFTSRestClient(
300 (FTSRestClient) TDBeaconsFTSRestClient.getInstance(),
304 private static String dev_url = "https://wwwdev.ebi.ac.uk/pdbe/pdbe-kb/3dbeacons/api/uniprot/summary/";
305 private static String prod_url = "https://www.ebi.ac.uk/pdbe/pdbe-kb/3dbeacons/api/uniprot/summary/";
308 * check that the mock request and response are the same as the response from
309 * a live 3D-beacons endpoint
313 @Test(groups = { "Network", "Integration" })
314 public void verifyMockTDBRequest() throws Exception
317 for (String[] otherMock:mocks)
319 verifyMockTDBRequest(otherMock[0],otherMock[1]);
322 private void verifyMockTDBRequest(String mockRequest, String _mockResponse) throws Exception
324 URL tdb_req = new URL(prod_url + mockRequest);
325 byte[] resp = tdb_req.openStream().readAllBytes();
326 String tresp = new String(resp, StandardCharsets.UTF_8);
327 assertEquals(_mockResponse.trim(), tresp.trim());
330 @Test(groups = { "Functional" })
331 public void testMockTDBRequest()
335 List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
338 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
339 .getDataColumnByNameOrCode("Model Id"));
340 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
341 .getDataColumnByNameOrCode("model_url"));
342 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
343 .getDataColumnByNameOrCode("provider"));
344 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
345 .getDataColumnByNameOrCode("model_category"));
346 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
347 .getDataColumnByNameOrCode("qmean_avg_local_score"));
348 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
349 .getDataColumnByNameOrCode("uniprot_start"));
350 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
351 .getDataColumnByNameOrCode("uniprot_end"));
352 } catch (Exception e1)
354 e1.printStackTrace();
356 System.out.println("wantedFields >>" + wantedFields);
358 FTSRestRequest request = new FTSRestRequest();
359 FTSRestResponse response;
361 request.setResponseSize(100);
362 request.setFieldToSearchBy("");
363 request.setWantedFields(wantedFields);
364 // check 404 behaviour
365 request.setSearchTerm("P00000.json");
369 response = TDBeaconsFTSRestClient.getInstance()
370 .executeRequest(request);
372 assertNull(response);
373 } catch (Exception e)
376 Assert.fail("Unexpected failure during mock 3DBeacons 404 test");
379 // check 200 behaviour
380 request.setSearchTerm("P38398.json");
381 System.out.println("request : " + request.getFieldToSearchBy());
382 // System.out.println(request.toString());
386 response = TDBeaconsFTSRestClient.getInstance()
387 .executeRequest(request);
388 } catch (Exception e)
391 Assert.fail("Couldn't execute webservice call!");
394 assertTrue(response.getSearchSummary() != null);
395 assertTrue(response.getNumberOfItemsFound() > 3); // 4 atm
396 System.out.println("Search summary : \n" + response.getSearchSummary());
398 // System.out.println(response.getSearchSummary().size());
401 @Test(groups = { "External", "Network" })
402 public void executeRequestTest()
404 List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
407 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
408 .getDataColumnByNameOrCode("Model Id"));
409 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
410 .getDataColumnByNameOrCode("model_url"));
411 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
412 .getDataColumnByNameOrCode("provider"));
413 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
414 .getDataColumnByNameOrCode("model_category"));
415 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
416 .getDataColumnByNameOrCode("confidence_avg_local_score"));
417 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
418 .getDataColumnByNameOrCode("uniprot_start"));
419 wantedFields.add(TDBeaconsFTSRestClient.getInstance()
420 .getDataColumnByNameOrCode("uniprot_end"));
421 } catch (Exception e1)
423 e1.printStackTrace();
425 System.out.println("wantedFields >>" + wantedFields);
427 FTSRestRequest request = new FTSRestRequest();
428 request.setResponseSize(100);
429 request.setFieldToSearchBy("");
430 request.setSearchTerm("P01318.json");
431 request.setWantedFields(wantedFields);
432 System.out.println("request : " + request.getFieldToSearchBy());
433 // System.out.println(request.toString());
435 FTSRestResponse response;
438 response = TDBeaconsFTSRestClient.getInstance()
439 .executeRequest(request);
440 } catch (Exception e)
443 Assert.fail("Couldn't execute webservice call!");
446 assertTrue(response.getSearchSummary() != null);
447 assertTrue(response.getNumberOfItemsFound() > 3); // 4 atm
448 System.out.println("Search summary : \n" + response.getSearchSummary());
449 // System.out.println(response.getSearchSummary().size());