Search in sources :

Example 11 with Study

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

the class StudyImporterForGitHubDataIT method importAll.

@Test
public void importAll() throws StudyImporterException {
    StudyImporterForGitHubData importer = createImporter();
    final List<String> geoTerms = new ArrayList<String>();
    importer.setGeoNamesService(new GeoNamesService() {

        @Override
        public boolean hasTermForLocale(String locality) {
            return true;
        }

        @Override
        public LatLng findLatLng(String termsOrLocale) throws IOException {
            geoTerms.add(termsOrLocale);
            return new LatLng(10, 10);
        }
    });
    importStudy(importer);
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    List<String> refs = new ArrayList<String>();
    List<String> DOIs = new ArrayList<String>();
    List<String> externalIds = new ArrayList<String>();
    List<String> sources = new ArrayList<String>();
    for (Study study : allStudies) {
        DOIs.add(study.getDOI());
        externalIds.add(study.getExternalId());
        refs.add(study.getCitation());
        sources.add(study.getSource());
    }
    assertThat(refs, hasItem("Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1"));
    assertThat(DOIs, hasItem("doi:10.1007/s13127-011-0039-1"));
    assertThat(DOIs, hasItem("doi:10.3354/meps09511"));
    assertThat(DOIs, hasItem("doi:10.2307/3544990"));
    assertThat(externalIds, hasItem("http://dx.doi.org/10.2307/3544990"));
    assertThat(sources, hasItem(containsString("Accessed at")));
    assertThat(sources, hasItem(containsString("Miller")));
    assertThat(sources, hasItem(containsString("http://gomexsi.tamucc.edu")));
    assertThat(geoTerms, hasItem("GEONAMES:8556192"));
    assertThat(taxonIndex.findTaxonByName("Leptoconchus incycloseris"), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Sandalolitha dentata"), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Pterois volitans/miles"), is(notNullValue()));
}
Also used : Study(org.eol.globi.domain.Study) GeoNamesService(org.eol.globi.service.GeoNamesService) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) IOException(java.io.IOException) LatLng(org.eol.globi.geo.LatLng) Test(org.junit.Test)

Example 12 with Study

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

the class StudyImporterForGitHubDataIT method importREEM.

@Test
public void importREEM() throws StudyImporterException {
    StudyImporterForGitHubData importer = createImporter();
    importer.importData("globalbioticinteractions/noaa-reem");
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    assertThat(allStudies.size(), is(3));
    int specimenCount = 0;
    for (Study study : allStudies) {
        final Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
        for (Relationship specimen : specimens) {
            specimenCount++;
        }
    }
    assertThat(specimenCount > 0, is(true));
}
Also used : Study(org.eol.globi.domain.Study) Relationship(org.neo4j.graphdb.Relationship) Test(org.junit.Test)

Example 13 with Study

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

the class StudyImporterForGitHubDataIT method importNHM.

