1 package jalview.ext.ensembl;
3 import static org.testng.AssertJUnit.assertEquals;
5 import jalview.datamodel.DBRefEntry;
7 import java.io.BufferedReader;
8 import java.io.IOException;
9 import java.io.StringReader;
11 import java.util.List;
13 import org.testng.annotations.Test;
15 public class EnsemblXrefTest
18 private static final String JSON =
19 "[{\"primary_id\":\"CCDS5863\",\"dbname\":\"CCDS\"}," +
20 "{\"primary_id\":\"P15056\",\"dbname\":\"Uniprot/SWISSPROT\",\"synonyms\":[\"C21\"]}," +
21 "{\"primary_id\":\"GO:0000165\",\"dbname\":\"GO\"}]";
24 @Test(groups = "Functional")
25 public void testGetCrossReferences()
27 System.out.println(JSON);
28 EnsemblXref testee = new EnsemblXref("http://rest.ensembl.org")
31 protected BufferedReader getHttpResponse(URL url, List<String> ids)
34 return new BufferedReader(new StringReader(JSON));
38 // synonyms and GO terms are not returned
39 List<DBRefEntry> dbrefs = testee.getCrossReferences("ABCDE");
40 assertEquals(2, dbrefs.size());
41 assertEquals("CCDS", dbrefs.get(0).getSource());
42 assertEquals("CCDS5863", dbrefs.get(0).getAccessionId());
43 // Uniprot name should get converted to Jalview canonical form
44 assertEquals("UNIPROT", dbrefs.get(1).getSource());
45 assertEquals("P15056", dbrefs.get(1).getAccessionId());