JAL-2189 apply license
[jalview.git] / test / jalview / ext / ensembl / EnsemblProteinTest.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.ext.ensembl;
22
23 import static org.testng.AssertJUnit.assertEquals;
24
25 import org.testng.Assert;
26 import org.testng.annotations.Test;
27
28 public class EnsemblProteinTest
29 {
30
31   @Test(groups = "Functional")
32   public void testIsValidReference() throws Exception
33   {
34     EnsemblSequenceFetcher esq = new EnsemblProtein();
35     Assert.assertTrue(esq.isValidReference("CCDS5863.1"));
36     Assert.assertTrue(esq.isValidReference("ENSP00000288602"));
37     Assert.assertFalse(esq.isValidReference("ENST00000288602"));
38     Assert.assertFalse(esq.isValidReference("ENSG00000288602"));
39     // non-human species having a 3 character identifier included:
40     Assert.assertTrue(esq.isValidReference("ENSMUSP00000099398"));
41   }
42
43   @Test(groups = "Functional")
44   public void testGetAccesionIdFromQuery() throws Exception
45   {
46     EnsemblSequenceFetcher esq = new EnsemblProtein();
47     assertEquals("ENSP00000288602",
48             esq.getAccessionIdFromQuery("ENSP00000288602"));
49     assertEquals("ENSMUSP00000288602",
50             esq.getAccessionIdFromQuery("ENSMUSP00000288602"));
51
52     // ENST converted to ENSP
53     assertEquals("ENSP00000288602",
54             esq.getAccessionIdFromQuery("ENST00000288602"));
55     assertEquals("ENSMUSP00000288602",
56             esq.getAccessionIdFromQuery("ENSMUST00000288602"));
57
58     // with valid separator:
59     assertEquals("ENSP00000288604",
60             esq.getAccessionIdFromQuery("ENSP00000288604 ENSP00000288602"));
61
62     // with wrong separator:
63     assertEquals("ENSP00000288604,ENSP00000288602",
64             esq.getAccessionIdFromQuery("ENSP00000288604,ENSP00000288602"));
65   }
66
67 }