Search in sources :

Example 31 with TaxonImpl

use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.

the class LinkerOpenTreeOfLifeTest method copyAndLink.

@Test
public void copyAndLink() {
    final TaxonImpl taxon = new TaxonImpl();
    taxon.setExternalId("GBIF:123");
    final Taxon linkedTaxon = LinkerOpenTreeOfLife.copyAndLinkToOpenTreeTaxon(taxon, 555L);
    assertThat(linkedTaxon.getExternalId(), is("OTT:555"));
    assertThat(linkedTaxon.getExternalUrl(), is("https://tree.opentreeoflife.org/opentree/ottol@555"));
}
Also used : TaxonImpl(org.eol.globi.domain.TaxonImpl) Taxon(org.eol.globi.domain.Taxon) Test(org.junit.Test)

Example 32 with TaxonImpl

use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.

the class LinkerOpenTreeOfLifeTest method assertOTTLink.

protected void assertOTTLink(String name, int expectedCount, String ottId) throws NodeFactoryException, PropertyEnricherException {
    OpenTreeTaxonIndex index = null;
    try {
        index = new OpenTreeTaxonIndex(getClass().getResource("taxonomy-small.tsv"));
        taxonIndex.getOrCreateTaxon(new TaxonImpl(name, null));
        new LinkerTermMatcher(getGraphDb()).link();
        new LinkerOpenTreeOfLife(getGraphDb(), index).link();
        Collection<String> externalIds = LinkerTestUtil.assertHasOther(name, expectedCount, taxonIndex, RelTypes.SAME_AS);
        assertThat(externalIds, hasItem(TaxonomyProvider.OPEN_TREE_OF_LIFE.getIdPrefix() + ottId));
    } finally {
        if (index != null) {
            index.destroy();
        }
    }
}
Also used : TaxonImpl(org.eol.globi.domain.TaxonImpl) OpenTreeTaxonIndex(org.eol.globi.opentree.OpenTreeTaxonIndex)

Example 33 with TaxonImpl

use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.

the class LinkerTaxonIndexTest method findByStringWithWhitespaces.

@Test
public void findByStringWithWhitespaces() throws NodeFactoryException {
    NonResolvingTaxonIndex taxonService = new NonResolvingTaxonIndex(getGraphDb());
    taxonService.getOrCreateTaxon(setTaxonProps(new TaxonImpl("Homo sapiens")));
    resolveNames();
    new LinkerTaxonIndex(getGraphDb()).link();
    assertThat(getGraphDb().index().existsForNodes("taxonNameSuggestions"), is(true));
    Index<Node> index = getGraphDb().index().forNodes("taxonNameSuggestions");
    Query query = new TermQuery(new Term("name", "name"));
    IndexHits<Node> hits = index.query(query);
    assertThat(hits.size(), is(1));
    hits = index.query("name", "s nme~");
    assertThat(hits.size(), is(1));
    hits = index.query("name", "geRman~");
    assertThat(hits.size(), is(1));
    hits = index.query("name:geRman~ AND name:som~");
    assertThat(hits.size(), is(1));
    hits = index.query("name:hmo~ AND name:SApiens~");
    assertThat(hits.size(), is(1));
    hits = index.query("name:hmo~ AND name:sapiens~");
    assertThat(hits.size(), is(1));
    // queries are case sensitive . . . should all be lower cased.
    hits = index.query("name:HMO~ AND name:saPIENS~");
    assertThat(hits.size(), is(0));
}
Also used : TermQuery(org.apache.lucene.search.TermQuery) Query(org.apache.lucene.search.Query) TermQuery(org.apache.lucene.search.TermQuery) NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) TaxonImpl(org.eol.globi.domain.TaxonImpl) Node(org.neo4j.graphdb.Node) TaxonNode(org.eol.globi.domain.TaxonNode) Term(org.apache.lucene.index.Term) ResolvingTaxonIndexTest(org.eol.globi.taxon.ResolvingTaxonIndexTest) Test(org.junit.Test)

Example 34 with TaxonImpl

use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.

the class NameResolverTest method iNaturalistTaxon.

@Test
public void iNaturalistTaxon() throws NodeFactoryException {
    Specimen someOtherOrganism = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Blaus bla", "INAT_TAXON:58831"));
    Specimen someOtherOrganism2 = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Redus rha", "INAT_TAXON:126777"));
    someOtherOrganism.ate(someOtherOrganism2);
    final NameResolver nameResolver = new NameResolver(getGraphDb(), new NonResolvingTaxonIndex(getGraphDb()));
    nameResolver.setBatchSize(1L);
    nameResolver.resolve();
    Taxon resolvedTaxon = taxonIndex.findTaxonById("INAT_TAXON:58831");
    assertThat(resolvedTaxon, is(notNullValue()));
    assertThat(resolvedTaxon.getExternalId(), is("INAT_TAXON:58831"));
    assertThat(resolvedTaxon.getName(), is("Blaus bla"));
    Taxon resolvedTaxon2 = taxonIndex.findTaxonByName("Blaus bla");
    assertThat(resolvedTaxon2, is(notNullValue()));
    assertThat(resolvedTaxon2.getExternalId(), is("INAT_TAXON:58831"));
}
Also used : Specimen(org.eol.globi.domain.Specimen) NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) TaxonImpl(org.eol.globi.domain.TaxonImpl) Taxon(org.eol.globi.domain.Taxon) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 35 with TaxonImpl

use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.

the class LinkerTermMatcherTest method hasFishBaseLinks.

@Test
public void hasFishBaseLinks() throws NodeFactoryException, PropertyEnricherException {
    taxonIndex.getOrCreateTaxon(new TaxonImpl("Ariopsis felis", null));
    new LinkerTermMatcher(getGraphDb()).link();
    Collection<String> ids = LinkerTestUtil.assertHasOther("Ariopsis felis", 8, taxonIndex, RelTypes.SAME_AS);
    assertThat(ids, hasItem("FBC:FB:SpecCode:947"));
    assertThat(ids, hasItem("INAT_TAXON:94635"));
}
Also used : TaxonImpl(org.eol.globi.domain.TaxonImpl) Test(org.junit.Test)

Aggregations

TaxonImpl (org.eol.globi.domain.TaxonImpl)123 Specimen (org.eol.globi.domain.Specimen)59 Test (org.junit.Test)54 Taxon (org.eol.globi.domain.Taxon)42 StudyImpl (org.eol.globi.domain.StudyImpl)34 Study (org.eol.globi.domain.Study)32 Location (org.eol.globi.domain.Location)16 LocationImpl (org.eol.globi.domain.LocationImpl)15 TaxonNode (org.eol.globi.domain.TaxonNode)13 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)12 IOException (java.io.IOException)11 TermImpl (org.eol.globi.domain.TermImpl)11 StringWriter (java.io.StringWriter)9 ArrayList (java.util.ArrayList)7 Date (java.util.Date)7 HashMap (java.util.HashMap)7 NonResolvingTaxonIndex (org.eol.globi.taxon.NonResolvingTaxonIndex)7 Map (java.util.Map)5 Node (org.neo4j.graphdb.Node)5 File (java.io.File)4