Search in sources :

Example 11 with StudyImpl

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

the class ExporterAssociationAggregatesTest method exportNoMatchTaxa.

@Test
public void exportNoMatchTaxa() throws IOException, NodeFactoryException, ParseException {
    String[] studyTitles = { "myStudy1", "myStudy2" };
    for (String studyTitle : studyTitles) {
        Study myStudy = nodeFactory.getOrCreateStudy(new StudyImpl(studyTitle, "data source description", null, ExternalIdUtil.toCitation("contributor", "description", "pubYear")));
        Specimen specimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl(PropertyAndValueDictionary.NO_MATCH, null));
        specimen.ate(nodeFactory.createSpecimen(myStudy, new TaxonImpl(PropertyAndValueDictionary.NO_MATCH, null)));
    }
    resolveNames();
    ExporterAssociationAggregates exporter = new ExporterAssociationAggregates();
    StringWriter row = new StringWriter();
    for (String studyTitle : studyTitles) {
        Study myStudy1 = nodeFactory.findStudy(studyTitle);
        exporter.exportStudy(myStudy1, row, false);
    }
    assertThat(row.getBuffer().toString(), equalTo(""));
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) StringWriter(java.io.StringWriter) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 12 with StudyImpl

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

the class ExporterAssociationAggregatesTest method createTestData.

private void createTestData(Double length, String studyTitle) throws NodeFactoryException, ParseException {
    Study myStudy = nodeFactory.getOrCreateStudy(new StudyImpl(studyTitle, "data source description", null, ExternalIdUtil.toCitation("contributor", "description", "pubYear")));
    Specimen specimen = nodeFactory.createSpecimen(myStudy, setPathAndId(new TaxonImpl("Homo sapiens", null)));
    specimen.setStomachVolumeInMilliLiter(666.0);
    specimen.setLifeStage(new TermImpl("GlOBI:JUVENILE", "JUVENILE"));
    specimen.setPhysiologicalState(new TermImpl("GlOBI:DIGESTATE", "DIGESTATE"));
    specimen.setBodyPart(new TermImpl("GLOBI:BONE", "BONE"));
    nodeFactory.setUnixEpochProperty(specimen, new Date(ExportTestUtil.utcTestTime()));
    TaxonImpl taxon = new TaxonImpl("Canis lupus", null);
    Specimen otherSpecimen = nodeFactory.createSpecimen(myStudy, setPathAndId(taxon));
    otherSpecimen.setVolumeInMilliLiter(124.0);
    specimen.ate(otherSpecimen);
    specimen.ate(otherSpecimen);
    if (null != length) {
        specimen.setLengthInMm(length);
    }
    Location location = nodeFactory.getOrCreateLocation(new LocationImpl(44.0, 120.0, -60.0, null));
    specimen.caughtIn(location);
}
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) LocationImpl(org.eol.globi.domain.LocationImpl) Date(java.util.Date) TermImpl(org.eol.globi.domain.TermImpl) Location(org.eol.globi.domain.Location)

Example 13 with StudyImpl

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

the class ExportUnmatchedTaxonNamesTest method exportOnePredatorTwoPrey.

@Test
public void exportOnePredatorTwoPrey() throws NodeFactoryException, IOException {
    taxonIndex = ExportTestUtil.taxonIndexWithEnricher(null, getGraphDb());
    String title = "my study\"";
    String citation = "citation my study";
    Study study = nodeFactory.getOrCreateStudy(new StudyImpl(title, "my first source", null, citation));
    taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapiens", null));
    Specimen predatorSpecimen = nodeFactory.createSpecimen(study, human());
    taxonIndex.getOrCreateTaxon(new TaxonImpl("Canis lupus", null));
    Specimen preySpecimen6 = nodeFactory.createSpecimen(study, dog());
    predatorSpecimen.interactsWith(preySpecimen6, InteractType.ATE);
    Specimen preySpecimen5 = nodeFactory.createSpecimen(study, dog());
    predatorSpecimen.interactsWith(preySpecimen5, InteractType.ATE);
    Specimen preySpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Caniz", null));
    predatorSpecimen.ate(preySpecimen);
    Specimen predatorSpecimen23 = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens2", null));
    Specimen preySpecimen4 = nodeFactory.createSpecimen(study, dog());
    predatorSpecimen23.interactsWith(preySpecimen4, InteractType.ATE);
    Specimen predatorSpecimen22 = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens2", null));
    Specimen preySpecimen3 = nodeFactory.createSpecimen(study, dog());
    predatorSpecimen22.interactsWith(preySpecimen3, InteractType.ATE);
    Study study2 = nodeFactory.getOrCreateStudy(new StudyImpl("my study2", "my source2", null, "citation study2"));
    Specimen predatorSpecimen21 = nodeFactory.createSpecimen(study2, new TaxonImpl("Homo sapiens2", null));
    Specimen preySpecimen2 = nodeFactory.createSpecimen(study2, dog());
    predatorSpecimen21.interactsWith(preySpecimen2, InteractType.ATE);
    Specimen predatorSpecimen2 = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens3", PropertyAndValueDictionary.NO_MATCH));
    Specimen preySpecimen1 = nodeFactory.createSpecimen(study, dog());
    predatorSpecimen2.interactsWith(preySpecimen1, InteractType.ATE);
    resolveNames();
    StringWriter writer = new StringWriter();
    new ExportUnmatchedTaxonNames().exportStudy(study, writer, true);
    assertThat(writer.toString(), is("unmatched taxon name\tunmatched taxon id\tname status\tsimilar to taxon name\tsimilar to taxon path\tsimilar to taxon id\tstudy\tsource" + "\nCaniz\t\t\t\t\t\tcitation my study\tmy first source" + "\nHomo sapiens2\t\t\t\t\t\tcitation my study\tmy first source" + "\nHomo sapiens3\tno:match\t\t\t\t\tcitation my study\tmy first source"));
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) StringWriter(java.io.StringWriter) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 14 with StudyImpl

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

