X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fws%2Fsifts%2FSiftsClient.java;h=acca50f861973ce4a593a3193efc89d0644c9429;hb=4dc7619bed1c475c35f328601b5d7d46116327a6;hp=e08b8cbfe59b94513880406db9d7301c7170806b;hpb=49321390421afef1f818b3b1ec10badd83e95cc2;p=jalview.git diff --git a/src/jalview/ws/sifts/SiftsClient.java b/src/jalview/ws/sifts/SiftsClient.java index e08b8cb..acca50f 100644 --- a/src/jalview/ws/sifts/SiftsClient.java +++ b/src/jalview/ws/sifts/SiftsClient.java @@ -149,7 +149,6 @@ public class SiftsClient implements SiftsClientI siftsEntry = parseSIFTs(siftsFile); } - /** * Parse the given SIFTs File and return a JAXB POJO of parsed data * @@ -276,21 +275,21 @@ public class SiftsClient implements SiftsClientI { siftsDownloadDir.mkdirs(); } - // System.out.println(">> Download ftp url : " + siftsFileFTPURL); - URL url = new URL(siftsFileFTPURL); - URLConnection conn = url.openConnection(); - InputStream inputStream = conn.getInputStream(); - FileOutputStream outputStream = new FileOutputStream( - downloadedSiftsFile); - byte[] buffer = new byte[BUFFER_SIZE]; - int bytesRead = -1; - while ((bytesRead = inputStream.read(buffer)) != -1) - { - outputStream.write(buffer, 0, bytesRead); - } - outputStream.close(); - inputStream.close(); - // System.out.println(">>> File downloaded : " + downloadedSiftsFile); + // System.out.println(">> Download ftp url : " + siftsFileFTPURL); + URL url = new URL(siftsFileFTPURL); + URLConnection conn = url.openConnection(); + InputStream inputStream = conn.getInputStream(); + FileOutputStream outputStream = new FileOutputStream( + downloadedSiftsFile); + byte[] buffer = new byte[BUFFER_SIZE]; + int bytesRead = -1; + while ((bytesRead = inputStream.read(buffer)) != -1) + { + outputStream.write(buffer, 0, bytesRead); + } + outputStream.close(); + inputStream.close(); + // System.out.println(">>> File downloaded : " + downloadedSiftsFile); return new File(downloadedSiftsFile); } @@ -338,11 +337,10 @@ public class SiftsClient implements SiftsClientI { continue; } + String canonicalSource = DBRefUtils.getCanonicalName(dbRef + .getSource()); if (isValidDBRefEntry(dbRef) - && dbRef.isPrimary() - && (DBRefUtils.getCanonicalName(dbRef.getSource()) - .equalsIgnoreCase(DBRefSource.UNIPROT) || DBRefUtils - .getCanonicalName(dbRef.getSource()) + && (canonicalSource.equalsIgnoreCase(DBRefSource.UNIPROT) || canonicalSource .equalsIgnoreCase(DBRefSource.PDB))) { return dbRef; @@ -392,8 +390,8 @@ public class SiftsClient implements SiftsClientI String pdbFile, String chain) throws SiftsException { structId = (chain == null) ? pdbId : pdbId + "|" + chain; - System.out.println("Getting mapping for: " + pdbId + "|" + chain - + " : seq- " + seq.getName()); + System.out.println("Getting SIFTS mapping for " + structId + ": seq " + + seq.getName()); final StringBuilder mappingDetails = new StringBuilder(128); PrintStream ps = new PrintStream(System.out) @@ -472,12 +470,13 @@ public class SiftsClient implements SiftsClientI int pdbStart = UNASSIGNED; int pdbEnd = UNASSIGNED; - Integer[] keys = mapping.keySet().toArray(new Integer[0]); - Arrays.sort(keys); - if (keys.length < 1) + if (mapping.isEmpty()) { - throw new SiftsException(">>> Empty SIFTS mapping generated!!"); + throw new SiftsException("SIFTS mapping failed"); } + + Integer[] keys = mapping.keySet().toArray(new Integer[0]); + Arrays.sort(keys); seqStart = keys[0]; seqEnd = keys[keys.length - 1]; @@ -612,6 +611,7 @@ public class SiftsClient implements SiftsClientI } } } + /** * * @param chainId @@ -763,8 +763,6 @@ public class SiftsClient implements SiftsClientI } } - - @Override public Entity getEntityById(String id) throws SiftsException {