From e7ededcb39fb85d21cb5069eab1497d9c6bb86e8 Mon Sep 17 00:00:00 2001 From: goodb Date: Thu, 23 Jul 2020 12:24:51 -0700 Subject: [PATCH] adding root types for partial responses. --- .../json/MolecularModelJsonRenderer.java | 18 +++++++++++++++ .../BlazegraphOntologyManagerTest.java | 23 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/minerva-core/src/main/java/org/geneontology/minerva/json/MolecularModelJsonRenderer.java b/minerva-core/src/main/java/org/geneontology/minerva/json/MolecularModelJsonRenderer.java index 194e098b..07c8bad5 100644 --- a/minerva-core/src/main/java/org/geneontology/minerva/json/MolecularModelJsonRenderer.java +++ b/minerva-core/src/main/java/org/geneontology/minerva/json/MolecularModelJsonRenderer.java @@ -208,6 +208,23 @@ private static JsonAnnotation[] renderAnnotations(Set annotations } public Pair renderIndividuals(Collection individuals) { + + //add root types in case these are new to the model + if(go_lego_repo!=null) { + try { + if(type_roots==null) { + type_roots = new HashMap>(); + } + Map> t_r = go_lego_repo.getSuperCategoryMapForIndividuals(new HashSet(individuals), ont); + if(t_r!=null) { + type_roots.putAll(t_r); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + List iObjs = new ArrayList(); Set individualIds = new HashSet(); final Set opAxioms = new HashSet(); @@ -218,6 +235,7 @@ public Pair renderIndividuals(Collection axioms = ont.getObjectPropertyAssertionAxioms(i); diff --git a/minerva-core/src/test/java/org/geneontology/minerva/BlazegraphOntologyManagerTest.java b/minerva-core/src/test/java/org/geneontology/minerva/BlazegraphOntologyManagerTest.java index e80ba029..3835b4ad 100644 --- a/minerva-core/src/test/java/org/geneontology/minerva/BlazegraphOntologyManagerTest.java +++ b/minerva-core/src/test/java/org/geneontology/minerva/BlazegraphOntologyManagerTest.java @@ -255,4 +255,27 @@ public void testGetUpperTypes() throws IOException { assertTrue("WBGene00000275 not subclass of CHEBI_36695 information biomacromolecule", supers.contains("http://purl.obolibrary.org/obo/CHEBI_33695")); assertTrue("WBGene00000275 not subclass of CHEBI_24431 chemical entity", supers.contains("http://purl.obolibrary.org/obo/CHEBI_24431")); } + + @Test + public void testGetComplexPortalTypes() throws IOException { + //make sure its possible to get from leaf to root for the key classes + Set uris = new HashSet(); + String cp1 = "http://purl.obolibrary.org/obo/ComplexPortal_CPX-9"; + String cp2 = "http://purl.obolibrary.org/obo/ComplexPortal_CPX-4082"; +//this doesn't work now. It should work while the ones above do not. this is problem with the neo ontology. +// String cp3 = "https://www.ebi.ac.uk/complexportal/complex/CPX-9"; + uris.add(cp1); + uris.add(cp2); +// uris.add(cp3); + + Map> uri_roots = onto_repo.getSuperCategoryMap(uris); + Set supers = uri_roots.get(cp1); + assertTrue("ComplexPortal_CPX-9 not an information biomacromolecule", supers.contains("http://purl.obolibrary.org/obo/CHEBI_33695")); + supers = uri_roots.get(cp2); + assertTrue("ComplexPortal_CPX-4082 not an information biomacromolecule", supers.contains("http://purl.obolibrary.org/obo/CHEBI_33695")); +// supers = uri_roots.get(cp3); +// assertTrue("ComplexPortal_CPX-9 as https://www.ebi.ac.uk/complexportal/complex/CPX-9 is not an information biomacromolecule", supers.contains("http://purl.obolibrary.org/obo/CHEBI_33695")); + + + } }