use of org.molgenis.ontology.core.meta.Ontology in project molgenis by molgenis.
the class OntologyImportServiceIT method verifyOwlAsSystem.
private void verifyOwlAsSystem() {
// Verify two imported rows (organization and team, as these are interesting examples)
List<Entity> entities = dataService.findAll("sys_ont_OntologyTerm").collect(Collectors.toList());
Optional<Entity> organizationOpt = entities.stream().filter(e -> e.getString("ontologyTermName").equals("organization")).findFirst();
assertTrue(organizationOpt.isPresent());
Entity organization = organizationOpt.get();
Optional<Entity> teamOpt = entities.stream().filter(e -> e.getString("ontologyTermName").equals("team")).findFirst();
assertTrue(teamOpt.isPresent());
Entity team = teamOpt.get();
// Verify organization
assertEquals(organization.getString("ontologyTermIRI"), "http://www.molgenis.org#Organization");
assertEquals(organization.getString("ontologyTermName"), "organization");
// verify organization ontologyTermSynonym
Iterable<Entity> ontologyTermSynonym = organization.getEntities("ontologyTermSynonym");
List<Entity> termSynonymRefList = new ArrayList<>();
ontologyTermSynonym.forEach(termSynonymRefList::add);
assertEquals(termSynonymRefList.size(), 1);
Entity organizationOntologyTermSynonym = dataService.findOneById("sys_ont_OntologyTermSynonym", termSynonymRefList.get(0).getIdValue());
assertEquals(organizationOntologyTermSynonym.getString("ontologyTermSynonym"), "organization");
// verify organization ontology
Ontology ontology = (Ontology) organization.get("ontology");
assertEquals(ontology.getOntologyName(), "ontology-small");
// Verify the team row
assertEquals(team.getString("ontologyTermIRI"), "http://www.molgenis.org#Team");
assertEquals(team.getString("ontologyTermName"), "team");
// verify team dynamic annotations
Iterable<Entity> dynamicAnnotationItr = team.getEntities("ontologyTermDynamicAnnotation");
List<Entity> dynamicAnnotations = new ArrayList<>();
dynamicAnnotationItr.forEach(dynamicAnnotations::add);
assertEquals(dynamicAnnotations.size(), 2);
Entity annotationOne = dataService.findOneById("sys_ont_OntologyTermDynamicAnnotation", dynamicAnnotations.get(0).getIdValue());
assertEquals(annotationOne.getString("label"), "friday:2412423");
Entity annotationTwo = dataService.findOneById("sys_ont_OntologyTermDynamicAnnotation", dynamicAnnotations.get(1).getIdValue());
assertEquals(annotationTwo.getString("label"), "molgenis:1231424");
// verify team ontology
ontology = (Ontology) team.get("ontology");
assertEquals(ontology.getOntologyName(), "ontology-small");
}
use of org.molgenis.ontology.core.meta.Ontology in project molgenis by molgenis.
the class InformationContentServiceTest method createWordIDF.
@Test
public void createWordIDF() {
String ontologyIri = "http://www.molgenis.org";
Ontology ontology = ontologyFactory.create();
ontology.setOntologyIri(ontologyIri);
when(dataService.findOne(ONTOLOGY, new QueryImpl<>().eq(OntologyMetaData.ONTOLOGY_IRI, ontologyIri))).thenReturn(ontology);
when(dataService.count(ONTOLOGY_TERM, new QueryImpl<>().eq(OntologyTermMetaData.ONTOLOGY, ontology))).thenReturn((long) 100);
QueryRule queryRule = new QueryRule(singletonList(new QueryRule(OntologyTermMetaData.ONTOLOGY_TERM_SYNONYM, Operator.FUZZY_MATCH, "hear")));
queryRule.setOperator(Operator.DIS_MAX);
QueryRule finalQuery = new QueryRule(asList(new QueryRule(OntologyTermMetaData.ONTOLOGY, Operator.EQUALS, ontology), new QueryRule(Operator.AND), queryRule));
when(dataService.count(ONTOLOGY_TERM, new QueryImpl<>(finalQuery))).thenReturn((long) 30);
QueryRule queryRule2 = new QueryRule(singletonList(new QueryRule(OntologyTermMetaData.ONTOLOGY_TERM_SYNONYM, Operator.FUZZY_MATCH, "impair")));
queryRule2.setOperator(Operator.DIS_MAX);
QueryRule finalQuery2 = new QueryRule(asList(new QueryRule(OntologyTermMetaData.ONTOLOGY, Operator.EQUALS, ontology), new QueryRule(Operator.AND), queryRule2));
when(dataService.count(ONTOLOGY_TERM, new QueryImpl<>(finalQuery2))).thenReturn((long) 10);
Map<String, Double> expectedWordIDF = informationContentService.createWordIDF("hearing impairment", ontologyIri);
Assert.assertEquals(expectedWordIDF.get("hear").intValue(), 2);
Assert.assertEquals(expectedWordIDF.get("impair").intValue(), 3);
}
use of org.molgenis.ontology.core.meta.Ontology in project molgenis by molgenis.
the class OntologyImportServiceIT method verifyOboAsSystem.
private void verifyOboAsSystem() {
List<Entity> ontologies = dataService.findAll("sys_ont_Ontology").collect(Collectors.toList());
Ontology ontology = (Ontology) ontologies.get(0);
assertEquals(ontology.getOntologyName(), "ontology-small");
List<Entity> synonyms = dataService.findAll("sys_ont_OntologyTerm").collect(Collectors.toList());
verifyOboRow(synonyms, "molgenis ontology core", "http://purl.obolibrary.org/obo/TEMP#molgenis-ontology-core");
verifyOboRow(synonyms, "molgenis", "http://purl.obolibrary.org/obo/TEMP#molgenis");
verifyOboRow(synonyms, "Thing", "http://purl.obolibrary.org/obo/TEMP#Thing");
}
Aggregations