Search in sources :

Example 6 with Specimen

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.");
    }
}
Also used : Study(org.eol.globi.domain.Study) StudyImpl(org.eol.globi.domain.StudyImpl) Specimen(org.eol.globi.domain.Specimen) LocationImpl(org.eol.globi.domain.LocationImpl) ArrayList(java.util.ArrayList) List(java.util.List) LatLng(org.eol.globi.geo.LatLng) HashMap(java.util.HashMap) Map(java.util.Map) Location(org.eol.globi.domain.Location)

Example 7 with Specimen

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;
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 8 with 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());
    }
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) StudyImpl(org.eol.globi.domain.StudyImpl) LocationImpl(org.eol.globi.domain.LocationImpl) LatLng(org.eol.globi.geo.LatLng) IOException(java.io.IOException) Location(org.eol.globi.domain.Location)

Example 9 with Specimen

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;
}
Also used : Specimen(org.eol.globi.domain.Specimen)

Example 10 with Specimen

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++;
            }
        }
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonNode(org.eol.globi.domain.TaxonNode) Relationship(org.neo4j.graphdb.Relationship) TreeMap(java.util.TreeMap)

Aggregations

Specimen (org.eol.globi.domain.Specimen)91 TaxonImpl (org.eol.globi.domain.TaxonImpl)59 Study (org.eol.globi.domain.Study)38 StudyImpl (org.eol.globi.domain.StudyImpl)34 Location (org.eol.globi.domain.Location)31 LocationImpl (org.eol.globi.domain.LocationImpl)22 Test (org.junit.Test)17 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)15 IOException (java.io.IOException)15 Date (java.util.Date)14 Relationship (org.neo4j.graphdb.Relationship)12 HashMap (java.util.HashMap)11 Taxon (org.eol.globi.domain.Taxon)11 SpecimenNode (org.eol.globi.domain.SpecimenNode)9 TermImpl (org.eol.globi.domain.TermImpl)9 ArrayList (java.util.ArrayList)8 InteractType (org.eol.globi.domain.InteractType)7 LatLng (org.eol.globi.geo.LatLng)6 Map (java.util.Map)5 TaxonNode (org.eol.globi.domain.TaxonNode)5