use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForPlanque method importLink.
private void importLink(LabeledCSVParser parser, Map<String, List<String>> pairWiseKeyToFullCitation) throws NodeFactoryException, StudyImporterException {
final String linkKey = parser.getValueByLabel("PWKEY");
List<String> longReferences = pairWiseKeyToFullCitation.get(linkKey);
if (CollectionUtils.isEmpty(longReferences)) {
LOG.debug("no reference found for [" + linkKey + "] on line [" + parser.lastLineNumber() + "], using source citation instead");
longReferences = new ArrayList<String>() {
{
add(getSourceCitation());
}
};
}
for (String longReference : longReferences) {
String studyId = "PLANQUE-" + StringUtils.abbreviate(longReference, 20) + MD5.getHashString(longReference);
Study localStudy = nodeFactory.getOrCreateStudy(new StudyImpl(studyId, getSourceCitation(), 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);
}
}
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForKelpForest 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 = nodeFactory.getOrCreateStudy(new StudyImpl(source, source, "doi:10.1371/journal.pone.0109356", source));
LabeledCSVParser parser = parserFactory.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 = parserFactory.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.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForJRFerrerParis method importStudy.
@Override
public void importStudy() throws StudyImporterException {
String citation = "Ferrer-Paris, José R.; Sánchez-Mercado, Ada Y.; Lozano, Cecilia; Zambrano, Liset; Soto, José; Baettig, Jessica; Leal, María (2014): A compilation of larval host-plant records for six families of butterflies (Lepidoptera: Papilionoidea) from available electronic resources. figshare. http://dx.doi.org/10.6084/m9.figshare.1168861 . " + CitationUtil.createLastAccessedString(RESOURCE);
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("Ferrer-Paris 2014", citation, "http://dx.doi.org/10.6084/m9.figshare.1168861", citation));
try {
LabeledCSVParser parser = parserFactory.createParser(RESOURCE, CharsetConstant.UTF8);
while (parser.getLine() != null) {
String butterflyName = createTaxon(parser, "Lepidoptera Name");
String plantName = createTaxon(parser, "Hostplant Name");
if (validNames(butterflyName, plantName, study, parser.lastLineNumber())) {
addAssociation(study, parser, butterflyName, plantName);
}
}
} catch (IOException e) {
throw new StudyImporterException("failed to access resource [" + RESOURCE + "]");
}
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryIT method createStudyWithDOIResolving.
@Test
public void createStudyWithDOIResolving() throws NodeFactoryException {
NodeFactoryNeo4j fullNodeFactory = new NodeFactoryNeo4j(getGraphDb());
fullNodeFactory.setDoiResolver(new DOIResolverImpl());
Study study = fullNodeFactory.getOrCreateStudy(new StudyImpl("bla", "source", "doi:10.1073/pnas.1216534110", ""));
assertThat(study.getCitation(), is("DePalma RA, Burnham DA, Martin LD, Rothschild BM, Larson PL. Physical evidence of predatory behavior in Tyrannosaurus rex. Proceedings of the National Academy of Sciences [Internet]. 2013 July 15;110(31):12560–12564. Available from: http://dx.doi.org/10.1073/pnas.1216534110"));
assertThat(study.getDOI(), is("doi:10.1073/pnas.1216534110"));
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryIT method createStudy.
@Test
public void createStudy() throws NodeFactoryException {
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("bla", "source", "http://dx.doi.org/10.1111/j.1469-7998.1966.tb02907.x", ExternalIdUtil.toCitation(null, "descr", null)));
assertThat(study.getDOI(), is("http://dx.doi.org/10.1111/j.1469-7998.1966.tb02907.x"));
assertThat(study.getCitation(), is("http://dx.doi.org/10.1111/j.1469-7998.1966.tb02907.x"));
}
Aggregations