From: jprocter Date: Fri, 8 Jul 2011 14:59:02 +0000 (+0100) Subject: open each query result from an alignment datasource as a X-Git-Tag: Release_2_7~142 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=56d8f0b05df600ea54388d58cf505d911beb630a;p=jalview.git open each query result from an alignment datasource as a different alignment (JAL-865) --- diff --git a/src/jalview/datamodel/DBRefSource.java b/src/jalview/datamodel/DBRefSource.java index b9442df..e060b54 100755 --- a/src/jalview/datamodel/DBRefSource.java +++ b/src/jalview/datamodel/DBRefSource.java @@ -125,4 +125,9 @@ public class DBRefSource * time. */ public static final Object MULTIACC = "MULTIACC"; + + /** + * DB query returns an alignment for each accession provided. + */ + public static final Object ALIGNMENTDB = "ALIGNMENTS"; } diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index b7cccf7..14c0a00 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -444,9 +444,11 @@ public class SequenceFetcher extends JPanel implements Runnable resetDialog(); return; } - AlignmentI aresult = null; + ArrayList aresultq=new ArrayList(); + ArrayList aresult = new ArrayList(); Object source = database.getSelectedItem(); Enumeration en = new StringTokenizer(textArea.getText(), ";"); + boolean isAliSource=false; try { guiWindow.setProgressBar( @@ -454,6 +456,7 @@ public class SequenceFetcher extends JPanel implements Runnable Thread.currentThread().hashCode()); DbSourceProxy proxy = sfetch.getSourceProxy((String) sources .get(source)); + isAliSource = proxy.isA(DBRefSource.ALIGNMENTDB); if (proxy.getAccessionSeparator() == null) { while (en.hasMoreElements()) @@ -485,14 +488,8 @@ public class SequenceFetcher extends JPanel implements Runnable } if (indres != null) { - if (aresult == null) - { - aresult = indres; - } - else - { - aresult.append(indres); - } + aresultq.add(item); + aresult.add(indres); } } catch (Exception e) { @@ -514,7 +511,8 @@ public class SequenceFetcher extends JPanel implements Runnable } try { - aresult = proxy.getSequenceRecords(multiacc.toString()); + aresultq.add(multiacc.toString()); + aresult.add(proxy.getSequenceRecords(multiacc.toString())); } catch (OutOfMemoryError oome) { new OOMWarning("fetching " + multiacc + " from " @@ -547,9 +545,24 @@ public class SequenceFetcher extends JPanel implements Runnable + " from " + database.getSelectedItem()); e.printStackTrace(); } - if (aresult != null) + if (aresult != null && aresult.size()>0) { - parseResult(aresult, null, null); + AlignmentI ar=null; + if (isAliSource) { + // new window for each result + while (aresult.size()>0) + { + parseResult(aresult.remove(0), aresultq.remove(0)+" "+getDefaultRetrievalTitle(), null); + } + } else { + // concatenate all results in one window + while (aresult.size()>0) + { + if (ar==null) { ar = aresult.remove(0);} + else { ar.append(aresult.remove(0)); }; + } + parseResult(ar, null, null); + } } // only remove visual delay after we finished parsing. guiWindow.setProgressBar(null, Thread.currentThread().hashCode()); @@ -728,6 +741,13 @@ public class SequenceFetcher extends JPanel implements Runnable return null; } + /** + * + * @return a standard title for any results retrieved using the currently selected source and settings + */ + public String getDefaultRetrievalTitle() { + return "Retrieved from " + database.getSelectedItem(); + } AlignmentI parseResult(AlignmentI al, String title, String currentFileFormat) { @@ -748,7 +768,7 @@ public class SequenceFetcher extends JPanel implements Runnable if (title == null) { - title = "Retrieved from " + database.getSelectedItem(); + title = getDefaultRetrievalTitle(); } SequenceFeature[] sfs = null; for (Enumeration sq = al.getSequences().elements(); sq diff --git a/src/jalview/ws/dbsources/Pfam.java b/src/jalview/ws/dbsources/Pfam.java index 834dd12..1b2a0c4 100644 --- a/src/jalview/ws/dbsources/Pfam.java +++ b/src/jalview/ws/dbsources/Pfam.java @@ -46,6 +46,7 @@ abstract public class Pfam extends DbSourceProxyImpl implements super(); // all extensions of this PFAM source base class are DOMAINDB sources addDbSourceProperty(jalview.datamodel.DBRefSource.DOMAINDB); + addDbSourceProperty(jalview.datamodel.DBRefSource.ALIGNMENTDB); } /* diff --git a/src/jalview/ws/seqfetcher/DbSourceProxy.java b/src/jalview/ws/seqfetcher/DbSourceProxy.java index 9c5356a..67097ef 100644 --- a/src/jalview/ws/seqfetcher/DbSourceProxy.java +++ b/src/jalview/ws/seqfetcher/DbSourceProxy.java @@ -120,4 +120,12 @@ public interface DbSourceProxy * @return one or more string buffers for each individual query */ public StringBuffer getRawRecords(); + + + /** + * Find out more info about the source. + * @param dbsourceproperty - one of the database reference source properties in jalview.datamodel.DBRefSource + * @return true if the source has this property + */ + public boolean isA(Object dbsourceproperty); } diff --git a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java index 44de157..94d7577 100644 --- a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java +++ b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java @@ -128,4 +128,12 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy return sequences; } + @Override + public boolean isA(Object dbsourceproperty) + { + assert(dbsourceproperty!=null); + return (props==null) ? false : props.containsKey(dbsourceproperty); + } + + }