@Test
public void importNHM() throws StudyImporterException {
    StudyImporterForGitHubData importer = createImporter();
    importer.importData("globalbioticinteractions/natural-history-museum-london-interactions-bank");
    resolveNames();
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    assertThat(taxonIndex.findTaxonByName("Magnifera indica"), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Hermagoras sigillatus"), is(notNullValue()));
    List<String> citations = new ArrayList<String>();
    List<String> dois = new ArrayList<String>();
    for (Study study : allStudies) {
        assertThat(study.getSource(), is(Matchers.notNullValue()));
        assertThat(study.getCitation(), is(Matchers.notNullValue()));
        citations.add(study.getCitation());
        dois.add(study.getDOI());
    }
    assertThat(citations, hasItem("F.  Seow-Choen, A Taxonomic Guide to the Stick Insects of Borneo. Kota Kinabalu: Natural History Publications (Borneo), 2016."));
    assertThat(dois, hasItem("10.2307/3503496"));
}
Also used : Study(org.eol.globi.domain.Study) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 14 with Study

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

the class StudyImporterForICESTest method parseSelection.

@Test
public void parseSelection() throws NodeFactoryException, StudyImporterException, ParseException {
    String firstBunchOfLines = "File Name,Latitude,Longitude,Estimated Lat/Lon,Date/Time,Year,Quarter,Month,Day,Time,Station/Haul,Sample Number,ICES StomachID,Depth,Temperature,Country,Ship,ICES Rectangle,Sampling Method,Predator,Predator NODC Code,Predator (mean) Lengh,Predator (mean) Weight,Predator (mean) Age,Predator Lower Length Bound,Predator Upper Length Bound,CPUE,Number Stomachs With Food,Number Stomachs Regurgitated,Number Stomachs With Skeletal Remains,Number Stomachs Empty,Number Stomachs,Digestion Stage,Prey Species Name,Prey NODC Code,Prey Weight,Prey Lower Length Bound,Prey Upper Length Bound,Prey Number,ICES Internal ID\n" + "Exccoddatsto_815,55.25,8.5,Yes,01/01/1981 00:00:00,1981,1,1,1,,,26,26,,,,,39F8,Demersal sampling,Gadus morhua,8791030402,125,,,100,150,29,26,0,0,2,28,,Polychaeta,5001000000,1.5,,,5,1\n" + "Exccoddatsto_815,55.25,8.5,Yes,01/01/1981 00:00:00,1981,1,1,1,,,26,26,,,,,39F8,Demersal sampling,Gadus morhua,8791030402,125,,,100,150,29,26,0,0,2,28,,Nereis,5001240400,5.3,,,1,2\n" + "Exccoddatsto_815,55.25,8.5,Yes,01/01/1981 00:00:00,1981,1,1,1,,,26,26,,,,,39F8,Demersal sampling,Gadus morhua,8791030402,125,,,100,150,29,26,0,0,2,28,,,5515290302,4.8,,,2,3";
    StudyImporterForICES importer = new StudyImporterForICES(new TestParserFactory(firstBunchOfLines), nodeFactory);
    importStudy(importer);
    Study study = getStudySingleton(getGraphDb());
    assertNotNull(taxonIndex.findTaxonByName("Gadus morhua"));
    assertNotNull(taxonIndex.findTaxonByName("Polychaeta"));
    assertNotNull(taxonIndex.findTaxonByName("Nereis"));
    Iterable<Relationship> collectedRels = NodeUtil.getSpecimens(study);
    int specimenCollected = 0;
    int preyEaten = 0;
    for (Relationship rel : collectedRels) {
        assertThat(rel.getProperty(SpecimenConstant.DATE_IN_UNIX_EPOCH), is(DateUtil.parsePatternUTC("1981", "yyyy").toDate().getTime()));
        Node specimen = rel.getEndNode();
        assertNotNull(specimen);
        Iterable<Relationship> relationships = specimen.getRelationships(Direction.OUTGOING, NodeUtil.asNeo4j(InteractType.ATE));
        for (Relationship ignored : relationships) {
            assertThat(specimen.getProperty(SpecimenConstant.LENGTH_IN_MM), is(125.0));
            preyEaten++;
        }
        Relationship collectedAtRelationship = specimen.getSingleRelationship(NodeUtil.asNeo4j(RelTypes.COLLECTED_AT), Direction.OUTGOING);
        assertNotNull(collectedAtRelationship);
        Node locationNode = collectedAtRelationship.getEndNode();
        assertNotNull(locationNode);
        assertThat((Double) locationNode.getProperty(LocationConstant.LATITUDE), is(55.25));
        assertThat((Double) locationNode.getProperty(LocationConstant.LONGITUDE), is(8.5));
        specimenCollected++;
    }
    assertThat(specimenCollected, Is.is(3));
    assertThat(preyEaten, Is.is(2));
}
Also used : Study(org.eol.globi.domain.Study) Relationship(org.neo4j.graphdb.Relationship) Node(org.neo4j.graphdb.Node) Test(org.junit.Test)

Example 15 with Study

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

the class StudyImporterForICESTest method importOneEveryThousandLines.

@Test
public void importOneEveryThousandLines() throws StudyImporterException {
    StudyImporterForICES studyImporterFor = new StudyImporterForICES(new ParserFactoryLocal(), nodeFactory);
    studyImporterFor.setFilter(new ImportFilter() {

        @Override
        public boolean shouldImportRecord(Long recordNumber) {
            return recordNumber % 1000 == 0;
        }
    });
    studyImporterFor.importStudy();
    List<Study> studies = NodeUtil.findAllStudies(getGraphDb());
    assertThat(studies.size(), is(1));
    Study study = studies.get(0);
    Iterator<Relationship> specimens = NodeUtil.getSpecimens(study).iterator();
    int specimenCount = 0;
    while (specimens.hasNext()) {
        specimens.next();
        specimenCount++;
    }
    assertThat(specimenCount, is(388));
}
Also used : Study(org.eol.globi.domain.Study) Relationship(org.neo4j.graphdb.Relationship) 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