use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class StudyImporterForLifeWatchGreeceTest method addTaxonNameForSpecimenNode.
private void addTaxonNameForSpecimenNode(Set<String> taxa, Node startNode) {
Specimen predatorSpecimen = new SpecimenNode(startNode);
Iterable<Relationship> classifications = NodeUtil.getClassifications(predatorSpecimen);
for (Relationship classification : classifications) {
taxa.add(new TaxonNode(classification.getEndNode()).getName());
}
}
use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class ExportUnmatchedTaxonNamesTest method exportOnePredatorNoPathButWithSameAs.
@Test
public void exportOnePredatorNoPathButWithSameAs() throws NodeFactoryException, IOException {
taxonIndex = ExportTestUtil.taxonIndexWithEnricher(null, getGraphDb());
String citation = "cite, study";
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("my, study", "my first, source", null, citation));
Specimen predatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapienz", null));
Taxon humanz = taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapienz", null));
TaxonImpl taxon = new TaxonImpl("Homo sapiens", "TESTING:123");
taxon.setPath("one | two | Homo sapiens");
NodeUtil.connectTaxa(taxon, (TaxonNode) humanz, getGraphDb(), RelTypes.SIMILAR_TO);
assertNotNull(humanz);
Specimen preySpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Caniz", null));
predatorSpecimen.interactsWith(preySpecimen, InteractType.ATE);
predatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens", null));
Node synonymNode = ((NodeBacked) taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapiens Synonym", null))).getUnderlyingNode();
Node node = ((NodeBacked) taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapiens", null))).getUnderlyingNode();
Transaction tx = getGraphDb().beginTx();
try {
node.createRelationshipTo(synonymNode, NodeUtil.asNeo4j(RelTypes.SAME_AS));
tx.success();
} finally {
tx.finish();
}
preySpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Canis", null));
predatorSpecimen.ate(preySpecimen);
resolveNames();
StringWriter writer = new StringWriter();
new ExportUnmatchedTaxonNames().exportStudy(study, writer, true);
assertThat(writer.toString(), is("unmatched taxon name\tunmatched taxon id\tname status\tsimilar to taxon name\tsimilar to taxon path\tsimilar to taxon id\tstudy\tsource" + "\nHomo sapienz\t\t\tHomo sapiens\tone | two | Homo sapiens\tTESTING:123\tcite, study\tmy first, source" + "\nCaniz\t\t\t\t\t\tcite, study\tmy first, source" + "\nCanis\t\t\t\t\t\tcite, study\tmy first, source"));
}
use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class NonResolvingTaxonIndexTest method createTaxon.
@Test
public final void createTaxon() throws NodeFactoryException {
Taxon taxon1 = new TaxonImpl("bla bla", null);
taxon1.setPath(null);
TaxonNode taxon = taxonService.getOrCreateTaxon(taxon1);
assertThat(taxon, is(notNullValue()));
assertEquals("bla bla", taxon.getName());
}
use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class ResolvingTaxonIndexTest method indexResolvedOnly.
@Test
public void indexResolvedOnly() throws NodeFactoryException {
TaxonNode unresolvedTaxon = getIndex().getOrCreateTaxon(new TaxonImpl("not resolved"));
assertNotNull(unresolvedTaxon);
assertFalse(TaxonUtil.isResolved(unresolvedTaxon));
final ResolvingTaxonIndex indexResolvedOnly = getIndex();
indexResolvedOnly.setIndexResolvedTaxaOnly(true);
assertNull(indexResolvedOnly.getOrCreateTaxon(new TaxonImpl("no resolving either", null)));
}
use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class LinkerTaxonIndexTest method linking.
@Test
public void linking() throws NodeFactoryException {
Taxon taxonFound = new TaxonImpl("Homo sapiens", "Bar:123");
taxonFound.setPath("Animalia | Mammalia | Homo sapiens");
Taxon taxon = taxonIndex.getOrCreateTaxon(taxonFound);
TaxonImpl taxon1 = new TaxonImpl("Homo sapiens also", "FOO:444");
taxon1.setPathIds("BARZ:111 | FOOZ:777");
NodeUtil.connectTaxa(taxon1, (TaxonNode) taxon, getGraphDb(), RelTypes.SAME_AS);
taxon = taxonIndex.getOrCreateTaxon(new TaxonImpl("Bla blaus", null));
taxon.setExternalId("FOO 1234");
resolveNames();
new LinkerTaxonIndex(getGraphDb()).link();
IndexHits<Node> hits = getGraphDb().index().forNodes(LinkerTaxonIndex.INDEX_TAXON_NAMES_AND_IDS).query("*:*");
Node next = hits.next();
assertThat(new TaxonNode(next).getName(), is("Homo sapiens"));
assertThat(hits.hasNext(), is(true));
hits.close();
assertSingleHit(PropertyAndValueDictionary.PATH + ":BAR\\:123");
assertSingleHit(PropertyAndValueDictionary.PATH + ":FOO\\:444");
assertSingleHit(PropertyAndValueDictionary.PATH + ":FOO\\:444 " + PropertyAndValueDictionary.PATH + ":BAR\\:123");
assertSingleHit(PropertyAndValueDictionary.PATH + ":BAR\\:*");
assertSingleHit(PropertyAndValueDictionary.PATH + ":Homo");
assertSingleHit(PropertyAndValueDictionary.PATH + ":\"Homo sapiens\"");
Taxon node = taxonIndex.findTaxonByName("Homo sapiens");
assertThat(((NodeBacked) node).getUnderlyingNode().getProperty(PropertyAndValueDictionary.EXTERNAL_IDS).toString(), is("Animalia | Mammalia | Homo sapiens | BARZ:111 | FOOZ:777 | Bar:123 | FOO:444"));
assertThat(((NodeBacked) node).getUnderlyingNode().getProperty(PropertyAndValueDictionary.NAME_IDS).toString(), is("Bar:123 | FOO:444"));
assertThat(new TaxonFuzzySearchIndex(getGraphDb()).query("name:sapienz~").size(), is(1));
assertThat(new TaxonFuzzySearchIndex(getGraphDb()).query("name:sapienz").size(), is(0));
}
Aggregations