JAL-2087 /info/species client, alias cache, type-assist demo
[jalview.git] / test / jalview / ext / ensembl / EnsemblSpeciesTest.java
1 package jalview.ext.ensembl;
2
3 import static org.testng.Assert.assertEquals;
4
5 import jalview.bin.Cache;
6 import jalview.ext.ensembl.EnsemblSpecies.EnsemblTaxon;
7
8 import java.util.List;
9 import java.util.Map;
10
11 import org.apache.log4j.Logger;
12 import org.testng.annotations.Test;
13
14 import junit.extensions.PA;
15
16 public class EnsemblSpeciesTest
17 {
18   @Test(groups = "Network")
19   public void testGetSpecies_ensembl()
20   {
21     Cache.log = Logger.getRootLogger();
22     EnsemblSpecies species = EnsemblSpecies.getSpecies(true);
23     System.out.println("Ensembllookup map size = "
24             + ((Map) PA.getValue(species, "lookup")).size());
25
26     List<EnsemblTaxon> matches = species.getNameMatches("homo sapiens");
27     assertEquals(matches.size(), 1);
28     EnsemblTaxon match = matches.get(0);
29     assertEquals(match.ncbiId, "9606");
30
31     matches = species.getNameMatches("mus ");
32     assertEquals(matches.size(), 6);
33     match = matches.get(0);
34     assertEquals(match.ncbiId, "10089");
35     assertEquals(match.name, "mus_caroli");
36     match = matches.get(1);
37     assertEquals(match.ncbiId, "10090");
38     assertEquals(match.commonName, "house mouse");
39     match = matches.get(2);
40     assertEquals(match.ncbiId, "10091");
41     assertEquals(match.displayName, "Mouse CAST/EiJ");
42     assertEquals(match.commonName, "south eastern house mouse");
43   }
44
45   @Test(groups = "Network")
46   public void testGetSpecies_ensemblGenomes()
47   {
48     Cache.log = Logger.getRootLogger();
49     EnsemblSpecies species = EnsemblSpecies.getSpecies(false);
50     System.out.println("EnsemblGenomes lookup map size = "
51             + ((Map) PA.getValue(species, "lookup")).size());
52
53     List<EnsemblTaxon> matches = species.getNameMatches("streptomyces al");
54     assertEquals(matches.size(), 12);
55     assertEquals(matches.get(0).ncbiId, "132473");
56     assertEquals(matches.get(0).name, "streptomyces_alboniger");
57     assertEquals(matches.get(1).ncbiId, "68570");
58     assertEquals(matches.get(1).displayName, "Streptomyces albulus");
59     assertEquals(matches.get(2).ncbiId, "68570");
60     assertEquals(matches.get(2).name, "streptomyces_albulus_gca_001646665");
61   }
62 }