X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fdbsources%2FUniprot.java;h=371eb50bc227365a4e74ae147aa73ea94a0d6261;hb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;hp=b9fe52f607fa5d970405292dcb40478d3821d537;hpb=e7338a61f3ce96dadf44ac80b2b32cc5ba4b94c8;p=jalview.git diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index b9fe52f..371eb50 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -144,13 +144,12 @@ public class Uniprot extends DbSourceProxyImpl "(UNIPROT\\|?|UNIPROT_|UNIREF\\d+_|UNIREF\\d+\\|?)", ""); AlignmentI al = null; - String downloadstring = getDomain() + "/uniprot/" + queries - + ".xml"; + String downloadstring = getDomain() + "/uniprot/" + queries + ".xml"; URL url = new URL(downloadstring); - HttpURLConnection urlconn = (HttpURLConnection)url.openConnection(); + HttpURLConnection urlconn = (HttpURLConnection) url.openConnection(); // anything other than 200 means we don't have data - // TODO: JAL-3882 reuse the EnsemblRestClient's fair + // TODO: JAL-3882 reuse the EnsemblRestClient's fair // use/backoff logic to retry when the server tells us to go away if (urlconn.getResponseCode() == 200) { @@ -168,7 +167,7 @@ public class Uniprot extends DbSourceProxyImpl } stopQuery(); return al; - + } catch (Exception e) { throw (e); @@ -193,8 +192,7 @@ public class Uniprot extends DbSourceProxyImpl String seqString = entry.getSequence().getValue().replaceAll("\\s*", ""); - SequenceI sequence = new Sequence(id, - seqString); + SequenceI sequence = new Sequence(id, seqString); sequence.setDescription(getUniprotEntryDescription(entry)); /* @@ -202,12 +200,12 @@ public class Uniprot extends DbSourceProxyImpl */ final String dbVersion = getDbVersion(); List dbRefs = new ArrayList<>(); - boolean canonical=true; + boolean canonical = true; for (String accessionId : entry.getAccession()) { DBRefEntry dbRef = new DBRefEntry(DBRefSource.UNIPROT, dbVersion, - accessionId,null,canonical); - canonical=false; + accessionId, null, canonical); + canonical = false; dbRefs.add(dbRef); } @@ -512,10 +510,12 @@ public class Uniprot extends DbSourceProxyImpl XMLStreamReader streamReader = XMLInputFactory.newInstance() .createXMLStreamReader(is); javax.xml.bind.Unmarshaller um = jc.createUnmarshaller(); - JAXBElement uniprotElement = - um.unmarshal(streamReader, jalview.xml.binding.uniprot.Uniprot.class); - jalview.xml.binding.uniprot.Uniprot uniprot = uniprotElement.getValue(); - + JAXBElement uniprotElement = um + .unmarshal(streamReader, + jalview.xml.binding.uniprot.Uniprot.class); + jalview.xml.binding.uniprot.Uniprot uniprot = uniprotElement + .getValue(); + if (uniprot != null && !uniprot.getEntry().isEmpty()) { entries = uniprot.getEntry(); @@ -523,7 +523,10 @@ public class Uniprot extends DbSourceProxyImpl } catch (JAXBException | XMLStreamException | FactoryConfigurationError e) { - if (e instanceof javax.xml.bind.UnmarshalException && e.getCause()!=null && e.getCause() instanceof XMLStreamException && e.getCause().getMessage().contains("[row,col]:[1,1]")) + if (e instanceof javax.xml.bind.UnmarshalException + && e.getCause() != null + && e.getCause() instanceof XMLStreamException + && e.getCause().getMessage().contains("[row,col]:[1,1]")) { // trying to parse an empty stream return null;