Search in sources :

Example 11 with DOI

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

the class DOIResolverCacheTest method initCacheTwice.

@Test
public void initCacheTwice() throws IOException, PropertyEnricherException {
    String bla = "doi\tcitation" + "\ndoi:10.some/doi\tsome citation" + "\ndoi:10.some/other/doi\tsome other citation";
    Reader reader = new StringReader(bla);
    doiResolverCache.init(reader);
    doiResolverCache.init(reader);
    Map<String, DOI> doiForReference = doiResolverCache.resolveDoiFor(Arrays.asList("some citation", "some other citation"));
    assertThat(doiForReference.get("some other citation").toString(), is("10.some/other/doi"));
    assertThat(doiForReference.get("some citation").toString(), is("10.some/doi"));
}
Also used : StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 12 with DOI

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

the class DOIResolverCacheTest method initCacheNoTabs.

@Test
public void initCacheNoTabs() throws IOException, PropertyEnricherException {
    String bla = "doi citation\n" + "10.some/A citationA\n" + "10.some/B citationB";
    Reader reader = new StringReader(bla);
    doiResolverCache.init(reader);
    Map<String, DOI> doiForReference = doiResolverCache.resolveDoiFor(Collections.singletonList("citationA"));
    assertThat(doiForReference.get("citationA"), is(not(new DOI("some", "A"))));
}
Also used : StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 13 with DOI

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

the class DOIResolverImplTest method extractDOIBelowMinScore.

@Test
public void extractDOIBelowMinScore() throws IOException, MalformedDOIException {
    String response = IOUtils.toString(getClass().getResourceAsStream("crossRefReply.json"), StandardCharsets.UTF_8);
    DOIResolverImpl doiResolver = new DOIResolverImpl();
    doiResolver.setMinMatchScore(200);
    DOI doi = doiResolver.extractDOI(response);
    assertThat(doi, is(nullValue()));
}
Also used : DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 14 with DOI

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

the class GraphExporterImplTest method exportAll.

@Test
public void exportAll() throws StudyImporterException, IOException {
    File tmpDir = folder.newFolder();
    assertNotNull(tmpDir);
    assertThat(tmpDir.list().length, is(0));
    Study study = nodeFactory.getOrCreateStudy(new StudyImpl("a study", new DOI("12345", "123"), null));
    Specimen human = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens", "NCBI:123"));
    human.ate(nodeFactory.createSpecimen(study, new TaxonImpl("Canis familiaris", "BLA:444")));
    resolveNames();
    new GraphExporterImpl().export(getGraphDb(), tmpDir);
    new GraphExporterInteractionsTSVImpl().export(getGraphDb(), tmpDir);
    assertThat(tmpDir.list().length, is(8));
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) File(java.io.File) DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 15 with DOI

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

the class NodeFactoryNeo4jTest method createStudyWithSameExternalIdInDifferentNamespace.

@Test
public void createStudyWithSameExternalIdInDifferentNamespace() 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/spacz", URI.create("foo:bar"), is -> is));
    study2.setExternalId("foo:bar");
    StudyNode study2Created = getNodeFactory().getOrCreateStudy(study2);
    assertThat(study1Created.getExternalId(), is("foo:bar"));
    assertThat(study1Created.getOriginatingDataset().getNamespace(), is("name/space"));
    assertThat(study2Created.getExternalId(), is("foo:bar"));
    assertThat(study2Created.getOriginatingDataset().getNamespace(), is("name/spacz"));
}
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)

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