X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblXref.java;h=77768a6fa94243a7b354545010333b6547370e36;hb=f59dd9efbb3dfc313ab0b0507832e21cd0076fe1;hp=313572f0639e01419292a35d3464dd232958cb55;hpb=76de4fc452184b56e01960d05cb2235b1807e836;p=jalview.git diff --git a/src/jalview/ext/ensembl/EnsemblXref.java b/src/jalview/ext/ensembl/EnsemblXref.java index 313572f..77768a6 100644 --- a/src/jalview/ext/ensembl/EnsemblXref.java +++ b/src/jalview/ext/ensembl/EnsemblXref.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.ext.ensembl; import jalview.datamodel.AlignmentI; @@ -41,7 +61,7 @@ class EnsemblXref extends EnsemblRestClient super(d); dbName = dbSource; xrefVersion = dbSource + ":" + version; - + } @Override @@ -68,18 +88,6 @@ class EnsemblXref extends EnsemblRestClient return true; } - @Override - protected String getRequestMimeType(boolean multipleIds) - { - return "application/json"; - } - - @Override - protected String getResponseMimeType() - { - return "application/json"; - } - /** * Calls the Ensembl xrefs REST endpoint and retrieves any cross-references * ("primary_id") for the given identifier (Ensembl accession id) and database @@ -93,8 +101,8 @@ class EnsemblXref extends EnsemblRestClient */ public List getCrossReferences(String identifier) { - List result = new ArrayList(); - List ids = new ArrayList(); + List result = new ArrayList<>(); + List ids = new ArrayList<>(); ids.add(identifier); BufferedReader br = null; @@ -104,8 +112,11 @@ class EnsemblXref extends EnsemblRestClient if (url != null) { br = getHttpResponse(url, ids); + if (br != null) + { + result = parseResponse(br); + } } - return (parseResponse(br)); } catch (IOException e) { // ignore @@ -140,7 +151,7 @@ class EnsemblXref extends EnsemblRestClient throws IOException { JSONParser jp = new JSONParser(); - List result = new ArrayList(); + List result = new ArrayList<>(); try { JSONArray responses = (JSONArray) jp.parse(br); @@ -148,16 +159,13 @@ class EnsemblXref extends EnsemblRestClient while (rvals.hasNext()) { JSONObject val = (JSONObject) rvals.next(); - String dbName = val.get("dbname").toString(); - if (dbName.equals(GO_GENE_ONTOLOGY)) - { - continue; - } + String db = val.get("dbname").toString(); String id = val.get("primary_id").toString(); - if (dbName != null && id != null) + if (db != null && id != null + && !GO_GENE_ONTOLOGY.equals(db)) { - dbName = DBRefUtils.getCanonicalName(dbName); - DBRefEntry dbref = new DBRefEntry(dbName, getXRefVersion(), id); + db = DBRefUtils.getCanonicalName(db); + DBRefEntry dbref = new DBRefEntry(db, getXRefVersion(), id); result.add(dbref); } } @@ -191,7 +199,7 @@ class EnsemblXref extends EnsemblRestClient protected URL getUrl(String identifier) { String url = getDomain() + "/xrefs/id/" + identifier - + "?content-type=application/json&all_levels=1"; + + CONTENT_TYPE_JSON + "&all_levels=1"; try { return new URL(url);