| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.ws.dbsources; |
| 22 |
|
|
| 23 |
|
import java.io.InputStream; |
| 24 |
|
import java.net.HttpURLConnection; |
| 25 |
|
import java.net.URL; |
| 26 |
|
import java.util.ArrayList; |
| 27 |
|
import java.util.List; |
| 28 |
|
import java.util.Locale; |
| 29 |
|
import java.util.Vector; |
| 30 |
|
|
| 31 |
|
import javax.xml.bind.JAXBContext; |
| 32 |
|
import javax.xml.bind.JAXBElement; |
| 33 |
|
import javax.xml.bind.JAXBException; |
| 34 |
|
import javax.xml.stream.FactoryConfigurationError; |
| 35 |
|
import javax.xml.stream.XMLInputFactory; |
| 36 |
|
import javax.xml.stream.XMLStreamException; |
| 37 |
|
import javax.xml.stream.XMLStreamReader; |
| 38 |
|
|
| 39 |
|
import com.stevesoft.pat.Regex; |
| 40 |
|
|
| 41 |
|
import jalview.bin.Cache; |
| 42 |
|
import jalview.bin.Console; |
| 43 |
|
import jalview.datamodel.Alignment; |
| 44 |
|
import jalview.datamodel.AlignmentI; |
| 45 |
|
import jalview.datamodel.DBRefEntry; |
| 46 |
|
import jalview.datamodel.DBRefSource; |
| 47 |
|
import jalview.datamodel.PDBEntry; |
| 48 |
|
import jalview.datamodel.Sequence; |
| 49 |
|
import jalview.datamodel.SequenceFeature; |
| 50 |
|
import jalview.datamodel.SequenceI; |
| 51 |
|
import jalview.schemes.ResidueProperties; |
| 52 |
|
import jalview.util.HttpUtils; |
| 53 |
|
import jalview.util.StringUtils; |
| 54 |
|
import jalview.ws.seqfetcher.DbSourceProxyImpl; |
| 55 |
|
import jalview.xml.binding.uniprot.DbReferenceType; |
| 56 |
|
import jalview.xml.binding.uniprot.Entry; |
| 57 |
|
import jalview.xml.binding.uniprot.FeatureType; |
| 58 |
|
import jalview.xml.binding.uniprot.LocationType; |
| 59 |
|
import jalview.xml.binding.uniprot.PositionType; |
| 60 |
|
import jalview.xml.binding.uniprot.PropertyType; |
| 61 |
|
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
@author |
| 68 |
|
|
| 69 |
|
|
| |
|
| 71.2% |
Uncovered Elements: 74 (257) |
Complexity: 69 |
Complexity Density: 0.42 |
|
| 70 |
|
public class Uniprot extends DbSourceProxyImpl |
| 71 |
|
{ |
| 72 |
|
private static final String DEFAULT_UNIPROT_DOMAIN = "https://rest.uniprot.org"; |
| 73 |
|
|
| 74 |
|
private static final String BAR_DELIMITER = "|"; |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 79 |
22 |
public Uniprot()... |
| 80 |
|
{ |
| 81 |
22 |
super(); |
| 82 |
|
} |
| 83 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 84 |
0 |
private String getDomain()... |
| 85 |
|
{ |
| 86 |
0 |
return Cache.getDefault("UNIPROT_DOMAIN", DEFAULT_UNIPROT_DOMAIN); |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
@see |
| 93 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 94 |
0 |
@Override... |
| 95 |
|
public String getAccessionSeparator() |
| 96 |
|
{ |
| 97 |
0 |
return null; |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
@see |
| 104 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 105 |
0 |
@Override... |
| 106 |
|
public Regex getAccessionValidator() |
| 107 |
|
{ |
| 108 |
0 |
return new Regex("([A-Z]+[0-9]+[A-Z0-9]+|[A-Z0-9]+_[A-Z0-9]+)"); |
| 109 |
|
} |
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
@see |
| 115 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 116 |
2455 |
@Override... |
| 117 |
|
public String getDbSource() |
| 118 |
|
{ |
| 119 |
2455 |
return DBRefSource.UNIPROT; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
@see |
| 126 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 127 |
2 |
@Override... |
| 128 |
|
public String getDbVersion() |
| 129 |
|
{ |
| 130 |
2 |
return "0"; |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
@see |
| 137 |
|
|
| |
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 4 |
Complexity Density: 0.21 |
|
| 138 |
0 |
@Override... |
| 139 |
|
public AlignmentI getSequenceRecords(String queries) throws Exception |
| 140 |
|
{ |
| 141 |
0 |
startQuery(); |
| 142 |
0 |
try |
| 143 |
|
{ |
| 144 |
0 |
queries = queries.toUpperCase(Locale.ROOT).replaceAll( |
| 145 |
|
"(UNIPROT\\|?|UNIPROT_|UNIREF\\d+_|UNIREF\\d+\\|?)", ""); |
| 146 |
0 |
AlignmentI al = null; |
| 147 |
|
|
| 148 |
0 |
String downloadstring = getDomain() + "/uniprotkb/" + queries |
| 149 |
|
+ ".xml"; |
| 150 |
|
|
| 151 |
0 |
URL url = new URL(downloadstring); |
| 152 |
0 |
HttpURLConnection urlconn = (HttpURLConnection) HttpUtils |
| 153 |
|
.openConnection(url); |
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
0 |
if (urlconn.getResponseCode() == 200) |
| 158 |
|
{ |
| 159 |
0 |
InputStream istr = urlconn.getInputStream(); |
| 160 |
0 |
List<Entry> entries = getUniprotEntries(istr); |
| 161 |
0 |
if (entries != null) |
| 162 |
|
{ |
| 163 |
0 |
List<SequenceI> seqs = new ArrayList<>(); |
| 164 |
0 |
for (Entry entry : entries) |
| 165 |
|
{ |
| 166 |
0 |
seqs.add(uniprotEntryToSequence(entry)); |
| 167 |
|
} |
| 168 |
0 |
al = new Alignment(seqs.toArray(new SequenceI[seqs.size()])); |
| 169 |
|
} |
| 170 |
|
} |
| 171 |
0 |
stopQuery(); |
| 172 |
0 |
return al; |
| 173 |
|
|
| 174 |
|
} catch (Exception e) |
| 175 |
|
{ |
| 176 |
0 |
throw (e); |
| 177 |
|
} finally |
| 178 |
|
{ |
| 179 |
0 |
stopQuery(); |
| 180 |
|
} |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
|
| 184 |
|
|
| 185 |
|
|
| 186 |
|
@param |
| 187 |
|
@return |
| 188 |
|
|
| |
|
| 74.8% |
Uncovered Elements: 27 (107) |
Complexity: 22 |
Complexity Density: 0.3 |
|
| 189 |
2 |
SequenceI uniprotEntryToSequence(Entry entry)... |
| 190 |
|
{ |
| 191 |
2 |
String id = getUniprotEntryId(entry); |
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
2 |
String seqString = entry.getSequence().getValue().replaceAll("\\s*", |
| 196 |
|
""); |
| 197 |
|
|
| 198 |
2 |
SequenceI sequence = new Sequence(id, seqString); |
| 199 |
2 |
sequence.setDescription(getUniprotEntryDescription(entry)); |
| 200 |
2 |
final String uniprotRecordVersion = "" + entry.getVersion(); |
| 201 |
|
|
| 202 |
|
|
| 203 |
|
|
| 204 |
2 |
final String dbVersion = getDbVersion(); |
| 205 |
2 |
List<DBRefEntry> dbRefs = new ArrayList<>(); |
| 206 |
2 |
boolean canonical = true; |
| 207 |
2 |
for (String accessionId : entry.getAccession()) |
| 208 |
|
{ |
| 209 |
4 |
DBRefEntry dbRef = new DBRefEntry(DBRefSource.UNIPROT, |
| 210 |
|
uniprotRecordVersion, accessionId, null, canonical); |
| 211 |
4 |
canonical = false; |
| 212 |
4 |
dbRefs.add(dbRef); |
| 213 |
|
} |
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
2 |
Vector<PDBEntry> pdbRefs = new Vector<>(); |
| 222 |
2 |
for (DbReferenceType dbref : entry.getDbReference()) |
| 223 |
|
{ |
| 224 |
48 |
String type = dbref.getType(); |
| 225 |
48 |
DBRefEntry dbr = new DBRefEntry(type, |
| 226 |
|
DBRefSource.UNIPROT + ":" + dbVersion, dbref.getId()); |
| 227 |
48 |
dbRefs.add(dbr); |
| 228 |
48 |
if ("PDB".equals(type)) |
| 229 |
|
{ |
| 230 |
1 |
pdbRefs.add(new PDBEntry(dbr)); |
| 231 |
|
} |
| 232 |
48 |
if ("EMBL".equals(type)) |
| 233 |
|
{ |
| 234 |
|
|
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| 238 |
|
|
| 239 |
|
|
| 240 |
|
|
| 241 |
9 |
String cdsId = getProperty(dbref.getProperty(), |
| 242 |
|
"protein sequence ID"); |
| 243 |
9 |
if (cdsId != null && cdsId.trim().length() > 0) |
| 244 |
|
{ |
| 245 |
|
|
| 246 |
9 |
String[] vrs = cdsId.split("\\."); |
| 247 |
9 |
String version = vrs.length > 1 ? vrs[1] |
| 248 |
|
: DBRefSource.UNIPROT + ":" + uniprotRecordVersion; |
| 249 |
9 |
dbr = new DBRefEntry(DBRefSource.EMBLCDS, version, vrs[0]); |
| 250 |
|
|
| 251 |
|
|
| 252 |
9 |
dbr.setCanonical(true); |
| 253 |
9 |
dbRefs.add(dbr); |
| 254 |
|
} |
| 255 |
|
} |
| 256 |
48 |
if (type != null |
| 257 |
|
&& type.toLowerCase(Locale.ROOT).startsWith("ensembl")) |
| 258 |
|
{ |
| 259 |
|
|
| 260 |
0 |
String[] vrs = dbref.getId().split("\\."); |
| 261 |
0 |
String version = vrs.length > 1 ? vrs[1] |
| 262 |
|
: DBRefSource.UNIPROT + ":" + uniprotRecordVersion; |
| 263 |
0 |
dbr.setAccessionId(vrs[0]); |
| 264 |
0 |
dbr.setVersion(version); |
| 265 |
|
|
| 266 |
|
|
| 267 |
|
|
| 268 |
|
|
| 269 |
|
|
| 270 |
|
|
| 271 |
|
|
| 272 |
|
|
| 273 |
0 |
String cdsId = getProperty(dbref.getProperty(), |
| 274 |
|
"protein sequence ID"); |
| 275 |
0 |
if (cdsId != null && cdsId.trim().length() > 0) |
| 276 |
|
{ |
| 277 |
|
|
| 278 |
0 |
String[] cdsVrs = cdsId.split("\\."); |
| 279 |
0 |
String cdsVersion = cdsVrs.length > 1 ? cdsVrs[1] |
| 280 |
|
: DBRefSource.UNIPROT + ":" + uniprotRecordVersion; |
| 281 |
0 |
dbr = new DBRefEntry(DBRefSource.ENSEMBL, |
| 282 |
|
DBRefSource.UNIPROT + ":" + cdsVersion, cdsVrs[0]); |
| 283 |
0 |
dbRefs.add(dbr); |
| 284 |
|
} |
| 285 |
|
} |
| 286 |
|
} |
| 287 |
|
|
| 288 |
|
|
| 289 |
|
|
| 290 |
|
|
| 291 |
2 |
sequence.setPDBId(pdbRefs); |
| 292 |
2 |
if (entry.getFeature() != null) |
| 293 |
|
{ |
| 294 |
2 |
for (FeatureType uf : entry.getFeature()) |
| 295 |
|
{ |
| 296 |
21 |
LocationType location = uf.getLocation(); |
| 297 |
21 |
int start = 0; |
| 298 |
21 |
int end = 0; |
| 299 |
21 |
String uncertain_start = null, uncertain_end = null, |
| 300 |
|
uncertain_pos = null; |
| 301 |
21 |
if (location.getPosition() != null) |
| 302 |
|
{ |
| 303 |
8 |
if (location.getPosition().getPosition() == null |
| 304 |
|
|| "unknown".equals(location.getPosition().getStatus())) |
| 305 |
|
{ |
| 306 |
0 |
Console.warn( |
| 307 |
|
"Ignoring single position feature with uncertain location " |
| 308 |
|
+ uf.getType() + ":" + getDescription(uf)); |
| 309 |
0 |
uncertain_pos = location.getPosition().getStatus() == null |
| 310 |
|
? "unknown" |
| 311 |
|
: location.getPosition().getStatus(); |
| 312 |
|
} |
| 313 |
|
else |
| 314 |
|
{ |
| 315 |
8 |
start = location.getPosition().getPosition().intValue(); |
| 316 |
8 |
end = start; |
| 317 |
|
} |
| 318 |
|
} |
| 319 |
|
else |
| 320 |
|
{ |
| 321 |
13 |
if (location.getBegin().getPosition() == null) |
| 322 |
|
{ |
| 323 |
1 |
Console.warn( |
| 324 |
|
"Setting start position of feature with uncertain start to 1: " |
| 325 |
|
+ uf.getType() + ":" + getDescription(uf)); |
| 326 |
1 |
start = sequence.getStart(); |
| 327 |
1 |
uncertain_start = location.getBegin().getStatus(); |
| 328 |
|
} |
| 329 |
|
else |
| 330 |
|
{ |
| 331 |
12 |
start = location.getBegin().getPosition().intValue(); |
| 332 |
|
} |
| 333 |
13 |
if (location.getEnd().getPosition() == null) |
| 334 |
|
{ |
| 335 |
1 |
Console.warn( |
| 336 |
|
"Setting start position of feature with uncertain start to 1: " |
| 337 |
|
+ uf.getType() + ":" + getDescription(uf)); |
| 338 |
1 |
end = sequence.getEnd(); |
| 339 |
1 |
uncertain_end = location.getEnd().getStatus(); |
| 340 |
|
} |
| 341 |
|
else |
| 342 |
|
{ |
| 343 |
12 |
end = location.getEnd().getPosition().intValue(); |
| 344 |
|
} |
| 345 |
|
} |
| 346 |
21 |
SequenceFeature sf = new SequenceFeature(uf.getType(), |
| 347 |
|
getDescription(uf), start, end, "Uniprot"); |
| 348 |
21 |
sf.setStatus(uf.getStatus()); |
| 349 |
21 |
if (uncertain_end != null) |
| 350 |
|
{ |
| 351 |
1 |
sf.setValue("end_status", uncertain_end); |
| 352 |
|
} |
| 353 |
21 |
if (uncertain_start != null) |
| 354 |
|
{ |
| 355 |
1 |
sf.setValue("start_status", uncertain_start); |
| 356 |
|
} |
| 357 |
21 |
if (uncertain_pos != null) |
| 358 |
|
{ |
| 359 |
0 |
sf.setValue("pos_status", uncertain_pos); |
| 360 |
|
} |
| 361 |
21 |
sequence.addSequenceFeature(sf); |
| 362 |
|
} |
| 363 |
|
} |
| 364 |
2 |
for (DBRefEntry dbr : dbRefs) |
| 365 |
|
{ |
| 366 |
61 |
sequence.addDBRef(dbr); |
| 367 |
|
} |
| 368 |
2 |
return sequence; |
| 369 |
|
} |
| 370 |
|
|
| 371 |
|
|
| 372 |
|
|
| 373 |
|
|
| 374 |
|
@param |
| 375 |
|
@return |
| 376 |
|
|
| |
|
| 98.2% |
Uncovered Elements: 1 (56) |
Complexity: 15 |
Complexity Density: 0.44 |
|
| 377 |
35 |
static String getDescription(FeatureType feature)... |
| 378 |
|
{ |
| 379 |
35 |
String orig = feature.getOriginal(); |
| 380 |
35 |
List<String> variants = feature.getVariation(); |
| 381 |
35 |
StringBuilder sb = new StringBuilder(); |
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
|
| 386 |
|
|
| 387 |
|
|
| 388 |
35 |
boolean asHtml = false; |
| 389 |
35 |
if (orig != null && !orig.isEmpty() && variants != null |
| 390 |
|
&& !variants.isEmpty()) |
| 391 |
|
{ |
| 392 |
14 |
int p = 0; |
| 393 |
14 |
for (String var : variants) |
| 394 |
|
{ |
| 395 |
|
|
| 396 |
|
|
| 397 |
|
|
| 398 |
|
|
| 399 |
|
|
| 400 |
21 |
sb.append("p."); |
| 401 |
21 |
if (orig.length() < 4) |
| 402 |
|
{ |
| 403 |
36 |
for (int c = 0, clen = orig.length(); c < clen; c++) |
| 404 |
|
{ |
| 405 |
21 |
char origchar = orig.charAt(c); |
| 406 |
21 |
String orig3 = ResidueProperties.aa2Triplet.get("" + origchar); |
| 407 |
21 |
sb.append(orig3 == null ? origchar |
| 408 |
|
: StringUtils.toSentenceCase(orig3)); |
| 409 |
|
} |
| 410 |
|
} |
| 411 |
|
else |
| 412 |
|
{ |
| 413 |
6 |
sb.append(orig); |
| 414 |
|
} |
| 415 |
|
|
| 416 |
21 |
LocationType location = feature.getLocation(); |
| 417 |
21 |
PositionType start = location.getPosition() == null |
| 418 |
|
? location.getBegin() |
| 419 |
|
: location.getPosition(); |
| 420 |
21 |
sb.append(Integer.toString(start.getPosition().intValue())); |
| 421 |
|
|
| 422 |
21 |
if (var.length() < 4) |
| 423 |
|
{ |
| 424 |
52 |
for (int c = 0, clen = var.length(); c < clen; c++) |
| 425 |
|
{ |
| 426 |
34 |
char varchar = var.charAt(c); |
| 427 |
34 |
String var3 = ResidueProperties.aa2Triplet.get("" + varchar); |
| 428 |
|
|
| 429 |
34 |
sb.append(var3 != null ? StringUtils.toSentenceCase(var3) |
| 430 |
|
: "" + varchar); |
| 431 |
|
} |
| 432 |
|
} |
| 433 |
|
else |
| 434 |
|
{ |
| 435 |
3 |
sb.append(var); |
| 436 |
|
} |
| 437 |
21 |
if (++p != variants.size()) |
| 438 |
|
{ |
| 439 |
7 |
sb.append("<br/> "); |
| 440 |
7 |
asHtml = true; |
| 441 |
|
} |
| 442 |
|
else |
| 443 |
|
{ |
| 444 |
14 |
sb.append(" "); |
| 445 |
|
} |
| 446 |
|
} |
| 447 |
|
} |
| 448 |
35 |
String description = feature.getDescription(); |
| 449 |
35 |
if (description != null) |
| 450 |
|
{ |
| 451 |
26 |
sb.append(description); |
| 452 |
|
} |
| 453 |
35 |
if (asHtml) |
| 454 |
|
{ |
| 455 |
7 |
sb.insert(0, "<html>"); |
| 456 |
7 |
sb.append("</html>"); |
| 457 |
|
} |
| 458 |
|
|
| 459 |
35 |
return sb.toString(); |
| 460 |
|
} |
| 461 |
|
|
| 462 |
|
|
| 463 |
|
|
| 464 |
|
|
| 465 |
|
|
| 466 |
|
@param |
| 467 |
|
@param |
| 468 |
|
@return |
| 469 |
|
|
| |
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 470 |
13 |
static String getProperty(List<PropertyType> properties, String key)... |
| 471 |
|
{ |
| 472 |
13 |
String value = null; |
| 473 |
13 |
if (properties != null) |
| 474 |
|
{ |
| 475 |
13 |
for (PropertyType prop : properties) |
| 476 |
|
{ |
| 477 |
15 |
if (key.equals(prop.getType())) |
| 478 |
|
{ |
| 479 |
13 |
value = prop.getValue(); |
| 480 |
13 |
break; |
| 481 |
|
} |
| 482 |
|
} |
| 483 |
|
} |
| 484 |
13 |
return value; |
| 485 |
|
} |
| 486 |
|
|
| 487 |
|
|
| 488 |
|
|
| 489 |
|
|
| 490 |
|
@param |
| 491 |
|
@return |
| 492 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 493 |
3 |
static String getUniprotEntryDescription(Entry entry)... |
| 494 |
|
{ |
| 495 |
3 |
String desc = ""; |
| 496 |
3 |
if (entry.getProtein() != null |
| 497 |
|
&& entry.getProtein().getRecommendedName() != null) |
| 498 |
|
{ |
| 499 |
|
|
| 500 |
3 |
desc = entry.getProtein().getRecommendedName().getFullName() |
| 501 |
|
.getValue(); |
| 502 |
|
} |
| 503 |
3 |
return desc; |
| 504 |
|
} |
| 505 |
|
|
| 506 |
|
|
| 507 |
|
|
| 508 |
|
|
| 509 |
|
|
| 510 |
|
@param |
| 511 |
|
@return |
| 512 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 513 |
3 |
static String getUniprotEntryId(Entry entry)... |
| 514 |
|
{ |
| 515 |
3 |
StringBuilder name = new StringBuilder(32); |
| 516 |
3 |
for (String n : entry.getName()) |
| 517 |
|
{ |
| 518 |
5 |
if (name.length() > 0) |
| 519 |
|
{ |
| 520 |
2 |
name.append(BAR_DELIMITER); |
| 521 |
|
} |
| 522 |
5 |
name.append(n); |
| 523 |
|
} |
| 524 |
3 |
return name.toString(); |
| 525 |
|
} |
| 526 |
|
|
| 527 |
|
|
| 528 |
|
|
| 529 |
|
|
| 530 |
|
@see |
| 531 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 3 |
Complexity Density: 3 |
|
| 532 |
0 |
@Override... |
| 533 |
|
public boolean isValidReference(String accession) |
| 534 |
|
{ |
| 535 |
|
|
| 536 |
0 |
return (accession == null || accession.length() < 2) ? false |
| 537 |
|
: getAccessionValidator().search(accession); |
| 538 |
|
} |
| 539 |
|
|
| 540 |
|
|
| 541 |
|
|
| 542 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 543 |
0 |
@Override... |
| 544 |
|
public String getTestQuery() |
| 545 |
|
{ |
| 546 |
0 |
return "P00340"; |
| 547 |
|
} |
| 548 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 549 |
2439 |
@Override... |
| 550 |
|
public String getDbName() |
| 551 |
|
{ |
| 552 |
2439 |
return "Uniprot"; |
| 553 |
|
} |
| 554 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 555 |
0 |
@Override... |
| 556 |
|
public int getTier() |
| 557 |
|
{ |
| 558 |
0 |
return 0; |
| 559 |
|
} |
| 560 |
|
|
| 561 |
|
|
| 562 |
|
|
| 563 |
|
|
| 564 |
|
|
| 565 |
|
|
| 566 |
|
@param |
| 567 |
|
@return |
| 568 |
|
|
| |
|
| 64.7% |
Uncovered Elements: 6 (17) |
Complexity: 8 |
Complexity Density: 0.62 |
|
| 569 |
5 |
public List<Entry> getUniprotEntries(InputStream is)... |
| 570 |
|
{ |
| 571 |
5 |
List<Entry> entries = null; |
| 572 |
5 |
try |
| 573 |
|
{ |
| 574 |
5 |
JAXBContext jc = JAXBContext |
| 575 |
|
.newInstance("jalview.xml.binding.uniprot"); |
| 576 |
5 |
XMLStreamReader streamReader = XMLInputFactory.newInstance() |
| 577 |
|
.createXMLStreamReader(is); |
| 578 |
5 |
javax.xml.bind.Unmarshaller um = jc.createUnmarshaller(); |
| 579 |
5 |
JAXBElement<jalview.xml.binding.uniprot.Uniprot> uniprotElement = um |
| 580 |
|
.unmarshal(streamReader, |
| 581 |
|
jalview.xml.binding.uniprot.Uniprot.class); |
| 582 |
5 |
jalview.xml.binding.uniprot.Uniprot uniprot = uniprotElement |
| 583 |
|
.getValue(); |
| 584 |
|
|
| 585 |
5 |
if (uniprot != null && !uniprot.getEntry().isEmpty()) |
| 586 |
|
{ |
| 587 |
5 |
entries = uniprot.getEntry(); |
| 588 |
|
} |
| 589 |
|
} catch (JAXBException | XMLStreamException |
| 590 |
|
| FactoryConfigurationError e) |
| 591 |
|
{ |
| 592 |
0 |
if (e instanceof javax.xml.bind.UnmarshalException |
| 593 |
|
&& e.getCause() != null |
| 594 |
|
&& e.getCause() instanceof XMLStreamException |
| 595 |
|
&& e.getCause().getMessage().contains("[row,col]:[1,1]")) |
| 596 |
|
{ |
| 597 |
|
|
| 598 |
0 |
return null; |
| 599 |
|
} |
| 600 |
0 |
e.printStackTrace(); |
| 601 |
|
} |
| 602 |
5 |
return entries; |
| 603 |
|
} |
| 604 |
|
} |