c7be59a9be5ab638344aa896a1b13deed5381503
[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 com.stevesoft.pat.Regex;
21
22 import jalview.datamodel.AlignmentI;
23 import jalview.datamodel.DBRefSource;
24 import jalview.ws.seqfetcher.DbSourceProxy;
25
26 /**
27  * @author JimP
28  * 
29  */
30 public class EmblSource extends EmblXmlSource implements DbSourceProxy
31 {
32
33   public EmblSource()
34   {
35     addDbSourceProperty(DBRefSource.DNASEQDB);
36     addDbSourceProperty(DBRefSource.CODINGSEQDB);
37   }
38
39   /*
40    * (non-Javadoc)
41    * 
42    * @see jalview.ws.DbSourceProxy#getAccessionSeparator()
43    */
44   public String getAccessionSeparator()
45   {
46     // TODO Auto-generated method stub
47     return null;
48   }
49
50   /*
51    * (non-Javadoc)
52    * 
53    * @see jalview.ws.DbSourceProxy#getAccessionValidator()
54    */
55   public Regex getAccessionValidator()
56   {
57     return new com.stevesoft.pat.Regex("^[A-Z]+[0-9]+");
58   }
59
60   /*
61    * (non-Javadoc)
62    * 
63    * @see jalview.ws.DbSourceProxy#getDbSource()
64    */
65   public String getDbSource()
66   {
67     return DBRefSource.EMBL;
68   }
69
70   /*
71    * (non-Javadoc)
72    * 
73    * @see jalview.ws.DbSourceProxy#getDbVersion()
74    */
75   public String getDbVersion()
76   {
77     // TODO Auto-generated method stub
78     return "0";
79   }
80
81   /*
82    * (non-Javadoc)
83    * 
84    * @see jalview.ws.DbSourceProxy#getSequenceRecords(java.lang.String[])
85    */
86   public AlignmentI getSequenceRecords(String queries) throws Exception
87   {
88     return getEmblSequenceRecords(DBRefSource.EMBL, queries);
89   }
90
91   /*
92    * (non-Javadoc)
93    * 
94    * @see jalview.ws.DbSourceProxy#isValidReference(java.lang.String)
95    */
96   public boolean isValidReference(String accession)
97   {
98     // most embl refs look like ..
99
100     return (accession == null || accession.length() < 2) ? false
101             : getAccessionValidator().search(accession);
102
103   }
104
105   /**
106    * return LHD_CHICK coding gene
107    */
108   public String getTestQuery()
109   {
110     return "X53828";
111   }
112
113   public String getDbName()
114   {
115     return "EMBL"; // getDbSource();
116   }
117
118   @Override
119   public int getTier()
120   {
121     return 0;
122   }
123 }