From 1264492492895d589709a9b23ebf82e35a730198 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 29 Sep 2017 16:47:48 +0100 Subject: [PATCH] JAL-2745 JAL-2748 direct download of XML from uniprot.org --- src/jalview/ws/dbsources/Uniprot.java | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index c868576..fd68c12 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -31,13 +31,13 @@ import jalview.datamodel.SequenceI; import jalview.datamodel.xdb.uniprot.UniprotEntry; import jalview.datamodel.xdb.uniprot.UniprotFeature; import jalview.datamodel.xdb.uniprot.UniprotFile; -import jalview.ws.ebi.EBIFetchClient; import jalview.ws.seqfetcher.DbSourceProxyImpl; -import java.io.File; -import java.io.FileReader; +import java.io.InputStream; +import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; +import java.net.URLConnection; import java.util.ArrayList; import java.util.Vector; @@ -162,17 +162,21 @@ public class Uniprot extends DbSourceProxyImpl queries = queries.toUpperCase().replaceAll( "(UNIPROT\\|?|UNIPROT_|UNIREF\\d+_|UNIREF\\d+\\|?)", ""); AlignmentI al = null; - EBIFetchClient ebi = new EBIFetchClient(); - // uniprotxml parameter required since december 2007 - // uniprotkb dbname changed introduced december 2008 - File file = ebi.fetchDataAsFile("uniprotkb:" + queries, "uniprotxml", - "xml"); + + String downloadstring = "http://www.uniprot.org/uniprot/" + queries + + ".xml"; + URL url = null; + URLConnection urlconn = null; + + url = new URL(downloadstring); + urlconn = url.openConnection(); + InputStream istr = urlconn.getInputStream(); Vector entries = getUniprotEntries( - new FileReader(file)); + new InputStreamReader(istr, "UTF-8")); if (entries != null) { - ArrayList seqs = new ArrayList(); + ArrayList seqs = new ArrayList<>(); for (UniprotEntry entry : entries) { seqs.add(uniprotEntryToSequenceI(entry)); @@ -184,8 +188,10 @@ public class Uniprot extends DbSourceProxyImpl return al; } catch (Exception e) { - stopQuery(); throw (e); + } finally + { + stopQuery(); } } -- 1.7.10.2