X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fseqfetcher%2FDbSourceProxyImpl.java;h=0a4d9a82ee485d434595786eed96fee1ecca3cbb;hb=16848e28863ed4b50713939adb525e1d85ff7575;hp=da7e09a0bd5570d9e76319a23c47f732cfb6cf6b;hpb=865a855a4ca87eadb3e5ff284ed32ed307d9c34b;p=jalview.git diff --git a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java index da7e09a..0a4d9a8 100644 --- a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java +++ b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java @@ -1,28 +1,30 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.ws.seqfetcher; -import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; -import java.util.Hashtable; +import com.stevesoft.pat.Regex; /** * common methods for implementations of the DbSourceProxy interface. @@ -32,50 +34,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; @@ -86,6 +59,7 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy * * @see jalview.ws.DbSourceProxy#queryInProgress() */ + @Override public boolean queryInProgress() { return queryInProgress; @@ -116,10 +90,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", @@ -129,10 +103,54 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy } @Override - public boolean isA(Object dbsourceproperty) + public String getAccessionIdFromQuery(String query) + { + Regex vgr = getAccessionValidator(); + if (vgr == null) + { + return query; + } + vgr.search(query); + if (vgr.numSubs() > 0) + { + return (vgr.stringMatched(1)); + } + else + { + return (vgr.stringMatched()); + } + } + + /** + * 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() { - assert (dbsourceproperty != null); - return (props == null) ? false : props.containsKey(dbsourceproperty); + return false; } + /** + * Answers false - override as required in subclasses + */ + @Override + public boolean isAlignmentSource() + { + return false; + } + + @Override + public String getDescription() + { + return null; + } }