use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.
the class DatasetImporterForKelpForest method importStudy.
@Override
public void importStudy() throws StudyImporterException {
try {
String source = "Beas-Luna, R., Novak, M., Carr, M. H., Tinker, M. T., Black, A., Caselle, J. E., … Iles, A. (2014). An Online Database for Informing Ecological Network Models: http://kelpforest.ucsc.edu. PLoS ONE, 9(10), e109356. doi:10.1371/journal.pone.0109356";
Study study = getNodeFactory().getOrCreateStudy(new StudyImpl(source, new DOI("1371", "journal.pone.0109356"), source));
LabeledCSVParser parser = getParserFactory().createParser(NODES, "UTF-8");
String[] line;
Map<String, Long> nameToId = new HashMap<String, Long>();
while ((line = parser.getLine()) != null) {
if (line.length > 2) {
String name = parser.getValueByLabel("working_name");
String itisId = parser.getValueByLabel("itis_id");
Long id = StringUtils.isBlank(itisId) ? null : Long.parseLong(itisId);
id = (id != null && id > 0L) ? id : null;
nameToId.put(name, id);
}
}
Map<String, InteractType> typeToType = new HashMap<String, InteractType>() {
{
put("trophic", InteractType.ATE);
put("parasitic", InteractType.PARASITE_OF);
}
};
parser = getParserFactory().createParser(LINKS, "UTF-8");
while ((line = parser.getLine()) != null) {
if (line.length > 2) {
String interactionType = parser.getValueByLabel("type");
InteractType interactType = typeToType.get(interactionType);
if (null == interactType) {
LOG.warn("ignoring type [" + interactionType + "] on line: [" + (parser.getLastLineNumber() + 1) + "]");
} else {
Specimen sourceSpecimen = createSpecimen(parser, nameToId, "node_1_working_name", "node1_stage", study);
Specimen targetSpecimen = createSpecimen(parser, nameToId, "node_2_working_name", "node2_stage", study);
sourceSpecimen.interactsWith(targetSpecimen, interactType);
}
}
}
} catch (IOException | NodeFactoryException e) {
throw new StudyImporterException("failed to import", e);
}
}
use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.
the class DatasetImporterForHafner method importStudy.
@Override
public void importStudy() throws StudyImporterException {
try {
LabeledCSVParser parser = getParserFactory().createParser(RESOURCE, "UTF-8");
while (parser.getLine() != null) {
String sourceCitation = "Mark S. Hafner, Philip D. Sudman, Francis X. Villablanca, Theresa A. Spradling, James W. Demastes, Steven A. Nadler. (1994). Disparate Rates of Molecular Evolution in Cospeciating Hosts and Parasites. Science 265: 1087-1090. doi:10.1126/science.8066445";
Study study = getNodeFactory().getOrCreateStudy(new StudyImpl("hafner1994", new DOI("1126", "science.8066445"), sourceCitation));
String hostName = parser.getValueByLabel("Host");
String parasiteName = parser.getValueByLabel("Parasite");
Specimen host = getNodeFactory().createSpecimen(study, new TaxonImpl(hostName, null));
Specimen parasite = getNodeFactory().createSpecimen(study, new TaxonImpl(parasiteName, null));
parasite.interactsWith(host, InteractType.PARASITE_OF);
}
} catch (IOException | NodeFactoryException e) {
throw new StudyImporterException("failed to import [" + RESOURCE + "]", e);
}
}
use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.
the class DatasetImporterForRobledo method importStudy.
@Override
public void importStudy() throws StudyImporterException {
String description = "García-Robledo C, Erickson DL, Staines CL, Erwin TL, Kress WJ. Tropical Plant–Herbivore Networks: Reconstructing Species Interactions Using DNA Barcodes Heil M, editor. PLoS ONE [Internet]. 2013 January 8;8(1):e52967. Available from: https://doi.org/10.1371/journal.pone.0052967";
DOI doi = new DOI("1371", "journal.pone.0052967");
Study study1 = new StudyImpl("García-Robledo et al 2013", doi, description);
Study study = getNodeFactory().getOrCreateStudy(study1);
Map<String, String> abrLookup = buildPlantLookup();
// spatial location from: http://www.ots.ac.cr/index.php?option=com_content&task=view&id=163&Itemid=348
Double latitude = LocationUtil.parseDegrees("10°26'N");
Double longitude = LocationUtil.parseDegrees("83°59'W");
Location location;
try {
location = getNodeFactory().getOrCreateLocation(new LocationImpl(latitude, longitude, 35.0, null));
} catch (NodeFactoryException e) {
throw new StudyImporterException("failed to create location", e);
}
// TODO: need to map date range of collections
URI studyResource = URI.create("robledo/table_s1_extract.csv");
try {
LabeledCSVParser parser = getParserFactory().createParser(studyResource, CharsetConstant.UTF8);
while (parser.getLine() != null) {
String beetleName = parser.getValueByLabel("Herbivore species");
String beetleScientificName = completeBeetleName(beetleName);
Specimen predator = getNodeFactory().createSpecimen(study, new TaxonImpl(beetleScientificName, null));
predator.caughtIn(location);
for (String plantAbbreviation : abrLookup.keySet()) {
String plantScientificName = abrLookup.get(plantAbbreviation);
String valueByLabel = parser.getValueByLabel(plantAbbreviation);
try {
int interactionCode = Integer.parseInt(valueByLabel);
if (interactionCode > 0) {
Specimen plant = getNodeFactory().createSpecimen(study, new TaxonImpl(plantScientificName, null));
plant.caughtIn(location);
predator.ate(plant);
}
} catch (NumberFormatException ex) {
getLogger().warn(study, "malformed or no value [" + valueByLabel + "] found for [" + plantScientificName + "(" + plantAbbreviation + ")" + "] and beetle [" + beetleScientificName + "] could be found in [" + studyResource + ":" + parser.lastLineNumber() + "]");
}
}
}
} catch (IOException e) {
throw new StudyImporterException("problem reading [" + studyResource + "]", e);
} catch (NodeFactoryException e) {
throw new StudyImporterException("cannot create specimens from [" + studyResource + "]", e);
}
}
use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.
the class DatasetImporterForRoopnarine method importStudy.
@Override
public void importStudy() throws StudyImporterException {
String suffix = ".csv";
String prefix = "roopnarine/857470.item.";
URI trophicGuildLookup = URI.create(prefix + 4 + suffix);
final Map<Integer, List<String>> trophicGuildNumberToSpeciesMap = buildGuildLookup(trophicGuildLookup);
Map<String, LatLng> resourceLocation = resourceLocationMap(suffix, prefix);
DOI doi = new DOI("7167", "2013/857470");
Study study = getNodeFactory().getOrCreateStudy(new StudyImpl("Roopnarine et al 2013", doi, null));
for (Map.Entry<String, LatLng> resourceLatLngEntry : resourceLocation.entrySet()) {
LatLng latLng = resourceLatLngEntry.getValue();
Location location;
try {
location = getNodeFactory().getOrCreateLocation(new LocationImpl(latLng.getLat(), latLng.getLng(), 0.0, null));
} catch (NodeFactoryException e) {
throw new StudyImporterException("failed to create location", e);
}
URI studyResource = URI.create(resourceLatLngEntry.getKey());
getLogger().info(study, "import of [" + studyResource + "] started...");
List<Specimen> predatorSpecimen = importTrophicInteractions(trophicGuildLookup, trophicGuildNumberToSpeciesMap, studyResource, study, location);
getLogger().info(study, "import of [" + studyResource + "] done.");
}
}
Aggregations