Search in sources :

Example 41 with DatasetImpl

use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.

the class DatasetImporterForTSVTest 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";
    DatasetImpl dataset = getDataset(new TreeMap<URI, String>() {

        {
            put(URI.create("/interactions.tsv"), minimalLines);
        }
    });
    DatasetImporterForTSV importer = new DatasetImporterForTSV(null, nodeFactory);
    importer.setDataset(dataset);
    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");
}
Also used : Taxon(org.eol.globi.domain.Taxon) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) URI(java.net.URI) Test(org.junit.Test)

Example 42 with DatasetImpl

use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.

the class DatasetImporterForTSVTest method importFewLinesCSVAndTSV.

@Test
public void importFewLinesCSVAndTSV() throws StudyImporterException {
    DatasetImpl dataset = getDataset(new TreeMap<URI, String>() {

        {
            put(URI.create("/interactions.tsv"), firstFewLinesTSV);
            put(URI.create("/interactions.csv"), firstFewLinesCSV);
        }
    });
    DatasetImporterForTSV importer = new DatasetImporterForTSV(null, nodeFactory);
    importer.setDataset(dataset);
    importStudy(importer);
    assertExists("Leptoconchus incycloseris");
    assertExists("TESTLeptoconchus incycloseris");
    assertExists("Sandalolitha dentata");
    assertStudyTitles("someRepodoi:10.1007/s13127-011-0039-1");
}
Also used : DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) URI(java.net.URI) Test(org.junit.Test)

Example 43 with DatasetImpl

use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.

the class DatasetImporterForTSVTest method assertArgumentType.

private void assertArgumentType(String firstFewLines, final RelTypes argumentType) throws StudyImporterException {
    DatasetImpl dataset = getDataset(new TreeMap<URI, String>() {

        {
            put(URI.create("/interactions.tsv"), firstFewLines);
        }
    });
    DatasetImporterForTSV importer = new DatasetImporterForTSV(null, nodeFactory);
    importer.setDataset(dataset);
    importStudy(importer);
    final AtomicBoolean foundStudy = new AtomicBoolean(false);
    NodeUtil.findStudies(getGraphDb(), new NodeListener() {

        @Override
        public void on(Node node) {
            assertTrue(node.hasRelationship(Direction.OUTGOING, NodeUtil.asNeo4j(argumentType)));
            foundStudy.set(true);
        }
    });
    assertThat(foundStudy.get(), is(true));
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) NodeListener(org.eol.globi.util.NodeListener) Node(org.neo4j.graphdb.Node) StudyNode(org.eol.globi.domain.StudyNode) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) URI(java.net.URI)

Example 44 with DatasetImpl

use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.

the class DatasetImporterForPlanqueIT method importAll.

@Test
public void importAll() throws StudyImporterException, IOException {
    final List<String> errorMessages = new ArrayList<String>();
    BaseDatasetImporter importer = new DatasetImporterForPlanque(new ParserFactoryLocal(), nodeFactory);
    JsonNode config = new ObjectMapper().readTree("{ \"citation\": \"Benjamin Planque, Raul Primicerio, Kathrine Michalsen, Michaela Aschan, Grégoire Certain, Padmini Dalpadado, Harald Gjøsæater, Cecilie Hansen, Edda Johannesen, Lis Lindal Jørgensen, Ina Kolsum, Susanne Kortsch, Lise-Marie Leclerc, Lena Omli, Mette Skern-Mauritzen, and Magnus Wiedmann 2014. Who eats whom in the Barents Sea: a food web topology from plankton to whales. Ecology 95:1430–1430. https://doi.org/10.1890/13-1062.1\",\n" + "  \"doi\": \"https://doi.org/10.1890/13-1062.1\",\n" + "  \"format\": \"planque\",\n" + "  \"resources\": {\n" + "    \"links\": \"http://www.esapubs.org/archive/ecol/E095/124/revised/PairwiseList.txt\",\n" + "    \"references\": \"http://www.esapubs.org/archive/ecol/E095/124/revised/References.txt\",\n" + "    \"referencesForLinks\": \"http://www.esapubs.org/archive/ecol/E095/124/revised/PairWise2References.txt\"\n" + "  }\n" + "}");
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"), inStream -> inStream);
    dataset.setConfig(config);
    importer.setDataset(dataset);
    importer.setLogger(new NullImportLogger() {

        @Override
        public void warn(LogContext ctx, String message) {
            errorMessages.add(message);
        }
    });
    importStudy(importer);
    int interactionCount = 0;
    List<StudyNode> studies = NodeUtil.findAllStudies(getGraphDb());
    for (StudyNode study : studies) {
        interactionCount += getSpecimenCount(study);
    }
    assertThat(interactionCount, is(4900));
    int uniqueReference = 236;
    // note that the +1 is for all links that had no reference associated to it
    assertThat(studies.size(), is(uniqueReference + 1));
    assertThat(taxonIndex.findTaxonByName("Trisopterus esmarkii"), is(notNullValue()));
    assertThat(errorMessages.size(), is(0));
}
Also used : NullImportLogger(org.eol.globi.tool.NullImportLogger) ArrayList(java.util.ArrayList) LogContext(org.eol.globi.domain.LogContext) JsonNode(com.fasterxml.jackson.databind.JsonNode) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) StudyNode(org.eol.globi.domain.StudyNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 45 with DatasetImpl

use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.

the class DatasetImporterForJSONLDTest method importStaticInvalid.

@Test(expected = StudyImporterException.class)
public void importStaticInvalid() throws StudyImporterException, URISyntaxException {
    DatasetImporter importer = new DatasetImporterForJSONLD(null, nodeFactory);
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"), inStream -> inStream);
    dataset.setConfigURI(URI.create("classpath:/org/eol/globi/data/globi-jsonld/globi-dataset.jsonld.invalid"));
    importer.setDataset(dataset);
    importStudy(importer);
}
Also used : 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