Search in sources :

Example 6 with GlobalNamesService

use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.

the class GlobalNamesServiceTest method lookupNCBIBacteria.

@Test
public void lookupNCBIBacteria() throws PropertyEnricherException {
    GlobalNamesService service = new GlobalNamesService(GlobalNamesSources.NCBI);
    HashMap<String, String> props1 = new HashMap<String, String>();
    props1.put(PropertyAndValueDictionary.NAME, "Bacteria");
    Map<String, String> enrich = service.enrich(props1);
    assertThat(enrich.get(PropertyAndValueDictionary.NAME), is("Bacteria"));
    final String path = enrich.get(PropertyAndValueDictionary.PATH);
    assertThat(path, is(" | Bacteria"));
    final String pathNames = enrich.get(PropertyAndValueDictionary.PATH_NAMES);
    assertThat(pathNames, is(" | superkingdom"));
    final String pathIds = enrich.get(PropertyAndValueDictionary.PATH_IDS);
    assertThat(pathIds, is("NCBI:131567 | NCBI:2"));
    assertThat(StringUtils.split(path, CharsetConstant.SEPARATOR_CHAR).length, is(2));
    assertThat(StringUtils.split(pathIds, CharsetConstant.SEPARATOR_CHAR).length, is(2));
    assertThat(StringUtils.split(pathNames, CharsetConstant.SEPARATOR_CHAR).length, is(2));
    assertThat(enrich.get(PropertyAndValueDictionary.EXTERNAL_ID), is("NCBI:2"));
    assertThat(enrich.get(PropertyAndValueDictionary.COMMON_NAMES), is(nullValue()));
}
Also used : HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) GlobalNamesService(org.eol.globi.taxon.GlobalNamesService) Test(org.junit.Test)

Example 7 with GlobalNamesService

use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.

the class GlobalNamesServiceTest method lookupWORMS.

@Test
public void lookupWORMS() throws PropertyEnricherException {
    GlobalNamesService service = new GlobalNamesService(GlobalNamesSources.WORMS);
    HashMap<String, String> props = new HashMap<String, String>();
    props.put(PropertyAndValueDictionary.NAME, "Anura");
    Map<String, String> enrich = service.enrich(props);
    assertThat(enrich.get(PropertyAndValueDictionary.NAME), is("Anura"));
}
Also used : HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) GlobalNamesService(org.eol.globi.taxon.GlobalNamesService) Test(org.junit.Test)

Example 8 with GlobalNamesService

use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.

the class GlobalNamesServiceTest method lookupNCBI.

@Test
public void lookupNCBI() throws PropertyEnricherException {
    GlobalNamesService service = new GlobalNamesService(GlobalNamesSources.NCBI);
    HashMap<String, String> props1 = new HashMap<String, String>();
    props1.put(PropertyAndValueDictionary.NAME, "Homo sapiens");
    Map<String, String> enrich = service.enrich(props1);
    assertThat(enrich.get(PropertyAndValueDictionary.NAME), is("Homo sapiens"));
    assertThat(enrich.get(PropertyAndValueDictionary.PATH), is(" | Eukaryota | Opisthokonta | Metazoa | Eumetazoa | Bilateria | Deuterostomia | Chordata | Craniata | Vertebrata | Gnathostomata | Teleostomi | Euteleostomi | Sarcopterygii | Dipnotetrapodomorpha | Tetrapoda | Amniota | Mammalia | Theria | Eutheria | Boreoeutheria | Euarchontoglires | Primates | Haplorrhini | Simiiformes | Catarrhini | Hominoidea | Hominidae | Homininae | Homo | Homo sapiens"));
    assertThat(enrich.get(PropertyAndValueDictionary.PATH_IDS), is("NCBI:131567 | NCBI:2759 | NCBI:33154 | NCBI:33208 | NCBI:6072 | NCBI:33213 | NCBI:33511 | NCBI:7711 | NCBI:89593 | NCBI:7742 | NCBI:7776 | NCBI:117570 | NCBI:117571 | NCBI:8287 | NCBI:1338369 | NCBI:32523 | NCBI:32524 | NCBI:40674 | NCBI:32525 | NCBI:9347 | NCBI:1437010 | NCBI:314146 | NCBI:9443 | NCBI:376913 | NCBI:314293 | NCBI:9526 | NCBI:314295 | NCBI:9604 | NCBI:207598 | NCBI:9605 | NCBI:9606"));
    assertThat(enrich.get(PropertyAndValueDictionary.PATH_NAMES), is(" | superkingdom |  | kingdom |  |  |  | phylum | subphylum |  |  |  |  |  |  |  |  | class |  |  |  | superorder | order | suborder | infraorder | parvorder | superfamily | family | subfamily | genus | species"));
    assertThat(enrich.get(PropertyAndValueDictionary.RANK), is("species"));
    assertThat(enrich.get(PropertyAndValueDictionary.EXTERNAL_ID), is("NCBI:9606"));
    assertThat(enrich.get(PropertyAndValueDictionary.COMMON_NAMES), is(nullValue()));
}
Also used : HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) GlobalNamesService(org.eol.globi.taxon.GlobalNamesService) Test(org.junit.Test)

