Search in sources :

Example 76 with Specimen

use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.

the class ExporterTaxaDistinctTest method excludeNoMatchNames.

@Test
public void excludeNoMatchNames() throws NodeFactoryException, IOException {
    Study study = nodeFactory.createStudy(new StudyImpl("bla", null, null, null));
    Specimen predator = nodeFactory.createSpecimen(study, new TaxonImpl(PropertyAndValueDictionary.NO_MATCH, "EOL:1234"));
    Specimen prey = nodeFactory.createSpecimen(study, new TaxonImpl(PropertyAndValueDictionary.NO_MATCH, "EOL:122"));
    predator.ate(prey);
    assertThat(exportStudy(study), not(containsString(PropertyAndValueDictionary.NO_MATCH)));
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 77 with Specimen

use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.

the class InteractionListenerImpl method createSpecimen.

private Specimen createSpecimen(Map<String, String> link, Study study, String taxonNameLabel, String taxonIdLabel, String bodyPartName, String bodyPartId) throws StudyImporterException {
    String sourceTaxonName = link.get(taxonNameLabel);
    String sourceTaxonId = link.get(taxonIdLabel);
    Specimen source = nodeFactory.createSpecimen(study, new TaxonImpl(sourceTaxonName, sourceTaxonId));
    setBasisOfRecordIfAvailable(link, source);
    setDateTimeIfAvailable(link, source);
    setBodyPartIfAvailable(link, source, bodyPartName, bodyPartId);
    return source;
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 78 with Specimen

use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.

the class StudyImporterForPlanque method addInteractionForPredator.

private void addInteractionForPredator(LabeledCSVParser parser, Study localStudy, String predatorName) throws NodeFactoryException, StudyImporterException {
    Specimen predator = nodeFactory.createSpecimen(localStudy, new TaxonImpl(normalizeName(predatorName), null));
    // from http://www.geonames.org/630674/barents-sea.html
    Location location = nodeFactory.getOrCreateLocation(new LocationImpl(74.0, 36.0, null, null));
    predator.caughtIn(location);
    String preyName = parser.getValueByLabel("PREY");
    if (StringUtils.isBlank(preyName)) {
        getLogger().warn(localStudy, "found empty prey name on line [" + parser.lastLineNumber() + "]");
    } else {
        Specimen prey = nodeFactory.createSpecimen(localStudy, new TaxonImpl(normalizeName(preyName), null));
        prey.caughtIn(location);
        predator.ate(prey);
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl) LocationImpl(org.eol.globi.domain.LocationImpl) Location(org.eol.globi.domain.Location)

Example 79 with Specimen

use of org.eol.globi.domain.Specimen 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);
    }
}
Also used : InteractType(org.eol.globi.domain.InteractType) Study(org.eol.globi.domain.Study) HashMap(java.util.HashMap) StudyImpl(org.eol.globi.domain.StudyImpl) LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) IOException(java.io.IOException) Specimen(org.eol.globi.domain.Specimen)

Example 80 with Specimen

use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.

the class StudyImporterForJRFerrerParis method addAssociation.

private void addAssociation(Study study, LabeledCSVParser parser, String butterflyName, String plantName) throws StudyImporterException {
    Specimen instigatorSpecimen;
    try {
        instigatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl(butterflyName, null));
    } catch (NodeFactoryException e) {
        throw new StudyImporterException("failed to create butterfly specimen [" + butterflyName + "] on line [" + parser.lastLineNumber() + "]", e);
    }
    Specimen targetSpecimen;
    try {
        targetSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl(plantName, null));
        instigatorSpecimen.ate(targetSpecimen);
    } catch (NodeFactoryException e) {
        throw new StudyImporterException("failed to associate butterfly [" + butterflyName + "] to plant [" + plantName + "] on line [" + parser.lastLineNumber() + "]", e);
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl)

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