1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ext.ensembl; |
22 |
|
|
23 |
|
import jalview.datamodel.AlignmentI; |
24 |
|
import jalview.datamodel.DBRefSource; |
25 |
|
import jalview.util.JSONUtils; |
26 |
|
|
27 |
|
import java.io.BufferedReader; |
28 |
|
import java.io.IOException; |
29 |
|
import java.net.MalformedURLException; |
30 |
|
import java.net.URL; |
31 |
|
import java.util.HashMap; |
32 |
|
import java.util.Iterator; |
33 |
|
import java.util.List; |
34 |
|
import java.util.Map; |
35 |
|
import java.util.Set; |
36 |
|
|
37 |
|
import org.json.simple.parser.ParseException; |
38 |
|
|
|
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 13 |
Complexity Density: 0.65 |
|
39 |
|
public class EnsemblInfo extends EnsemblRestClient |
40 |
|
{ |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
private static Map<String, String> divisions; |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
0 |
@Override... |
60 |
|
public String getDbName() |
61 |
|
{ |
62 |
0 |
return "ENSEMBL"; |
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
0 |
@Override... |
66 |
|
public AlignmentI getSequenceRecords(String queries) throws Exception |
67 |
|
{ |
68 |
0 |
return null; |
69 |
|
} |
70 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
0 |
@Override... |
72 |
|
protected URL getUrl(List<String> ids) throws MalformedURLException |
73 |
|
{ |
74 |
0 |
return null; |
75 |
|
} |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
0 |
@Override... |
78 |
|
protected boolean useGetRequest() |
79 |
|
{ |
80 |
0 |
return true; |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
@param |
89 |
|
@return |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
91 |
0 |
public String getDomain(String division)... |
92 |
|
{ |
93 |
0 |
if (divisions == null) |
94 |
|
{ |
95 |
0 |
fetchDivisions(); |
96 |
|
} |
97 |
0 |
return divisions.get(division.toUpperCase()); |
98 |
|
} |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
104 |
0 |
void fetchDivisions()... |
105 |
|
{ |
106 |
0 |
divisions = new HashMap<>(); |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
0 |
divisions.put(DBRefSource.ENSEMBL.toUpperCase(), ensemblDomain); |
112 |
0 |
try |
113 |
|
{ |
114 |
0 |
@SuppressWarnings("unchecked") |
115 |
|
Iterator<Object> rvals = (Iterator<Object>) getJSON(getDivisionsUrl(ensemblGenomesDomain), null, -1, MODE_ITERATOR, null); |
116 |
0 |
if (rvals == null) |
117 |
0 |
return; |
118 |
0 |
while (rvals.hasNext()) |
119 |
|
{ |
120 |
0 |
String division = rvals.next().toString(); |
121 |
0 |
divisions.put(division.toUpperCase(), ensemblGenomesDomain); |
122 |
|
} |
123 |
|
} catch (IOException | ParseException | NumberFormatException e) |
124 |
|
{ |
125 |
|
|
126 |
|
} |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
@param |
132 |
|
|
133 |
|
@return |
134 |
|
@throws |
135 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
136 |
0 |
URL getDivisionsUrl(String domain) throws MalformedURLException... |
137 |
|
{ |
138 |
0 |
return new URL(domain |
139 |
|
+ "/info/divisions?content-type=application/json"); |
140 |
|
} |
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
@return |
146 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
147 |
0 |
public Set<String> getDivisions() {... |
148 |
0 |
if (divisions == null) |
149 |
|
{ |
150 |
0 |
fetchDivisions(); |
151 |
|
} |
152 |
|
|
153 |
0 |
return divisions.keySet(); |
154 |
|
} |
155 |
|
} |