BasicAnnotationPropagator extends AbstractAnnotationPredictor implements AnnotationPredictor { protected static Set<OWLClass> getIsaPartofSuperClassClosure(Collection<OWLClass> annotations, OWLGraphWrapper graph, OWLReasoner r) { Set<OWLClass> classes = new HashSet<OWLClass>(); for (OWLClass owlClass : annotations) { classes.add(owlClass); classes.addAll(r.getSuperClasses(owlClass, false).getFlattened()); } LinkedList<OWLClass> queue = new LinkedList<OWLClass>(classes); while (queue.isEmpty() == false) { OWLClass cls = queue.removeFirst(); Set<OWLClass> partOfLinks = getDirectLinkedClasses(cls, "part_of", graph); if (!partOfLinks.isEmpty()) { for (OWLClass partOfLink : partOfLinks) { boolean added = classes.add(partOfLink); if(added) { Set<OWLClass> flattened = r.getSuperClasses(partOfLink, false).getFlattened(); for (OWLClass newClass : flattened) { if (classes.add(newClass)) { queue.add(newClass); } } } } } } return classes; } BasicAnnotationPropagator(GafDocument gafDocument, OWLGraphWrapper graph, boolean throwExceptions); @Override boolean isInitialized(); @Override List<Prediction> predictForBioEntities(Map<Bioentity, ? extends Collection<GeneAnnotation>> annMap); List<Prediction> predictForBioEntity(Bioentity e, Collection<GeneAnnotation> annotations); @Override void dispose();  }
@Test public void test1() throws Exception { ParserWrapper pw = new ParserWrapper(); OWLGraphWrapper g = pw.parseToOWLGraph(getResourceIRIString("rules/ontology/annotation-propagation-module.obo")); ElkReasonerFactory f = new ElkReasonerFactory(); OWLReasoner reasoner = f.createReasoner(g.getSourceOntology()); assertMapping("GO:0035556", "occurs_in", g, reasoner, 'F', "GO:0005622"); assertMapping("GO:0009881", "part_of", g, reasoner, 'P', "GO:0007165"); Set<OWLClass> closure = BasicAnnotationPropagator.getIsaPartofSuperClassClosure(Collections.singleton(g.getOWLClassByIdentifier("GO:0006415")), g, reasoner); assertTrue(closure.contains(g.getOWLClassByIdentifier("GO:0006412"))); }