use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForTSVTest 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";
DatasetImporterForTSV importer = new DatasetImporterForTSV(null, nodeFactory);
DatasetImpl dataset = getDataset(new TreeMap<URI, String>() {
{
put(URI.create("/interactions.tsv"), firstFewLines);
}
});
importer.setDataset(dataset);
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<StudyNode> 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.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method createStudyWithDifferentExternalIdInDifferentNamespace.
@Test
public void createStudyWithDifferentExternalIdInDifferentNamespace() throws NodeFactoryException {
StudyImpl study1 = new StudyImpl("myTitle", new DOI("myDoi", "123"), null);
study1.setOriginatingDataset(new DatasetImpl("name/space", URI.create("foo:bar"), is -> is));
study1.setExternalId("foo:bar");
StudyNode study1Created = getNodeFactory().getOrCreateStudy(study1);
StudyImpl study2 = new StudyImpl("myTitle", new DOI("myDoi", "123"), null);
study2.setOriginatingDataset(new DatasetImpl("name/spacz", URI.create("foo:bar"), is -> is));
study2.setExternalId("foo:baz");
StudyNode study2Created = getNodeFactory().getOrCreateStudy(study2);
assertThat(study1Created.getExternalId(), is("foo:bar"));
assertThat(study1Created.getOriginatingDataset().getNamespace(), is("name/space"));
assertThat(study2Created.getExternalId(), is("foo:baz"));
assertThat(study2Created.getOriginatingDataset().getNamespace(), is("name/spacz"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForSaproxylicIntegrationTest method importAll.
@Test
public void importAll() throws StudyImporterException {
DatasetImporter importer = new StudyImporterTestFactory(nodeFactory).instantiateImporter(DatasetImporterForSaproxylic.class);
importer.setDataset(new DatasetImpl("some/test", URI.create("classpath:/org/eol/globi/data/saproxylic"), inStream -> inStream));
importStudy(importer);
assertNotNull(taxonIndex.findTaxonByName("Fagus sylvatica"));
assertNotNull(taxonIndex.findTaxonByName("Epuraea variegata"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class CmdGenerateReportTest method generateIndividualStudySourceReports.
@Test
public void generateIndividualStudySourceReports() throws NodeFactoryException {
Dataset originatingDataset1 = nodeFactory.getOrCreateDataset(new DatasetImpl("az/source", URI.create("http://example.com"), inStream -> inStream));
StudyImpl study1 = new StudyImpl("a title", null, "citation");
study1.setOriginatingDataset(originatingDataset1);
createStudy(study1);
StudyImpl study2 = new StudyImpl("another title", null, "citation");
study2.setOriginatingDataset(originatingDataset1);
createStudy(study2);
Dataset originatingDataset3 = nodeFactory.getOrCreateDataset(new DatasetImpl("zother/source", URI.create("http://example.com"), inStream -> inStream));
StudyImpl study3 = new StudyImpl("yet another title", null, null);
study3.setOriginatingDataset(originatingDataset3);
createStudy(study3);
resolveNames();
new CmdGenerateReport(getGraphDb(), cacheService).generateReportForSourceIndividuals();
String escapedQuery = QueryParser.escape("globi:az/source");
IndexHits<Node> reports = getGraphDb().index().forNodes("reports").query(StudyConstant.SOURCE_ID, escapedQuery);
Node reportNode = reports.getSingle();
assertThat(reportNode.getProperty(StudyConstant.SOURCE_ID), is("globi:az/source"));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(2));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(8));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
reports.close();
IndexHits<Node> otherReports = getGraphDb().index().forNodes("reports").query(StudyConstant.SOURCE_ID, "globi\\:zother\\/source");
Node otherReport = otherReports.getSingle();
assertThat(otherReport.getProperty(StudyConstant.SOURCE_ID), is("globi:zother/source"));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(1));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(4));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class CmdGenerateReportTest method generateStudySourceOrganizationReports.
@Test
public void generateStudySourceOrganizationReports() throws NodeFactoryException {
Dataset originatingDataset1 = nodeFactory.getOrCreateDataset(new DatasetImpl("az/source1", URI.create("http://example.com"), inStream -> inStream));
StudyImpl study1 = new StudyImpl("a title", null, "citation");
study1.setOriginatingDataset(originatingDataset1);
createStudy(study1);
Dataset originatingDataset2 = nodeFactory.getOrCreateDataset(new DatasetImpl("az/source2", URI.create("http://example.com"), inStream -> inStream));
StudyImpl study2 = new StudyImpl("another title", null, "citation");
study2.setOriginatingDataset(originatingDataset2);
createStudy(study2);
Dataset originatingDataset3 = nodeFactory.getOrCreateDataset(new DatasetImpl("zother/source", URI.create("http://example.com"), inStream -> inStream));
StudyImpl study3 = new StudyImpl("yet another title", null, null);
study3.setOriginatingDataset(originatingDataset3);
createStudy(study3);
resolveNames();
new CmdGenerateReport(getGraphDb(), cacheService).generateReportForSourceOrganizations();
IndexHits<Node> reports = getGraphDb().index().forNodes("reports").query(StudyConstant.SOURCE_ID, "globi\\:az");
Node reportNode = reports.getSingle();
assertThat(reportNode.getProperty(StudyConstant.SOURCE_ID), is("globi:az"));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(2));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(2));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(2));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(8));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
reports.close();
IndexHits<Node> otherReports = getGraphDb().index().forNodes("reports").query(StudyConstant.SOURCE_ID, "globi\\:zother");
Node otherReport = otherReports.getSingle();
assertThat(otherReport.getProperty(StudyConstant.SOURCE_ID), is("globi:zother"));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(1));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(4));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
}
Aggregations