+
+// public int TDBeaconsFTSPanel2(String result)
+// {
+// int seqlength = executeParse(result);
+// return seqlength;
+// }
+
+ public static int executeParse(String query) {
+ BufferedReader reader;
+ String line;
+ StringBuffer responseContent = new StringBuffer();
+ try {
+ URL url = new URL("https://wwwdev.ebi.ac.uk/pdbe/pdbe-kb/3dbeacons-hub-api/uniprot/summary/" + query + ".json");
+ connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("GET");
+ connection.setConnectTimeout(5000); // <=>5seconds
+ connection.setReadTimeout(5000);
+ // Status check up, 200 = connection succesful
+ int status = connection.getResponseCode();
+ // System.out.println(status);
+
+ if (status > 299) {
+ reader = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
+ while ((line = reader.readLine()) != null) {
+ responseContent.append(line);
+ }
+ reader.close();
+ } else {
+ reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ while ((line = reader.readLine()) != null) {
+ responseContent.append(line);
+ }
+ reader.close();
+ }
+ //System.out.println(responseContent.toString());
+ int seq = parse(responseContent.toString());
+ return seq;
+
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ connection.disconnect();
+ }
+ return (Integer) null;
+
+ }
+
+ public static int parse(String jsonString) {
+ JSONObject entry = new JSONObject(jsonString);
+ System.out.println(entry);
+ int length = entry.getJSONObject("uniprot_entry").getInt("sequence_length");
+ String ac = entry.getJSONObject("uniprot_entry").getString("ac");
+
+ JSONArray structures = entry.getJSONArray("structures");
+ for (int i=0 ; i < structures.length() ; i++) {
+ String id = structures.getJSONObject(i).getString("model_identifier");
+ //System.out.println("identifier num " + i + " : " + id);
+ }
+ System.out.println("length : " + length + "; access name : " + ac);
+ return length;
+
+}