Search in sources :

Example 26 with LocationImpl

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

the class StudyImporterForWrast method addNextRecordToStudy.

private void addNextRecordToStudy(LabeledCSVParser csvParser, Study study, Map<String, String> columnToNormalizedTermMapper, LengthParser lengthParser) throws StudyImporterException {
    String seasonName = csvParser.getValueByLabel(columnToNormalizedTermMapper.get(SEASON));
    String preyItem = csvParser.getValueByLabel(columnToNormalizedTermMapper.get(PREY_SPECIES));
    if (preyItem == null) {
        getLogger().warn(study, "no prey name for line [" + csvParser.getLastLineNumber() + "]");
    } else {
        Specimen prey = createAndClassifySpecimen(preyItem, study);
        String habitat = csvParser.getValueByLabel(COLUMN_MAPPER.get(HABITAT));
        String site = csvParser.getValueByLabel(COLUMN_MAPPER.get(SITE));
        String region = csvParser.getValueByLabel(COLUMN_MAPPER.get(REGION));
        String sampleLocationId = createLocationId(habitat, region, site);
        Map<String, LatLng> averageLocations = getLocationMap();
        LatLng latLng1 = averageLocations.get(sampleLocationId);
        if (latLng1 == null) {
            throw new StudyImporterException("no location information for [" + sampleLocationId + "] on line [" + csvParser.getLastLineNumber() + "] found in [" + averageLocations + "]");
        }
        if (depthMap == null) {
            depthMap = createDepthMap(study);
        }
        Double depth = depthMap.get(createDepthId(seasonName, region, site, habitat));
        Double altitude = depth == null ? null : -depth;
        if (depth == null) {
            getLogger().warn(study, createMsgPrefix(csvParser) + " failed to find depth for habitat, region, site and season: [" + createDepthId(seasonName, region, site, habitat) + "], skipping entry");
        }
        Location sampleLocation;
        try {
            sampleLocation = nodeFactory.getOrCreateLocation(new LocationImpl(latLng1.getLat(), latLng1.getLng(), altitude, null));
        } catch (NodeFactoryException e) {
            throw new StudyImporterException("failed to create location", e);
        }
        prey.caughtIn(sampleLocation);
        prey.caughtDuring(getOrCreateSeason(seasonName));
        String speciesName = csvParser.getValueByLabel(columnToNormalizedTermMapper.get(PREDATOR_SPECIES));
        String predatorId = csvParser.getValueByLabel(columnToNormalizedTermMapper.get(PREDATOR_SPECIMEN_ID));
        Map<String, Specimen> predatorMap = getPredatorSpecimenMap();
        Specimen predator = predatorMap.get(predatorId);
        if (predator == null) {
            predator = addPredatorSpecimen(csvParser, study, lengthParser, seasonName, sampleLocation, speciesName, predatorId, predatorMap);
        }
        predator.ate(prey);
        Date date = parseCollectionDate(csvParser, study);
        try {
            nodeFactory.setUnixEpochProperty(predator, date);
            nodeFactory.setUnixEpochProperty(prey, date);
        } catch (NodeFactoryException e) {
            throw new StudyImporterException("specimen not associated to study", e);
        }
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) LocationImpl(org.eol.globi.domain.LocationImpl) LatLng(org.eol.globi.geo.LatLng) Date(java.util.Date) Location(org.eol.globi.domain.Location)

Example 27 with LocationImpl

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

the class StudyImporterForSimonsTest method createAndPopulateStudy.

@Test
public void createAndPopulateStudy() throws StudyImporterException {
    String csvString = "\"Obs\",\"spcode\", \"sizecl\", \"cruise\", \"stcode\", \"numstom\", \"numfood\", \"pctfull\", \"predator famcode\", \"prey\", \"number\", \"season\", \"depth\", \"transect\", \"alphcode\", \"taxord\", \"station\", \"long\", \"lat\", \"time\", \"sizeclass\", \"predator\"\n";
    csvString += "1, 1, 16, 3, 2, 6, 6, 205.5, 1, \"Ampelisca sp. (abdita complex)\", 1, \"Summer\", 60, \"Chandeleur Islands\", \"aabd\", 47.11, \"C2\", 348078.84, 3257617.25, 313, \"201-300\", \"Rhynchoconger flavus\"\n";
    csvString += "1, 1, 16, 3, 2, 6, 6, 205.5, 1, \"Ampelisca agassizi\", 1, \"Summer\", 60, \"Chandeleur Islands\", \"aabd\", 47.11, \"C2\", 348078.84, 3257617.25, 313, \"201-300\", \"Rhynchoconger flavus\"\n";
    csvString += "2, 11, 2, 1, 1, 20, 15, 592.5, 6, \"Ampelisca sp. (abdita complex)\", 1, \"Summer\", 20, \"Chandeleur Islands\", \"aabd\", 47.11, \"C1\", 344445.31, 3323087.25, 144, \"26-50\", \"Halieutichthys aculeatus\"\n";
    StudyImporterForSimons importer = new StudyImporterForSimons(new TestParserFactory(csvString), nodeFactory);
    importStudy(importer);
    assertNotNull(taxonIndex.findTaxonByName("Rhynchoconger flavus"));
    assertNotNull(taxonIndex.findTaxonByName("Halieutichthys aculeatus"));
    assertNotNull(taxonIndex.findTaxonByName("Ampelisca sp. (abdita complex)"));
    assertNotNull(nodeFactory.findStudy("Simons 1997"));
    assertNotNull(nodeFactory.findLocation(new LocationImpl(LAT_1, LONG_1, -60.0d, null)));
    assertNotNull(nodeFactory.findLocation(new LocationImpl(LAT_2, LONG_2, -20.0d, null)));
    assertNotNull(nodeFactory.findSeason("summer"));
    Study foundStudy = nodeFactory.findStudy("Simons 1997");
    assertNotNull(foundStudy);
    for (Relationship rel : NodeUtil.getSpecimens(foundStudy)) {
        Node specimen = rel.getEndNode();
        Node speciesNode = specimen.getSingleRelationship(NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS), Direction.OUTGOING).getEndNode();
        String scientificName = (String) speciesNode.getProperty("name");
        if ("Rhynchoconger flavus".equals(scientificName)) {
            String seasonName = "summer";
            String genusName = "Ampelisca sp. (abdita complex)";
            double length = (201.0d + 300.0d) / 2.0d;
            assertSpecimen(specimen, LONG_1, LAT_1, -60.0, seasonName, genusName, length);
            Iterable<Relationship> ateRelationships = specimen.getRelationships(Direction.OUTGOING, NodeUtil.asNeo4j(InteractType.ATE));
            List<String> preyNames = new ArrayList<String>();
            for (Relationship ateRel : ateRelationships) {
                Node preyTaxonNode = ateRel.getEndNode().getRelationships(Direction.OUTGOING, NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS)).iterator().next().getEndNode();
                preyNames.add(preyTaxonNode.getProperty(PropertyAndValueDictionary.NAME).toString());
            }
            assertThat(preyNames, hasItem("Ampelisca sp. (abdita complex)"));
            assertThat(preyNames.contains("Ampelisca agassizi"), Is.is(true));
            assertThat(preyNames.size(), Is.is(2));
        } else if ("Halieutichthys aculeatus".equals(scientificName)) {
            String genusName = "Ampelisca sp. (abdita complex)";
            String seasonName = "summer";
            double length = (26.0d + 50.0d) / 2.0d;
            assertSpecimen(specimen, LONG_2, LAT_2, -20.0, seasonName, genusName, length);
        } else if ("Ampelisca sp. (abdita complex)".equals(scientificName)) {
            Node locationNode = specimen.getSingleRelationship(NodeUtil.asNeo4j(RelTypes.COLLECTED_AT), Direction.OUTGOING).getEndNode();
            assertNotNull(locationNode);
            assertTrue(locationNode.hasProperty(LocationConstant.LONGITUDE));
            assertTrue(locationNode.hasProperty(LocationConstant.ALTITUDE));
            assertTrue(locationNode.hasProperty(LocationConstant.LATITUDE));
        } else if ("Ampelisca agassizi".equals(scientificName)) {
            assertPreySpecimen(specimen, LONG_1, LAT_1, -60.0);
        } else {
            fail("found predator with unexpected scientificName [" + scientificName + "]");
        }
    }
}
Also used : Study(org.eol.globi.domain.Study) Relationship(org.neo4j.graphdb.Relationship) Node(org.neo4j.graphdb.Node) ArrayList(java.util.ArrayList) LocationImpl(org.eol.globi.domain.LocationImpl) Test(org.junit.Test)