the class InteractionListenerImpl method studyFromLink.

private StudyImpl studyFromLink(Map<String, String> link) {
    String referenceCitation = link.get(REFERENCE_CITATION);
    StudyImpl study1 = new StudyImpl(link.get(REFERENCE_ID), link.get(STUDY_SOURCE_CITATION), link.get(REFERENCE_DOI), referenceCitation);
    final String referenceUrl = link.get(REFERENCE_URL);
    if (StringUtils.isBlank(study1.getExternalId()) && StringUtils.isNotBlank(referenceUrl)) {
        study1.setExternalId(referenceUrl);
    }
    return study1;
}
Also used : StudyImpl(org.eol.globi.domain.StudyImpl)

Example 15 with StudyImpl

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

the class StudyImporterForHurlbert method importRecords.

private void importRecords(Set<String> regions, Set<String> locales, Set<String> habitats, Record record, String sourceCitation) throws StudyImporterException {
    String namespace = getDataset() == null ? "" : getDataset().getNamespace();
    StudyImpl study1 = new StudyImpl(namespace + sourceCitation, "Allen Hurlbert. Avian Diet Database (https://github.com/hurlbertlab/dietdatabase/). " + CitationUtil.createLastAccessedString(RESOURCE), null, sourceCitation);
    study1.setOriginatingDataset(getDataset());
    Study study = nodeFactory.getOrCreateStudy(study1);
    // ID,Common_Name,Scientific_Name,,,,Prey_Common_Name,Fraction_Diet_By_Wt_or_Vol,Fraction_Diet_By_Items,Fraction_Occurrence,Fraction_Diet_Unspecified,Item Sample Size,Bird Sample size,Sites,StudyNode Type,Notes,Source
    String[] preyLabels = { "Prey_Kingdom", "Prey_Phylum", "Prey_Class", "Prey_Order", "Prey_Suborder", "Prey_Family", "Prey_Genus", "Prey_Scientific_Name" };
    ArrayUtils.reverse(preyLabels);
    String preyTaxonName = null;
    for (String preyLabel : preyLabels) {
        preyTaxonName = columnValueOrNull(record, preyLabel);
        if (StringUtils.isNotBlank(preyTaxonName) && !"NA".equalsIgnoreCase(preyTaxonName)) {
            break;
        }
    }
    String predatorTaxonName = StringUtils.trim(columnValueOrNull(record, "Scientific_Name"));
    if (StringUtils.isNotBlank(StringUtils.trim(predatorTaxonName)) && StringUtils.isNotBlank(StringUtils.trim(preyTaxonName))) {
        importInteraction(regions, locales, habitats, record, study, preyTaxonName, predatorTaxonName);
    }
}
Also used : Study(org.eol.globi.domain.Study) StudyImpl(org.eol.globi.domain.StudyImpl)

Aggregations

StudyImpl (org.eol.globi.domain.StudyImpl)82 Study (org.eol.globi.domain.Study)60 Test (org.junit.Test)40 Specimen (org.eol.globi.domain.Specimen)33 TaxonImpl (org.eol.globi.domain.TaxonImpl)33 IOException (java.io.IOException)20 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)17 Location (org.eol.globi.domain.Location)15 StringWriter (java.io.StringWriter)12 LocationImpl (org.eol.globi.domain.LocationImpl)12 Date (java.util.Date)9 HashMap (java.util.HashMap)9 Taxon (org.eol.globi.domain.Taxon)9 StudyNode (org.eol.globi.domain.StudyNode)7 Node (org.neo4j.graphdb.Node)7 File (java.io.File)6 TermImpl (org.eol.globi.domain.TermImpl)6 DatasetImpl (org.eol.globi.service.DatasetImpl)6 InteractType (org.eol.globi.domain.InteractType)5 NonResolvingTaxonIndex (org.eol.globi.taxon.NonResolvingTaxonIndex)5