From: tcofoegbu Date: Tue, 22 Mar 2016 17:02:10 +0000 (+0000) Subject: resolve conflict with Mungo's merge X-Git-Tag: Release_2_10_0~290 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9fe87bd08ab29b6fe53364f387d7a2e3a8d39994;hp=-c;p=jalview.git resolve conflict with Mungo's merge --- 9fe87bd08ab29b6fe53364f387d7a2e3a8d39994 diff --combined src/jalview/ws/dbsources/EmblXmlSource.java index d063247,4041606..0085221 --- a/src/jalview/ws/dbsources/EmblXmlSource.java +++ b/src/jalview/ws/dbsources/EmblXmlSource.java @@@ -29,14 -29,15 +29,15 @@@ import jalview.util.MessageManager import jalview.ws.ebi.EBIFetchClient; import java.io.File; + import java.util.ArrayList; + import java.util.List; public abstract class EmblXmlSource extends EbiFileRetrievedProxy { - - /** - * Last properly parsed embl file. + /* + * JAL-1856 Embl returns this text for query not found */ - public EmblFile efile = null; + private static final String EMBL_NOT_FOUND_REPLY = "ERROR 12 No entries found."; public EmblXmlSource() { @@@ -62,8 -63,7 +63,8 @@@ try { reply = dbFetch.fetchDataAsFile( - emprefx.toLowerCase() + ":" + query.trim(), "emblxml", null); + emprefx.toLowerCase() + ":" + query.trim(), "emblxml", null, + ".xml"); } catch (Exception e) { stopQuery(); @@@ -89,68 -89,36 +90,36 @@@ public AlignmentI getEmblSequenceRecords(String emprefx, String query, File reply) throws Exception { - SequenceI seqs[] = null; - StringBuffer result = new StringBuffer(); + EmblFile efile = null; + List seqs = new ArrayList(); + if (reply != null && reply.exists()) { - efile = null; file = reply.getAbsolutePath(); - if (reply.length() > 25) + if (reply.length() > EMBL_NOT_FOUND_REPLY.length()) { efile = EmblFile.getEmblFile(reply); } - else - { - result.append(MessageManager.formatMessage( - "label.no_embl_record_found", - new String[] { emprefx.toLowerCase(), query.trim() })); - } } + + List peptides = new ArrayList(); if (efile != null) { for (EmblEntry entry : efile.getEntries()) { - SequenceI[] seqparts = entry.getSequences(false, true, emprefx); - // TODO: use !fetchNa,!fetchPeptide here instead - see todo in EmblEntry - if (seqparts != null) + SequenceI seq = entry.getSequence(emprefx, peptides); + if (seq != null) { - SequenceI[] newseqs = null; - int si = 0; - if (seqs == null) - { - newseqs = new SequenceI[seqparts.length]; - } - else - { - newseqs = new SequenceI[seqs.length + seqparts.length]; - - for (; si < seqs.length; si++) - { - newseqs[si] = seqs[si]; - seqs[si] = null; - } - } - for (int j = 0; j < seqparts.length; si++, j++) - { - newseqs[si] = seqparts[j].deriveSequence(); - // place DBReferences on dataset and refer - } - seqs = newseqs; - + seqs.add(seq.deriveSequence()); + // place DBReferences on dataset and refer } } } - else - { - result = null; - } + AlignmentI al = null; - if (seqs != null && seqs.length > 0) + if (!seqs.isEmpty()) { - al = new Alignment(seqs); - result.append(MessageManager.formatMessage( - "label.embl_successfully_parsed", new String[] { emprefx })); - results = result; + al = new Alignment(seqs.toArray(new SequenceI[seqs.size()])); } stopQuery(); return al; diff --combined src/jalview/ws/ebi/EBIFetchClient.java index 468b7f0,b09cbaa..9f6bc65 --- a/src/jalview/ws/ebi/EBIFetchClient.java +++ b/src/jalview/ws/ebi/EBIFetchClient.java @@@ -20,6 -20,7 +20,7 @@@ */ package jalview.ws.ebi; + import jalview.datamodel.DBRefSource; import jalview.util.MessageManager; import java.io.BufferedInputStream; @@@ -90,22 -91,22 +91,24 @@@ public class EBIFetchClien * * @param ids * the query formatted as db:query1;query2;query3 - * @param f + * @param format * the format wanted * @param s * - unused parameter * @return the file holding the response * @throws OutOfMemoryError */ - public File fetchDataAsFile(String ids, String f, String s, String ext) - public File fetchDataAsFile(String ids, String format, String s) ++ ++ public File fetchDataAsFile(String ids, String format, String s, ++ String ext) throws OutOfMemoryError { File outFile = null; try { - outFile = File.createTempFile("jalview", ".xml"); + outFile = File.createTempFile("jalview", ext); outFile.deleteOnExit(); - fetchData(ids, f, s, outFile); + fetchData(ids, format, s, outFile); if (outFile.length() == 0) { outFile.delete(); @@@ -122,20 -123,20 +125,20 @@@ * * @param ids * db:query1;query2;query3 - * @param f + * @param format * raw/xml * @param s * not used - remove? * * @return Raw string array result of query set */ - public String[] fetchData(String ids, String f, String s) + public String[] fetchData(String ids, String format, String s) throws OutOfMemoryError { - return fetchData(ids, f, s, null); + return fetchData(ids, format, s, null); } - public String[] fetchData(String ids, String f, String s, File outFile) + String[] fetchData(String ids, String f, String s, File outFile) throws OutOfMemoryError { // Need to split @@@ -183,16 -184,27 +186,27 @@@ return (rslts.length == 0 ? null : rslts); } - public String[] fetchBatch(String ids, String db, String f, String s, + public String[] fetchBatch(String ids, String dbPath, String format, String s, File outFile) throws OutOfMemoryError { - long time = System.currentTimeMillis(); - // max 200 ids can be added at one time + // long time = System.currentTimeMillis(); + /* + * JAL-1855 dbfetch from ena_sequence, ena_coding + */ + if (dbPath.equalsIgnoreCase(DBRefSource.EMBL)) + { + dbPath = "ena_sequence"; + } + else if (dbPath.equalsIgnoreCase(DBRefSource.EMBLCDS)) + { + dbPath = "ena_coding"; + } + try { URL rcall = new URL("http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/" - + db.toLowerCase() + "/" + ids.toLowerCase() - + (f != null ? "/" + f : "")); + + dbPath.toLowerCase() + "/" + ids.toLowerCase() + + (format != null ? "/" + format : "")); InputStream is = new BufferedInputStream(rcall.openStream()); if (outFile != null) @@@ -221,7 -233,7 +235,7 @@@ } catch (OutOfMemoryError er) { - System.out.println("OUT OF MEMORY DOWNLOADING QUERY FROM " + db + System.out.println("OUT OF MEMORY DOWNLOADING QUERY FROM " + dbPath + ":\n" + ids); throw er; } catch (Exception ex) @@@ -231,14 -243,15 +245,15 @@@ { return null; } - System.err.println("Unexpected exception when retrieving from " + db + System.err.println("Unexpected exception when retrieving from " + + dbPath + "\nQuery was : '" + ids + "'"); ex.printStackTrace(System.err); return null; } finally { - // System.err.println("Took " + (System.currentTimeMillis() - time) - // / 1000 + " secs for one call."); + // System.err.println("EBIFetch took " + (System.currentTimeMillis() - + // time) + " ms"); } return null; }