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"));
}
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();
}
}
}
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));
}
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"));
}
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"));
}
Aggregations