use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForBioInfo method createRelations.
protected void createRelations(LabeledCSVParser parser, Map<String, String> refMap, Map<String, Taxon> taxonMap) throws StudyImporterException {
try {
long count = 1;
while (parser.getLine() != null) {
if (importFilter.shouldImportRecord(count)) {
String refIds = parser.getValueByLabel("list of reference ids");
if (StringUtils.isNotBlank(refIds)) {
String[] ids = StringUtils.split(refIds, ";");
for (String id : ids) {
String trimmedId = StringUtils.trim(id);
Study study = createStudy(trimmedId, refMap.get(trimmedId));
String relationship = parser.getValueByLabel("relationship");
if (StringUtils.isBlank(relationship)) {
getLogger().warn(study, "no relationship for record on line [" + (parser.lastLineNumber() + 1) + "]");
}
InteractType interactType = INTERACTION_MAPPING.get(relationship);
if (null == interactType) {
getLogger().warn(study, "no mapping found for relationship [" + relationship + "] for record on line [" + (parser.lastLineNumber() + 1) + "]");
} else {
importInteraction(parser, study, interactType, taxonMap);
}
}
}
}
count++;
}
} catch (IOException e1) {
throw new StudyImporterException("problem reading trophic relations data", e1);
}
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForBrose method importLine.
private void importLine(LabeledCSVParser parser, Map<String, String> refMap) throws StudyImporterException {
Study localStudy = null;
try {
String shortReference = StringUtils.trim(parser.getValueByLabel("Link reference"));
if (!refMap.containsKey(shortReference)) {
throw new StudyImporterException("failed to find ref [" + shortReference + "] on line [" + parser.lastLineNumber() + "]");
}
String longReference = refMap.get(shortReference);
localStudy = nodeFactory.getOrCreateStudy(new StudyImpl("BROSE-" + StringUtils.abbreviate(longReference, 20), SOURCE, null, ExternalIdUtil.toCitation(null, longReference, null)));
String name = getName(parser, "Taxonomy consumer", "Common name(s) consumer");
if (StringUtils.isBlank(name)) {
getLogger().warn(localStudy, "found empty name on line [" + parser.lastLineNumber() + "]");
} else {
addInteractionForConsumer(parser, localStudy, name);
}
} catch (NodeFactoryException e) {
throw new StudyImporterException("problem creating nodes at line [" + parser.lastLineNumber() + "]", e);
} catch (NumberFormatException e) {
String message = "skipping record, found malformed field at line [" + parser.lastLineNumber() + "]: ";
if (localStudy != null) {
getLogger().warn(localStudy, message + e.getMessage());
}
}
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForByrnes method importLine.
private void importLine(LabeledCSVParser parser, Map<String, String> refMap) throws StudyImporterException {
Study localStudy = null;
try {
String refList = StringUtils.trim(parser.getValueByLabel("Reference"));
String[] refs;
if (StringUtils.isBlank(refList)) {
refs = new String[] { "Byrnes, J.E. et al., 2011. Climate-driven increases in storm frequency simplify kelp forest food webs. Global Change Biology, 17(8), pp.2513–2524. Available at: http://dx.doi.org/10.1111/j.1365-2486.2011.02409.x." };
} else {
refs = StringUtils.split(refList, ",");
}
for (String ref : refs) {
String singleShortRef = StringUtils.trim(ref);
String longRef = refMap.get(singleShortRef);
String citation = StringUtils.isBlank(longRef) ? singleShortRef : longRef;
localStudy = nodeFactory.getOrCreateStudy(new StudyImpl("BYRNES-" + StringUtils.abbreviate(citation, 32), SOURCE, null, citation));
String predatorName = parser.getValueByLabel("Predator");
if (StringUtils.isBlank(predatorName)) {
getLogger().warn(localStudy, "found empty predator name on line [" + parser.lastLineNumber() + "]");
} else {
addInteractionForPredator(parser, localStudy, predatorName);
}
}
} catch (NodeFactoryException e) {
throw new StudyImporterException("problem creating nodes at line [" + parser.lastLineNumber() + "]", e);
} catch (NumberFormatException e) {
String message = "skipping record, found malformed field at line [" + parser.lastLineNumber() + "]: ";
if (localStudy != null) {
getLogger().warn(localStudy, message + e.getMessage());
}
}
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForBarnes method importLine.
private void importLine(LabeledCSVParser parser, Map<String, String> refMap) throws StudyImporterException {
Study localStudy = null;
try {
String shortReference = StringUtils.trim(parser.getValueByLabel("Reference"));
if (!refMap.containsKey(shortReference)) {
throw new StudyImporterException("failed to find ref [" + shortReference + "] on line [" + parser.lastLineNumber() + "]");
}
String longReference = refMap.get(shortReference);
localStudy = nodeFactory.getOrCreateStudy(new StudyImpl("BARNES-" + shortReference, SOURCE, null, ExternalIdUtil.toCitation(null, longReference, null)));
String predatorName = parser.getValueByLabel("Predator");
if (StringUtils.isBlank(predatorName)) {
getLogger().warn(localStudy, "found empty predator name on line [" + parser.lastLineNumber() + "]");
} else {
addInteractionForPredator(parser, localStudy, predatorName);
}
} catch (NodeFactoryException e) {
throw new StudyImporterException("problem creating nodes at line [" + parser.lastLineNumber() + "]", e);
} catch (NumberFormatException e) {
String message = "skipping record, found malformed field at line [" + parser.lastLineNumber() + "]: ";
if (localStudy != null) {
getLogger().warn(localStudy, message + e.getMessage());
}
}
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForBlewett method importStudy.
@Override
public void importStudy() throws StudyImporterException {
String citation = "Blewett DA, Hensley RA, and Stevens PW, Feeding Habits of Common Snook, Centropomus Undecimalis, in Charlotte Harbor, Florida, Gulf and Caribbean Research Vol 18, 1–13, 2006. doi:10.18785/gcr.1801.01 ";
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("Blewett 2006", StudyImporterForGoMexSI2.GOMEXI_SOURCE_DESCRIPTION, null, citation));
try {
Map<String, Location> collectionLocationMap = new HashMap<>();
Map<String, Date> collectionTimeMap = new HashMap<String, Date>();
buildLocationTimeMaps(collectionLocationMap, collectionTimeMap, study);
parsePredatorPreyInteraction(study, collectionLocationMap, collectionTimeMap);
} catch (IOException e) {
throw new StudyImporterException("failed to read resource", e);
} catch (NodeFactoryException e) {
throw new StudyImporterException("failed to create taxon", e);
} catch (TermLookupServiceException e) {
throw new StudyImporterException("failed to map terms", e);
}
}
Aggregations