Search in sources :

Example 61 with Study

use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.

the class InteractionListenerImplTest method importAssociatedTaxa.

@Test
public void importAssociatedTaxa() throws StudyImporterException {
    final InteractionListenerImpl listener = new InteractionListenerImpl(nodeFactory, null, new ImportLogger() {

        @Override
        public void warn(LogContext study, String message) {
            fail("got message: " + message);
        }

        @Override
        public void info(LogContext study, String message) {
        }

        @Override
        public void severe(LogContext study, String message) {
            fail("got message: " + message);
        }
    });
    final HashMap<String, String> link = new HashMap<>();
    link.put(SOURCE_TAXON_NAME, "donald");
    link.put(SOURCE_TAXON_ID, "duck");
    link.put(SOURCE_BODY_PART_ID, "bla:123");
    link.put(SOURCE_BODY_PART_NAME, "snout");
    link.put("associatedTaxa", "parasite of: Mini mouse");
    link.put(StudyImporterForMetaTable.EVENT_DATE, "20160404T21:31:40Z");
    link.put(StudyImporterForMetaTable.LATITUDE, "12.1");
    link.put(StudyImporterForMetaTable.LONGITUDE, "13.2");
    link.put(REFERENCE_ID, "123");
    link.put(STUDY_SOURCE_CITATION, "some source ref");
    link.put(REFERENCE_CITATION, "");
    link.put(REFERENCE_DOI, "doi:1234");
    listener.newLink(link);
    final List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    assertThat(allStudies.size(), is(1));
    final Study study = allStudies.get(0);
    assertThat(study.getCitation(), is(""));
    boolean foundPair = false;
    for (Relationship specimenRel : NodeUtil.getSpecimens(study)) {
        final SpecimenNode predator = new SpecimenNode(specimenRel.getEndNode());
        for (Relationship hosts : ((NodeBacked) predator).getUnderlyingNode().getRelationships(NodeUtil.asNeo4j(InteractType.PARASITE_OF), Direction.OUTGOING)) {
            final SpecimenNode host = new SpecimenNode(hosts.getEndNode());
            final TaxonNode hostTaxon = getOrigTaxon(host);
            final TaxonNode predTaxon = getOrigTaxon(predator);
            assertThat(hostTaxon.getName(), is("Mini mouse"));
            assertThat(predTaxon.getName(), is("donald"));
            assertThat(predTaxon.getExternalId(), is("duck"));
            foundPair = true;
        }
    }
    assertThat(foundPair, is(true));
}
Also used : Study(org.eol.globi.domain.Study) TaxonNode(org.eol.globi.domain.TaxonNode) HashMap(java.util.HashMap) LogContext(org.eol.globi.domain.LogContext) SpecimenNode(org.eol.globi.domain.SpecimenNode) Relationship(org.neo4j.graphdb.Relationship) Test(org.junit.Test)

Example 62 with Study

use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.

the class NodeFactoryIT method createLogMessage.

@Test
public void createLogMessage() throws NodeFactoryException {
    Study bla = nodeFactory.createStudy(new StudyImpl("bla", null, null, null));
    bla.appendLogMessage("one two three", Level.INFO);
    List<LogMessage> logMessages = bla.getLogMessages();
    assertThat(logMessages.size(), is(1));
    assertThat(logMessages.get(0).getMessage(), is("one two three"));
    assertThat(logMessages.get(0).getLevel(), is("INFO"));
}
Also used : Study(org.eol.globi.domain.Study) LogMessage(org.eol.globi.domain.LogMessage) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 63 with Study

use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.

the class StudyImporterForRoopnarineTest method importLine.

