1 package jalview.ext.ensembl;
3 import static org.testng.AssertJUnit.assertEquals;
4 import static org.testng.AssertJUnit.assertFalse;
6 import jalview.datamodel.DBRefEntry;
8 import java.io.BufferedReader;
9 import java.io.IOException;
10 import java.io.StringReader;
12 import java.util.List;
14 import org.testng.annotations.Test;
16 public class EnsemblXrefTest
19 private static final String JSON =
20 "[{\"primary_id\":\"CCDS5863\",\"dbname\":\"CCDS\"}," +
21 "{\"primary_id\":\"P15056\",\"dbname\":\"Uniprot/SWISSPROT\",\"synonyms\":[\"C21\"]}," +
22 "{\"primary_id\":\"GO:0000165\",\"dbname\":\"GO\"}]";
25 @Test(groups = "Functional")
26 public void testGetCrossReferences()
28 String dbName = "ENSEMBL";
29 String dbVers = "0.6.2b1";
30 System.out.println(JSON);
31 EnsemblXref testee = new EnsemblXref("http://rest.ensembl.org", dbName,
35 protected BufferedReader getHttpResponse(URL url, List<String> ids)
38 return new BufferedReader(new StringReader(JSON));
42 // synonyms and GO terms are not returned
43 List<DBRefEntry> dbrefs = testee.getCrossReferences("ABCDE");
44 assertEquals(2, dbrefs.size());
45 assertEquals("CCDS", dbrefs.get(0).getSource());
46 assertEquals("CCDS5863", dbrefs.get(0).getAccessionId());
47 assertFalse(dbrefs.get(0).isPrimary());
48 assertEquals(dbName + ":" + dbVers, dbrefs.get(0).getVersion());
49 // Uniprot name should get converted to Jalview canonical form
50 assertEquals("UNIPROT", dbrefs.get(1).getSource());
51 assertEquals("P15056", dbrefs.get(1).getAccessionId());
52 assertEquals(dbName + ":" + dbVers, dbrefs.get(1).getVersion());
53 assertFalse(dbrefs.get(1).isPrimary());