Search in sources :

Example 6 with NonResolvingTaxonIndex

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

the class TaxonInteractionIndexerTest method buildTaxonInterIndex.

@Test
public void buildTaxonInterIndex() throws NodeFactoryException, PropertyEnricherException {
    Specimen human = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Homo sapiens", "NCBI:9606"));
    Specimen animal = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Canis lupus", "WORMS:2"));
    human.ate(animal);
    for (int i = 0; i < 10; i++) {
        Specimen fish = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Arius felis", "WORMS:158711"));
        human.ate(fish);
    }
    assertNull(taxonIndex.findTaxonById("WORMS:2"));
    assertNull(taxonIndex.findTaxonByName("Homo sapiens"));
    new NameResolver(getGraphDb(), new NonResolvingTaxonIndex(getGraphDb())).resolve();
    new TaxonInteractionIndexer(getGraphDb()).index();
    Taxon homoSapiens = taxonIndex.findTaxonByName("Homo sapiens");
    assertNotNull(homoSapiens);
    Iterable<Relationship> rels = ((NodeBacked) homoSapiens).getUnderlyingNode().getRelationships(Direction.OUTGOING, NodeUtil.asNeo4j(InteractType.ATE));
    List<String> humanFood = new ArrayList<String>();
    List<Long> counts = new ArrayList<Long>();
    List<String> labels = new ArrayList<>();
    for (Relationship rel : rels) {
        humanFood.add((String) rel.getEndNode().getProperty("name"));
        counts.add((Long) rel.getProperty("count"));
        labels.add((String) rel.getProperty("label"));
    }
    assertThat(humanFood.size(), is(4));
    assertThat(humanFood, hasItems("Arius felis", "Canis lupus"));
    assertThat(counts, hasItems(10L, 1L));
    assertThat(labels, hasItems("eats"));
}
Also used : NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) TaxonImpl(org.eol.globi.domain.TaxonImpl) Taxon(org.eol.globi.domain.Taxon) StudyImpl(org.eol.globi.domain.StudyImpl) ArrayList(java.util.ArrayList) Specimen(org.eol.globi.domain.Specimen) Relationship(org.neo4j.graphdb.Relationship) Test(org.junit.Test)

Example 7 with NonResolvingTaxonIndex

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

the class NameResolverTest method doNameResolving.

@Test
public void doNameResolving() throws NodeFactoryException, PropertyEnricherException {
    Specimen human = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Homo sapiens", "NCBI:9606"));
    Specimen animal = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Animalia", "WORMS:2"));
    human.ate(animal);
    Specimen fish = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Arius felis", "WORMS:158711"));
    human.ate(fish);
    assertNull(taxonIndex.findTaxonById("NCBI:9606"));
    assertNull(taxonIndex.findTaxonByName("Homo sapiens"));
    final NameResolver nameResolver = new NameResolver(getGraphDb(), new NonResolvingTaxonIndex(getGraphDb()));
    nameResolver.setBatchSize(1L);
    nameResolver.resolve();
    assertAnimalia(taxonIndex.findTaxonById("WORMS:2"));
    assertThat(taxonIndex.findTaxonByName("Arius felis"), is(notNullValue()));
    Taxon homoSapiens = taxonIndex.findTaxonByName("Homo sapiens");
    assertNotNull(homoSapiens);
    assertThat(homoSapiens.getExternalId(), is("NCBI:9606"));
}
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 8 with NonResolvingTaxonIndex

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

the class LinkerTermMatcherTest method lestesExcludeSuspectedHomonyms.

@Test
public void lestesExcludeSuspectedHomonyms() throws NodeFactoryException, PropertyEnricherException {
    taxonIndex = new NonResolvingTaxonIndex(getGraphDb());
    Taxon lestes = taxonIndex.getOrCreateTaxon(addProps(new TaxonImpl("Lestes", null)));
    assertThat(lestes.getPath(), is("Animalia | Insecta | Lestes"));
    new LinkerTermMatcher(getGraphDb()).link();
    Collection<String> ids = LinkerTestUtil.assertHasOther("Lestes", 7, taxonIndex, RelTypes.SAME_AS);
    assertThat(ids, hasItems("NCBI:181491", "ITIS:102061", "IRMNG:1320006", "GBIF:1423980", "OTT:1090993"));
    assertThat(ids, hasItems("INAT_TAXON:89475"));
}
Also used : NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) Taxon(org.eol.globi.domain.Taxon) TaxonImpl(org.eol.globi.domain.TaxonImpl) Test(org.junit.Test)

Aggregations

NonResolvingTaxonIndex (org.eol.globi.taxon.NonResolvingTaxonIndex)8 TaxonImpl (org.eol.globi.domain.TaxonImpl)7 Test (org.junit.Test)7 Specimen (org.eol.globi.domain.Specimen)5 StudyImpl (org.eol.globi.domain.StudyImpl)5 Taxon (org.eol.globi.domain.Taxon)5 ArrayList (java.util.ArrayList)2 File (java.io.File)1 Term (org.apache.lucene.index.Term)1 Query (org.apache.lucene.search.Query)1 TermQuery (org.apache.lucene.search.TermQuery)1 Study (org.eol.globi.domain.Study)1 TaxonNode (org.eol.globi.domain.TaxonNode)1 DOIResolverCache (org.eol.globi.service.DOIResolverCache)1 ResolvingTaxonIndex (org.eol.globi.taxon.ResolvingTaxonIndex)1 ResolvingTaxonIndexTest (org.eol.globi.taxon.ResolvingTaxonIndexTest)1 TaxonCacheService (org.eol.globi.taxon.TaxonCacheService)1 Node (org.neo4j.graphdb.Node)1 Relationship (org.neo4j.graphdb.Relationship)1