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.DataSourceType;
26 import jalview.io.FileFormatI;
27 import jalview.io.FormatAdapter;
28 import jalview.io.IdentifyFile;
31 * common methods for implementations of the DbSourceProxy interface.
36 public abstract class DbSourceProxyImpl implements DbSourceProxy
39 boolean queryInProgress = false;
41 protected StringBuffer results = null;
43 public DbSourceProxyImpl()
50 * @see jalview.ws.DbSourceProxy#getRawRecords()
53 public StringBuffer getRawRecords()
61 * @see jalview.ws.DbSourceProxy#queryInProgress()
64 public boolean queryInProgress()
66 return queryInProgress;
70 * call to set the queryInProgress flag
73 protected void startQuery()
75 queryInProgress = true;
79 * call to clear the queryInProgress flag
82 protected void stopQuery()
84 queryInProgress = false;
88 * create an alignment from raw text file...
91 * @return null or a valid alignment
94 protected AlignmentI parseResult(String result) throws Exception
96 AlignmentI sequences = null;
97 FileFormatI format = new IdentifyFile().identify(result,
98 DataSourceType.PASTE);
101 sequences = new FormatAdapter().readFile(result.toString(),
102 DataSourceType.PASTE, format);
108 * Returns the first accession id in the query (up to the first accession id
109 * separator), or the whole query if there is no separator or it is not found
112 public String getAccessionIdFromQuery(String query)
114 String sep = getAccessionSeparator();
119 int sepPos = query.indexOf(sep);
120 return sepPos == -1 ? query : query.substring(0, sepPos);
124 * Default is only one accession id per query - override if more are allowed.
127 public int getMaximumQueryCount()
133 * Returns false - override to return true for DNA coding data sources
136 public boolean isDnaCoding()
142 * Answers false - override as required in subclasses
145 public boolean isAlignmentSource()
151 public String getDescription()
157 public FeatureSettingsModelI getFeatureColourScheme()