@Test
public void importLine() throws StudyImporterException, NodeFactoryException {
    // note that this test data is a modified version of the actual data - please don't use this data for actual analysis purposes
    final String trophicGuildsToSpeciesLookup = "\"Guild Number\",\"Taxa\",\"Fish Body Length\",\"Cayman Islands\",\"Cuba\",\"Jamaica\"\n" + "1,\"something something\",,,,\n" + "2,\"Skeletonema tropicum        \",,,,\n" + "3,\"Something else        \",,,,\n" + "11,\" Epinephelus striatus          \",122,\"x \",\"x\",\"x\"\n" + "12,\" Negaprion brevirostris        \",240,\"x \",\" \",\" \"\n" + "13,\" Carcharhinus perezi           \",300,\"x \",\"x\",\"x\"\n" + "14,\" Rhizoprionodon porosus        \",75,\"x \",\"x\",\" \"\n" + "14,\" Sphyrna tiburo                \",80,\"x \",\" \",\" \"\n" + "14,\" Galeocerdo cuvieri            \",500,\"  \",,";
    final String trophicInteractions = "\"Guild Number\",\"Guild Description\",\"Foraging Habitat\",\"Number of Prey\",\"Prey\"\n" + "1,\"Planktonic bacteria   \",\".\",0,\".\"\n" + "2,\"Phytoplankton         \",\".\",0,\".\"\n" + "3,\"Nanno-zooplankton     \",\".\",30,\"1, 2\"\n" + "4,\"Filamentous macroalgae\",\".\",0,\".\"\n" + "5,\"Sheet macroalgae      \",\".\",0,\".\"\n" + "6,\"Coarsely branched macroalgae                 \",\".\",0,\".\"\n" + "7,\"Jointed calcareous macroalgae                \",\".\",0,\".\"\n" + "8,\"Thick leathery macroalgae                    \",\".\",0,\".\"\n" + "9,\"Crustose coralline algae                     \",\".\",0,\".\"\n" + "10,\"Seagrasses            \",\".\",0,\".\"\n" + "11,\"Epibenthic sponges    \",\".\",30,\"1,  2\"\n" + "12,\"Endolithic sponges    \",\".\",30,\"1,   2\"\n" + "13,\"Ahermatypic benthic corals\",\".\",35,\"1\"\n" + "14,\"Hermatypic corals\",\".\",36,\"2\"";
    StudyImporterForRoopnarine importer = new StudyImporterForRoopnarine(new ParserFactory() {

        @Override
        public LabeledCSVParser createParser(String studyResource, String characterEncoding) throws IOException {
            ParserFactory factory;
            if (studyResource.contains("4.csv")) {
                factory = new TestParserFactory(trophicGuildsToSpeciesLookup);
            } else {
                factory = new TestParserFactory(trophicInteractions);
            }
            return factory.createParser("", characterEncoding);
        }
    }, nodeFactory);
    importStudy(importer);
    Study study = getStudySingleton(getGraphDb());
    assertNotNull(taxonIndex.findTaxonByName("Negaprion brevirostris"));
    assertNotNull(taxonIndex.findTaxonByName("Carcharhinus perezi"));
    assertNotNull(taxonIndex.findTaxonByName("Galeocerdo cuvieri"));
    Iterable<Relationship> collectedRels = NodeUtil.getSpecimens(study);
    int totalRels = validateSpecimen(collectedRels);
    assertThat(totalRels, Is.is(51));
}
Also used : Study(org.eol.globi.domain.Study) Relationship(org.neo4j.graphdb.Relationship) IOException(java.io.IOException) LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) Test(org.junit.Test)

Example 64 with Study

use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.

the class StudyImporterForRoopnarineTest method importAll.

@Ignore("roopnarine imports eats more memory that other study imports")
@Test
public void importAll() throws StudyImporterException {
    StudyImporterForRoopnarine studyImporterFor = new StudyImporterForRoopnarine(new ParserFactoryLocal(), nodeFactory);
    studyImporterFor.importStudy();
    List<Study> studies = NodeUtil.findAllStudies(getGraphDb());
    assertThat(studies.size(), is(1));
    Study study = studies.get(0);
    Iterable<Relationship> collectedRels = NodeUtil.getSpecimens(study);
    int totalRels = validateSpecimen(collectedRels);
    assertThat(totalRels, Is.is(1939));
    assertNotNull(taxonIndex.findTaxonByName("Lestrigonus bengalensis"));
    assertNotNull(taxonIndex.findTaxonByName("Bracyscelus crusculum"));
}
Also used : Study(org.eol.globi.domain.Study) Relationship(org.neo4j.graphdb.Relationship) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 65 with Study

use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.

the class StudyImporterForSIADIT method importAll.

@Test
public void importAll() throws StudyImporterException {
    StudyImporterForSIAD importer = new StudyImporterForSIAD(new ParserFactoryLocal(), nodeFactory);
    importStudy(importer);
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    assertThat(allStudies.size() > 1, is(true));
    Taxon taxon = taxonIndex.findTaxonByName("Anisakis");
    assertThat(taxon, is(notNullValue()));
    taxon = taxonIndex.findTaxonByName("Abbreviata");
    assertThat(taxon, is(notNullValue()));
}
Also used : Study(org.eol.globi.domain.Study) Taxon(org.eol.globi.domain.Taxon) Test(org.junit.Test)

Aggregations

Study (org.eol.globi.domain.Study)141 Test (org.junit.Test)84 StudyImpl (org.eol.globi.domain.StudyImpl)61 Specimen (org.eol.globi.domain.Specimen)38 Relationship (org.neo4j.graphdb.Relationship)33 TaxonImpl (org.eol.globi.domain.TaxonImpl)32 IOException (java.io.IOException)30 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)24 Location (org.eol.globi.domain.Location)24 StringWriter (java.io.StringWriter)21 LocationImpl (org.eol.globi.domain.LocationImpl)20 ArrayList (java.util.ArrayList)17 HashMap (java.util.HashMap)16 Taxon (org.eol.globi.domain.Taxon)16 SpecimenNode (org.eol.globi.domain.SpecimenNode)14 Date (java.util.Date)13 DatasetImpl (org.eol.globi.service.DatasetImpl)13 Node (org.neo4j.graphdb.Node)12 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)10 InteractType (org.eol.globi.domain.InteractType)9