Search in sources :

Example 36 with Specimen

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

the class StudyImporterForBell method importStudy.

@Override
public void importStudy() throws StudyImporterException {
    for (String resource : RESOURCE) {
        LabeledCSVParser parser = null;
        try {
            parser = parserFactory.createParser(resource, "UTF-8");
            while (parser.getLine() != null) {
                String sourceCitation = "Bell, K. C., Matek, D., Demboski, J. R., & Cook, J. A. (2015). Expanded Host Range of Sucking Lice and Pinworms of Western North American Chipmunks. Comparative Parasitology, 82(2), 312–321. doi:10.1654/4756.1 . Data provided by Kayce C. Bell.";
                String guid = parser.getValueByLabel("GUID");
                String externalId = "http://arctos.database.museum/guid/" + guid;
                String description = null;
                String collectionId = null;
                for (String key : REFS.keySet()) {
                    if (guid.startsWith(key)) {
                        description = REFS.get(key);
                        collectionId = key;
                        break;
                    }
                }
                if (StringUtils.isBlank(description)) {
                    LOG.warn("missing collectionId [" + guid + "] in file [" + resource + "] on line [" + parser.lastLineNumber() + "]");
                    description = sourceCitation;
                    collectionId = "";
                }
                Study study = nodeFactory.getOrCreateStudy(new StudyImpl("bell-" + collectionId, sourceCitation, "http://dx.doi.org/10.1654/4756.1", ExternalIdUtil.toCitation(null, sourceCitation + " " + description, null)));
                String genus = parser.getValueByLabel("Genus");
                String species = parser.getValueByLabel("Species");
                String parasiteName = StringUtils.join(new String[] { StringUtils.trim(genus), StringUtils.trim(species) }, " ");
                Specimen parasite = nodeFactory.createSpecimen(study, new TaxonImpl(parasiteName, null));
                parasite.setExternalId(externalId);
                Location location = getLocation(parser, parasite);
                parasite.caughtIn(location);
                String scientificName = parser.getValueByLabel("SCIENTIFIC_NAME");
                String hostName = StringUtils.trim(scientificName);
                Specimen host = nodeFactory.createSpecimen(study, new TaxonImpl(hostName, null));
                host.caughtIn(location);
                host.setExternalId(externalId);
                parasite.interactsWith(host, InteractType.PARASITE_OF);
                Date date = parseDate(parser);
                nodeFactory.setUnixEpochProperty(parasite, date);
                nodeFactory.setUnixEpochProperty(host, date);
            }
        } catch (Throwable e) {
            throw new StudyImporterException(getErrorMessage(resource, parser), e);
        }
    }
}
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) LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) Date(java.util.Date) Location(org.eol.globi.domain.Location)

Example 37 with Specimen

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

the class StudyImporterForBioInfo method createSpecimen.

private Specimen createSpecimen(Study study, LabeledCSVParser labeledCSVParser, String externalId) throws StudyImporterException {
    try {
        Specimen specimen = nodeFactory.createSpecimen(study, new TaxonImpl(null, TaxonomyProvider.NBN.getIdPrefix() + externalId));
        setSpecimenExternalId(labeledCSVParser, specimen);
        return specimen;
    } catch (NodeFactoryException e) {
        throw new StudyImporterException("failed to create taxon with scientific name [" + externalId + "]", e);
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 38 with Specimen

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

the class StudyImporterForByrnes method addInteractionForPredator.

private void addInteractionForPredator(LabeledCSVParser parser, Study localStudy, String predatorName) throws NodeFactoryException, StudyImporterException {
    Specimen predator = nodeFactory.createSpecimen(localStudy, new TaxonImpl(predatorName, null));
    String preyName = parser.getValueByLabel("Prey");
    if (StringUtils.isBlank(preyName)) {
        getLogger().warn(localStudy, "found empty prey name on line [" + parser.lastLineNumber() + "]");
    } else {
        Specimen prey = nodeFactory.createSpecimen(localStudy, new TaxonImpl(preyName, null));
        String feedingLink = parser.getValueByLabel("Feeding Link?");
        if (StringUtils.equals("1", StringUtils.trim(feedingLink))) {
            predator.ate(prey);
        } else {
            predator.interactsWith(prey, InteractType.INTERACTS_WITH);
        }
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 39 with Specimen

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

the class StudyImporterForBlewett method setLocationAndDate.

private void setLocationAndDate(Map<String, Location> locationMap, Map<String, Date> collectionTimeMap, List<Specimen> items, String collectionCode) throws NodeFactoryException {
    String collectionCodeTrim = collectionCode.trim();
    Location location = locationMap.get(collectionCodeTrim);
    if (location != null) {
        for (Specimen item : items) {
            item.caughtIn(location);
        }
    }
    Date collectionDatetime = collectionTimeMap.get(collectionCodeTrim);
    if (collectionDatetime != null) {
        for (Specimen item : items) {
            nodeFactory.setUnixEpochProperty(item, collectionDatetime);
        }
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) Date(java.util.Date) Location(org.eol.globi.domain.Location)

Example 40 with Specimen

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

the class StudyImporterForBlewett method addPredator.

private Specimen addPredator(Study study, LabeledCSVParser parser, String[] line) throws NodeFactoryException, TermLookupServiceException {
    Specimen predatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Centropomus undecimalis", null));
    predatorSpecimen.setLifeStage(nodeFactory.getTermLookupService().lookupTermByName("adult"));
    try {
        String length = parser.getValueByLabel("Standard Length");
        predatorSpecimen.setLengthInMm(Double.parseDouble(length));
    } catch (NumberFormatException ex) {
        getLogger().warn(study, "found malformed length in line:" + parser.lastLineNumber() + " [" + StringUtils.join(line, ",") + "]");
    }
    return predatorSpecimen;
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Aggregations

Specimen (org.eol.globi.domain.Specimen)91 TaxonImpl (org.eol.globi.domain.TaxonImpl)59 Study (org.eol.globi.domain.Study)38 StudyImpl (org.eol.globi.domain.StudyImpl)34 Location (org.eol.globi.domain.Location)31 LocationImpl (org.eol.globi.domain.LocationImpl)22 Test (org.junit.Test)17 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)15 IOException (java.io.IOException)15 Date (java.util.Date)14 Relationship (org.neo4j.graphdb.Relationship)12 HashMap (java.util.HashMap)11 Taxon (org.eol.globi.domain.Taxon)11 SpecimenNode (org.eol.globi.domain.SpecimenNode)9 TermImpl (org.eol.globi.domain.TermImpl)9 ArrayList (java.util.ArrayList)8 InteractType (org.eol.globi.domain.InteractType)7 LatLng (org.eol.globi.geo.LatLng)6 Map (java.util.Map)5 TaxonNode (org.eol.globi.domain.TaxonNode)5