Example 28 with LocationImpl

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

the class StudyImporterForCruaud method importStudy.

@Override
public void importStudy() throws StudyImporterException {
    LabeledCSVParser dataParser;
    try {
        dataParser = parserFactory.createParser(RESOURCE_PATH, CharsetConstant.UTF8);
    } catch (IOException e) {
        throw new StudyImporterException("failed to read resource [" + RESOURCE_PATH + "]", e);
    }
    try {
        Study study = nodeFactory.getOrCreateStudy(new StudyImpl("cruaud", SOURCE, "http://dx.doi.org/10.1093/sysbio/sys068", null));
        while (dataParser.getLine() != null) {
            if (importFilter.shouldImportRecord((long) dataParser.getLastLineNumber())) {
                try {
                    String parasiteName = StringUtils.trim(dataParser.getValueByLabel("Family and Species"));
                    String hostName = StringUtils.trim(dataParser.getValueByLabel("Natural host Ficus species"));
                    hostName = StringUtils.replace(hostName, "F.", "Ficus");
                    if (areNamesAvailable(parasiteName, hostName)) {
                        Specimen parasite = nodeFactory.createSpecimen(study, new TaxonImpl(parasiteName, null));
                        Specimen host = nodeFactory.createSpecimen(study, new TaxonImpl(hostName, null));
                        parasite.interactsWith(host, InteractType.PARASITE_OF);
                        String samplingLocation = StringUtils.trim(dataParser.getValueByLabel("Sampling location"));
                        if (getGeoNamesService().hasTermForLocale(samplingLocation)) {
                            LatLng pointForLocality = getGeoNamesService().findLatLng(samplingLocation);
                            if (pointForLocality == null) {
                                LOG.warn("no location associated with locality [" + samplingLocation + "]");
                            } else {
                                Location location = nodeFactory.getOrCreateLocation(new LocationImpl(pointForLocality.getLat(), pointForLocality.getLng(), null, null));
                                parasite.caughtIn(location);
                                host.caughtIn(location);
                            }
                        } else {
                            LOG.warn("no location associated with locality [" + samplingLocation + "]");
                        }
                    }
                } catch (NodeFactoryException | NumberFormatException e) {
                    throw new StudyImporterException("failed to import line [" + (dataParser.lastLineNumber() + 1) + "]", e);
                }
            }
        }
    } catch (IOException e) {
        throw new StudyImporterException("problem importing [" + RESOURCE_PATH + "]", e);
    }
}
Also used : Study(org.eol.globi.domain.Study) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) IOException(java.io.IOException) Specimen(org.eol.globi.domain.Specimen) LocationImpl(org.eol.globi.domain.LocationImpl) LatLng(org.eol.globi.geo.LatLng) Location(org.eol.globi.domain.Location)

