refactor abstract sequence fetching and DBSource machinery to their own package
[jalview.git] / src / jalview / ws / seqfetcher / DbSourceProxy.java
1 package jalview.ws.seqfetcher;\r
2 \r
3 import jalview.datamodel.AlignmentI;\r
4 \r
5 import java.util.Hashtable;\r
6 \r
7 import com.stevesoft.pat.Regex;\r
8 /**\r
9  * generic Reference Retrieval interface for a particular database source/version as cited in DBRefEntry.\r
10  * TODO: add/define property to describe max number of queries that this source can cope with at once.\r
11  * TODO: add/define mechanism for retrieval of Trees and distance matrices from a database (unify with io)\r
12  * @author JimP\r
13  *\r
14  */\r
15 public interface DbSourceProxy\r
16 {\r
17   /**\r
18    * \r
19    * @return source string constant used for this DB source\r
20    */\r
21   public String getDbSource();\r
22   /**\r
23    * \r
24    * @return version string for this database.\r
25    */\r
26   public String getDbVersion();\r
27   /**\r
28    * Separator between individual accession queries for a database that allows multiple IDs\r
29    * to be fetched in a single query. Null implies that only a single ID can be fetched at a time.\r
30    * @return string for separating concatenated queries (as individually validated by the accession validator)\r
31    */\r
32   public String getAccessionSeparator();\r
33   /**\r
34    * Regular expression for checking form of query string understood by this source.\r
35    * @return null or a validation regex\r
36    */\r
37   public Regex getAccessionValidator();\r
38   /**\r
39    * DbSource properties hash - define the capabilities of this source\r
40    * Property hash methods defined in DbSourceProxyImpl.\r
41    * See constants in jalview.datamodel.DBRefSource for definition of properties.\r
42    * @return \r
43    */\r
44   public Hashtable getDbSourceProperties();\r
45   /**\r
46    * \r
47    * @return a test/example query that can be used to validate retrieval and parsing mechanisms\r
48    */\r
49   public String getTestQuery();\r
50   /**\r
51    * optionally implemented\r
52    * @param accession\r
53    * @return\r
54    */\r
55   public boolean isValidReference(String accession);\r
56   /**\r
57    * make one or more queries to the database\r
58    * and attempt to parse the response into an alignment\r
59    * @param queries\r
60    * @return null if queries were successful but result was not parsable\r
61    * @throws Exception TODO\r
62    */\r
63   public AlignmentI getSequenceRecords(String queries) throws Exception;\r
64   /**\r
65    * \r
66    * @return true if a query is currently being made\r
67    */\r
68   public boolean queryInProgress();\r
69   /**\r
70    * get the raw reponse from the last set of queries\r
71    * @return one or more string buffers for each individual query\r
72    */\r
73   public StringBuffer getRawRecords();\r
74 }\r