use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForRoopnarine method importStudy.
@Override
public void importStudy() throws StudyImporterException {
String suffix = ".csv";
String prefix = "roopnarine/857470.item.";
String trophicGuildLookup = prefix + 4 + suffix;
final Map<Integer, List<String>> trophicGuildNumberToSpeciesMap = buildGuildLookup(trophicGuildLookup);
Map<String, LatLng> resourceLocation = resourceLocationMap(suffix, prefix);
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("Roopnarine et al 2013", "Roopnarine, P.D. & Hertog, R., 2013. Detailed Food Web Networks of Three Greater Antillean Coral Reef Systems: The Cayman Islands, Cuba, and Jamaica. DatasetImpl Papers in Ecology, 2013, pp.1–9. Available at: http://dx.doi.org/10.7167/2013/857470.", "http://dx.doi.org/10.7167/2013/857470", null));
for (Map.Entry<String, LatLng> resourceLatLngEntry : resourceLocation.entrySet()) {
LatLng latLng = resourceLatLngEntry.getValue();
Location location;
try {
location = nodeFactory.getOrCreateLocation(new LocationImpl(latLng.getLat(), latLng.getLng(), 0.0, null));
} catch (NodeFactoryException e) {
throw new StudyImporterException("failed to create location", e);
}
String studyResource = 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.");
}
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForSPIRE method createSpecimen.
private Specimen createSpecimen(String taxonName, Study study) throws NodeFactoryException {
taxonName = taxonName.replaceAll("_", " ");
Specimen specimen = nodeFactory.createSpecimen(study, new TaxonImpl(taxonName, null));
if (taxonName.contains("adult")) {
addLifeStage(specimen, "adult");
} else if (taxonName.contains("juvenile")) {
addLifeStage(specimen, "juvenile");
} else if (taxonName.contains(" egg")) {
addLifeStage(specimen, "egg");
} else if (taxonName.contains("larvae")) {
addLifeStage(specimen, "larvae");
} else if (taxonName.contains("immature")) {
addLifeStage(specimen, "immature");
} else if (taxonName.contains("nymphs")) {
addLifeStage(specimen, "nymphs");
}
return specimen;
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForSPIRE method importValidLink.
private void importValidLink(Map<String, String> properties) throws NodeFactoryException {
Study study = nodeFactory.getOrCreateStudy(new StudyImpl(properties.get(StudyConstant.TITLE), SOURCE_SPIRE, null, properties.get(StudyConstant.DESCRIPTION)));
try {
Specimen predator = createSpecimen(properties.get(PREDATOR_NAME), study);
String locality = properties.get(LOCALITY_ORIGINAL);
LatLng latLng = getGeoNamesService().findLatLng(locality);
if (latLng == null) {
getLogger().warn(study, "failed to find location for county [" + locality + "]");
} else {
Location location = nodeFactory.getOrCreateLocation(new LocationImpl(latLng.getLat(), latLng.getLng(), null, null));
predator.caughtIn(location);
String habitat = properties.get(OF_HABITAT);
if (StringUtils.isNotBlank(habitat)) {
addEnvironment(location, "SPIRE:" + habitat, habitat);
}
}
Specimen prey = createSpecimen(properties.get(PREY_NAME), study);
predator.ate(prey);
} catch (NodeFactoryException e) {
getLogger().warn(study, "failed to import trophic link with properties [" + properties + "]: " + e.getMessage());
} catch (IOException e) {
getLogger().warn(study, "failed to import trophic link with properties [" + properties + "]: " + e.getMessage());
}
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForWrast method addPredatorSpecimen.
private Specimen addPredatorSpecimen(LabeledCSVParser csvParser, Study study, LengthParser lengthParser, String seasonName, Location sampleLocation, String speciesName, String predatorId, Map<String, Specimen> predatorMap) throws StudyImporterException {
Specimen predator = createAndClassifySpecimen(speciesName, study);
predatorMap.put(predatorId, predator);
predator.setLengthInMm(lengthParser.parseLengthInMm(csvParser));
if (null != sampleLocation) {
predator.caughtIn(sampleLocation);
}
predator.caughtDuring(getOrCreateSeason(seasonName));
return predator;
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class LinkerTrustyNanoPubs method generateOrganisms.
public static void generateOrganisms(StringBuilder builder, InteractionNode interaction) {
Collection<Specimen> participants = interaction.getParticipants();
Map<Long, Integer> nodeIdParticipantMap = new TreeMap<>();
int participantNumber = 0;
for (Specimen participant : participants) {
builder.append(String.format("\n obo:RO_0000057 :Organism_%d ", participantNumber));
builder.append(participants.size() - 1 == participantNumber ? "." : ";");
nodeIdParticipantMap.put(((NodeBacked) participant).getNodeID(), participantNumber);
participantNumber++;
}
participantNumber = 0;
for (Specimen participant : participants) {
Iterable<Relationship> classification = NodeUtil.getClassifications(participant);
if (classification != null && classification.iterator().hasNext()) {
TaxonNode taxonNode = new TaxonNode(classification.iterator().next().getEndNode());
String ncbiTaxonId = resolveNCBITaxonId(taxonNode);
if (StringUtils.isNotBlank(ncbiTaxonId)) {
builder.append(String.format("\n :Organism_%d a NCBITaxon:%s ", participantNumber, ncbiTaxonId));
Iterable<Relationship> interactRel = ((NodeBacked) participant).getUnderlyingNode().getRelationships(Direction.OUTGOING, NodeUtil.asNeo4j(InteractType.values()));
for (Relationship relationship : interactRel) {
if (!relationship.hasProperty(PropertyAndValueDictionary.INVERTED)) {
if (relationship.hasProperty(PropertyAndValueDictionary.IRI)) {
String interactIRI = relationship.getProperty(PropertyAndValueDictionary.IRI).toString();
if (StringUtils.isNotBlank(interactIRI)) {
builder.append(";\n");
builder.append(String.format(" <%s> :Organism_%d ", interactIRI, nodeIdParticipantMap.get(relationship.getEndNode().getId())));
}
}
}
}
builder.append(".");
participantNumber++;
}
}
}
}
Aggregations