QuerySubsetGenerator { public void createSubOntologyFromDLQuery(String dlQueryString, OWLGraphWrapper sourceGraph, OWLGraphWrapper targetGraph, OWLReasonerFactory reasonerFactory, Set<OWLOntology> toMerge) { try { Set<OWLClass> subset; subset = DLQueryTool.executeDLQuery(dlQueryString, sourceGraph, reasonerFactory); if (subset.isEmpty()) { return; } createSubSet(targetGraph, subset, toMerge); } catch (OWLParserException e) { LOG.error("Could not parse query: "+dlQueryString, e); return; } catch (OWLOntologyCreationException e) { LOG.error("Could not create ontology.", e); return; } }  void createSubOntologyFromDLQuery(String dlQueryString,
			OWLGraphWrapper sourceGraph, OWLGraphWrapper targetGraph, 
			OWLReasonerFactory reasonerFactory, Set<OWLOntology> toMerge); void createSubOntologyFromDLQuery(OWLClass namedQuery,
			OWLGraphWrapper sourceGraph, OWLGraphWrapper targetGraph, 
			OWLReasonerFactory reasonerFactory, Set<OWLOntology> toMerge); void createSubSet(OWLGraphWrapper targetGraph, 
			Set<OWLClass> subset, Set<OWLOntology> toMerge); void createSubSet(OWLGraphWrapper targetGraph, 
			Set<OWLClass> subset, Set<OWLOntology> toMerge, boolean isExcludeClosure,
			boolean isRemoveDangling);  }
@Test public void testCreateSubOntologyFromDLQuery() throws Exception { QuerySubsetGenerator generator = new QuerySubsetGenerator(); OWLGraphWrapper sourceGraph = getSourceGraph(); OWLGraphWrapper targetGraph = getTargetGraph(); String dlQueryString = "FBbt_00005106 and 'part_of' some FBbt_00005095"; OWLReasonerFactory reasonerFactory; if (useElk) { reasonerFactory = new ElkReasonerFactory(); } else { reasonerFactory = new org.semanticweb.HermiT.ReasonerFactory(); } String query1 = "FBbt_00005106"; String query2 = "FBbt_00005106 and 'part_of' some FBbt_00005095"; int neuronClassCount = DLQueryTool.executeDLQuery(query1, sourceGraph, reasonerFactory).size(); int neuronAndBrainClassCount = DLQueryTool.executeDLQuery(query2, sourceGraph, reasonerFactory).size(); assertTrue(neuronClassCount > 1); assertTrue(neuronAndBrainClassCount > 1 && neuronAndBrainClassCount < neuronClassCount); Set<OWLOntology> toMerge = sourceGraph.getAllOntologies(); generator.createSubOntologyFromDLQuery(dlQueryString, sourceGraph, targetGraph, reasonerFactory, toMerge); Owl2Obo owl2Obo = new Owl2Obo(); OBODoc oboDoc = owl2Obo.convert(targetGraph.getSourceOntology()); if (renderObo) { renderOBO(oboDoc); } assertTrue(oboDoc.getTermFrames().size() > neuronAndBrainClassCount); }