use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForGoMexSI2IT method assertThatSomeDataIsImported.
private static void assertThatSomeDataIsImported(NodeFactory nodeFactory, TaxonIndex taxonIndex) throws StudyImporterException, NodeFactoryException {
Study study = nodeFactory.findStudy("Divita et al 1983");
assertSpecimenProperties(((NodeBacked) study).getUnderlyingNode().getGraphDatabase());
assertNotNull(study);
assertThat(study.getTitle(), is("Divita et al 1983"));
assertThat(study.getExternalId(), is(ExternalIdUtil.urlForExternalId("GAME:2689")));
assertThat(study.getCitation(), is("Regina Divita, Mischelle Creel, Peter Sheridan. 1983. Foods of coastal fishes during brown shrimp Penaeus aztecus, migration from Texas estuaries (June - July 1981)."));
assertNotNull(nodeFactory.findStudy("Beaumariage 1973"));
assertNotNull(nodeFactory.findStudy("Baughman, 1943"));
assertNotNull(taxonIndex.findTaxonByName("Chloroscombrus chrysurus"));
assertNotNull(taxonIndex.findTaxonByName("Micropogonias undulatus"));
assertNotNull(taxonIndex.findTaxonByName("Amphipoda"));
assertNotNull(taxonIndex.findTaxonByName("Crustacea"));
Taxon taxon = taxonIndex.findTaxonByName("Scomberomorus cavalla");
List<String> preyList = new ArrayList<String>();
final List<String> titles = new ArrayList<String>();
Iterable<Relationship> classifiedAsRels = ((NodeBacked) taxon).getUnderlyingNode().getRelationships(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS));
int count = 0;
for (Relationship classifiedAsRel : classifiedAsRels) {
Node predatorSpecimen = classifiedAsRel.getStartNode();
Specimen predator = new SpecimenNode(predatorSpecimen);
Iterable<Relationship> stomachContents = NodeUtil.getStomachContents(predator);
for (Relationship prey : stomachContents) {
Relationship singleRelationship = prey.getEndNode().getSingleRelationship(NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS), Direction.OUTGOING);
preyList.add((String) singleRelationship.getEndNode().getProperty("name"));
}
count++;
Relationship collectedBy = predatorSpecimen.getSingleRelationship(NodeUtil.asNeo4j(RelTypes.COLLECTED), Direction.INCOMING);
assertThat(collectedBy, is(notNullValue()));
String title = (String) collectedBy.getStartNode().getProperty("title");
titles.add(title);
}
assertThat(count > 7, is(true));
assertThat(preyList, hasItem("Organic matter"));
assertThat(preyList, hasItem("Triglidae"));
assertThat(preyList, hasItem("Sparidae"));
assertThat(titles, hasItem("Beaumariage 1973"));
assertThat(titles, hasItem("Blanton et al 1972"));
assertNotNull(taxon);
final String footprintWKT = WKT_FOOTPRINT2;
LocationImpl expectedLocation = new LocationImpl(29.346953, -92.980614, -13.641, footprintWKT);
expectedLocation.setLocality("Louisiana inner continental shelf");
Location location = nodeFactory.findLocation(expectedLocation);
assertThat(location, is(notNullValue()));
assertThat(location.getFootprintWKT(), is(footprintWKT));
assertThat(location.getLocality(), is("Louisiana inner continental shelf"));
assertNotNull(location);
List<Environment> environments = location.getEnvironments();
assertThat(environments.size(), not(is(0)));
assertThat(environments.get(0).getExternalId(), is("http://cmecscatalog.org/classification/aquaticSetting/13"));
assertThat(environments.get(0).getName(), is("Marine Nearshore Subtidal"));
assertNotNull(nodeFactory.findStudy("GoMexSI"));
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class ExportTestUtil method createTestData.
public static Study createTestData(Double length, NodeFactory factory) throws NodeFactoryException, ParseException {
Study myStudy = factory.createStudy(new StudyImpl("myStudy", null, null, null));
Specimen specimen1 = factory.createSpecimen(myStudy, new TaxonImpl("Homo sapiens", "EOL:45634"));
specimen1.setStomachVolumeInMilliLiter(666.0);
specimen1.setLifeStage(new TermImpl("GLOBI:JUVENILE", "JUVENILE"));
specimen1.setPhysiologicalState(new TermImpl("GLOBI:DIGESTATE", "DIGESTATE"));
specimen1.setBodyPart(new TermImpl("GLOBI:BONE", "BONE"));
factory.setUnixEpochProperty(specimen1, ExportTestUtil.utcTestDate());
final Specimen specimen2 = factory.createSpecimen(myStudy, new TaxonImpl("Canis lupus", "EOL:123"));
specimen2.setVolumeInMilliLiter(124.0);
specimen1.ate(specimen2);
final Specimen specimen3 = factory.createSpecimen(myStudy, new TaxonImpl("Canis lupus", "EOL:123"));
specimen3.setVolumeInMilliLiter(18.0);
specimen1.ate(specimen3);
if (null != length) {
specimen1.setLengthInMm(length);
}
Location location = factory.getOrCreateLocation(new LocationImpl(88.0, -120.0, -60.0, null));
specimen1.caughtIn(location);
return myStudy;
}
use of org.eol.globi.domain.Specimen 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(""));
}
use of org.eol.globi.domain.Specimen 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);
}
use of org.eol.globi.domain.Specimen 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"));
}
Aggregations