File: use_simple_json

package info (click to toggle)
biojava4-live 4.2.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 107,220 kB
  • ctags: 31,849
  • sloc: java: 245,462; xml: 27,569; sh: 95; makefile: 72; python: 64
file content (55 lines) | stat: -rw-r--r-- 1,972 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Subject: use simple_json library
Author: Olivier Sallou <osallou@debian.org>
Description: json.org library is not "free", use simple_json
 library and update according to API
Last-Updated: 2012-12-02

--- a/biojava-ws/src/main/java/org/biojava/nbio/ws/hmmer/RemoteHmmerScan.java
+++ b/biojava-ws/src/main/java/org/biojava/nbio/ws/hmmer/RemoteHmmerScan.java
@@ -20,8 +20,10 @@
  */
 package org.biojava.nbio.ws.hmmer;
 
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
+
 import org.biojava.nbio.core.sequence.ProteinSequence;
 
 import java.io.*;
@@ -132,15 +134,13 @@
 
 		SortedSet<HmmerResult> results = new TreeSet<HmmerResult>();
 		try {
-			JSONObject json =  JSONObject.fromObject(result.toString());
-
-			JSONObject hmresults = json.getJSONObject("results");
-
+			JSONObject json= (JSONObject) JSONValue.parse(result.toString());
+			JSONObject hmresults = (JSONObject) json.get("results");
 
-			JSONArray hits = hmresults.getJSONArray("hits");
+			JSONArray hits = (JSONArray) hmresults.get("hits");
 
 			for(int i =0 ; i < hits.size() ; i++){
-				JSONObject hit = hits.getJSONObject(i);
+				JSONObject hit = (JSONObject) hits.get(i);
 				//System.out.println("hit: "+ hit);
 
 				HmmerResult hmmResult = new HmmerResult();
@@ -165,11 +165,11 @@
 				hmmResult.setPvalue((Double)hit.get("pvalue"));
 				hmmResult.setScore(Float.parseFloat((String)hit.get("score")));
 
-				JSONArray hmmdomains = hit.getJSONArray("domains");
+				JSONArray hmmdomains = (JSONArray) hit.get("domains");
 
 				SortedSet<HmmerDomain> domains = new TreeSet<HmmerDomain>();
 				for ( int j= 0 ; j < hmmdomains.size() ; j++){
-					JSONObject d = hmmdomains.getJSONObject(j);
+					JSONObject d = (JSONObject) hmmdomains.get(j);
 					//System.out.println(d);
 					Integer is_included = getInteger(d.get("is_included"));
 					if ( is_included == 0) {