2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.seqfetcher;
23 import jalview.api.FeatureSettingsModelI;
24 import jalview.datamodel.AlignmentI;
25 import jalview.io.FormatAdapter;
26 import jalview.io.IdentifyFile;
29 * common methods for implementations of the DbSourceProxy interface.
34 public abstract class DbSourceProxyImpl implements DbSourceProxy
37 boolean queryInProgress = false;
39 protected StringBuffer results = null;
41 public DbSourceProxyImpl()
48 * @see jalview.ws.DbSourceProxy#getRawRecords()
51 public StringBuffer getRawRecords()
59 * @see jalview.ws.DbSourceProxy#queryInProgress()
62 public boolean queryInProgress()
64 return queryInProgress;
68 * call to set the queryInProgress flag
71 protected void startQuery()
73 queryInProgress = true;
77 * call to clear the queryInProgress flag
80 protected void stopQuery()
82 queryInProgress = false;
86 * create an alignment from raw text file...
89 * @return null or a valid alignment
92 protected AlignmentI parseResult(String result) throws Exception
94 AlignmentI sequences = null;
95 String format = new IdentifyFile().identify(result, "Paste");
96 if (FormatAdapter.isValidFormat(format))
98 sequences = new FormatAdapter().readFile(result.toString(), "Paste",
105 * Returns the first accession id in the query (up to the first accession id
106 * separator), or the whole query if there is no separator or it is not found
109 public String getAccessionIdFromQuery(String query)
111 String sep = getAccessionSeparator();
116 int sepPos = query.indexOf(sep);
117 return sepPos == -1 ? query : query.substring(0, sepPos);
121 * Default is only one accession id per query - override if more are allowed.
124 public int getMaximumQueryCount()
130 * Returns false - override to return true for DNA coding data sources
133 public boolean isDnaCoding()
139 * Answers false - override as required in subclasses
142 public boolean isAlignmentSource()
148 public String getDescription()
154 public FeatureSettingsModelI getFeatureColourScheme()