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.io.IOException; |
24 |
|
import java.net.MalformedURLException; |
25 |
|
import java.net.URL; |
26 |
|
import java.util.ArrayList; |
27 |
|
import java.util.Iterator; |
28 |
|
import java.util.List; |
29 |
|
import java.util.Map; |
30 |
|
|
31 |
|
import org.json.simple.parser.ParseException; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@see |
37 |
|
@author |
38 |
|
|
39 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 12 |
Complexity Density: 0.39 |
|
40 |
|
public class EnsemblSymbol extends EnsemblXref |
41 |
|
{ |
42 |
|
private static final String GENE = "gene"; |
43 |
|
|
44 |
|
private static final String TYPE = "type"; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@param |
50 |
|
@param |
51 |
|
@param |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
53 |
0 |
public EnsemblSymbol(String domain, String dbName, String dbVersion)... |
54 |
|
{ |
55 |
0 |
super(domain, dbName, dbVersion); |
56 |
|
} |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
@param |
75 |
|
|
76 |
|
@param |
77 |
|
|
78 |
|
@param |
79 |
|
|
80 |
|
|
81 |
|
@return |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
83 |
0 |
protected URL getUrl(String id, Species species, String... type)... |
84 |
|
{ |
85 |
0 |
StringBuilder sb = new StringBuilder(); |
86 |
0 |
sb.append(getDomain()).append("/xrefs/symbol/") |
87 |
|
.append(species.toString()).append("/").append(id) |
88 |
|
.append(CONTENT_TYPE_JSON); |
89 |
0 |
for (String t : type) |
90 |
|
{ |
91 |
0 |
sb.append("&object_type=").append(t); |
92 |
|
} |
93 |
0 |
try |
94 |
|
{ |
95 |
0 |
String url = sb.toString(); |
96 |
0 |
return new URL(url); |
97 |
|
} catch (MalformedURLException e) |
98 |
|
{ |
99 |
0 |
return null; |
100 |
|
} |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
@param |
108 |
|
@return |
109 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 9 |
Complexity Density: 0.41 |
|
110 |
0 |
@SuppressWarnings("unchecked")... |
111 |
|
public List<String> getGeneIds(String identifier) |
112 |
|
{ |
113 |
0 |
List<String> result = new ArrayList<String>(); |
114 |
0 |
List<String> ids = new ArrayList<String>(); |
115 |
0 |
ids.add(identifier); |
116 |
|
|
117 |
0 |
String[] queries = identifier.split(getAccessionSeparator()); |
118 |
0 |
try |
119 |
|
{ |
120 |
0 |
for (String query : queries) |
121 |
|
{ |
122 |
0 |
for (Species taxon : Species.getModelOrganisms()) |
123 |
|
{ |
124 |
0 |
String geneId = null; |
125 |
0 |
try |
126 |
|
{ |
127 |
0 |
Iterator<Object> rvals = (Iterator<Object>) getJSON( |
128 |
|
getUrl(query, taxon, GENE), ids, -1, MODE_ITERATOR, |
129 |
|
null); |
130 |
0 |
if (rvals == null) |
131 |
0 |
continue; |
132 |
0 |
while (rvals.hasNext()) |
133 |
|
{ |
134 |
0 |
Map<String, Object> val = (Map<String, Object>) rvals.next(); |
135 |
0 |
String id = val.get(JSON_ID).toString(); |
136 |
0 |
String type = val.get(TYPE).toString(); |
137 |
0 |
if (id != null && GENE.equals(type)) |
138 |
|
{ |
139 |
0 |
geneId = id; |
140 |
0 |
break; |
141 |
|
} |
142 |
|
} |
143 |
|
} catch (ParseException e) |
144 |
|
{ |
145 |
|
|
146 |
|
} |
147 |
|
|
148 |
0 |
if (geneId != null && !result.contains(geneId)) |
149 |
|
{ |
150 |
0 |
result.add(geneId); |
151 |
|
} |
152 |
|
} |
153 |
|
} |
154 |
|
} catch (IOException e) |
155 |
|
{ |
156 |
|
|
157 |
|
} |
158 |
0 |
return result; |
159 |
|
} |
160 |
|
|
161 |
|
} |