X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fseqfetcher%2FDbSourceProxyImpl.java;h=5bed7209772625e4ab6f29a60ba12ed5012a3eb5;hb=37de9310bec3501cbc6381e0c3dcb282fcaad812;hp=719027f514ab983e7d2b80cbe1a0e81cccd5bade;hpb=ad15cff29620f960119f80176f1fd443da9f6763;p=jalview.git diff --git a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java index 719027f..5bed720 100644 --- a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java +++ b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java @@ -20,12 +20,11 @@ */ package jalview.ws.seqfetcher; -import jalview.datamodel.Alignment; +import jalview.api.FeatureSettingsModelI; +import jalview.datamodel.AlignmentI; import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; -import java.util.Hashtable; - /** * common methods for implementations of the DbSourceProxy interface. * @@ -34,50 +33,21 @@ import java.util.Hashtable; */ public abstract class DbSourceProxyImpl implements DbSourceProxy { - public DbSourceProxyImpl() - { - // default constructor - do nothing probably. - } - private Hashtable props = null; - - /* - * (non-Javadoc) - * - * @see jalview.ws.DbSourceProxy#getDbSourceProperties() - */ - public Hashtable getDbSourceProperties() - { - if (props == null) - { - props = new Hashtable(); - } - return props; - } + boolean queryInProgress = false; - protected void addDbSourceProperty(Object propname) - { - addDbSourceProperty(propname, propname); - } + protected StringBuffer results = null; - protected void addDbSourceProperty(Object propname, Object propvalue) + public DbSourceProxyImpl() { - if (props == null) - { - props = new Hashtable(); - } - props.put(propname, propvalue); } - boolean queryInProgress = false; - - protected StringBuffer results = null; - /* * (non-Javadoc) * * @see jalview.ws.DbSourceProxy#getRawRecords() */ + @Override public StringBuffer getRawRecords() { return results; @@ -88,6 +58,7 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy * * @see jalview.ws.DbSourceProxy#queryInProgress() */ + @Override public boolean queryInProgress() { return queryInProgress; @@ -118,10 +89,10 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy * @return null or a valid alignment * @throws Exception */ - protected Alignment parseResult(String result) throws Exception + protected AlignmentI parseResult(String result) throws Exception { - Alignment sequences = null; - String format = new IdentifyFile().Identify(result, "Paste"); + AlignmentI sequences = null; + String format = new IdentifyFile().identify(result, "Paste"); if (FormatAdapter.isValidFormat(format)) { sequences = new FormatAdapter().readFile(result.toString(), "Paste", @@ -130,11 +101,58 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy return sequences; } + /** + * Returns the first accession id in the query (up to the first accession id + * separator), or the whole query if there is no separator or it is not found + */ @Override - public boolean isA(Object dbsourceproperty) + public String getAccessionIdFromQuery(String query) { - assert (dbsourceproperty != null); - return (props == null) ? false : props.containsKey(dbsourceproperty); + String sep = getAccessionSeparator(); + if (sep == null) + { + return query; + } + int sepPos = query.indexOf(sep); + return sepPos == -1 ? query : query.substring(0, sepPos); + } + + /** + * Default is only one accession id per query - override if more are allowed. + */ + @Override + public int getMaximumQueryCount() + { + return 1; + } + + /** + * Returns false - override to return true for DNA coding data sources + */ + @Override + public boolean isDnaCoding() + { + return false; } + /** + * Answers false - override as required in subclasses + */ + @Override + public boolean isAlignmentSource() + { + return false; + } + + @Override + public String getDescription() + { + return ""; + } + + @Override + public FeatureSettingsModelI getFeatureColourScheme() + { + return null; + } }