Search in sources :

Example 86 with Specimen

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

the class ExportUnmatchedTaxonNamesTest method exportOnePredatorNoPathButWithSameAs.

@Test
public void exportOnePredatorNoPathButWithSameAs() throws NodeFactoryException, IOException {
    taxonIndex = ExportTestUtil.taxonIndexWithEnricher(null, getGraphDb());
    String citation = "cite, study";
    Study study = nodeFactory.getOrCreateStudy(new StudyImpl("my, study", "my first, source", null, citation));
    Specimen predatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapienz", null));
    Taxon humanz = taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapienz", null));
    TaxonImpl taxon = new TaxonImpl("Homo sapiens", "TESTING:123");
    taxon.setPath("one | two | Homo sapiens");
    NodeUtil.connectTaxa(taxon, (TaxonNode) humanz, getGraphDb(), RelTypes.SIMILAR_TO);
    assertNotNull(humanz);
    Specimen preySpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Caniz", null));
    predatorSpecimen.interactsWith(preySpecimen, InteractType.ATE);
    predatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens", null));
    Node synonymNode = ((NodeBacked) taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapiens Synonym", null))).getUnderlyingNode();
    Node node = ((NodeBacked) taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapiens", null))).getUnderlyingNode();
    Transaction tx = getGraphDb().beginTx();
    try {
        node.createRelationshipTo(synonymNode, NodeUtil.asNeo4j(RelTypes.SAME_AS));
        tx.success();
    } finally {
        tx.finish();
    }
    preySpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Canis", null));
    predatorSpecimen.ate(preySpecimen);
    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" + "\nHomo sapienz\t\t\tHomo sapiens\tone | two | Homo sapiens\tTESTING:123\tcite, study\tmy first, source" + "\nCaniz\t\t\t\t\t\tcite, study\tmy first, source" + "\nCanis\t\t\t\t\t\tcite, study\tmy first, source"));
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) NodeBacked(org.eol.globi.domain.NodeBacked) Transaction(org.neo4j.graphdb.Transaction) StringWriter(java.io.StringWriter) TaxonImpl(org.eol.globi.domain.TaxonImpl) Taxon(org.eol.globi.domain.Taxon) Node(org.neo4j.graphdb.Node) TaxonNode(org.eol.globi.domain.TaxonNode) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 87 with Specimen

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

the class ExportFlatInteractionsTest method eatPrey.

private Specimen eatPrey(Specimen specimen, String scientificName, String externalId, Study study) throws NodeFactoryException {
    final TaxonImpl preyTaxon = new TaxonImpl(scientificName, externalId);
    preyTaxon.setPath("preyPathElem1 | preyPathElem2");
    Specimen otherSpecimen = factory.createSpecimen(study, preyTaxon);
    otherSpecimen.setVolumeInMilliLiter(124.0);
    specimen.ate(otherSpecimen);
    return otherSpecimen;
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 88 with Specimen

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

the class ExportFlatInteractionsTest method specimenEatCatAndDog.

private void specimenEatCatAndDog(Double length, Study myStudy, String scientificName, String externalId) throws NodeFactoryException {
    Specimen specimen = collectSpecimen(myStudy, scientificName, externalId);
    eatPrey(specimen, "Canis lupus", "EOL:555", myStudy);
    eatPrey(specimen, "Felis domesticus", "EOL:666", myStudy);
    eatPrey(specimen, "Blah blahuuuu", PropertyAndValueDictionary.NO_MATCH, myStudy);
    if (null != length) {
        specimen.setLengthInMm(length);
    }
    LocationImpl location1 = new LocationImpl(12.0, -45.9, -60.0, null);
    location1.setLocality("some locale");
    location1.setLocalityId("some:localeid");
    Location location = factory.getOrCreateLocation(location1);
    specimen.caughtIn(location);
}
Also used : Specimen(org.eol.globi.domain.Specimen) LocationImpl(org.eol.globi.domain.LocationImpl) Location(org.eol.globi.domain.Location)

Example 89 with Specimen

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

the class ExportFlatInteractionsTest method collectSpecimen.

private Specimen collectSpecimen(Study myStudy, String scientificName, String externalId) throws NodeFactoryException {
    final TaxonImpl taxon = new TaxonImpl(scientificName, externalId);
    taxon.setPath("pathElem1 | pathElem 2");
    Specimen specimen = factory.createSpecimen(myStudy, taxon);
    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"));
    factory.setUnixEpochProperty(specimen, new Date(ExportTestUtil.utcTestTime()));
    return specimen;
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl) Date(java.util.Date) TermImpl(org.eol.globi.domain.TermImpl)

Example 90 with Specimen

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

the class ExporterMeasurementOrFactTest method createTestData.

private void createTestData(Double length, String targetTaxonName, String sourceTaxonName) throws NodeFactoryException, ParseException {
    Study myStudy = nodeFactory.createStudy(new StudyImpl("myStudy", null, null, null));
    Specimen specimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl(sourceTaxonName, "externalId1"));
    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, ExportTestUtil.utcTestDate());
    Specimen otherSpecimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl(targetTaxonName, "externalId2"));
    otherSpecimen.setVolumeInMilliLiter(124.0);
    specimen.ate(otherSpecimen);
    otherSpecimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl(targetTaxonName, "externalId2"));
    otherSpecimen.setVolumeInMilliLiter(18.0);
    specimen.ate(otherSpecimen);
    if (null != length) {
        specimen.setLengthInMm(length);
    }
    Location location = nodeFactory.getOrCreateLocation(new LocationImpl(22.0, 129.9, -60.0, null));
    specimen.caughtIn(location);
    resolveNames();
}
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) TermImpl(org.eol.globi.domain.TermImpl) Location(org.eol.globi.domain.Location)

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