Search in sources :

Example 16 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class NodeFactoryNeo4jTest method createStudyWithDifferentExternalId.

@Test
public void createStudyWithDifferentExternalId() throws NodeFactoryException {
    StudyImpl study1 = new StudyImpl("myTitle", new DOI("myDoi", "123"), null);
    study1.setExternalId("foo:bar");
    StudyNode study1Created = getNodeFactory().getOrCreateStudy(study1);
    StudyImpl study2 = new StudyImpl("myTitle", new DOI("myDoi", "123"), null);
    study2.setExternalId("foo:baz");
    StudyNode study2Created = getNodeFactory().getOrCreateStudy(study2);
    assertThat(study1Created.getExternalId(), is("foo:bar"));
    assertThat(study2Created.getExternalId(), is("foo:baz"));
}
Also used : StudyImpl(org.eol.globi.domain.StudyImpl) DOI(org.globalbioticinteractions.doi.DOI) StudyNode(org.eol.globi.domain.StudyNode) Test(org.junit.Test)

Example 17 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class NodeFactoryNeo4jTest method createStudyWithDifferentExternalIdInSameNamespace.

@Test
public void createStudyWithDifferentExternalIdInSameNamespace() 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/space", URI.create("foo:bar"), is -> is));
    study2.setExternalId("foo:baz");
    StudyNode study2Created = getNodeFactory().getOrCreateStudy(study2);
    assertThat(study1Created.getExternalId(), is("foo:bar"));
    assertThat(study2Created.getExternalId(), is("foo:baz"));
}
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 18 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class NodeFactoryNeo4jTest method createStudyWithMatchingExternalIdDifferentTitle.

@Test
public void createStudyWithMatchingExternalIdDifferentTitle() throws NodeFactoryException {
    StudyImpl study1 = new StudyImpl("myTitle", new DOI("myDoi", "123"), null);
    study1.setExternalId("foo:bar");
    StudyNode study1Created = getNodeFactory().getOrCreateStudy(study1);
    StudyImpl study2 = new StudyImpl("myTitlez", new DOI("myDoi", "123"), null);
    study2.setExternalId("foo:bar");
    StudyNode study2Created = getNodeFactory().getOrCreateStudy(study2);
    assertThat(study1Created.getExternalId(), is("foo:bar"));
    assertThat(study1Created.getTitle(), is("myTitle"));
    assertThat(study2Created.getExternalId(), is("foo:bar"));
    assertThat(study2Created.getTitle(), is("myTitle"));
}
Also used : StudyImpl(org.eol.globi.domain.StudyImpl) DOI(org.globalbioticinteractions.doi.DOI) StudyNode(org.eol.globi.domain.StudyNode) Test(org.junit.Test)

Example 19 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class DatasetImporterForGemina method importStudy.

@Override
public void importStudy() throws StudyImporterException {
    URI studyResource = URI.create("gemina_search_2008-01-03.txt");
    try {
        String source = "Schriml, L. M., Arze, C., Nadendla, S., Ganapathy, A., Felix, V., Mahurkar, A., … Hall, N. (2009). GeMInA, Genomic Metadata for Infectious Agents, a geospatial surveillance pathogen database. Nucleic Acids Research, 38(Database), D754–D764. doi:10.1093/nar/gkp832";
        Study study = getNodeFactory().getOrCreateStudy(new StudyImpl(source, new DOI("1093", "nar/gkp832"), source));
        LabeledCSVParser parser = getParserFactory().createParser(studyResource, "UTF-8");
        parser.changeDelimiter('\t');
        String[] line;
        while ((line = parser.getLine()) != null) {
            if (line.length > 7) {
                String pathogenId = parser.getValueByLabel("Pathogen Taxonomy");
                String pathogenExternalId = StringUtils.isBlank(pathogenId) ? null : TaxonomyProvider.NCBI.getIdPrefix() + pathogenId;
                Specimen pathogen = getNodeFactory().createSpecimen(study, new TaxonImpl(parser.getValueByLabel("Pathogen"), pathogenExternalId));
                String hostId = line[7];
                String hostReservoirExternalId = StringUtils.isBlank(hostId) ? null : TaxonomyProvider.NCBI.getIdPrefix() + hostId;
                Specimen host = getNodeFactory().createSpecimen(study, new TaxonImpl(parser.getValueByLabel("Host/Reservoir"), hostReservoirExternalId));
                pathogen.interactsWith(host, InteractType.PATHOGEN_OF);
            }
        }
    } catch (IOException | NodeFactoryException e) {
        throw new StudyImporterException("failed to import [" + studyResource + "]", e);
    }
}
Also used : Study(org.eol.globi.domain.Study) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) IOException(java.io.IOException) URI(java.net.URI) Specimen(org.eol.globi.domain.Specimen) DOI(org.globalbioticinteractions.doi.DOI)

Example 20 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class DatasetImporterForJRFerrerParis method importStudy.

@Override
public void importStudy() throws StudyImporterException {
    String citation = "Ferrer-Paris, José R.; Sánchez-Mercado, Ada Y.; Lozano, Cecilia; Zambrano, Liset; Soto, José; Baettig, Jessica; Leal, María (2014): A compilation of larval host-plant records for six families of butterflies (Lepidoptera: Papilionoidea) from available electronic resources. figshare. https://doi.org/10.6084/m9.figshare.1168861 . " + CitationUtil.createLastAccessedString(RESOURCE.toString());
    Study study = getNodeFactory().getOrCreateStudy(new StudyImpl("Ferrer-Paris 2014", new DOI("6084", "m9.figshare.1168861"), citation));
    try {
        LabeledCSVParser parser = getParserFactory().createParser(RESOURCE, CharsetConstant.UTF8);
        while (parser.getLine() != null) {
            String butterflyName = createTaxon(parser, "Lepidoptera Name");
            String plantName = createTaxon(parser, "Hostplant Name");
            if (validNames(butterflyName, plantName, study, parser.lastLineNumber())) {
                addAssociation(study, parser, butterflyName, plantName);
            }
        }
    } catch (IOException e) {
        throw new StudyImporterException("failed to access resource [" + RESOURCE + "]");
    }
}
Also used : Study(org.eol.globi.domain.Study) StudyImpl(org.eol.globi.domain.StudyImpl) LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) IOException(java.io.IOException) DOI(org.globalbioticinteractions.doi.DOI)

Aggregations

DOI (org.globalbioticinteractions.doi.DOI)74 Test (org.junit.Test)50 StudyImpl (org.eol.globi.domain.StudyImpl)28 IOException (java.io.IOException)15 Study (org.eol.globi.domain.Study)15 Specimen (org.eol.globi.domain.Specimen)13 StudyNode (org.eol.globi.domain.StudyNode)12 Matchers.containsString (org.hamcrest.Matchers.containsString)12 TaxonImpl (org.eol.globi.domain.TaxonImpl)11 URI (java.net.URI)10 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 DatasetImpl (org.globalbioticinteractions.dataset.DatasetImpl)8 MalformedDOIException (org.globalbioticinteractions.doi.MalformedDOIException)8 Location (org.eol.globi.domain.Location)7 LocationImpl (org.eol.globi.domain.LocationImpl)7 ArrayList (java.util.ArrayList)6 Dataset (org.globalbioticinteractions.dataset.Dataset)6 Reader (java.io.Reader)5 StringReader (java.io.StringReader)5