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