Revert "Merge branch 'bug/JAL-3807_jpred-with-slivka' into alpha/JAL-3066_Jalview_212...
[jalview.git] / src / jalview / ws / dbsources / EmblSource.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
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
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.ws.dbsources;
22
23 import jalview.datamodel.AlignmentI;
24 import jalview.datamodel.DBRefSource;
25 import jalview.util.Platform;
26
27 import com.stevesoft.pat.Regex;
28
29 /**
30  * @author JimP
31  * 
32  */
33 public class EmblSource extends EmblXmlSource
34 {
35
36   private static Regex ACCESSION_REGEX;
37
38   public EmblSource()
39   {
40     super();
41   }
42
43   /*
44    * (non-Javadoc)
45    * 
46    * @see jalview.ws.DbSourceProxy#getAccessionSeparator()
47    */
48   @Override
49   public String getAccessionSeparator()
50   {
51     // TODO Auto-generated method stub
52     return null;
53   }
54
55   /*
56    * (non-Javadoc)
57    * 
58    * @see jalview.ws.DbSourceProxy#getAccessionValidator()
59    */
60   @Override
61   public Regex getAccessionValidator()
62   {
63     if (ACCESSION_REGEX == null)
64     {
65       ACCESSION_REGEX = Platform.newRegex("^[A-Z]+[0-9]+");
66     }
67     return ACCESSION_REGEX;
68   }
69
70   /*
71    * (non-Javadoc)
72    * 
73    * @see jalview.ws.DbSourceProxy#getDbSource()
74    */
75   @Override
76   public String getDbSource()
77   {
78     return DBRefSource.EMBL;
79   }
80
81   /*
82    * (non-Javadoc)
83    * 
84    * @see jalview.ws.DbSourceProxy#getDbVersion()
85    */
86   @Override
87   public String getDbVersion()
88   {
89     // TODO Auto-generated method stub
90     return "0";
91   }
92
93   /*
94    * (non-Javadoc)
95    * 
96    * @see jalview.ws.DbSourceProxy#getSequenceRecords(java.lang.String[])
97    */
98   @Override
99   public AlignmentI getSequenceRecords(String queries) throws Exception
100   {
101     return getEmblSequenceRecords(DBRefSource.EMBL, queries);
102   }
103
104   /*
105    * (non-Javadoc)
106    * 
107    * @see jalview.ws.DbSourceProxy#isValidReference(java.lang.String)
108    */
109   @Override
110   public boolean isValidReference(String accession)
111   {
112     // most embl refs look like ..
113
114     return (accession == null || accession.length() < 2) ? false
115             : getAccessionValidator().search(accession);
116
117   }
118
119   /**
120    * return LHD_CHICK coding gene
121    */
122   @Override
123   public String getTestQuery()
124   {
125     return "X53828";
126   }
127
128   @Override
129   public String getDbName()
130   {
131     return "EMBL"; // getDbSource();
132   }
133
134   @Override
135   public int getTier()
136   {
137     return 0;
138   }
139 }