2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.ext.ensembl;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertFalse;
26 import jalview.datamodel.DBRefEntry;
28 import java.io.BufferedReader;
29 import java.io.IOException;
30 import java.io.StringReader;
32 import java.util.List;
34 import org.testng.annotations.Test;
36 public class EnsemblXrefTest
39 private static final String JSON =
40 "[{\"primary_id\":\"CCDS5863\",\"dbname\":\"CCDS\"}," +
41 "{\"primary_id\":\"P15056\",\"dbname\":\"Uniprot/SWISSPROT\",\"synonyms\":[\"C21\"]}," +
42 "{\"primary_id\":\"GO:0000165\",\"dbname\":\"GO\"}]";
45 @Test(groups = "Functional")
46 public void testGetCrossReferences()
48 String dbName = "ENSEMBL";
49 String dbVers = "0.6.2b1";
50 System.out.println(JSON);
51 EnsemblXref testee = new EnsemblXref("http://rest.ensembl.org", dbName,
55 protected BufferedReader getHttpResponse(URL url, List<String> ids)
58 return new BufferedReader(new StringReader(JSON));
62 // synonyms and GO terms are not returned
63 List<DBRefEntry> dbrefs = testee.getCrossReferences("ABCDE");
64 assertEquals(2, dbrefs.size());
65 assertEquals("CCDS", dbrefs.get(0).getSource());
66 assertEquals("CCDS5863", dbrefs.get(0).getAccessionId());
67 assertFalse(dbrefs.get(0).isPrimaryCandidate());
68 assertEquals(dbName + ":" + dbVers, dbrefs.get(0).getVersion());
69 // Uniprot name should get converted to Jalview canonical form
70 assertEquals("UNIPROT", dbrefs.get(1).getSource());
71 assertEquals("P15056", dbrefs.get(1).getAccessionId());
72 assertEquals(dbName + ":" + dbVers, dbrefs.get(1).getVersion());
73 assertFalse(dbrefs.get(1).isPrimaryCandidate());