apply gpl development license
[jalview.git] / src / jalview / ws / dbsources / EmblSource.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)\r
3  * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  * \r
5  * This program is free software; you can redistribute it and/or\r
6  * modify it under the terms of the GNU General Public License\r
7  * as published by the Free Software Foundation; either version 2\r
8  * of the License, or (at your option) any later version.\r
9  * \r
10  * This program is distributed in the hope that it will be useful,\r
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13  * GNU General Public License for more details.\r
14  * \r
15  * You should have received a copy of the GNU General Public License\r
16  * along with this program; if not, write to the Free Software\r
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18  */\r
19 package jalview.ws.dbsources;\r
20 \r
21 import java.io.File;\r
22 import java.util.Hashtable;\r
23 import java.util.Iterator;\r
24 import java.util.StringTokenizer;\r
25 \r
26 import com.stevesoft.pat.Regex;\r
27 \r
28 import jalview.datamodel.Alignment;\r
29 import jalview.datamodel.AlignmentI;\r
30 import jalview.datamodel.DBRefSource;\r
31 import jalview.datamodel.SequenceI;\r
32 import jalview.datamodel.xdb.embl.EmblEntry;\r
33 import jalview.ws.ebi.EBIFetchClient;\r
34 import jalview.ws.seqfetcher.DbSourceProxy;\r
35 import jalview.ws.seqfetcher.DbSourceProxyImpl;\r
36 \r
37 /**\r
38  * @author JimP\r
39  * \r
40  */\r
41 public class EmblSource extends EmblXmlSource implements DbSourceProxy\r
42 {\r
43 \r
44   public EmblSource()\r
45   {\r
46     addDbSourceProperty(DBRefSource.DNASEQDB);\r
47     addDbSourceProperty(DBRefSource.CODINGSEQDB);\r
48   }\r
49 \r
50   /*\r
51    * (non-Javadoc)\r
52    * \r
53    * @see jalview.ws.DbSourceProxy#getAccessionSeparator()\r
54    */\r
55   public String getAccessionSeparator()\r
56   {\r
57     // TODO Auto-generated method stub\r
58     return null;\r
59   }\r
60 \r
61   /*\r
62    * (non-Javadoc)\r
63    * \r
64    * @see jalview.ws.DbSourceProxy#getAccessionValidator()\r
65    */\r
66   public Regex getAccessionValidator()\r
67   {\r
68     // TODO Auto-generated method stub\r
69     return null;\r
70   }\r
71 \r
72   /*\r
73    * (non-Javadoc)\r
74    * \r
75    * @see jalview.ws.DbSourceProxy#getDbSource()\r
76    */\r
77   public String getDbSource()\r
78   {\r
79     return DBRefSource.EMBL;\r
80   }\r
81 \r
82   /*\r
83    * (non-Javadoc)\r
84    * \r
85    * @see jalview.ws.DbSourceProxy#getDbVersion()\r
86    */\r
87   public String getDbVersion()\r
88   {\r
89     // TODO Auto-generated method stub\r
90     return "0";\r
91   }\r
92 \r
93   /*\r
94    * (non-Javadoc)\r
95    * \r
96    * @see jalview.ws.DbSourceProxy#getSequenceRecords(java.lang.String[])\r
97    */\r
98   public AlignmentI getSequenceRecords(String queries) throws Exception\r
99   {\r
100     return getEmblSequenceRecords(DBRefSource.EMBL, queries);\r
101   }\r
102   \r
103   /*\r
104    * (non-Javadoc)\r
105    * \r
106    * @see jalview.ws.DbSourceProxy#isValidReference(java.lang.String)\r
107    */\r
108   public boolean isValidReference(String accession)\r
109   {\r
110     // most embl refs look like ..\r
111     \r
112     return (accession==null || accession.length()<2) ? false : new com.stevesoft.pat.Regex("^[A-Z]+[0-9]+$").search(accession);\r
113     \r
114   }\r
115 \r
116   /**\r
117    * return LHD_CHICK coding gene\r
118    */\r
119   public String getTestQuery()\r
120   {\r
121     return "X53828";\r
122   }\r
123 \r
124   public String getDbName()\r
125   {\r
126     return "EMBL"; // getDbSource();\r
127   }\r
128 }\r