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