From 2de36153a84ca246643cd28b2ce05e9f4159dd89 Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 4 Aug 2008 14:16:18 +0000 Subject: [PATCH] pfam seed and full alignment retrieval and nicer ordering of sequence db sources in combobox --- src/jalview/gui/SequenceFetcher.java | 6 +-- src/jalview/ws/SequenceFetcher.java | 55 ++++++++++++++++++++++- src/jalview/ws/dbsources/Pfam.java | 53 +++++++++++++--------- src/jalview/ws/dbsources/PfamFull.java | 43 ++++++++++++++++++ src/jalview/ws/dbsources/PfamSeed.java | 44 ++++++++++++++++++ src/jalview/ws/seqfetcher/ASequenceFetcher.java | 20 +++++++++ 6 files changed, 195 insertions(+), 26 deletions(-) create mode 100644 src/jalview/ws/dbsources/PfamFull.java create mode 100644 src/jalview/ws/dbsources/PfamSeed.java diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 53f75a4..a66ec2f 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -50,7 +50,7 @@ extends JPanel implements Runnable StringBuffer result; final String noDbSelected = "-- Select Database --"; Hashtable sources = new Hashtable(); - private static ASequenceFetcher sfetch=null; + private static jalview.ws.SequenceFetcher sfetch=null; public SequenceFetcher(IProgressIndicator guiIndic) { final IProgressIndicator guiWindow = guiIndic; @@ -69,7 +69,7 @@ extends JPanel implements Runnable { guiWindow.setProgressBar("Initialising Sequence Database Fetchers", this.hashCode()); } - ASequenceFetcher sf = new jalview.ws.SequenceFetcher(); + jalview.ws.SequenceFetcher sf = new jalview.ws.SequenceFetcher(); if ( guiWindow!=null ) { guiWindow.setProgressBar("Initialising Sequence Database Fetchers", this.hashCode()); @@ -102,7 +102,7 @@ extends JPanel implements Runnable * and should be collapsed. */ - String dbs[] = sfetch.getSupportedDb(); + String dbs[] = sfetch.getOrderedSupportedSources(); for (int i=0; i=0; j--,i++) + { + srcs[i] = ((String[]) sorted[j])[0]; + sorted[j] = null; + } + + sorted = dassrc.toArray(); + tosort = new String[sorted.length]; + dassrc.clear(); + for (int j=0;j=0; j--,i++) + { + srcs[i] = ((String[]) sorted[j])[0]; + sorted[j] = null; + } + return srcs; + } + /** * simple run method to test dbsources. * @param argv */ diff --git a/src/jalview/ws/dbsources/Pfam.java b/src/jalview/ws/dbsources/Pfam.java index db765eb..4136e62 100644 --- a/src/jalview/ws/dbsources/Pfam.java +++ b/src/jalview/ws/dbsources/Pfam.java @@ -9,23 +9,25 @@ import com.stevesoft.pat.Regex; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; +import jalview.io.AppletFormatAdapter; import jalview.io.FastaFile; +import jalview.io.StockholmFile; import jalview.ws.seqfetcher.DbSourceProxy; import jalview.ws.seqfetcher.DbSourceProxyImpl; /** - * TODO: later PFAM is a complex datasource - it currently returns a seed alignment, but could optionally return a full alignment. * TODO: later PFAM is a complex datasource - it could return a tree in addition to an alignment - * TODO: HP: Incorporate jalview.gui.SequenceFetcher retrieval code here. + * TODO: create interface to pass alignment properties and tree back to sequence fetcher * @author JimP * */ -public class Pfam extends DbSourceProxyImpl implements DbSourceProxy +abstract public class Pfam extends DbSourceProxyImpl implements DbSourceProxy { public Pfam() { super(); - + // all extensions of this PFAM source base class are DOMAINDB sources + addDbSourceProperty(jalview.datamodel.DBRefSource.DOMAINDB); } /* (non-Javadoc) @@ -48,21 +50,24 @@ public class Pfam extends DbSourceProxyImpl implements DbSourceProxy /* (non-Javadoc) * @see jalview.ws.DbSourceProxy#getDbSource() - */ public String getDbSource() { + ** this doesn't work - DbSource is key for the hash of DbSourceProxy instances - 1:many mapping for DbSource to proxy will be lost. + ** suggest : PFAM is an 'alignment' source - means proxy is higher level than a sequence source. return jalview.datamodel.DBRefSource.PFAM; } + */ + /* (non-Javadoc) * @see jalview.ws.DbSourceProxy#getDbSourceProperties() - */ public Hashtable getDbSourceProperties() { - // TODO Auto-generated method stub + return null; } - + */ + /* (non-Javadoc) * @see jalview.ws.DbSourceProxy#getDbVersion() */ @@ -71,7 +76,11 @@ public class Pfam extends DbSourceProxyImpl implements DbSourceProxy // TODO Auto-generated method stub return null; } - public static String PFAMURL = "http://www.sanger.ac.uk/cgi-bin/Pfam/getalignment.pl?format=fal&acc="; + /** + * + * @return PFAM URL stub for this DbSource + */ + protected abstract String getPFAMURL(); /* (non-Javadoc) * @see jalview.ws.DbSourceProxy#getSequenceRecords(java.lang.String[]) */ @@ -79,16 +88,20 @@ public class Pfam extends DbSourceProxyImpl implements DbSourceProxy { // TODO: this is not a perfect implementation. We need to be able to add individual references to each sequence in each family alignment that's retrieved. startQuery(); - results = new StringBuffer(); - // split queries into many little ones. - results.append(new FastaFile( - PFAMURL+queries.trim().toUpperCase(), "URL").print()); - stopQuery(); - AlignmentI rcds = parseResult(results.toString()); + AlignmentI rcds = new jalview.io.FormatAdapter().readFile(getPFAMURL()+queries.trim().toUpperCase(), jalview.io.FormatAdapter.URL,"STH"); for (int s=0,sNum=rcds.getHeight(); s