Search in sources :

Example 1 with Environment

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

the class StudyImporterForGoMexSI2IT method assertThatSomeDataIsImported.

private static void assertThatSomeDataIsImported(NodeFactory nodeFactory, TaxonIndex taxonIndex) throws StudyImporterException, NodeFactoryException {
    Study study = nodeFactory.findStudy("Divita et al 1983");
    assertSpecimenProperties(((NodeBacked) study).getUnderlyingNode().getGraphDatabase());
    assertNotNull(study);
    assertThat(study.getTitle(), is("Divita et al 1983"));
    assertThat(study.getExternalId(), is(ExternalIdUtil.urlForExternalId("GAME:2689")));
    assertThat(study.getCitation(), is("Regina Divita, Mischelle Creel, Peter Sheridan. 1983. Foods of coastal fishes during brown shrimp Penaeus aztecus, migration from Texas estuaries (June - July 1981)."));
    assertNotNull(nodeFactory.findStudy("Beaumariage 1973"));
    assertNotNull(nodeFactory.findStudy("Baughman, 1943"));
    assertNotNull(taxonIndex.findTaxonByName("Chloroscombrus chrysurus"));
    assertNotNull(taxonIndex.findTaxonByName("Micropogonias undulatus"));
    assertNotNull(taxonIndex.findTaxonByName("Amphipoda"));
    assertNotNull(taxonIndex.findTaxonByName("Crustacea"));
    Taxon taxon = taxonIndex.findTaxonByName("Scomberomorus cavalla");
    List<String> preyList = new ArrayList<String>();
    final List<String> titles = new ArrayList<String>();
    Iterable<Relationship> classifiedAsRels = ((NodeBacked) taxon).getUnderlyingNode().getRelationships(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS));
    int count = 0;
    for (Relationship classifiedAsRel : classifiedAsRels) {
        Node predatorSpecimen = classifiedAsRel.getStartNode();
        Specimen predator = new SpecimenNode(predatorSpecimen);
        Iterable<Relationship> stomachContents = NodeUtil.getStomachContents(predator);
        for (Relationship prey : stomachContents) {
            Relationship singleRelationship = prey.getEndNode().getSingleRelationship(NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS), Direction.OUTGOING);
            preyList.add((String) singleRelationship.getEndNode().getProperty("name"));
        }
        count++;
        Relationship collectedBy = predatorSpecimen.getSingleRelationship(NodeUtil.asNeo4j(RelTypes.COLLECTED), Direction.INCOMING);
        assertThat(collectedBy, is(notNullValue()));
        String title = (String) collectedBy.getStartNode().getProperty("title");
        titles.add(title);
    }
    assertThat(count > 7, is(true));
    assertThat(preyList, hasItem("Organic matter"));
    assertThat(preyList, hasItem("Triglidae"));
    assertThat(preyList, hasItem("Sparidae"));
    assertThat(titles, hasItem("Beaumariage 1973"));
    assertThat(titles, hasItem("Blanton et al 1972"));
    assertNotNull(taxon);
    final String footprintWKT = WKT_FOOTPRINT2;
    LocationImpl expectedLocation = new LocationImpl(29.346953, -92.980614, -13.641, footprintWKT);
    expectedLocation.setLocality("Louisiana inner continental shelf");
    Location location = nodeFactory.findLocation(expectedLocation);
    assertThat(location, is(notNullValue()));
    assertThat(location.getFootprintWKT(), is(footprintWKT));
    assertThat(location.getLocality(), is("Louisiana inner continental shelf"));
    assertNotNull(location);
    List<Environment> environments = location.getEnvironments();
    assertThat(environments.size(), not(is(0)));
    assertThat(environments.get(0).getExternalId(), is("http://cmecscatalog.org/classification/aquaticSetting/13"));
    assertThat(environments.get(0).getName(), is("Marine Nearshore Subtidal"));
    assertNotNull(nodeFactory.findStudy("GoMexSI"));
}
Also used : Study(org.eol.globi.domain.Study) Taxon(org.eol.globi.domain.Taxon) JsonNode(org.codehaus.jackson.JsonNode) Node(org.neo4j.graphdb.Node) SpecimenNode(org.eol.globi.domain.SpecimenNode) ArrayList(java.util.ArrayList) SpecimenNode(org.eol.globi.domain.SpecimenNode) Specimen(org.eol.globi.domain.Specimen) NodeBacked(org.eol.globi.domain.NodeBacked) Relationship(org.neo4j.graphdb.Relationship) LocationImpl(org.eol.globi.domain.LocationImpl) Environment(org.eol.globi.domain.Environment) Location(org.eol.globi.domain.Location)

