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.datamodel.AlignmentI;
24 import jalview.io.FormatAdapter;
25 import jalview.io.IdentifyFile;
27 import com.stevesoft.pat.Regex;
30 * common methods for implementations of the DbSourceProxy interface.
35 public abstract class DbSourceProxyImpl implements DbSourceProxy
38 boolean queryInProgress = false;
40 protected StringBuffer results = null;
42 public DbSourceProxyImpl()
49 * @see jalview.ws.DbSourceProxy#getRawRecords()
52 public StringBuffer getRawRecords()
60 * @see jalview.ws.DbSourceProxy#queryInProgress()
63 public boolean queryInProgress()
65 return queryInProgress;
69 * call to set the queryInProgress flag
72 protected void startQuery()
74 queryInProgress = true;
78 * call to clear the queryInProgress flag
81 protected void stopQuery()
83 queryInProgress = false;
87 * create an alignment from raw text file...
90 * @return null or a valid alignment
93 protected AlignmentI parseResult(String result) throws Exception
95 AlignmentI sequences = null;
96 String format = new IdentifyFile().identify(result, "Paste");
97 if (FormatAdapter.isValidFormat(format))
99 sequences = new FormatAdapter().readFile(result.toString(), "Paste",
106 public String getAccessionIdFromQuery(String query)
108 Regex vgr = getAccessionValidator();
114 if (vgr.numSubs() > 0)
116 return (vgr.stringMatched(1));
120 return (vgr.stringMatched());
125 * Default is only one accession id per query - override if more are allowed.
128 public int getMaximumQueryCount()
134 * Returns false - override to return true for DNA coding data sources
137 public boolean isDnaCoding()
143 * Answers false - override as required in subclasses
146 public boolean isAlignmentSource()