use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForCoetzerTest method importSome.
@Test
public void importSome() throws StudyImporterException, IOException {
StudyImporterForCoetzer importer = new StudyImporterForCoetzer(null, nodeFactory);
DatasetImpl dataset = new DatasetLocal();
JsonNode config = new ObjectMapper().readTree("{\"citation\": \"source citation\", \"resources\": {\"archive\": \"coetzer/CatalogOfAfrotropicalBees.zip\"}}");
dataset.setConfig(config);
importer.setDataset(dataset);
importStudy(importer);
List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
for (Study allStudy : allStudies) {
assertThat(allStudy.getSource(), startsWith("source citation"));
assertThat(allStudy.getSource(), containsString("Accessed at"));
}
assertThat(taxonIndex.findTaxonByName("Agrostis tremula"), is(notNullValue()));
assertThat(taxonIndex.findTaxonByName("Coelioxys erythrura"), is(notNullValue()));
assertThat(taxonIndex.findTaxonByName("Patellapis namaquensis"), is(notNullValue()));
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForCookTest method importFirstFewLines.
@Test
public void importFirstFewLines() throws IOException, NodeFactoryException, StudyImporterException {
String firstFiveLines = "\"Date\",\"Individual\",\"Fish Length\",\"Infected\",\"Iso 1\",\"Iso 2\",\"Iso 3\",\"Iso 4 \",\"Iso 5\",\"Iso #\",,\n" + "8/10/2010,22,15.6,1,\"NA\",\"NA\",0,0,0,2,,\"Notes: All fish collected were Atlantic Croaker (Micropogonias undulatus) and measured in total length (cm). Isopods collected were Cymothoa excisa. For the Infected column 1= infected and 0= not infected. Numbers for the isopods are total length in cm and the Iso# represents the number of isopods found per fish. \"\n" + "8/10/2010,1,14.7,1,1.6,0.67,0,0,0,2,,\n" + "8/10/2010,5,14.2,1,1.53,0.7,0,0,0,2,,\n" + "8/10/2010,2,13.2,1,1.42,0.71,0.52,0.45,0,4,,\n";
StudyImporterForCook importer = new StudyImporterForCook(new TestParserFactory(firstFiveLines), nodeFactory);
importStudy(importer);
Study study = getStudySingleton(getGraphDb());
Taxon hostTaxon = taxonIndex.findTaxonByName("Micropogonias undulatus");
assertThat(hostTaxon, is(notNullValue()));
Taxon parasiteTaxon = taxonIndex.findTaxonByName("Cymothoa excisa");
assertThat(parasiteTaxon, is(notNullValue()));
assertThat("missing location", nodeFactory.findLocation(new LocationImpl(27.85, -(97.0 + 8.0 / 60.0), -3.0, null)), is(notNullValue()));
int count = 0;
boolean foundFirstHost = false;
Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
for (Relationship collected_rel : specimens) {
assertThat(collected_rel.getProperty(SpecimenConstant.DATE_IN_UNIX_EPOCH), is(notNullValue()));
Node specimen = collected_rel.getEndNode();
if (specimen.hasProperty(SpecimenConstant.LENGTH_IN_MM)) {
Object property = specimen.getProperty(SpecimenConstant.LENGTH_IN_MM);
if (new Double(156.0).equals(property)) {
assertTaxonClassification(specimen, ((NodeBacked) hostTaxon).getUnderlyingNode());
foundFirstHost = true;
Iterable<Relationship> parasiteRel = specimen.getRelationships(Direction.INCOMING, NodeUtil.asNeo4j(InteractType.PARASITE_OF));
for (Relationship relationship : parasiteRel) {
Node parasite = relationship.getStartNode();
assertThat(parasite.hasProperty(SpecimenConstant.LENGTH_IN_MM), is(false));
assertTaxonClassification(parasite, ((NodeBacked) parasiteTaxon).getUnderlyingNode());
}
}
}
count++;
}
assertThat(count, is(14));
assertThat(foundFirstHost, is(true));
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForBaremoreTest method importLine.
@Test
public void importLine() throws StudyImporterException, NodeFactoryException {
String csvContent = "\"Shark Id\",\"Date\",\"Survey type\",\"Shark TL\",\"Gape length (cm)\",\"Mat State\",\"Prey code\",\"Common name\",\"Prey No\",\"No in stomach\",\"SL (mm)\",\"FL\",\"TL\",\"VC\",\"Length\",\"Height\",\"Other measurement\",\"Measurement type\",\"Weight (g)\",\"% Dig\",\"Notes\"\n" + "13,2/7/2003,\"Dependent\",68,,\"Juv\",\"ATCR\",\"Atlantic croaker\",1,1,,,,,,,,,2.81,90,\"1 pr eyes, otos. Weighed with otos\"\n" + "131,3/14/2003,\"Dependent\",68,,\"Juv\",\"ATCR\",\"Atlantic croaker\",4,1,,,,,,,,,8.25,90,\"Bones, scales, vert in pieces. 1 pair otos\"\n" + "394,12/16/2003,\"Dependent\",103,,\"Mat\",\"ATCR\",\"Atlantic croaker\",1,1,175,,,,,,,,64.24,30,\n" + "401,12/16/2003,\"Dependent\",85,,\"Juv\",\"ATCR\",\"Atlantic croaker\",2,1,,,192,,,,,,76.27,0,\"In stomach but suspciously undigested. Some scales gone\"\n" + "402,12/16/2003,\"Dependent\",97,,\"Mat\",\"ATCR\",\"Atlantic croaker\",1,1,,,,120,,,,,51.88,60,\n" + "402,12/16/2003,\"Dependent\",97,,\"Mat\",\"ATCR\",\"Atlantic croaker\",2,1,,,,,,,,,6.28,90,\"W/ otos\"";
StudyImporterForBaremore studyImporter = new StudyImporterForBaremore(new TestParserFactory(csvContent), nodeFactory);
importStudy(studyImporter);
Study study = getStudySingleton(getGraphDb());
assertNotNull(taxonIndex.findTaxonByName("Squatina dumeril"));
assertNotNull(taxonIndex.findTaxonByName("Atlantic croaker"));
Iterable<Relationship> collectedRels = NodeUtil.getSpecimens(study);
int totalRels = validateSpecimen(collectedRels);
assertThat(totalRels, Is.is(11));
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class ExporterMeasurementOrFactTest method exportMissingLength.
@Test
public void exportMissingLength() throws IOException, NodeFactoryException, ParseException {
createTestData(null, "Canis lupus", "Homo sapiens");
String expected = "\nglobi:occur:stomach_volume:2\tglobi:occur:2\tyes\t\t\tstomach volume\t666.0\thttp://purl.obolibrary.org/obo/UO_0000098\t\t\t1992-03-30T08:00:00Z\t\t\t\tmyStudy\t\t\tglobi:ref:1" + "\nglobi:occur:volume:4\tglobi:occur:4\tyes\t\t\tvolume\t124.0\thttp://purl.obolibrary.org/obo/UO_0000098\t\t\t1992-03-30T08:00:00Z\t\t\t\tmyStudy\t\t\tglobi:ref:1" + "\nglobi:occur:volume:6\tglobi:occur:6\tyes\t\t\tvolume\t18.0\thttp://purl.obolibrary.org/obo/UO_0000098\t\t\t1992-03-30T08:00:00Z\t\t\t\tmyStudy\t\t\tglobi:ref:1";
Study myStudy1 = nodeFactory.findStudy("myStudy");
StringWriter row = new StringWriter();
new ExporterMeasurementOrFact().exportStudy(myStudy1, row, false);
assertThat(row.getBuffer().toString(), equalTo(expected));
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class ExporterOccurrenceAggregatesTest method exportToCSVNoHeader.
@Test
public void exportToCSVNoHeader() throws NodeFactoryException, IOException, ParseException {
createTestData(123.0);
resolveNames();
Study myStudy1 = nodeFactory.findStudy("myStudy");
StringWriter row = new StringWriter();
new ExporterOccurrenceAggregates().exportDistinct(myStudy1, row);
String expectedData = getExpectedData();
int linesPerHeader = 1;
int numberOfExpectedDistinctSourceTargetInteractions = 12;
String actualData = row.getBuffer().toString();
assertThat(actualData, equalTo(expectedData));
assertThat(actualData.split("\n").length, Is.is(linesPerHeader + numberOfExpectedDistinctSourceTargetInteractions));
}
Aggregations