Search in sources :

Example 51 with StudyImpl

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

the class LinkerTrustyNanoPubsTest method populateDataset.

public NodeFactoryWithDatasetContext populateDataset(DatasetImpl dataset) throws NodeFactoryException {
    TaxonIndex taxonIndex = getOrCreateTaxonIndex();
    // see https://github.com/jhpoelen/eol-globi-data/wiki/Nanopubs
    StudyImpl study = new StudyImpl("some study", "some source", "http://doi.org/123.23/222", "some study citation");
    NodeFactoryWithDatasetContext factory = new NodeFactoryWithDatasetContext(nodeFactory, dataset);
    Interaction interaction = factory.createInteraction(factory.createStudy(study));
    TaxonImpl donaldTaxon = new TaxonImpl("donald duck", "NCBI:1234");
    Specimen donald = factory.createSpecimen(interaction, donaldTaxon);
    donald.classifyAs(taxonIndex.getOrCreateTaxon(donaldTaxon));
    Taxon mickeyTaxon = new TaxonImpl("mickey mouse", "NCBI:4444");
    Taxon mickeyTaxonEOL = taxonIndex.getOrCreateTaxon(new TaxonImpl("mickey mouse", "EOL:567"));
    NodeUtil.connectTaxa(mickeyTaxon, (TaxonNode) mickeyTaxonEOL, getGraphDb(), RelTypes.SAME_AS);
    Specimen mickey = factory.createSpecimen(interaction, mickeyTaxonEOL);
    mickey.classifyAs(taxonIndex.getOrCreateTaxon(mickeyTaxonEOL));
    donald.ate(mickey);
    return factory;
}
Also used : Specimen(org.eol.globi.domain.Specimen) Interaction(org.eol.globi.domain.Interaction) TaxonImpl(org.eol.globi.domain.TaxonImpl) Taxon(org.eol.globi.domain.Taxon) StudyImpl(org.eol.globi.domain.StudyImpl) TaxonIndex(org.eol.globi.data.TaxonIndex) NodeFactoryWithDatasetContext(org.eol.globi.data.NodeFactoryWithDatasetContext)

Example 52 with StudyImpl

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

the class NameResolverTest method doNameResolving.

@Test
public void doNameResolving() throws NodeFactoryException, PropertyEnricherException {
    Specimen human = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Homo sapiens", "NCBI:9606"));
    Specimen animal = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Animalia", "WORMS:2"));
    human.ate(animal);
    Specimen fish = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Arius felis", "WORMS:158711"));
    human.ate(fish);
    assertNull(taxonIndex.findTaxonById("NCBI:9606"));
    assertNull(taxonIndex.findTaxonByName("Homo sapiens"));
    final NameResolver nameResolver = new NameResolver(getGraphDb(), new NonResolvingTaxonIndex(getGraphDb()));
    nameResolver.setBatchSize(1L);
    nameResolver.resolve();
    assertAnimalia(taxonIndex.findTaxonById("WORMS:2"));
    assertThat(taxonIndex.findTaxonByName("Arius felis"), is(notNullValue()));
    Taxon homoSapiens = taxonIndex.findTaxonByName("Homo sapiens");
    assertNotNull(homoSapiens);
    assertThat(homoSapiens.getExternalId(), is("NCBI:9606"));
}
Also used : Specimen(org.eol.globi.domain.Specimen) NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) TaxonImpl(org.eol.globi.domain.TaxonImpl) Taxon(org.eol.globi.domain.Taxon) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 53 with StudyImpl

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

the class ReportGeneratorTest method generateStudyReport.

@Test
public void generateStudyReport() throws NodeFactoryException {
    StudyImpl study1 = new StudyImpl("a second title", "a third source", null, null);
    study1.setSourceId("a/third/source");
    createStudy(study1);
    StudyImpl studyWithDoi = new StudyImpl("a title", "a third source", "doi:12345", "citation");
    studyWithDoi.setSourceId("a/third/source");
    createStudy(studyWithDoi);
    resolveNames();
    new ReportGenerator(getGraphDb()).generateReportForStudies();
    IndexHits<Node> reports = getGraphDb().index().forNodes("reports").get(StudyConstant.TITLE, "a title");
    assertThat(reports.size(), is(1));
    Node reportNode = reports.getSingle();
    assertThat((String) reportNode.getProperty(StudyConstant.TITLE), is("a title"));
    assertThat((String) reportNode.getProperty(StudyConstant.SOURCE_ID), is("a/third/source"));
    assertThat((String) reportNode.getProperty(StudyConstant.CITATION), is("citation"));
    assertThat((String) reportNode.getProperty(StudyConstant.DOI), is("doi:12345"));
    assertThat((String) reportNode.getProperty(PropertyAndValueDictionary.EXTERNAL_ID), is("http://dx.doi.org/12345"));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(4));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
    reports.close();
    reports = getGraphDb().index().forNodes("reports").get(StudyConstant.TITLE, "a second title");
    assertThat(reports.size(), is(1));
    reportNode = reports.getSingle();
    assertThat((String) reportNode.getProperty(StudyConstant.TITLE), is("a second title"));
    assertThat((String) reportNode.getProperty(StudyConstant.SOURCE_ID), is("a/third/source"));
    assertThat(reportNode.hasProperty(StudyConstant.CITATION), is(false));
    assertThat(reportNode.hasProperty(StudyConstant.DOI), is(false));
    assertThat(reportNode.hasProperty(PropertyAndValueDictionary.EXTERNAL_ID), is(false));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(4));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
    reports.close();
}
Also used : Node(org.neo4j.graphdb.Node) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 54 with StudyImpl

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

