@Test public final void testNormalizeInoh() { // there're two Protein objects that have entityReference // rdf:ID="IMR_0100366_G_alpha_s_Canonical" (in fact a generic ProteinReference inproperly // defined); // and that PR has two UniProt UnificationXref: P63092 (human), P63095 (rat). // Identifiers.org URI for the PR should NOT be generated. // // Also, there was a bug when replacing the PR's URI (warning: IllegalBioPAXArgumentException: // Incompatible type!..) // The cause is that there was a (weird, invalid) PublicationXref having db:id as UniProt:P63092 // that gets the same URI! // To avoid such issues altogether (despite illegal pub. xrefs), the Normalizer won't use // Identifiers.org for PublicationXrefs anymore. Model model = simpleIO.convertFromOWL(getClass().getResourceAsStream("/test-inoh.owl")); Normalizer normalizer = new Normalizer(); normalizer.setXmlBase(""); normalizer.normalize(model); // A weird PublicationXref that uses a UniProt ID won't be normalized: assertFalse(model.containsID("http://identifiers.org/uniprot/P63092")); // A PR with two UniProt IDs/unif.xrefs - human, rat - won't be normalized! assertTrue(model.containsID(model.getXmlBase() + "IMR_0100366_G_alpha_s_Canonical")); assertEquals( "ProteinReference", model .getByID(model.getXmlBase() + "IMR_0100366_G_alpha_s_Canonical") .getModelInterface() .getSimpleName()); }
@Test public final void testSearch() throws IOException { SimpleIOHandler reader = new SimpleIOHandler(); Model model = reader.convertFromOWL( resourceLoader.getResource("classpath:merge/pathwaydata1.owl").getInputStream()); SearchEngine searchEngine = new SearchEngine(model, indexLocation); searchEngine.index(); assertTrue(new File(indexLocation).exists()); SearchResponse response = searchEngine.search("ATP", 0, null, null, null); assertNotNull(response); assertFalse(response.isEmpty()); assertEquals(7, response.getSearchHit().size()); assertEquals(7, response.getNumHits().intValue()); CPathSettings.getInstance().setDebugEnabled(false); response = searchEngine.search("ATP", 0, Interaction.class, null, null); assertNotNull(response); assertFalse(response.isEmpty()); assertEquals(2, response.getSearchHit().size()); // if cPath2 debugging is disabled, - no score/explain in the excerpt assertFalse(response.getSearchHit().get(0).getExcerpt().contains("-SCORE-")); // enable cPath2 debugging... CPathSettings.getInstance().setDebugEnabled(true); response = searchEngine.search("ATP", 0, Pathway.class, null, null); assertNotNull(response); assertFalse(response.isEmpty()); assertEquals(1, response.getSearchHit().size()); SearchHit hit = response.getSearchHit().get(0); assertEquals(4, hit.getSize().intValue()); // no. member processes, not counting the hit itself assertTrue(hit.getExcerpt().contains("-SCORE-")); CPathSettings.getInstance().setDebugEnabled(false); // test a special implementation for wildcard queries response = searchEngine.search("*", 0, Pathway.class, null, null); assertNotNull(response); assertFalse(response.isEmpty()); assertEquals(1, response.getSearchHit().size()); // find all objects (this here works with page=0 as long as the // total no. objects in the test model < max hits per page) response = searchEngine.search("*", 0, null, null, null); assertEquals(50, response.getSearchHit().size()); response = searchEngine.search("*", 0, PhysicalEntity.class, null, null); assertEquals(8, response.getSearchHit().size()); response = searchEngine.search("*", 0, PhysicalEntity.class, null, new String[] {"562"}); assertEquals(2, response.getSearchHit().size()); response = searchEngine.search("*", 0, PhysicalEntity.class, null, new String[] {"Escherichia"}); assertFalse(response.isEmpty()); assertEquals(2, response.getSearchHit().size()); response = searchEngine.search("*", 0, PhysicalEntity.class, null, new String[] {"Escherichia coliü"}); assertFalse(response.isEmpty()); assertEquals(2, response.getSearchHit().size()); response = searchEngine.search("*", 0, Provenance.class, null, null); assertEquals(2, response.getSearchHit().size()); response = searchEngine.search("*", 0, Provenance.class, new String[] {"kegg"}, null); assertEquals(1, response.getSearchHit().size()); // datasource filter using a URI (required for -update-counts console command and // datasources.html page to work) response = searchEngine.search( "*", 0, Pathway.class, new String[] {"http://identifiers.org/kegg.pathway/"}, null); assertFalse(response.isEmpty()); assertEquals(1, response.getSearchHit().size()); response = searchEngine.search("pathway:glycolysis", 0, SmallMoleculeReference.class, null, null); assertEquals(5, response.getSearchHit().size()); // test search with pagination searchEngine.setMaxHitsPerPage(10); response = searchEngine.search("*", 0, null, null, null); assertEquals(0, response.getPageNo().intValue()); assertEquals(50, response.getNumHits().intValue()); assertEquals(10, response.getSearchHit().size()); response = searchEngine.search("*", 1, null, null, null); assertEquals(10, response.getSearchHit().size()); assertEquals(1, response.getPageNo().intValue()); }