Skip to content

Commit

Permalink
Merge pull request #340 from geneontology/add-root-types-for-partial-…
Browse files Browse the repository at this point in the history
…response

adding root types for partial model responses
  • Loading branch information
goodb authored Jul 23, 2020
2 parents 567d6a0 + e7ededc commit 7304c44
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,23 @@ private static JsonAnnotation[] renderAnnotations(Set<OWLAnnotation> annotations
}

public Pair<JsonOwlIndividual[], JsonOwlFact[]> renderIndividuals(Collection<OWLNamedIndividual> 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<OWLNamedIndividual, Set<String>>();
}
Map<OWLNamedIndividual, Set<String>> t_r = go_lego_repo.getSuperCategoryMapForIndividuals(new HashSet<OWLNamedIndividual>(individuals), ont);
if(t_r!=null) {
type_roots.putAll(t_r);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

List<JsonOwlIndividual> iObjs = new ArrayList<JsonOwlIndividual>();
Set<OWLNamedIndividual> individualIds = new HashSet<OWLNamedIndividual>();
final Set<OWLObjectPropertyAssertionAxiom> opAxioms = new HashSet<OWLObjectPropertyAssertionAxiom>();
Expand All @@ -218,6 +235,7 @@ public Pair<JsonOwlIndividual[], JsonOwlFact[]> renderIndividuals(Collection<OWL
individualIds.add(named);
}
}

// filter object property axioms. Only retain axioms which use individuals from the given subset
for (OWLNamedIndividual i : individualIds) {
Set<OWLObjectPropertyAssertionAxiom> axioms = ont.getObjectPropertyAssertionAxioms(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> uris = new HashSet<String>();
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<String, Set<String>> uri_roots = onto_repo.getSuperCategoryMap(uris);
Set<String> 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"));


}
}

0 comments on commit 7304c44

Please sign in to comment.