Example 29 with LocationImpl

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

the class StudyImporterForDunne method importStudy.

@Override
public void importStudy() throws StudyImporterException {
    Study study = createStudy();
    try {
        LabeledCSVParser nodes = parserFactory.createParser(getNodesResourceName(), CharsetConstant.UTF8);
        nodes.changeDelimiter(getDelimiter());
        Map<Integer, Taxon> taxonForNode = new HashMap<Integer, Taxon>();
        while (nodes.getLine() != null) {
            Integer nodeId = getNodeId(nodes);
            if (nodeId != null) {
                final String tsn = nodes.getValueByLabel("TSN");
                taxonForNode.put(nodeId, new TaxonImpl(nodes.getValueByLabel("Name"), TaxonomyProvider.ID_PREFIX_ITIS + tsn));
            }
        }
        LabeledCSVParser links = parserFactory.createParser(getLinksResourceName(), CharsetConstant.UTF8);
        links.changeDelimiter(getDelimiter());
        while (links.getLine() != null) {
            List<Location> locations = new ArrayList<>();
            if (getLocation() != null) {
                Location loc = nodeFactory.getOrCreateLocation(new LocationImpl(getLocation().getLat(), getLocation().getLng(), null, null));
                if (loc != null) {
                    locations.add(loc);
                }
            }
            for (Location location : locations) {
                addLink(study, taxonForNode, links, location);
            }
        }
    } catch (IOException e) {
        throw new StudyImporterException("failed to find data file(s)", e);
    } catch (NodeFactoryException e) {
        throw new StudyImporterException("failed to create nodes", e);
    }
}
Also used : Study(org.eol.globi.domain.Study) HashMap(java.util.HashMap) Taxon(org.eol.globi.domain.Taxon) TaxonImpl(org.eol.globi.domain.TaxonImpl) ArrayList(java.util.ArrayList) LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) IOException(java.io.IOException) LocationImpl(org.eol.globi.domain.LocationImpl) Location(org.eol.globi.domain.Location)

