Search in sources :

Example 91 with Study

use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.

the class NodeFactoryWithDatasetContextTest method createStudy.

@Test
public void createStudy() {
    NodeFactory factory = Mockito.mock(NodeFactory.class);
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"));
    NodeFactoryWithDatasetContext factoryWithDS = new NodeFactoryWithDatasetContext(factory, dataset);
    StudyImpl study = new StudyImpl("some title", "some source", "some doi", "some citation");
    study.setExternalId("some:id");
    factoryWithDS.createStudy(study);
    ArgumentCaptor<Study> argument = ArgumentCaptor.forClass(Study.class);
    verify(factory).createStudy(argument.capture());
    assertEquals("globi:some/namespace", argument.getValue().getSourceId());
    assertEquals("some title", argument.getValue().getTitle());
    assertEquals("some citation", argument.getValue().getCitation());
    assertEquals("some doi", argument.getValue().getDOI());
    assertEquals("some:id", argument.getValue().getExternalId());
}
Also used : Study(org.eol.globi.domain.Study) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.eol.globi.service.DatasetImpl) Test(org.junit.Test)

Example 92 with Study

use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.

the class GraphExporterImpl method export.

private void export(List<Study> importedStudies, String exportPath, String filename, DarwinCoreExporter studyExporter, FileWriter darwinCoreMeta) throws IOException {
    OutputStreamWriter writer = openStream(exportPath + filename);
    for (Study importedStudy : importedStudies) {
        boolean includeHeader = importedStudies.indexOf(importedStudy) == 0;
        studyExporter.exportStudy(importedStudy, writer, includeHeader);
    }
    closeStream(exportPath + filename, writer);
    LOG.info("darwin core meta file writing... ");
    studyExporter.exportDarwinCoreMetaTable(darwinCoreMeta, filename);
    LOG.info("darwin core meta file written. ");
}
Also used : Study(org.eol.globi.domain.Study)

Example 93 with Study

use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.

the class GraphExporterImpl method export.

@Override
public void export(GraphDatabaseService graphService, String baseDir) throws StudyImporterException {
    try {
        FileUtils.forceMkdir(new File(baseDir));
    } catch (IOException e) {
        throw new StudyImporterException("failed to create output dir [" + baseDir + "]", e);
    }
    LOG.info("site maps generating... ");
    File siteMapDir = new File(baseDir, "sitemap");
    final File citations = new File(siteMapDir, "citations");
    LOG.info("site maps at [" + citations.getAbsolutePath() + "] generating... ");
    new ExporterSiteMapForCitations().export(graphService, citations.getAbsolutePath());
    LOG.info("site maps at [" + citations.getAbsolutePath() + "] generated.");
    final File names = new File(siteMapDir, "names");
    LOG.info("site maps at [" + names.getAbsolutePath() + "] generating... ");
    final GraphExporter exporter = new ExporterSiteMapForNames();
    exporter.export(graphService, names.getAbsolutePath());
    LOG.info("site maps at [" + names.getAbsolutePath() + "] generated.");
    LOG.info("site maps generated... ");
    List<Study> studies = NodeUtil.findAllStudies(graphService);
    exportNames(baseDir, studies);
    // export to taxa for now, to avoid additional assemblies
    new ExportFlatInteractions().export(graphService, "tsv");
    new ExportCitations().export(graphService, "tsv");
    exportNCBILinkOut(graphService, baseDir, studies);
    exportDataOntology(studies, baseDir);
    exportDarwinCoreAggregatedByStudy(baseDir, studies);
    exportDarwinCoreAll(baseDir, studies);
}
Also used : Study(org.eol.globi.domain.Study) StudyImporterException(org.eol.globi.data.StudyImporterException)

Example 94 with Study

use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.

the class StudyImporterForBroseIT method importAll.

