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);
}
}
}
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);
}
}
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);
}
}
}
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);
}
}
}
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;
}
Aggregations