Example 2 with Environment

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

the class ExporterRDF method writeParticipantStatements.

public void writeParticipantStatements(Writer writer, Relationship ixnR, Node participant1) throws IOException {
    writeStatement(writer, Arrays.asList(blankNode(ixnR), iriNode(HAS_PARTICIPANT), blankNode(participant1)));
    writeStatement(writer, Arrays.asList(blankNode(participant1), iriNode(HAS_TYPE), iriNode(ORGANISM)));
    writeStatements(writer, taxonOfSpecimen(participant1));
    LocationNode location = new SpecimenNode(participant1).getSampleLocation();
    if (location != null) {
        for (Environment env : location.getEnvironments()) {
            String envoId = ExternalIdUtil.urlForExternalId(env.getExternalId());
            if (StringUtils.isNotBlank(envoId)) {
                writeStatement(writer, Arrays.asList(blankNode(participant1), iriNode(OCCURS_IN), iriNode(envoId)));
            }
        }
    }
}
Also used : LocationNode(org.eol.globi.domain.LocationNode) Environment(org.eol.globi.domain.Environment) SpecimenNode(org.eol.globi.domain.SpecimenNode)

Example 3 with Environment

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

the class StudyImporterForSPIRETest method assertSingleImport.

private void assertSingleImport(String spireHabitat, String envoId, String envoLabel) throws NodeFactoryException {
    StudyImporterForSPIRE studyImporterForSPIRE = createImporter();
    HashMap<String, String> properties = new HashMap<String, String>();
    properties.put(StudyConstant.TITLE, "the study of men eating dogs");
    properties.put(StudyImporterForSPIRE.PREY_NAME, "dog");
    properties.put(StudyImporterForSPIRE.PREDATOR_NAME, "man");
    properties.put(StudyImporterForSPIRE.LOCALITY_ORIGINAL, "something");
    properties.put(StudyImporterForSPIRE.OF_HABITAT, spireHabitat);
    studyImporterForSPIRE.importTrophicLink(properties);
    resolveNames();
    Taxon dog = taxonIndex.findTaxonByName("dog");
    assertThat(dog, is(notNullValue()));
    Taxon man = taxonIndex.findTaxonByName("man");
    assertThat(man, is(notNullValue()));
    Iterable<Relationship> specimenRels = ((NodeBacked) man).getUnderlyingNode().getRelationships(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS));
    int count = 0;
    for (Relationship specimenRel : specimenRels) {
        count++;
        Specimen specimen = new SpecimenNode(specimenRel.getStartNode());
        assertThat(specimen.getSampleLocation().getLatitude(), is(1.0));
        assertThat(specimen.getSampleLocation().getLongitude(), is(2.0));
        List<Environment> environments = specimen.getSampleLocation().getEnvironments();
        assertThat(environments.size(), is(1));
        Environment environment = environments.get(0);
        assertThat(environment.getExternalId(), is(envoId));
        assertThat(environment.getName(), is(envoLabel));
    }
    assertThat(count, is(1));
}
Also used : Specimen(org.eol.globi.domain.Specimen) HashMap(java.util.HashMap) Taxon(org.eol.globi.domain.Taxon) Relationship(org.neo4j.graphdb.Relationship) Environment(org.eol.globi.domain.Environment) SpecimenNode(org.eol.globi.domain.SpecimenNode)

Example 4 with Environment

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

the class StudyImporterForBroseTest method importHeadAndTail.

