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;
}
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"));
}
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();
}
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));
}
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));
}
Aggregations