Search in sources :

Example 1 with TaxonCacheService

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

the class Normalizer method resolveAndLinkTaxa.

private void resolveAndLinkTaxa(CommandLine cmdLine, GraphDatabaseService graphService) {
    if (cmdLine == null || !cmdLine.hasOption(OPTION_SKIP_RESOLVE_CITATIONS)) {
        LOG.info("resolving citations to DOIs ...");
        new LinkerDOI(graphService, new DOIResolverCache()).link();
        new LinkerDOI(graphService).link();
    } else {
        LOG.info("skipping citation resolving ...");
    }
    if (cmdLine == null || !cmdLine.hasOption(OPTION_SKIP_TAXON_CACHE)) {
        LOG.info("resolving names with taxon cache ...");
        final TaxonCacheService taxonCacheService = new TaxonCacheService("/taxa/taxonCache.tsv.gz", "/taxa/taxonMap.tsv.gz");
        try {
            ResolvingTaxonIndex index = new ResolvingTaxonIndex(taxonCacheService, graphService);
            index.setIndexResolvedTaxaOnly(true);
            TaxonFilter taxonCacheFilter = new TaxonFilter() {

                private KnownBadNameFilter knownBadNameFilter = new KnownBadNameFilter();

                @Override
                public boolean shouldInclude(Taxon taxon) {
                    return taxon != null && knownBadNameFilter.shouldInclude(taxon);
                }
            };
            new NameResolver(graphService, index, taxonCacheFilter).resolve();
            LOG.info("adding same and similar terms for resolved taxa...");
            List<Linker> linkers = new ArrayList<>();
            linkers.add(new LinkerTermMatcher(graphService, taxonCacheService));
            appendOpenTreeTaxonLinker(graphService, linkers);
            linkers.forEach(LinkUtil::doTimedLink);
            LOG.info("adding same and similar terms for resolved taxa done.");
        } finally {
            taxonCacheService.shutdown();
        }
        LOG.info("resolving names with taxon cache done.");
    } else {
        LOG.info("skipping taxon cache ...");
    }
    if (cmdLine == null || !cmdLine.hasOption(OPTION_SKIP_RESOLVE)) {
        new NameResolver(graphService, new NonResolvingTaxonIndex(graphService)).resolve();
        new TaxonInteractionIndexer(graphService).index();
    } else {
        LOG.info("skipping taxa resolving ...");
    }
    if (cmdLine == null || !cmdLine.hasOption(OPTION_SKIP_LINK)) {
        List<Linker> linkers = new ArrayList<>();
        linkers.add(new LinkerTaxonIndex(graphService));
        linkers.forEach(LinkUtil::doTimedLink);
    } else {
        LOG.info("skipping linking ...");
    }
    if (cmdLine == null || !cmdLine.hasOption(OPTION_SKIP_LINK_THUMBNAILS)) {
        LinkUtil.doTimedLink(new ImageLinker(graphService, null));
    } else {
        LOG.info("skipping linking of taxa to thumbnails ...");
    }
}
Also used : TaxonCacheService(org.eol.globi.taxon.TaxonCacheService) DOIResolverCache(org.eol.globi.service.DOIResolverCache) NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) Taxon(org.eol.globi.domain.Taxon) ArrayList(java.util.ArrayList) NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) ResolvingTaxonIndex(org.eol.globi.taxon.ResolvingTaxonIndex)

Example 2 with TaxonCacheService

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

the class LinkerTermMatcherTest method homoSapiensCachedTaxa.

@Test
public void homoSapiensCachedTaxa() throws NodeFactoryException, PropertyEnricherException {
    taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapiens", null));
    TaxonCacheService taxonCacheService = new TaxonCacheService("classpath:/org/eol/globi/taxon/taxonCache.tsv", "classpath:/org/eol/globi/taxon/taxonMap.tsv");
    new LinkerTermMatcher(getGraphDb(), taxonCacheService).link();
    LinkerTestUtil.assertHasOther("Homo sapiens", 2, taxonIndex, RelTypes.SAME_AS);
}
Also used : TaxonCacheService(org.eol.globi.taxon.TaxonCacheService) TaxonImpl(org.eol.globi.domain.TaxonImpl) Test(org.junit.Test)

Aggregations

TaxonCacheService (org.eol.globi.taxon.TaxonCacheService)2 ArrayList (java.util.ArrayList)1 Taxon (org.eol.globi.domain.Taxon)1 TaxonImpl (org.eol.globi.domain.TaxonImpl)1 DOIResolverCache (org.eol.globi.service.DOIResolverCache)1 NonResolvingTaxonIndex (org.eol.globi.taxon.NonResolvingTaxonIndex)1 ResolvingTaxonIndex (org.eol.globi.taxon.ResolvingTaxonIndex)1 Test (org.junit.Test)1