use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class TaxonUtilTest method copyTaxon.
@Test
public void copyTaxon() {
Taxon src = new TaxonImpl("name", "id");
src.setStatus(new TermImpl("statusId", "statusLabel"));
Taxon target = new TaxonImpl();
TaxonUtil.copy(src, target);
assertThat(target.getStatus().getId(), is("statusId"));
assertThat(target.getStatus().getName(), is("statusLabel"));
}
use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class ExporterTaxaDistinctTest method exportMissingLength.
@Test
public void exportMissingLength() throws IOException, NodeFactoryException, ParseException {
ExportTestUtil.createTestData(null, nodeFactory);
taxonIndex.getOrCreateTaxon(new TaxonImpl("Canis lupus", "EOL:123"));
taxonIndex.getOrCreateTaxon(new TaxonImpl("Canis", "EOL:126"));
taxonIndex.getOrCreateTaxon(new TaxonImpl("ThemFishes", "no:match"));
resolveNames();
Study myStudy1 = nodeFactory.findStudy("myStudy");
String actual = exportStudy(myStudy1);
assertThat(actual, containsString("EOL:123\tCanis lupus\t\t\t\t\t\t\t\t\thttp://eol.org/pages/123\t\t\t\t"));
assertThat(actual, containsString("EOL:45634\tHomo sapiens\t\t\t\t\t\t\t\t\thttp://eol.org/pages/45634\t\t\t\t"));
assertThat(actual, not(containsString("no:match\tThemFishes\t\t\t\t\t\t\t\t\t\t\t\t\t")));
assertThatNoTaxaAreExportedOnMissingHeader(myStudy1, new StringWriter());
}
use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class ExporterTaxaDistinctTest method excludeNoMatchNames.
@Test
public void excludeNoMatchNames() throws NodeFactoryException, IOException {
Study study = nodeFactory.createStudy(new StudyImpl("bla", null, null, null));
Specimen predator = nodeFactory.createSpecimen(study, new TaxonImpl(PropertyAndValueDictionary.NO_MATCH, "EOL:1234"));
Specimen prey = nodeFactory.createSpecimen(study, new TaxonImpl(PropertyAndValueDictionary.NO_MATCH, "EOL:122"));
predator.ate(prey);
assertThat(exportStudy(study), not(containsString(PropertyAndValueDictionary.NO_MATCH)));
}
use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class ExporterRDFTest method exportSPIRE.
@Test
public void exportSPIRE() throws IOException, StudyImporterException {
StudyImporterForSPIRE importer = new StudyImporterForSPIRE(null, nodeFactory);
importer.setFilter(recordNumber -> recordNumber < 5);
importer.setDataset(new DatasetLocal());
importStudy(importer);
List<Study> studies = NodeUtil.findAllStudies(getGraphDb());
Taxon taxon = taxonIndex.getOrCreateTaxon(new TaxonImpl("some taxon", null));
Taxon sameAsTaxon = taxonIndex.getOrCreateTaxon(new TaxonImpl("bugus same as taxon", "EOL:123"));
Transaction tx = getGraphDb().beginTx();
try {
assertThat(taxon, is(notNullValue()));
((NodeBacked) taxon).getUnderlyingNode().createRelationshipTo(((NodeBacked) sameAsTaxon).getUnderlyingNode(), NodeUtil.asNeo4j(RelTypes.SAME_AS));
tx.success();
} finally {
tx.finish();
}
File file = File.createTempFile("spire-as-light-globi", ".nq");
try {
Writer writer = new FileWriter(file);
ExporterRDF turtleExporter = new ExporterRDF();
for (Study study : studies) {
turtleExporter.exportStudy(study, writer, true);
}
writer.flush();
writer.close();
assertTrue(file.exists());
String content = IOUtils.toString(new FileInputStream(file));
assertThat(content, not(containsString("no:match")));
assertThat(content, containsString("http://purl.obolibrary.org/obo/ENVO_"));
} finally {
FileUtils.deleteQuietly(file);
}
}
use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class TaxonCacheServiceIT method init10k.
@Test
public void init10k() throws PropertyEnricherException {
final TaxonCacheService cacheService = new TaxonCacheService("/org/eol/globi/taxon/taxonCache10k.tsv.gz", "/org/eol/globi/taxon/taxonMap10k.tsv.gz");
cacheService.setCacheDir(mapdbDir);
StopWatch watch = new StopWatch();
final TaxonImpl taxon = new TaxonImpl();
taxon.setExternalId("EOL:1049789");
watch.start();
final Map<String, String> enriched = cacheService.enrich(TaxonUtil.taxonToMap(taxon));
assertThat(TaxonUtil.mapToTaxon(enriched).getPath(), is("Animalia | Chordata | Aves | Columbiformes | Columbidae | Turtur | Turtur tympanistria"));
watch.stop();
}
Aggregations