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