use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForSzoboszlaiIT method importAll.
@Test
public void importAll() throws StudyImporterException, IOException {
JsonNode config = new ObjectMapper().readTree("{ \"citation\": \"Szoboszlai AI, Thayer JA, Wood SA, Sydeman WJ, Koehn LE (2015) Data from: Forage species in predator diets: synthesis of data from the California Current. Dryad Digital Repository. http://dx.doi.org/10.5061/dryad.nv5d2\",\n" + " \"doi\": \"http://dx.doi.org/10.5061/dryad.nv5d2\",\n" + " \"format\": \"szoboszlai\",\n" + " \"resources\": {\n" + " \"links\": \"http://datadryad.org/bitstream/handle/10255/dryad.94536/CCPDDlinkdata_v1.csv\",\n" + " \"shapes\": \"http://datadryad.org/bitstream/handle/10255/dryad.94535/CCPDDlocationdata_v1.zip\"\n" + " }\n" + "}");
DatasetImpl dataset = new DatasetImpl("someRepo", URI.create("http://example.com"));
dataset.setConfig(config);
ParserFactory parserFactory = new ParserFactoryForDataset(dataset);
StudyImporterForSzoboszlai importer = new StudyImporterForSzoboszlai(parserFactory, nodeFactory);
importer.setDataset(dataset);
importStudy(importer);
List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
assertThat(allStudies.size(), is(not(0)));
Study firstStudy = allStudies.get(0);
Iterable<Relationship> specimens = NodeUtil.getSpecimens(firstStudy);
for (Relationship specimen : specimens) {
Specimen specimenNode = new SpecimenNode(specimen.getEndNode());
Location sampleLocation = specimenNode.getSampleLocation();
assertThat(sampleLocation, is(notNullValue()));
assertThat(sampleLocation.getLatitude(), is(notNullValue()));
assertThat(sampleLocation.getLongitude(), is(notNullValue()));
}
assertThat(taxonIndex.findTaxonByName("Thunnus thynnus"), is(notNullValue()));
assertThat(nodeFactory.findLocation(new LocationImpl(34.00824202376044, -120.72716166720323, null, null)), is(notNullValue()));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForTSVTest method wardeh.
@Test
public void wardeh() throws StudyImporterException {
String firstFewLines = "sourceTaxonId\tsourceTaxonName\tinteractionTypeId\tinteractionTypeName\ttargetTaxonId\ttargetTaxonName\tlocalityId\tlocalityName\tdecimalLatitude\tdecimalLongitude\tobservationDateTime\treferenceUrl\tsourceDoi\tsourceCitation\n" + "EOL:2912748\tbacillus subtilis\tRO:0002454\thasHost\tEOL:594885\tmorus alba\t\t\t\t\t\thttp://www.ncbi.nlm.nih.gov/nuccore/100172732\tdoi: 10.1038/sdata.2015.49\tWardeh, M. et al. Database of host-pathogen and related species interactions, and their global distribution. Sci. Data 2:150049 doi: 10.1038/sdata.2015.49 (2015)\n" + "EOL:741039\tbovine adenovirus c\tRO:0002454\thasHost\tEOL:328699\tbos taurus\t\t\t\t\t\thttp://www.ncbi.nlm.nih.gov/nuccore/1002418\tdoi: 10.1038/sdata.2015.49\tWardeh, M. et al. Database of host-pathogen and related species interactions, and their global distribution. Sci. Data 2:150049 doi: 10.1038/sdata.2015.49 (2015)\n" + "EOL:12141292\tichthyophonus hoferi\tRO:0002454\thasHost\tEOL:205418\tlimanda ferruginea\t\t\t\t\t\thttp://www.ncbi.nlm.nih.gov/nuccore/1002422\tdoi: 10.1038/sdata.2015.49\tWardeh, M. et al. Database of host-pathogen and related species interactions, and their global distribution. Sci. Data 2:150049 doi: 10.1038/sdata.2015.49 (2015)\n";
StudyImporterForTSV importer = new StudyImporterForTSV(new TestParserFactory(firstFewLines), nodeFactory);
importer.setDataset(new DatasetImpl("someRepo", URI.create("http://example.com")));
importStudy(importer);
Taxon taxon = taxonIndex.findTaxonById("EOL:2912748");
assertThat(taxon, is(notNullValue()));
assertThat(taxon.getName(), is("bacillus subtilis"));
assertThat(taxon.getExternalId(), is("EOL:2912748"));
final List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
final List<String> titles = new ArrayList<String>();
final List<String> ids = new ArrayList<String>();
for (Study study : allStudies) {
titles.add(study.getTitle());
ids.add(study.getExternalId());
}
assertThat(titles, hasItem("someRepohttp://www.ncbi.nlm.nih.gov/nuccore/100172732"));
assertThat(ids, hasItem("http://www.ncbi.nlm.nih.gov/nuccore/100172732"));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class IndexInteractionsTest method indexInteractions.
@Test
public void indexInteractions() throws NodeFactoryException {
TaxonIndex taxonIndex = getOrCreateTaxonIndex();
// see https://github.com/jhpoelen/eol-globi-data/wiki/Nanopubs
StudyImpl study = new StudyImpl("some study", "some source", "http://doi.org/123.23/222", "some study citation");
NodeFactoryWithDatasetContext factory = new NodeFactoryWithDatasetContext(nodeFactory, new DatasetImpl("some/namespace", URI.create("https://some.uri")));
Study interaction = factory.getOrCreateStudy(study);
TaxonImpl donaldTaxon = new TaxonImpl("donald duck", "NCBI:1234");
Specimen donald = factory.createSpecimen(interaction, donaldTaxon);
donald.classifyAs(taxonIndex.getOrCreateTaxon(donaldTaxon));
TaxonImpl mickeyTaxon = new TaxonImpl("mickey mouse", "NCBI:4444");
Taxon mickeyTaxonNCBI = taxonIndex.getOrCreateTaxon(new TaxonImpl("mickey mouse", "EOL:567"));
NodeUtil.connectTaxa(mickeyTaxon, (TaxonNode) mickeyTaxonNCBI, getGraphDb(), RelTypes.SAME_AS);
Specimen mickey = factory.createSpecimen(interaction, mickeyTaxon);
mickey.classifyAs(taxonIndex.getOrCreateTaxon(mickeyTaxon));
donald.ate(mickey);
new IndexInteractions(getGraphDb()).link();
NodeFactoryNeo4j nodeFactoryNeo4j = new NodeFactoryNeo4j(getGraphDb());
StudyImpl study1 = new StudyImpl("some study", "some source", null, "come citation");
study1.setOriginatingDataset(new DatasetImpl("some/namespace", URI.create("some:uri")));
StudyNode someStudy = nodeFactoryNeo4j.getOrCreateStudy(study1);
assertThat(interaction.getOriginatingDataset().getNamespace(), is(someStudy.getOriginatingDataset().getNamespace()));
assertThat(interaction.getTitle(), is(someStudy.getTitle()));
Iterable<Relationship> specimens = NodeUtil.getSpecimens(someStudy);
RelationshipType hasParticipant = NodeUtil.asNeo4j(RelTypes.HAS_PARTICIPANT);
Set<Long> ids = new HashSet<>();
List<Long> idList = new ArrayList<>();
for (Relationship specimen : specimens) {
assertThat(specimen.getEndNode().hasRelationship(Direction.INCOMING, hasParticipant), Is.is(true));
Relationship singleRelationship = specimen.getEndNode().getSingleRelationship(hasParticipant, Direction.INCOMING);
long id = singleRelationship.getStartNode().getId();
ids.add(id);
idList.add(id);
}
assertThat(ids.size(), Is.is(1));
assertThat(idList.size(), Is.is(2));
Node interactionNode = getGraphDb().getNodeById(idList.get(0));
assertTrue(interactionNode.hasRelationship(Direction.OUTGOING, NodeUtil.asNeo4j(RelTypes.DERIVED_FROM)));
assertTrue(interactionNode.hasRelationship(Direction.OUTGOING, NodeUtil.asNeo4j(RelTypes.ACCESSED_AT)));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class LinkerDOITest method createStudyDOIlookupCitationDisabled.
@Test
public void createStudyDOIlookupCitationDisabled() throws NodeFactoryException {
StudyImpl study1 = new StudyImpl("title", "some source", null, "some citation");
study1.setExternalId("some:id");
DatasetImpl originatingDataset = new DatasetImpl("some/namespace", URI.create("some:uri"));
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, false);
originatingDataset.setConfig(objectNode);
study1.setOriginatingDataset(originatingDataset);
Study study = getNodeFactory().getOrCreateStudy(study1);
assertThat(study.getSource(), is("some source"));
assertThat(study.getDOI(), is(nullValue()));
assertThat(study.getCitation(), is("some citation"));
assertThat(study.getTitle(), is("title"));
assertThat(study.getExternalId(), is("some:id"));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForTSVTest method importMinimal.
@Test
public void importMinimal() throws StudyImporterException {
String minimalLines = "sourceTaxonId\tsourceTaxonName\tinteractionTypeId\tinteractionTypeName\ttargetTaxonId\ttargetTaxonName\tlocalityId\tlocalityName\tdecimalLatitude\tdecimalLongitude\tobservationDateTime\treferenceDoi\treferenceCitation\n" + "EOL:123\t\tRO:0002444\t\tEOL:111\t\t\t\t\t\t\t\tGittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1\n" + "EOL:456\t\tRO:0002444\t\tEOL:222\t\t\t\t\t\t\t\tGittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1\n" + "EOL:678\t\tRO:0002444\t\tEOL:333\t\t\t\t\t\t\t\tGittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1\n" + "EOL:912\t\tRO:0002444\t\tEOL:444\t\t\t\t\t\t\t\tGittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1\n";
StudyImporterForTSV importer = new StudyImporterForTSV(new TestParserFactory(minimalLines), nodeFactory);
importer.setDataset(new DatasetImpl("someRepo", URI.create("http://example.com")));
importStudy(importer);
Taxon taxon = taxonIndex.findTaxonById("EOL:123");
assertThat(taxon, is(notNullValue()));
assertThat(taxon.getName(), is("no name"));
assertThat(taxon.getExternalId(), is("EOL:123"));
assertStudyTitles("someRepoGittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1");
}
Aggregations