Jalview 2.8 Source Header
[jalview.git] / src / jalview / ws / dbsources / EmblCdsSouce.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.util.Hashtable;
21
22 import com.stevesoft.pat.Regex;
23
24 import jalview.datamodel.AlignmentI;
25 import jalview.datamodel.DBRefSource;
26 import jalview.ws.seqfetcher.DbSourceProxy;
27
28 public class EmblCdsSouce extends EmblXmlSource implements DbSourceProxy
29 {
30
31   public EmblCdsSouce()
32   {
33     super();
34     addDbSourceProperty(DBRefSource.CODINGSEQDB);
35   }
36
37   public String getAccessionSeparator()
38   {
39     return null;
40   }
41
42   public Regex getAccessionValidator()
43   {
44     return new com.stevesoft.pat.Regex("^[A-Z]+[0-9]+");
45   }
46
47   public String getDbSource()
48   {
49     return DBRefSource.EMBLCDS;
50   }
51
52   public String getDbVersion()
53   {
54     return "0"; // TODO : this is dynamically set for a returned record - not
55     // tied to proxy
56   }
57
58   public AlignmentI getSequenceRecords(String queries) throws Exception
59   {
60     if (queries.indexOf(".") > -1)
61     {
62       queries = queries.substring(0, queries.indexOf("."));
63     }
64     return getEmblSequenceRecords(DBRefSource.EMBLCDS, queries);
65   }
66
67   public boolean isValidReference(String accession)
68   {
69     // most embl CDS refs look like ..
70     // TODO: improve EMBLCDS regex
71     return (accession == null || accession.length() < 2) ? false
72             : getAccessionValidator().search(accession);
73   }
74
75   /**
76    * cDNA for LDHA_CHICK swissprot sequence
77    */
78   public String getTestQuery()
79   {
80     return "CAA37824";
81   }
82
83   public String getDbName()
84   {
85     return "EMBL (CDS)";
86   }
87
88 }