From: Jim Procter Date: Fri, 29 Sep 2017 15:47:48 +0000 (+0100) Subject: JAL-2745 JAL-2748 direct download of XML from uniprot.org X-Git-Tag: Release_2_10_2b2^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=79c9d10d17b3ddf75110ab44a43cf12505baa7dd;p=jalview.git JAL-2745 JAL-2748 direct download of XML from uniprot.org patch for 2.10.2b1 branch --- diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index 30808fb..686cd83 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -30,13 +30,13 @@ import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.datamodel.UniprotEntry; import jalview.datamodel.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; @@ -161,17 +161,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)); @@ -183,8 +187,10 @@ public class Uniprot extends DbSourceProxyImpl return al; } catch (Exception e) { - stopQuery(); throw (e); + } finally + { + stopQuery(); } }