Search in sources :

Example 96 with TaxonImpl

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"));
}
Also used : Taxon(org.eol.globi.domain.Taxon) TaxonImpl(org.eol.globi.domain.TaxonImpl) TermImpl(org.eol.globi.domain.TermImpl) Test(org.junit.Test)

Example 97 with TaxonImpl

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());
}
Also used : Study(org.eol.globi.domain.Study) StringWriter(java.io.StringWriter) TaxonImpl(org.eol.globi.domain.TaxonImpl) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) Test(org.junit.Test)

Example 98 with TaxonImpl

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)));
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 99 with TaxonImpl

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);
    }
}
Also used : Study(org.eol.globi.domain.Study) Taxon(org.eol.globi.domain.Taxon) TaxonImpl(org.eol.globi.domain.TaxonImpl) FileWriter(java.io.FileWriter) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) DatasetLocal(org.eol.globi.service.DatasetLocal) FileInputStream(java.io.FileInputStream) StudyImporterForSPIRE(org.eol.globi.data.StudyImporterForSPIRE) Transaction(org.neo4j.graphdb.Transaction) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer) Test(org.junit.Test)

Example 100 with TaxonImpl

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();
}
Also used : TaxonImpl(org.eol.globi.domain.TaxonImpl) StopWatch(org.apache.commons.lang3.time.StopWatch) Test(org.junit.Test)

Aggregations

TaxonImpl (org.eol.globi.domain.TaxonImpl)123 Specimen (org.eol.globi.domain.Specimen)59 Test (org.junit.Test)54 Taxon (org.eol.globi.domain.Taxon)42 StudyImpl (org.eol.globi.domain.StudyImpl)34 Study (org.eol.globi.domain.Study)32 Location (org.eol.globi.domain.Location)16 LocationImpl (org.eol.globi.domain.LocationImpl)15 TaxonNode (org.eol.globi.domain.TaxonNode)13 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)12 IOException (java.io.IOException)11 TermImpl (org.eol.globi.domain.TermImpl)11 StringWriter (java.io.StringWriter)9 ArrayList (java.util.ArrayList)7 Date (java.util.Date)7 HashMap (java.util.HashMap)7 NonResolvingTaxonIndex (org.eol.globi.taxon.NonResolvingTaxonIndex)7 Map (java.util.Map)5 Node (org.neo4j.graphdb.Node)5 File (java.io.File)4