@Test
public void importHeadAndTail() throws IOException, StudyImporterException {
    final String headAndTail = "Link ID\tLink reference \tBody size reference\tGeographic location\tGeneral habitat\tSpecific habitat\tLink methodology\tBody size methodology\tTaxonomy consumer\tLifestage consumer\tCommon name(s) consumer\tMetabolic category consumer\tType of feeding interaction\tMinimum length (m) consumer\tMean length (m) consumer\tMaximum length (m) consumer\tMinimum mass (g) consumer\tMean mass (g) consumer\tMaximum mass (g) consumer\tTaxonomy resource\tLifestage - resource\tCommon name(s) resource\tMetabolic category resource\tMinimum length (m) resource\tMean length (m) resource\tMaximum length (m) resource\tMinimum mass (g) resource\tMean mass (g) resource\tMaximum mass (g) resource\tConsumer/resource body mass ratio\tNotes\n" + "1\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tBacteria\theterotrophic bacteria\therbivorous\t-999\t-999\t-999\t-999\t0.00000001\t-999\t-999\tadults\tPhytoplankton\tphoto-autotroph\t-999\t-999\t-999\t-999\t0.0001\t-999\t0.0001\t-999\n" + "2\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tBenthic carnivores\tinvertebrate\tpredacious\t-999\t-999\t-999\t-999\t10\t-999\t-999\tadults\tBenthic filter feeders\tinvertebrate\t-999\t-999\t-999\t-999\t10\t-999\t1\t-999\n" + "3\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMicrozooplankton\tinvertebrate\therbivorous\t-999\t-999\t-999\t-999\t0.0001\t-999\t-999\tadults\tPhytoplankton\tphoto-autotroph\t-999\t-999\t-999\t-999\t0.0001\t-999\t1\t-999\n" + "4\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMicrozooplankton\tinvertebrate\tbacterivorous\t-999\t-999\t-999\t-999\t0.0001\t-999\t-999\tadults\tBacteria\theterotrophic bacteria\t-999\t-999\t-999\t-999\t0.00000001\t-999\t10000\t-999\n" + "5\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMicrozooplankton\tinvertebrate\tpredacious\t-999\t-999\t-999\t-999\t0.0001\t-999\t-999\tadults\tMicrozooplankton\tinvertebrate\t-999\t-999\t-999\t-999\t0.0001\t-999\t1\t-999\n" + "6\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMesozooplankton\tinvertebrate\therbivorous\t-999\t-999\t-999\t-999\t0.01\t-999\t-999\tadults\tPhytoplankton\tphoto-autotroph\t-999\t-999\t-999\t-999\t0.0001\t-999\t100\t-999\n" + "7\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMesozooplankton\tinvertebrate\tpredacious\t-999\t-999\t-999\t-999\t0.01\t-999\t-999\tadults\tMicrozooplankton\tinvertebrate\t-999\t-999\t-999\t-999\t0.0001\t-999\t100\t-999\n" + "8\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMacrozooplankton\tinvertebrate\therbivorous\t-999\t-999\t-999\t-999\t1\t-999\t-999\tadults\tPhytoplankton\tphoto-autotroph\t-999\t-999\t-999\t-999\t0.0001\t-999\t10000\t-999\n" + "9\tYodzis (1998)\tYodzis (1998)\tAfrica, Benguela ecosystem\tmarine\tpelagic food web\tpublished account\t\"published account; expert; regression\"\t-999\tadults\tMacrozooplankton\tinvertebrate\tpredacious\t-999\t-999\t-999\t-999\t1\t-999\t-999\tadults\tMesozooplankton\tinvertebrate\t-999\t-999\t-999\t-999\t0.01\t-999\t100\t-999\n" + "16857\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tPraon dorsale\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.002034483\t0.002197044\t0.002344828\t-999\t-999\t-999\tAcyrthosiphon pisum\tadult\taphid\tinvertebrate\t0.002448276\t0.00264532\t0.002793103\t-999\t-999\t-999\t0.614787036\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 7 pairs of individuals were measured\"\n" + "16858\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphidius urticae\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.002\t0.002665025\t0.003517241\t-999\t-999\t-999\tMacrosiphum funestum\tadult\taphid\tinvertebrate\t0.002482759\t0.003214286\t0.003965517\t-999\t-999\t-999\t0.61203447\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 14 pairs of individuals were measured\"\n" + "16859\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tPraon dorsale\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.001965517\t0.001965517\t0.001965517\t-999\t-999\t-999\tAmphorophora rubi\tadult\taphid\tinvertebrate\t0.002482759\t0.002482759\t0.002482759\t-999\t-999\t-999\t0.542226802\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 1 pair of individuals were measured\"\n" + "16860\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tPraon dorsale\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.001896552\t0.001896552\t0.001896552\t-999\t-999\t-999\tMegoura viciaei\tadult\taphid\tinvertebrate\t0.002862069\t0.002862069\t0.002862069\t-999\t-999\t-999\t0.340224547\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 1 pair of individuals were measured\"\n" + "16861\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphelinus abdominalis\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.000793103\t0.000926724\t0.001206897\t-999\t-999\t-999\tSitobion fragariae / Sitobion avenae\tnymphs\taphid\tinvertebrate\t0.001310345\t0.001599138\t0.001896552\t-999\t-999\t-999\t0.239457874\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 16 pairs of individuals were measured\"\n" + "16862\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphelinus abdominalis\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.000965517\t0.000965517\t0.000965517\t-999\t-999\t-999\tAmphorophora rubi\tadult\taphid\tinvertebrate\t0.001689655\t0.001689655\t0.001689655\t-999\t-999\t-999\t0.230802396\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 1 pair of individuals were measured\"\n" + "16863\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphelinus abdominalis\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.000896552\t0.001132626\t0.001310345\t-999\t-999\t-999\tSitobion fragariae / Sitobion avenae\tadult\taphid\tinvertebrate\t0.001448276\t0.00201061\t0.002517241\t-999\t-999\t-999\t0.222324699\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 13 pairs of individuals were measured\"\n" + "16864\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphelinus abdominalis\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.001068966\t0.001206897\t0.001344828\t-999\t-999\t-999\tAcyrthosiphon pisum\tnymphs\taphid\tinvertebrate\t0.002034483\t0.002206897\t0.00237931\t-999\t-999\t-999\t0.205715371\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 2 pairs of individuals were measured\"\n" + "16865\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphelinus abdominalis\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.001103448\t0.00112069\t0.001137931\t-999\t-999\t-999\tMetopolophium albidum\tadult\taphid\tinvertebrate\t0.002034483\t0.002172414\t0.002310345\t-999\t-999\t-999\t0.176547741\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 2 pairs of individuals were measured\"\n" + "16866\tCohen et al. (2005)\tCohen et al. (2005)\t\"Country: United Kingdom; UTM: 51.24'N, 0.34'W; Silwood Park, Berkshire\"\tterrestrial\tabandoned field\trearing\t\"measurement; regression\"\tAphelinus varipes\tadult\tparasitoid wasp\tinvertebrate\tparasitoid\t0.000896552\t0.000896552\t0.000896552\t-999\t-999\t-999\tSitobion fragariae / Sitobion avenae\tnymphs\taphid\tinvertebrate\t0.001965517\t0.001965517\t0.001965517\t-999\t-999\t-999\t0.127890431\t\"newly emerged adult parsitoids were measured; resource length was measured without cauda; for data on individual body sizes and body sizes of hyperparasitoids and mummy parasitoids see Cohen et al. (2005); 1 pair of individuals were measured\"\n";
    TestParserFactory parserFactory = new TestParserFactory(new HashMap<String, String>() {

        {
            put(StudyImporterForBrose.RESOURCE_PATH, headAndTail);
            put(StudyImporterForBrose.REFERENCE_PATH, "short,full\nCohen et al. (2005),something long\nYodzis (1998),something longer");
        }
    });
    StudyImporter importer = new StudyImporterForBrose(parserFactory, nodeFactory);
    importStudy(importer);
    Taxon taxon = taxonIndex.findTaxonByName("Praon dorsale");
    Iterable<Relationship> relationships = ((NodeBacked) taxon).getUnderlyingNode().getRelationships(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS));
    for (Relationship relationship : relationships) {
        Node predatorSpecimenNode = relationship.getStartNode();
        assertThat((String) predatorSpecimenNode.getProperty(SpecimenConstant.LIFE_STAGE_LABEL), is("post-juvenile adult stage"));
        assertThat((String) predatorSpecimenNode.getProperty(SpecimenConstant.LIFE_STAGE_ID), is("UBERON:0000113"));
    }
    assertThat(taxon, is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Aphelinus abdominalis"), is(notNullValue()));
    Location location = nodeFactory.findLocation(new LocationImpl(51.24, -0.34, null, null));
    assertThat("missing location", location, is(notNullValue()));
    List<Environment> environments = location.getEnvironments();
    assertThat(environments.size(), is(1));
    assertThat(environments.get(0).getExternalId(), is("TEST:terrestrial abandoned field"));
    assertThat(environments.get(0).getName(), is("terrestrial abandoned field"));
}
Also used : Taxon(org.eol.globi.domain.Taxon) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) LocationImpl(org.eol.globi.domain.LocationImpl) Environment(org.eol.globi.domain.Environment) Location(org.eol.globi.domain.Location) Test(org.junit.Test)

Aggregations

Environment (org.eol.globi.domain.Environment)4 SpecimenNode (org.eol.globi.domain.SpecimenNode)3 Taxon (org.eol.globi.domain.Taxon)3 Relationship (org.neo4j.graphdb.Relationship)3 Location (org.eol.globi.domain.Location)2 LocationImpl (org.eol.globi.domain.LocationImpl)2 Specimen (org.eol.globi.domain.Specimen)2 Node (org.neo4j.graphdb.Node)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 JsonNode (org.codehaus.jackson.JsonNode)1 LocationNode (org.eol.globi.domain.LocationNode)1 NodeBacked (org.eol.globi.domain.NodeBacked)1 Study (org.eol.globi.domain.Study)1 Test (org.junit.Test)1