Search in sources :

Example 96 with Study

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

the class StudyImporterForBascompteIT method importAll.

@Test
public void importAll() throws StudyImporterException, IOException {
    StudyImporterForWebOfLife importer = new StudyImporterForWebOfLife(null, nodeFactory);
    importStudy(importer);
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    List<String> references = new ArrayList<String>();
    Set<String> referenceSet = new HashSet<String>();
    for (Study allStudy : allStudies) {
        assertThat(allStudy.getSource(), startsWith("Web of Life. Accessed at http://www.web-of-life.es/"));
        references.add(allStudy.getCitation());
        referenceSet.add(allStudy.getCitation());
    }
    assertThat(references.size(), is(referenceSet.size()));
    assertThat(references, hasItem("Arroyo, M.T.K., R. Primack & J.J. Armesto. 1982. Community studies in pollination ecology in the high temperate Andes of central Chile. I. Pollination mechanisms and altitudinal variation. Amer. J. Bot. 69:82-97."));
    assertThat(taxonIndex.findTaxonByName("Diplopterys pubipetala"), is(notNullValue()));
}
Also used : Study(org.eol.globi.domain.Study) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 97 with Study

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

the class StudyImporterForBellTest method importAll.

@Test
public void importAll() throws StudyImporterException, NodeFactoryException {
    StudyImporter importer = new StudyImporterForBell(new ParserFactoryLocal(), nodeFactory);
    importStudy(importer);
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    assertThat(allStudies.size(), is(6));
    for (Study study : allStudies) {
        assertThat(study.getSource(), is("Bell, K. C., Matek, D., Demboski, J. R., & Cook, J. A. (2015). Expanded Host Range of Sucking Lice and Pinworms of Western North American Chipmunks. Comparative Parasitology, 82(2), 312–321. doi:10.1654/4756.1 . Data provided by Kayce C. Bell."));
        assertThat(study.getDOI(), is("http://dx.doi.org/10.1654/4756.1"));
        assertThat(study.getCitation(), startsWith("Bell, K. C., Matek, D., Demboski, J. R., & Cook, J. A. (2015). Expanded Host Range of Sucking Lice and Pinworms of Western North American Chipmunks. Comparative Parasitology, 82(2), 312–321. doi:10.1654/4756.1 . Data provided by Kayce C. Bell."));
    }
    ExecutionResult execute = new ExecutionEngine(getGraphDb()).execute("START taxon = node:taxons('*:*') RETURN taxon.name");
    String actual = execute.dumpToString();
    assertThat(actual, containsString("Tamias"));
    assertThat(taxonIndex.findTaxonByName("Tamias speciosus"), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Hoplopleura arboricola"), is(notNullValue()));
    assertThat(nodeFactory.findStudy("bell-"), is(notNullValue()));
}
Also used : Study(org.eol.globi.domain.Study) ExecutionEngine(org.neo4j.cypher.javacompat.ExecutionEngine) ExecutionResult(org.neo4j.cypher.javacompat.ExecutionResult) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) Test(org.junit.Test)

Example 98 with Study

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

the class StudyImporterForAkinTest method importHeaderAndASingleSpecimen.