the class ReportGeneratorTest method generateCollectionReport.

@Test
public void generateCollectionReport() throws NodeFactoryException {
    DatasetImpl originatingDataset = new DatasetImpl("some/namespace", URI.create("http://example.com"));
    StudyImpl study1 = new StudyImpl("a title", "source", null, "citation");
    study1.setOriginatingDataset(originatingDataset);
    createStudy(study1);
    StudyImpl study2 = new StudyImpl("another title", "another source", null, "citation");
    study2.setOriginatingDataset(originatingDataset);
    createStudy(study2);
    resolveNames();
    new ReportGenerator(getGraphDb()).generateReportForCollection();
    IndexHits<Node> reports = getGraphDb().index().forNodes("reports").query("*:*");
    assertThat(reports.size(), is(1));
    Node reportNode = reports.getSingle();
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(2));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(2));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(8));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
}
Also used : Node(org.neo4j.graphdb.Node) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.eol.globi.service.DatasetImpl) Test(org.junit.Test)

Example 55 with StudyImpl

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

the class ReportGeneratorTest method generateIndividualStudySourceReports.

@Test
public void generateIndividualStudySourceReports() throws NodeFactoryException {
    StudyImpl study1 = new StudyImpl("a title", "az source", null, "citation");
    study1.setSourceId("az/source");
    createStudy(study1);
    StudyImpl study2 = new StudyImpl("another title", "az source", null, "citation");
    study2.setSourceId("az/source");
    createStudy(study2);
    StudyImpl study3 = new StudyImpl("yet another title", "zother source", null, null);
    study3.setSourceId("zother/source");
    createStudy(study3);
    resolveNames();
    new ReportGenerator(getGraphDb()).generateReportForSourceIndividuals();
    IndexHits<Node> reports = getGraphDb().index().forNodes("reports").get(StudyConstant.SOURCE_ID, "az/source");
    Node reportNode = reports.getSingle();
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(2));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(8));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
    assertThat((String) reportNode.getProperty(StudyConstant.SOURCE_ID), is("az/source"));
    reports.close();
    IndexHits<Node> otherReports = getGraphDb().index().forNodes("reports").get(StudyConstant.SOURCE_ID, "zother/source");
    Node otherReport = otherReports.getSingle();
    assertThat((String) otherReport.getProperty(StudyConstant.SOURCE_ID), is("zother/source"));
    assertThat((Integer) otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(1));
    assertThat((Integer) otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
    assertThat((Integer) otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
    assertThat((Integer) otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(4));
    assertThat((Integer) otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
    assertThat((Integer) otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
}
Also used : Node(org.neo4j.graphdb.Node) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Aggregations

StudyImpl (org.eol.globi.domain.StudyImpl)82 Study (org.eol.globi.domain.Study)60 Test (org.junit.Test)40 Specimen (org.eol.globi.domain.Specimen)33 TaxonImpl (org.eol.globi.domain.TaxonImpl)33 IOException (java.io.IOException)20 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)17 Location (org.eol.globi.domain.Location)15 StringWriter (java.io.StringWriter)12 LocationImpl (org.eol.globi.domain.LocationImpl)12 Date (java.util.Date)9 HashMap (java.util.HashMap)9 Taxon (org.eol.globi.domain.Taxon)9 StudyNode (org.eol.globi.domain.StudyNode)7 Node (org.neo4j.graphdb.Node)7 File (java.io.File)6 TermImpl (org.eol.globi.domain.TermImpl)6 DatasetImpl (org.eol.globi.service.DatasetImpl)6 InteractType (org.eol.globi.domain.InteractType)5 NonResolvingTaxonIndex (org.eol.globi.taxon.NonResolvingTaxonIndex)5