use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.
the class GeneOntologyServiceImpl method findTerm.
@Override
public Collection<OntologyTerm> findTerm(String queryString) {
if (!this.isReady())
return new HashSet<>();
if (GeneOntologyServiceImpl.log.isDebugEnabled())
GeneOntologyServiceImpl.log.debug("Searching Gene Ontology for '" + queryString + "'");
// make sure we are all-inclusive
queryString = queryString.trim();
queryString = queryString.replaceAll("\\s+", " AND ");
StopWatch timer = new StopWatch();
timer.start();
Collection<OntologyResource> rawMatches = new HashSet<>();
for (SearchIndex index : this.indices) {
rawMatches.addAll(OntologySearch.matchIndividuals(model, index, queryString));
}
if (timer.getTime() > 100) {
GeneOntologyServiceImpl.log.info("Find " + rawMatches.size() + " raw go terms from " + queryString + ": " + timer.getTime() + " ms");
}
timer.reset();
timer.start();
/*
* Required to make sure the descriptions are filled in.
*/
Collection<OntologyTerm> matches = new HashSet<>();
for (OntologyResource r : rawMatches) {
if (StringUtils.isBlank(r.getUri()))
continue;
OntologyTerm termForURI = GeneOntologyServiceImpl.getTermForURI(r.getUri());
if (termForURI == null) {
GeneOntologyServiceImpl.log.warn("No term for : " + r);
continue;
}
matches.add(termForURI);
}
if (timer.getTime() > 100) {
GeneOntologyServiceImpl.log.info("Convert " + rawMatches.size() + " raw go terms to terms: " + timer.getTime() + " ms");
}
return matches;
}
use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.
the class GeneOntologyServiceImpl method putOverlapGenes.
private void putOverlapGenes(Map<Long, Collection<OntologyTerm>> overlap, Collection<OntologyTerm> queryGeneTerms, Collection<Gene> genes) {
for (Object obj : genes) {
Gene gene = (Gene) obj;
if (queryGeneTerms.isEmpty()) {
overlap.put(gene.getId(), new HashSet<OntologyTerm>());
continue;
}
Collection<OntologyTerm> comparisonOntos = this.getGOTerms(gene);
if (comparisonOntos == null || comparisonOntos.isEmpty()) {
overlap.put(gene.getId(), new HashSet<OntologyTerm>());
continue;
}
overlap.put(gene.getId(), this.computeOverlap(queryGeneTerms, comparisonOntos));
}
}
use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.
the class GeneOntologyServiceTest2 method testAllParents.
@Test
public final void testAllParents() {
// regulation of erythrocyte aggregation
String id = "GO:0034118";
OntologyTerm termForId = GeneOntologyServiceImpl.getTermForId(id);
assertNotNull(termForId);
Collection<OntologyTerm> terms = GeneOntologyServiceTest2.gos.getAllParents(termForId);
// excludes "regulates" relations, excludes root.
/*
* regulation of homotypic cell-cell adhesion
*
* regulation of cell-cell adhesion
*
* regulation of cell adhesion
*
* regulation of cellular process
*
* regulation of biological process
*
* biological regulation
*
* (biological process)
*/
assertEquals(6, terms.size());
}
use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.
the class OntologyServiceTest method test.
@Test
public void test() {
os.getDiseaseOntologyService().loadTermsInNameSpace(this.getClass().getResourceAsStream("/data/loader/ontology/dotest.owl.xml"));
Collection<CharacteristicValueObject> name = os.findTermsInexact("diarrhea", null);
assertTrue(name.size() > 0);
OntologyTerm t1 = os.getTerm("http://purl.obolibrary.org/obo/DOID_0050001");
assertNotNull(t1);
// Actinomadura madurae infectious disease
assertTrue(os.isObsolete("http://purl.obolibrary.org/obo/DOID_0050001"));
// inflammatory diarrhea, not obsolete as of May 2012.
assertNotNull(os.getTerm("http://purl.obolibrary.org/obo/DOID_0050132"));
assertTrue(!os.isObsolete("http://purl.obolibrary.org/obo/DOID_0050132"));
}
use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.
the class GeneOntologyServiceTest method testGetParentsPartOf.
@Test
public final void testGetParentsPartOf() {
String id = "GO:0000332";
OntologyTerm termForId = GeneOntologyServiceTest.gos.getTermForId(id);
assertNotNull(termForId);
Collection<OntologyTerm> terms = GeneOntologyServiceTest.gos.getAllParents(termForId, true);
for (OntologyTerm term : terms) {
GeneOntologyServiceTest.log.info(term);
}
// is a subclass and partof.
assertEquals(12, terms.size());
}
Aggregations