Example 9 with GlobalNamesService

use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.

the class GlobalNamesServiceTest method lookupGBIF.

@Test
public void lookupGBIF() throws PropertyEnricherException {
    GlobalNamesService service = new GlobalNamesService(GlobalNamesSources.GBIF);
    service.setIncludeCommonNames(true);
    HashMap<String, String> props = new HashMap<String, String>();
    props.put(PropertyAndValueDictionary.NAME, "Anura");
    Map<String, String> enrich = service.enrich(props);
    assertThat(enrich.get(PropertyAndValueDictionary.NAME), is("Anura"));
    assertThat(enrich.get(PropertyAndValueDictionary.PATH), is("Animalia | Chordata | Amphibia | Anura"));
    assertThat(enrich.get(PropertyAndValueDictionary.PATH_IDS), is("GBIF:1 | GBIF:44 | GBIF:131 | GBIF:952"));
    assertThat(enrich.get(PropertyAndValueDictionary.PATH_NAMES), is("kingdom | phylum | class | order"));
    assertThat(enrich.get(PropertyAndValueDictionary.RANK), is("order"));
    assertThat(enrich.get(PropertyAndValueDictionary.EXTERNAL_ID), is("GBIF:952"));
    // assertThat(enrich.get(PropertyAndValueDictionary.COMMON_NAMES), containsString("Бесхвостые @ru"));
    assertThat(enrich.get(PropertyAndValueDictionary.COMMON_NAMES), containsString("\u0416\u0430\u0431\u044b @ru"));
    assertThat(enrich.get(PropertyAndValueDictionary.COMMON_NAMES), containsString("Frogs @en"));
}
Also used : HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) GlobalNamesService(org.eol.globi.taxon.GlobalNamesService) Test(org.junit.Test)

Example 10 with GlobalNamesService

use of org.eol.globi.taxon.GlobalNamesService in project eol-globi-data by jhpoelen.

the class GlobalNamesServiceTest method lookupITISFish.

@Test
public void lookupITISFish() throws PropertyEnricherException {
    GlobalNamesService service = new GlobalNamesService();
    service.setIncludeCommonNames(true);
    HashMap<String, String> props = new HashMap<String, String>();
    props.put(PropertyAndValueDictionary.NAME, "Ariopsis felis");
    Map<String, String> enrich = service.enrich(props);
    assertThat(enrich.get(PropertyAndValueDictionary.NAME), is("Ariopsis felis"));
    assertThat(enrich.get(PropertyAndValueDictionary.PATH), is("Animalia | Bilateria | Deuterostomia | Chordata | Vertebrata | Gnathostomata | Actinopterygii | Teleostei | Ostariophysi | Siluriformes | Ariidae | Ariopsis | Ariopsis felis"));
    assertThat(enrich.get(PropertyAndValueDictionary.PATH_IDS), is("ITIS:202423 | ITIS:914154 | ITIS:914156 | ITIS:158852 | ITIS:331030 | ITIS:914179 | ITIS:161061 | ITIS:161105 | ITIS:162845 | ITIS:163992 | ITIS:164157 | ITIS:639019 | ITIS:680665"));
    assertThat(enrich.get(PropertyAndValueDictionary.PATH_NAMES), is("Kingdom | Subkingdom | Infrakingdom | Phylum | Subphylum | Infraphylum | Superclass | Class | Superorder | Order | Family | Genus | Species"));
    assertThat(enrich.get(PropertyAndValueDictionary.RANK), is("Species"));
    assertThat(enrich.get(PropertyAndValueDictionary.EXTERNAL_ID), is("ITIS:680665"));
    assertThat(enrich.get(PropertyAndValueDictionary.COMMON_NAMES), is("bagre boca chica @Spanish"));
}
Also used : HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) GlobalNamesService(org.eol.globi.taxon.GlobalNamesService) Test(org.junit.Test)

Aggregations

GlobalNamesService (org.eol.globi.taxon.GlobalNamesService)21 Matchers.containsString (org.hamcrest.Matchers.containsString)21 Test (org.junit.Test)20 HashMap (java.util.HashMap)11 ArrayList (java.util.ArrayList)9 NameType (org.eol.globi.domain.NameType)9 Taxon (org.eol.globi.domain.Taxon)9 TermMatchListener (org.eol.globi.taxon.TermMatchListener)9