@Test
public void importAll() throws StudyImporterException {
    StudyImporterForBrose studyImporterForBrose = new StudyImporterForBrose(new ParserFactoryLocal(), nodeFactory);
    studyImporterForBrose.importStudy();
    List<Study> studies = NodeUtil.findAllStudies(getGraphDb());
    assertThat(studies.size(), is(20));
    for (Study study : studies) {
        assertThat(study.getTitle(), is(notNullValue()));
        assertThat(study.getSource(), is(notNullValue()));
        assertThat(StringUtils.isBlank(study.getCitation()), is(false));
    }
}
Also used : Study(org.eol.globi.domain.Study) Test(org.junit.Test)

Example 95 with Study

use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.

the class StudyImporterForByrnesTest method importAll.

@Test
public void importAll() throws StudyImporterException {
    StudyImporterForByrnes studyImporterForByrnes = new StudyImporterForByrnes(new ParserFactoryLocal(), nodeFactory);
    studyImporterForByrnes.importStudy();
    resolveNames();
    List<String> citationList = new ArrayList<String>();
    Set<String> citations = new HashSet<String>();
    List<Study> studies = NodeUtil.findAllStudies(getGraphDb());
    assertTrue(studies.size() > 0);
    for (Study study : studies) {
        assertThat(study.getTitle(), is(notNullValue()));
        assertThat(study.getSource(), is(notNullValue()));
        assertThat(study.getCitation(), is(notNullValue()));
        citations.add(study.getCitation());
        citationList.add(study.getCitation());
    }
    assertThat("found duplicates in citation list", citationList.size(), is(citations.size()));
    assertNotNull(taxonIndex.findTaxonByName("Anisotremus davidsonii"));
    assertThat(citations, hasItem("Pennings, S. C. 1990. Size-related shifts in herbivory: specialization in the sea hare Aplysia californica Cooper. Journal of Experimental Marine Biology and Ecology 142:43-61."));
    assertThat(citations, hasItem("Barry, J. and M. Ehret. 1993. Diet, food preference, and algal availability for fishes and crabs on intertidal reef communities in southern California. Environmental Biology of Fishes 37:75-95."));
    assertThat(citations, hasItem("Byrnes, J.E. et al., 2011. Climate-driven increases in storm frequency simplify kelp forest food webs. Global Change Biology, 17(8), pp.2513–2524. Available at: http://dx.doi.org/10.1111/j.1365-2486.2011.02409.x."));
    assertThat(citations, not(hasItem("17(8)")));
    ExecutionEngine executionEngine = new ExecutionEngine(getGraphDb());
    ExecutionResult result = executionEngine.execute("START taxon = node:taxons(name=\"Strongylocentrotus purpuratus\")" + " MATCH taxon<-[:CLASSIFIED_AS]-specimen-[:ATE]->prey-[:CLASSIFIED_AS]->preyTaxon " + " RETURN collect(distinct(preyTaxon.name))");
    assertThat(result.dumpToString(), containsString("Bossiella orbigiana"));
}
Also used : Study(org.eol.globi.domain.Study) ExecutionEngine(org.neo4j.cypher.javacompat.ExecutionEngine) ArrayList(java.util.ArrayList) ExecutionResult(org.neo4j.cypher.javacompat.ExecutionResult) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Study (org.eol.globi.domain.Study)141 Test (org.junit.Test)84 StudyImpl (org.eol.globi.domain.StudyImpl)61 Specimen (org.eol.globi.domain.Specimen)38 Relationship (org.neo4j.graphdb.Relationship)33 TaxonImpl (org.eol.globi.domain.TaxonImpl)32 IOException (java.io.IOException)30 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)24 Location (org.eol.globi.domain.Location)24 StringWriter (java.io.StringWriter)21 LocationImpl (org.eol.globi.domain.LocationImpl)20 ArrayList (java.util.ArrayList)17 HashMap (java.util.HashMap)16 Taxon (org.eol.globi.domain.Taxon)16 SpecimenNode (org.eol.globi.domain.SpecimenNode)14 Date (java.util.Date)13 DatasetImpl (org.eol.globi.service.DatasetImpl)13 Node (org.neo4j.graphdb.Node)12 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)10 InteractType (org.eol.globi.domain.InteractType)9