use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForBaremore method importStudy.
@Override
public void importStudy() throws StudyImporterException {
Study study;
try {
LabeledCSVParser parser = parserFactory.createParser(DATA_SOURCE, CharsetConstant.UTF8);
String[] line;
study = nodeFactory.getOrCreateStudy(new StudyImpl("Baremore 2010", StudyImporterForGoMexSI2.GOMEXI_SOURCE_DESCRIPTION, "doi:10.3354/ab00214", ExternalIdUtil.toCitation("Ivy E. Baremore", "Prey Selection By The Atlantic Angel Shark Squatina Dumeril In The Northeastern Gulf Of Mexico.", "2010")));
Location collectionLocation = nodeFactory.getOrCreateLocation(new LocationImpl(29.219302, -87.06665, null, null));
Map<Integer, Specimen> specimenMap = new HashMap<Integer, Specimen>();
while ((line = parser.getLine()) != null) {
Integer sharkId = Integer.parseInt(line[0]);
String collectionDateString = line[1];
if (isBlank(collectionDateString)) {
getLogger().warn(study, "line [" + parser.getLastLineNumber() + "] in [" + DATA_SOURCE + "]: missing collection date");
} else {
Specimen predatorSpecimen = specimenMap.get(sharkId);
if (predatorSpecimen == null) {
predatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Squatina dumeril", null));
predatorSpecimen.caughtIn(collectionLocation);
addLifeStage(parser, predatorSpecimen);
addCollectionDate(collectionDateString, predatorSpecimen);
}
specimenMap.put(sharkId, predatorSpecimen);
String totalLengthInCm = line[3];
try {
Double lengthInMm = Double.parseDouble(totalLengthInCm) * 10.0;
predatorSpecimen.setLengthInMm(lengthInMm);
} catch (NumberFormatException ex) {
throw new StudyImporterException("failed to parse length [" + totalLengthInCm);
}
String preySpeciesDescription = line[7];
if (StringUtils.isBlank(preySpeciesDescription)) {
getLogger().info(study, "found blank prey species description [" + preySpeciesDescription + "] on line [" + parser.lastLineNumber() + "]");
} else {
Specimen preySpecimen = nodeFactory.createSpecimen(study, new TaxonImpl(preySpeciesDescription, null));
preySpecimen.caughtIn(collectionLocation);
predatorSpecimen.ate(preySpecimen);
nodeFactory.setUnixEpochProperty(preySpecimen, nodeFactory.getUnixEpochProperty(predatorSpecimen));
}
}
}
} catch (IOException e) {
throw new StudyImporterException("failed to parse labels", e);
}
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForAkin method addPrey.
private void addPrey(Study study, LabeledCSVParser parser, String[] header, String[] line, Specimen specimen, Location location) throws StudyImporterException {
int firstPreyIndex = findIndexForColumnWithNameThrowOnMissing("Detritus", header);
for (int i = firstPreyIndex; i < line.length; i++) {
String preySpeciesName = header[i];
if (StringUtils.isNotBlank(preySpeciesName)) {
String preyVolumeString = line[i];
try {
if (StringUtils.isNotBlank(preyVolumeString)) {
double volume = Double.parseDouble(preyVolumeString);
if (volume > 0) {
Specimen prey = nodeFactory.createSpecimen(study, new TaxonImpl(preySpeciesName, null));
prey.setLifeStage(parseLifeStage(nodeFactory.getTermLookupService(), preySpeciesName));
prey.setVolumeInMilliLiter(volume);
prey.caughtIn(location);
specimen.ate(prey);
}
}
} catch (NumberFormatException ex) {
throw new StudyImporterException("failed to parse volume of prey [" + preySpeciesName + "] in stomach [" + preyVolumeString + "] on line [" + parser.getLastLineNumber() + "]");
} catch (TermLookupServiceException e) {
throw new StudyImporterException("failed to parse life stage of prey [" + preySpeciesName + "] in stomach [" + preyVolumeString + "] on line [" + parser.getLastLineNumber() + "]");
}
}
}
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForBlewett method parsePredatorPreyInteraction.
private void parsePredatorPreyInteraction(Study study, Map<String, Location> locationMap, Map<String, Date> collectionTimeMap) throws IOException, NodeFactoryException, TermLookupServiceException {
LabeledCSVParser parser = parserFactory.createParser("blewett/SnookDietData2000_02_Charlotte_Harbor_FL_Blewett_numeric_abundance.csv", CharsetConstant.UTF8);
String[] header = parser.getLabels();
String[] line;
while ((line = parser.getLine()) != null) {
if (line.length < 2) {
break;
}
Specimen predatorSpecimen = addPredator(study, parser, line);
List<Specimen> specimen = addPreyForPredator(header, line, study);
for (Specimen prey : specimen) {
predatorSpecimen.ate(prey);
}
String collectionCode = parser.getValueByLabel(COLLECTION_NO);
if (collectionCode != null) {
specimen.add(predatorSpecimen);
setLocationAndDate(locationMap, collectionTimeMap, specimen, collectionCode);
}
}
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForBarnes method addInteractionForPredator.
private void addInteractionForPredator(LabeledCSVParser parser, Study localStudy, String predatorName) throws NodeFactoryException, StudyImporterException {
Specimen predator = nodeFactory.createSpecimen(localStudy, new TaxonImpl(predatorName, null));
addLifeStage(parser, predator);
Double latitude = LocationUtil.parseDegrees(parser.getValueByLabel("Latitude"));
Double longitude = LocationUtil.parseDegrees(parser.getValueByLabel("Longitude"));
String depth = parser.getValueByLabel("Depth");
Double altitudeInMeters = -1.0 * Double.parseDouble(depth);
Location location = nodeFactory.getOrCreateLocation(new LocationImpl(latitude, longitude, altitudeInMeters, null));
predator.caughtIn(location);
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));
prey.caughtIn(location);
predator.ate(prey);
}
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForBioInfo method importInteraction.
private void importInteraction(LabeledCSVParser parser, Study study, InteractType interactType, Map<String, Taxon> taxonMap) throws StudyImporterException {
String passiveId = parser.getValueByLabel("passive NBN Code");
String activeId = parser.getValueByLabel("active NBN Code");
Specimen donorSpecimen = createSpecimen(parser, study, taxonMap, passiveId, parser.getValueByLabel("my passive taxon id"));
Specimen recipientSpecimen = createSpecimen(parser, study, taxonMap, activeId, parser.getValueByLabel("my active taxon id"));
if (donorSpecimen != null && recipientSpecimen != null) {
addLifeStage(parser, donorSpecimen, "stage of passive taxon", study);
addBodyPart(parser, donorSpecimen, "part of passive taxon", study);
addLifeStage(parser, recipientSpecimen, "stage of active taxon", study);
addBodyPart(parser, donorSpecimen, "part of active taxon", study);
recipientSpecimen.interactsWith(donorSpecimen, interactType);
}
}
Aggregations