Search in sources :

Example 56 with DatasetImpl

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"));
}
Also used : Study(org.eol.globi.domain.Study) Taxon(org.eol.globi.domain.Taxon) ArrayList(java.util.ArrayList) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) URI(java.net.URI) StudyNode(org.eol.globi.domain.StudyNode) Test(org.junit.Test)

Example 57 with DatasetImpl

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"));
}
Also used : NodeUtil(org.eol.globi.util.NodeUtil) Location(org.eol.globi.domain.Location) Date(java.util.Date) Direction(org.neo4j.graphdb.Direction) ExternalIdUtil(org.eol.globi.util.ExternalIdUtil) StringUtils(org.apache.commons.lang3.StringUtils) StudyImpl(org.eol.globi.domain.StudyImpl) InteractType(org.eol.globi.domain.InteractType) TaxonImpl(org.eol.globi.domain.TaxonImpl) Is.is(org.hamcrest.core.Is.is) URI(java.net.URI) LocationNode(org.eol.globi.domain.LocationNode) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) PropertyAndValueDictionary(org.eol.globi.domain.PropertyAndValueDictionary) EnvironmentNode(org.eol.globi.domain.EnvironmentNode) SpecimenConstant(org.eol.globi.domain.SpecimenConstant) SpecimenNode(org.eol.globi.domain.SpecimenNode) DateUtil(org.eol.globi.util.DateUtil) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Term(org.eol.globi.domain.Term) NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) Specimen(org.eol.globi.domain.Specimen) TermImpl(org.eol.globi.domain.TermImpl) LocationImpl(org.eol.globi.domain.LocationImpl) CoreMatchers.not(org.hamcrest.CoreMatchers.not) Environment(org.eol.globi.domain.Environment) DatasetConstant(org.globalbioticinteractions.dataset.DatasetConstant) TermLookupService(org.eol.globi.service.TermLookupService) RelTypes(org.eol.globi.domain.RelTypes) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Node(org.neo4j.graphdb.Node) ArrayList(java.util.ArrayList) DOI(org.globalbioticinteractions.doi.DOI) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TermLookupServiceException(org.eol.globi.service.TermLookupServiceException) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) DatasetNode(org.eol.globi.domain.DatasetNode) NodeBacked(org.eol.globi.domain.NodeBacked) Iterator(java.util.Iterator) Assert.assertNotNull(org.junit.Assert.assertNotNull) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) IOException(java.io.IOException) StudyNode(org.eol.globi.domain.StudyNode) Relationship(org.neo4j.graphdb.Relationship) Dataset(org.globalbioticinteractions.dataset.Dataset) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) Interaction(org.eol.globi.domain.Interaction) TaxonNode(org.eol.globi.domain.TaxonNode) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) DOI(org.globalbioticinteractions.doi.DOI) StudyNode(org.eol.globi.domain.StudyNode) Test(org.junit.Test)

Example 58 with DatasetImpl

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"));
}
Also used : DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Assert.assertNotNull(org.junit.Assert.assertNotNull) Test(org.junit.Test) URI(java.net.URI) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Test(org.junit.Test)

Example 59 with DatasetImpl

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));
}
Also used : CacheService(org.eol.globi.service.CacheService) IndexHits(org.neo4j.graphdb.index.IndexHits) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Specimen(org.eol.globi.domain.Specimen) StudyConstant(org.eol.globi.domain.StudyConstant) Test(org.junit.Test) IOException(java.io.IOException) StudyImpl(org.eol.globi.domain.StudyImpl) Node(org.neo4j.graphdb.Node) Rule(org.junit.Rule) TaxonImpl(org.eol.globi.domain.TaxonImpl) QueryParser(org.apache.lucene.queryparser.classic.QueryParser) NodeFactoryException(org.eol.globi.data.NodeFactoryException) Dataset(org.globalbioticinteractions.dataset.Dataset) PropertyAndValueDictionary(org.eol.globi.domain.PropertyAndValueDictionary) Is.is(org.hamcrest.core.Is.is) URI(java.net.URI) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) GraphDBTestCase(org.eol.globi.data.GraphDBTestCase) Study(org.eol.globi.domain.Study) TemporaryFolder(org.junit.rules.TemporaryFolder) Before(org.junit.Before) Dataset(org.globalbioticinteractions.dataset.Dataset) Node(org.neo4j.graphdb.Node) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Test(org.junit.Test)

Example 60 with DatasetImpl

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));
}
Also used : CacheService(org.eol.globi.service.CacheService) IndexHits(org.neo4j.graphdb.index.IndexHits) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Specimen(org.eol.globi.domain.Specimen) StudyConstant(org.eol.globi.domain.StudyConstant) Test(org.junit.Test) IOException(java.io.IOException) StudyImpl(org.eol.globi.domain.StudyImpl) Node(org.neo4j.graphdb.Node) Rule(org.junit.Rule) TaxonImpl(org.eol.globi.domain.TaxonImpl) QueryParser(org.apache.lucene.queryparser.classic.QueryParser) NodeFactoryException(org.eol.globi.data.NodeFactoryException) Dataset(org.globalbioticinteractions.dataset.Dataset) PropertyAndValueDictionary(org.eol.globi.domain.PropertyAndValueDictionary) Is.is(org.hamcrest.core.Is.is) URI(java.net.URI) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) GraphDBTestCase(org.eol.globi.data.GraphDBTestCase) Study(org.eol.globi.domain.Study) TemporaryFolder(org.junit.rules.TemporaryFolder) Before(org.junit.Before) Dataset(org.globalbioticinteractions.dataset.Dataset) Node(org.neo4j.graphdb.Node) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Test(org.junit.Test)

Aggregations

DatasetImpl (org.globalbioticinteractions.dataset.DatasetImpl)83 Test (org.junit.Test)73 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)50 URI (java.net.URI)32 JsonNode (com.fasterxml.jackson.databind.JsonNode)31 Dataset (org.globalbioticinteractions.dataset.Dataset)25 ArrayList (java.util.ArrayList)22 IOException (java.io.IOException)21 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)21 InteractionListener (org.eol.globi.process.InteractionListener)19 URL (java.net.URL)18 Map (java.util.Map)17 StudyNode (org.eol.globi.domain.StudyNode)17 HashMap (java.util.HashMap)16 Is.is (org.hamcrest.core.Is.is)16 List (java.util.List)15 StudyImpl (org.eol.globi.domain.StudyImpl)15 StringUtils (org.apache.commons.lang3.StringUtils)14 CoreMatchers.nullValue (org.hamcrest.CoreMatchers.nullValue)14 Is (org.hamcrest.core.Is)14