Example 30 with LocationImpl

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

the class StudyImporterForBroseTest method importHeadAndTail.

@Test
public void importHeadAndTail() throws IOException, StudyImporterException {
    final String headAndTail = "Link ID\tLink reference \tBody size reference\tGeographic location\tGeneral habitat\tSpecific habitat\tLink methodology\tBody size methodology\tTaxonomy consumer\tLifestage consumer\tCommon name(s) consumer\tMetabolic category consumer\tType of feeding interaction\tMinimum length (m) consumer\tMean length (m) consumer\tMaximum length (m) consumer\tMinimum mass (g) consumer\tMean mass (g) consumer\tMaximum mass (g) consumer\tTaxonomy resource\tLifestage - resource\tCommon name(s) resource\tMetabolic category resource\tMinimum length (m) resource\tMean length (m) resource\tMaximum length (m) resource\tMinimum mass (g) resource\tMean mass (g) resource\tMaximum mass (g) resource\tConsumer/resource body mass ratio\tNotes\n" + "1\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tBacteria\theterotrophic bacteria\therbivorous\t-999\t-999\t-999\t-999\t0.00000001\t-999\t-999\tadults\tPhytoplankton\tphoto-autotroph\t-999\t-999\t-999\t-999\t0.0001\t-999\t0.0001\t-999\n" + "2\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tBenthic carnivores\tinvertebrate\tpredacious\t-999\t-999\t-999\t-999\t10\t-999\t-999\tadults\tBenthic filter feeders\tinvertebrate\t-999\t-999\t-999\t-999\t10\t-999\t1\t-999\n" + "3\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMicrozooplankton\tinvertebrate\therbivorous\t-999\t-999\t-999\t-999\t0.0001\t-999\t-999\tadults\tPhytoplankton\tphoto-autotroph\t-999\t-999\t-999\t-999\t0.0001\t-999\t1\t-999\n" + "4\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMicrozooplankton\tinvertebrate\tbacterivorous\t-999\t-999\t-999\t-999\t0.0001\t-999\t-999\tadults\tBacteria\theterotrophic bacteria\t-999\t-999\t-999\t-999\t0.00000001\t-999\t10000\t-999\n" + "5\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMicrozooplankton\tinvertebrate\tpredacious\t-999\t-999\t-999\t-999\t0.0001\t-999\t-999\tadults\tMicrozooplankton\tinvertebrate\t-999\t-999\t-999\t-999\t0.0001\t-999\t1\t-999\n" + "6\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMesozooplankton\tinvertebrate\therbivorous\t-999\t-999\t-999\t-999\t0.01\t-999\t-999\tadults\tPhytoplankton\tphoto-autotroph\t-999\t-999\t-999\t-999\t0.0001\t-999\t100\t-999\n" + "7\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMesozooplankton\tinvertebrate\tpredacious\t-999\t-999\t-999\t-999\t0.01\t-999\t-999\tadults\tMicrozooplankton\tinvertebrate\t-999\t-999\t-999\t-999\t0.0001\t-999\t100\t-999\n" + "8\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMacrozooplankton\tinvertebrate\therbivorous\t-999\t-999\t-999\t-999\t1\t-999\t-999\tadults\tPhytoplankton\tphoto-autotroph\t-999\t-999\t-999\t-999\t0.0001\t-999\t10000\t-999\n" + "9\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMacrozooplankton\tinvertebrate\tpredacious\t-999\t-999\t-999\t-999\t1\t-999\t-999\tadults\tMesozooplankton\tinvertebrate\t-999\t-999\t-999\t-999\t0.01\t-999\t100\t-999\n" + "16857\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tPraon dorsale\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.002034483\t0.002197044\t0.002344828\t-999\t-999\t-999\tAcyrthosiphon pisum\tadult\taphid\tinvertebrate\t0.002448276\t0.00264532\t0.002793103\t-999\t-999\t-999\t0.614787036\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 7 pairs of individuals were measured\"\n" + "16858\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphidius urticae\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.002\t0.002665025\t0.003517241\t-999\t-999\t-999\tMacrosiphum funestum\tadult\taphid\tinvertebrate\t0.002482759\t0.003214286\t0.003965517\t-999\t-999\t-999\t0.61203447\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 14 pairs of individuals were measured\"\n" + "16859\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tPraon dorsale\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.001965517\t0.001965517\t0.001965517\t-999\t-999\t-999\tAmphorophora rubi\tadult\taphid\tinvertebrate\t0.002482759\t0.002482759\t0.002482759\t-999\t-999\t-999\t0.542226802\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 1 pair of individuals were measured\"\n" + "16860\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tPraon dorsale\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.001896552\t0.001896552\t0.001896552\t-999\t-999\t-999\tMegoura viciaei\tadult\taphid\tinvertebrate\t0.002862069\t0.002862069\t0.002862069\t-999\t-999\t-999\t0.340224547\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 1 pair of individuals were measured\"\n" + "16861\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphelinus abdominalis\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.000793103\t0.000926724\t0.001206897\t-999\t-999\t-999\tSitobion fragariae / Sitobion avenae\tnymphs\taphid\tinvertebrate\t0.001310345\t0.001599138\t0.001896552\t-999\t-999\t-999\t0.239457874\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 16 pairs of individuals were measured\"\n" + "16862\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphelinus abdominalis\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.000965517\t0.000965517\t0.000965517\t-999\t-999\t-999\tAmphorophora rubi\tadult\taphid\tinvertebrate\t0.001689655\t0.001689655\t0.001689655\t-999\t-999\t-999\t0.230802396\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 1 pair of individuals were measured\"\n" + "16863\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphelinus abdominalis\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.000896552\t0.001132626\t0.001310345\t-999\t-999\t-999\tSitobion fragariae / Sitobion avenae\tadult\taphid\tinvertebrate\t0.001448276\t0.00201061\t0.002517241\t-999\t-999\t-999\t0.222324699\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 13 pairs of individuals were measured\"\n" + "16864\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphelinus abdominalis\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.001068966\t0.001206897\t0.001344828\t-999\t-999\t-999\tAcyrthosiphon pisum\tnymphs\taphid\tinvertebrate\t0.002034483\t0.002206897\t0.00237931\t-999\t-999\t-999\t0.205715371\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 2 pairs of individuals were measured\"\n" + "16865\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphelinus abdominalis\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.001103448\t0.00112069\t0.001137931\t-999\t-999\t-999\tMetopolophium albidum\tadult\taphid\tinvertebrate\t0.002034483\t0.002172414\t0.002310345\t-999\t-999\t-999\t0.176547741\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 2 pairs of individuals were measured\"\n" + "16866\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphelinus varipes\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.000896552\t0.000896552\t0.000896552\t-999\t-999\t-999\tSitobion fragariae / Sitobion avenae\tnymphs\taphid\tinvertebrate\t0.001965517\t0.001965517\t0.001965517\t-999\t-999\t-999\t0.127890431\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 1 pair of individuals were measured\"\n";
    TestParserFactory parserFactory = new TestParserFactory(new HashMap<String, String>() {

        {
            put(StudyImporterForBrose.RESOURCE_PATH, headAndTail);
            put(StudyImporterForBrose.REFERENCE_PATH, "short,full\nCohen et al. (2005),something long\nYodzis (1998),something longer");
        }
    });
    StudyImporter importer = new StudyImporterForBrose(parserFactory, nodeFactory);
    importStudy(importer);
    Taxon taxon = taxonIndex.findTaxonByName("Praon dorsale");
    Iterable<Relationship> relationships = ((NodeBacked) taxon).getUnderlyingNode().getRelationships(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS));
    for (Relationship relationship : relationships) {
        Node predatorSpecimenNode = relationship.getStartNode();
        assertThat((String) predatorSpecimenNode.getProperty(SpecimenConstant.LIFE_STAGE_LABEL), is("post-juvenile adult stage"));
        assertThat((String) predatorSpecimenNode.getProperty(SpecimenConstant.LIFE_STAGE_ID), is("UBERON:0000113"));
    }
    assertThat(taxon, is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Aphelinus abdominalis"), is(notNullValue()));
    Location location = nodeFactory.findLocation(new LocationImpl(51.24, -0.34, null, null));
    assertThat("missing location", location, is(notNullValue()));
    List<Environment> environments = location.getEnvironments();
    assertThat(environments.size(), is(1));
    assertThat(environments.get(0).getExternalId(), is("TEST:terrestrial abandoned field"));
    assertThat(environments.get(0).getName(), is("terrestrial abandoned field"));
}
Also used : Taxon(org.eol.globi.domain.Taxon) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) LocationImpl(org.eol.globi.domain.LocationImpl) Environment(org.eol.globi.domain.Environment) Location(org.eol.globi.domain.Location) Test(org.junit.Test)

Aggregations

LocationImpl (org.eol.globi.domain.LocationImpl)40 Location (org.eol.globi.domain.Location)32 Specimen (org.eol.globi.domain.Specimen)22 Study (org.eol.globi.domain.Study)20 TaxonImpl (org.eol.globi.domain.TaxonImpl)15 StudyImpl (org.eol.globi.domain.StudyImpl)13 IOException (java.io.IOException)10 LatLng (org.eol.globi.geo.LatLng)9 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)8 Date (java.util.Date)8 Relationship (org.neo4j.graphdb.Relationship)7 HashMap (java.util.HashMap)6 Taxon (org.eol.globi.domain.Taxon)6 TermImpl (org.eol.globi.domain.TermImpl)6 Test (org.junit.Test)6 Node (org.neo4j.graphdb.Node)6 ArrayList (java.util.ArrayList)5 SpecimenNode (org.eol.globi.domain.SpecimenNode)3 List (java.util.List)2 Map (java.util.Map)2