File: use_simple_json

package info (click to toggle)
biojava4-live 4.2.12%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 107,308 kB
  • sloc: java: 246,191; xml: 27,590; sh: 95; makefile: 81; python: 64
file content (55 lines) | stat: -rw-r--r-- 1,957 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 org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -136,15 +138,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);
 
 				HmmerResult hmmResult = new HmmerResult();
 
@@ -168,11 +168,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);
 					Integer is_included = getInteger(d.get("is_included"));
 					if ( is_included == 0) {
 						continue;