@Test
public void importHeaderAndASingleSpecimen() throws StudyImporterException, ParseException {
    String csvString = ",\"Fish No\",\"Fish Species\",\"Date \",,\"Site \",\"SL(mm)\",\"Stomach volume\",\"Stomach status\",\"C. Method\",\"Detritus\",\"Sand\",\"Diatoms\",\"Centric diatoms\",\"Pennate diatoms\",\"Oscillatoria \",\"Filamentous algae\",\"Green algae\",\"Other blue green algae\",\"Unicellular green algae\",\"Brown algae\",\"Golden brown algae\",\"Nostocales (Blue green algae)\",\"Chara\",\"Ruppia maritima\",\"Other macrophytes\",\"Seeds\",\"Invertebrate eggs \",\"Fish bones\",\"Lucania parva eggs\",\"Other fish eggs\",\"Catfish egg\",\"Unidentified bone\",\"Fish eyes\",\"Fish otolith\",\"Ctenoid fish scale\",\"Cycloid fish scale\",\"Dinoflagellates (Noctiluca spp.)\",\"Protozoa\",\"Bivalvia\",\"Gastropoda\",\"Nematode\",\"Nemotode(Parasite)\",\"Calanoida copepoda\",\"Harpacticoida copepoda\",\"Copepoda nauplii\",\"Cyclopoid copepoda\",\"Cladocera\",\"Rotifera\",\"Unidefined zooplankton\",\"Chironomidae larvae\",\"Diptera 1\",\"Diptera 2\",\"Diptera midges(pupa)\",\"Polycheate worm\",\"Other annelid worms\",\"Amphipoda(Gammarus spp.)\",\"Corophium sp(amphipoda)\",\"Decopoda larvae\",\"Isopoda\",\"Unidentified invertebrate\",\"Other Ephemeroptera(Mayfly)\",\"Ephemeroptera(Baetidae)\",\"Coleoptera\",\"Other Hymenoptera\",\"Odonate\",\"Damselfly\",\"Other Thrips\",\"Thysanoptera (thrips)\",\"Pteromalitidae(Hymenoptera)\",\"Hemiptera\",\"Homoptera\",\"Unidentified insect larvae\",\"Arachnida \",\"Unidentified insects\",\"Mollusks (Oyster)\",\"Other Mollusks\",\"Ostracoda\",\"Brachyura (Crab zoea)\",\"Mysidacea\",\"Penneid shrimp post larvae\",\"Unidentified shrimp\",\"Palaemonotes pugio\",\"Peneaus setiferus\",\"Peneaus aztecus\",\"Callinectes sapidus\",\"Other crabs\",\"Neopunope sayi(mud crab)\",\"Myrophis punctatus (speckled worm eel)\",\"Mugil cephalus\",\"Brevoortia patronus\",\"Lepisosteus osseus \",\"Fundulus  grandis\",\"Other fundulus species\",\"Cyprinodon variegatus\",\"Pogonias cromis\",\"Menidia beryllina\",\"Anchoa mitchilli\",\"Other Sciaenidae species\",\"Lagodon rhomboides\",\"Arius felis\",\"Leiostomus xanthurus\",\"Gobiosoma bosc\",\"Lucania parva\",\"Micropogonias undulatus\",\"Cynoscion nebulosus\",\"Poecilia latipinna\",\"Unidentified fish\",\"Unidentified fish larvae\",\"Other Gobiidae \",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\n" + ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\n" + ",1,\"Pogonias cromis\",\"03.07.98\",,1,226,3,,\"Gillnet\",,0.15,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.6,,,,,,0.45,,,,,,,,,,,,,,,,,,1.35,0.45,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,";
    StudyImporter importer = new StudyImporterTestFactory(new TestParserFactory(csvString), nodeFactory).instantiateImporter((Class) StudyImporterForAkin.class);
    importStudy(importer);
    Study study = getStudySingleton(getGraphDb());
    Taxon taxon = taxonIndex.findTaxonByName("Pogonias cromis");
    assertNotNull(taxon);
    Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
    Relationship rel = specimens.iterator().next();
    assertThat(rel, is(not(nullValue())));
    Date expectedDate = DateUtil.parsePatternUTC("1998-03-07", "yyyy-MM-dd").toDate();
    assertThat(rel.getProperty(SpecimenConstant.DATE_IN_UNIX_EPOCH), is(expectedDate.getTime()));
    Node specimenNode = rel.getEndNode();
    assertThat(specimenNode.getProperty(SpecimenConstant.LENGTH_IN_MM), is(226.0));
    assertThat(specimenNode.getProperty(SpecimenConstant.STOMACH_VOLUME_ML), is(3.0));
    Specimen specimen = new SpecimenNode(specimenNode);
    assertThat(specimen.getSampleLocation().getAltitude(), is(-0.7));
    Node speciesNode = specimenNode.getSingleRelationship(NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS), Direction.OUTGOING).getEndNode();
    assertThat((String) speciesNode.getProperty("name"), is("Pogonias cromis"));
    Iterable<Relationship> ateRels = specimenNode.getRelationships(NodeUtil.asNeo4j(InteractType.ATE), Direction.OUTGOING);
    Map<String, Map<String, Object>> preys = new HashMap<String, Map<String, Object>>();
    for (Relationship ateRel : ateRels) {
        Node preyNode = ateRel.getEndNode();
        Node taxonNode = preyNode.getSingleRelationship(NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS), Direction.OUTGOING).getEndNode();
        String name = (String) taxonNode.getProperty("name");
        HashMap<String, Object> propertyMap = new HashMap<String, Object>();
        propertyMap.put("name", name);
        propertyMap.put(SpecimenConstant.VOLUME_IN_ML, preyNode.getProperty(SpecimenConstant.VOLUME_IN_ML));
        preys.put(name, propertyMap);
    }
    Map<String, Object> sand = preys.get("Sand");
    assertThat(sand, is(notNullValue()));
    assertThat((String) sand.get("name"), is("Sand"));
    assertThat((Double) sand.get(SpecimenConstant.VOLUME_IN_ML), is(0.15d));
    Map<String, Object> chironomidae = preys.get("Chironomidae larvae");
    assertThat(chironomidae, is(notNullValue()));
    assertThat((String) chironomidae.get("name"), is("Chironomidae larvae"));
    assertThat((Double) chironomidae.get(SpecimenConstant.VOLUME_IN_ML), is(0.6d));
    Map<String, Object> amphipoda = preys.get("Amphipoda(Gammarus spp.)");
    assertThat(amphipoda, is(notNullValue()));
    assertThat((String) amphipoda.get("name"), is("Amphipoda(Gammarus spp.)"));
    assertThat((Double) amphipoda.get(SpecimenConstant.VOLUME_IN_ML), is(0.45d));
    Map<String, Object> insecta = preys.get("Unidentified insects");
    assertThat(insecta, is(notNullValue()));
    assertThat((String) insecta.get("name"), is("Unidentified insects"));
    assertThat((Double) insecta.get(SpecimenConstant.VOLUME_IN_ML), is(1.35d));
    Map<String, Object> mollusca = preys.get("Mollusks (Oyster)");
    assertThat(mollusca, is(notNullValue()));
    assertThat((String) mollusca.get("name"), is("Mollusks (Oyster)"));
    assertThat((Double) mollusca.get(SpecimenConstant.VOLUME_IN_ML), is(0.45d));
    Node locationNode = specimenNode.getSingleRelationship(NodeUtil.asNeo4j(RelTypes.COLLECTED_AT), Direction.OUTGOING).getEndNode();
    assertThat((Double) locationNode.getProperty(LocationConstant.LATITUDE), is(28.645202d));
    assertThat((Double) locationNode.getProperty(LocationConstant.LONGITUDE), is(-96.099923d));
}
Also used : Study(org.eol.globi.domain.Study) HashMap(java.util.HashMap) Taxon(org.eol.globi.domain.Taxon) Node(org.neo4j.graphdb.Node) SpecimenNode(org.eol.globi.domain.SpecimenNode) SpecimenNode(org.eol.globi.domain.SpecimenNode) Date(java.util.Date) Specimen(org.eol.globi.domain.Specimen) Relationship(org.neo4j.graphdb.Relationship) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 99 with Study

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

