Search in sources :

Example 21 with Study

use of org.eol.globi.domain.Study 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 22 with Study

use of org.eol.globi.domain.Study 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 23 with Study

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

the class ExporterAssociationsTest method exportWithoutHeader.

@Test
public void exportWithoutHeader() throws IOException, NodeFactoryException, ParseException {
    createTestData(null);
    resolveNames();
    String expected = "\nglobi:assoc:4\tglobi:occur:2\thttp://purl.obolibrary.org/obo/RO_0002470\tglobi:occur:4\t\t\t\t\tdata source description\t\t\tglobi:ref:1" + "\nglobi:assoc:6\tglobi:occur:2\thttp://purl.obolibrary.org/obo/RO_0002470\tglobi:occur:4\t\t\t\t\tdata source description\t\t\tglobi:ref:1";
    Study myStudy1 = nodeFactory.findStudy("myStudy");
    StringWriter row = new StringWriter();
    new ExporterAssociations().exportStudy(myStudy1, row, false);
    assertThat(row.getBuffer().toString(), equalTo(expected));
}
Also used : Study(org.eol.globi.domain.Study) StringWriter(java.io.StringWriter) Test(org.junit.Test)

Example 24 with Study

use of org.eol.globi.domain.Study 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 25 with Study

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

the class InteractionListenerImpl method importValidLink.

private void importValidLink(Map<String, String> link) throws StudyImporterException, IOException {
    Study study = nodeFactory.getOrCreateStudy(studyFromLink(link));
    Specimen source = createSpecimen(link, study, SOURCE_TAXON_NAME, SOURCE_TAXON_ID, SOURCE_BODY_PART_NAME, SOURCE_BODY_PART_ID);
    Specimen target = createSpecimen(link, study, TARGET_TAXON_NAME, TARGET_TAXON_ID, TARGET_BODY_PART_NAME, TARGET_BODY_PART_ID);
    String interactionTypeId = link.get(INTERACTION_TYPE_ID);
    InteractType type = InteractType.typeOf(interactionTypeId);
    source.interactsWith(target, type, getOrCreateLocation(study, link));
}
Also used : InteractType(org.eol.globi.domain.InteractType) Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen)

Aggregations

Study (org.eol.globi.domain.Study)141 Test (org.junit.Test)84 StudyImpl (org.eol.globi.domain.StudyImpl)61 Specimen (org.eol.globi.domain.Specimen)38 Relationship (org.neo4j.graphdb.Relationship)33 TaxonImpl (org.eol.globi.domain.TaxonImpl)32 IOException (java.io.IOException)30 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)24 Location (org.eol.globi.domain.Location)24 StringWriter (java.io.StringWriter)21 LocationImpl (org.eol.globi.domain.LocationImpl)20 ArrayList (java.util.ArrayList)17 HashMap (java.util.HashMap)16 Taxon (org.eol.globi.domain.Taxon)16 SpecimenNode (org.eol.globi.domain.SpecimenNode)14 Date (java.util.Date)13 DatasetImpl (org.eol.globi.service.DatasetImpl)13 Node (org.neo4j.graphdb.Node)12 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)10 InteractType (org.eol.globi.domain.InteractType)9