the class StudyImporterForBaremoreTest method importAll.

@Test
public void importAll() throws StudyImporterException, NodeFactoryException {
    StudyImporterForBaremore studyImporter = new StudyImporterForBaremore(new ParserFactoryLocal(), nodeFactory);
    importStudy(studyImporter);
    Study study = getStudySingleton(getGraphDb());
    assertNotNull(taxonIndex.findTaxonByName("Squatina dumeril"));
    Iterable<Relationship> collectedRels = NodeUtil.getSpecimens(study);
    int totalRels = validateSpecimen(collectedRels);
    assertThat(totalRels, Is.is(1450));
}
Also used : Study(org.eol.globi.domain.Study) Relationship(org.neo4j.graphdb.Relationship) Test(org.junit.Test)

Example 100 with Study

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

the class StudyImporterForBlewettTest method importLines.

@Test
public void importLines() throws StudyImporterException, NodeFactoryException {
    String predatorPreyMapping = "\"Collection #\",\"Sp#\",\"Standard Length\",\"ID\",\"Far duoraum\",\"Cal sapidus\",\"Unid fish\",\"Anchoa spp\",\"Mug gyrans\",\"Bai chrysoura\",\"Portunus spp\",\"Bivalves\",\"Portunidae\",\"Lag rhomboides\",\"Xanthidae\",\"Palaemonidae\",\"Eucinostomus spp\",\"Mugil spp\",\"Alpheidae\",\"Atherinidae\",\"Syn foetens\",\"Ort chrysoptera\",\"Snails\",\"Euc gula\",\"Cynoscion spp\",\"Cyp. Variegatus\",\"Fun majalis\",\"Poe latipinna\",\"Unid crab\",\"Har jaguana\",\"Arm mierii\",\"Fun grandis\",\"Mic gulosus\",\"Ari felis\",\"Clupeidae\",\"Fundulus spp\",\"Diapterus/Eugerres spp\",\"Isopods\",\"Cyn nebulosus\",\"Opi oglinum\",\"Flo carpio\",\"Luc parva\",\"Uca spp\",\"Majidae\",\"Mug cephalus\",\"Squ empusa\",\"Opi robinsi\",\"Ariidae\",\"Sci ocellatus\",\"Unid shrimp\",\"Uca thayeri\",\"Grapsidae\",\"Lei xanthurus\",\"Elo saurus\",\"Brevoortia spp\"\n" + "\"CHD01101502\",1,549,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\n" + "\"CHD01102504\",1,548,\"E\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\n" + "\"CHD01102504\",2,550,,3,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\n" + "\"CHM000152\",1,580,\"E\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\n" + "\"CHM000152\",2,556,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,";
    String dateLocationString = "\"Collection #\",\"Longitude\",\"Latitude\",\"Time\",\"Date\",\"Temperature\",\"Salinity\"\n" + "\"CHD01101502\",-82.1625,26.72,10:55:00,1-Mar-00,22.4,33.8\n" + "\"CHD01102504\",-82.1625,26.72,10:55:00,1-Mar-00,22.4,33.8\n" + "\"CHM000151\",-82.1625,26.72,10:55:00,1-Mar-00,22.4,33.8\n" + "\"CHM000152\",-82.103833,26.651833,12:40:00,1-Mar-00,24.8,30.3\n" + "\"CHM000153\",-82.087333,26.644833,13:40:00,1-Mar-00,25.1,30.1\n" + "\"CHM000154\",-82.083167,26.671167,14:40:00,1-Mar-00,26,30.4\n" + "\"CHM000175\",-82.197833,26.688167,10:00:00,8-Mar-00,22.2,35.05\n" + "\"CHM000176\",-82.191333,26.667333,11:00:00,8-Mar-00,22.7,35.25";
    final TestParserFactory preyPredatorFactory = new TestParserFactory(predatorPreyMapping);
    final TestParserFactory dateLocationFactory = new TestParserFactory(dateLocationString);
    ParserFactory testFactory = new ParserFactory() {

        @Override
        public LabeledCSVParser createParser(String studyResource, String characterEncoding) throws IOException {
            LabeledCSVParser parser = null;
            if (studyResource.contains("abundance")) {
                parser = preyPredatorFactory.createParser(studyResource, characterEncoding);
            } else {
                parser = dateLocationFactory.createParser(studyResource, characterEncoding);
            }
            return parser;
        }
    };
    StudyImporter importer = new StudyImporterTestFactory(testFactory, nodeFactory).instantiateImporter((Class) StudyImporterForBlewett.class);
    importStudy(importer);
    Study study = getStudySingleton(getGraphDb());
    Iterable<Relationship> collectedRels = NodeUtil.getSpecimens(study);
    Relationship collectedRel = collectedRels.iterator().next();
    Date unixEpochProperty = nodeFactory.getUnixEpochProperty(new SpecimenNode(collectedRel.getEndNode()));
    assertThat(unixEpochProperty, is(not(nullValue())));
    assertThat(dateToString(unixEpochProperty), is("2000-03-01T10:55:00.000-06:00"));
    Node predatorNode = collectedRel.getEndNode();
    assertThat((String) predatorNode.getProperty(SpecimenConstant.LIFE_STAGE_LABEL), is("post-juvenile adult stage"));
    assertThat((String) predatorNode.getProperty(SpecimenConstant.LIFE_STAGE_ID), is("UBERON:0000113"));
    assertThat((Double) predatorNode.getProperty(SpecimenConstant.LENGTH_IN_MM), is(549.0));
    Node predatorTaxonNode = predatorNode.getRelationships(NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS), Direction.OUTGOING).iterator().next().getEndNode();
    assertThat((String) predatorTaxonNode.getProperty(PropertyAndValueDictionary.NAME), is("Centropomus undecimalis"));
    Iterable<Relationship> ate = predatorNode.getRelationships(NodeUtil.asNeo4j(InteractType.ATE), Direction.OUTGOING);
    Node preyNode = ate.iterator().next().getEndNode();
    assertThat(preyNode, is(not(nullValue())));
    Node taxonNode = preyNode.getRelationships(NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS), Direction.OUTGOING).iterator().next().getEndNode();
    assertThat(taxonNode, is(not(nullValue())));
    assertThat((String) taxonNode.getProperty(PropertyAndValueDictionary.NAME), is("Lag rhomboides"));
    Iterator<Relationship> i = collectedRels.iterator();
    i.next();
    collectedRel = i.next();
    predatorNode = collectedRel.getEndNode();
    assertThat((Double) predatorNode.getProperty(SpecimenConstant.LENGTH_IN_MM), is(548.0));
    ate = predatorNode.getRelationships(NodeUtil.asNeo4j(InteractType.ATE), Direction.OUTGOING);
    assertThat(ate.iterator().hasNext(), is(false));
    Location location = nodeFactory.findLocation(new LocationImpl(26.651833, -82.103833, 0.0, null));
    assertThat(location, is(not(nullValue())));
    Iterable<Relationship> specimenCaughtHere = NodeUtil.getSpecimenCaughtHere(location);
    Iterator<Relationship> iterator = specimenCaughtHere.iterator();
    assertThat(iterator.hasNext(), is(true));
    iterator.next();
    assertThat(iterator.hasNext(), is(true));
    iterator.next();
    assertThat(iterator.hasNext(), is(true));
    iterator.next();
    assertThat(iterator.hasNext(), is(false));
}
Also used : Study(org.eol.globi.domain.Study) Node(org.neo4j.graphdb.Node) SpecimenNode(org.eol.globi.domain.SpecimenNode) LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) SpecimenNode(org.eol.globi.domain.SpecimenNode) Date(java.util.Date) Relationship(org.neo4j.graphdb.Relationship) LocationImpl(org.eol.globi.domain.LocationImpl) Location(org.eol.globi.domain.Location) 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