use of ubic.gemma.model.genome.gene.phenotype.valueObject.GeneEvidenceValueObject in project Gemma by PavlidisLab.
the class PhenotypeAssociationDaoImpl method populateGenesWithPhenotypes.
/**
* @param queryObject execute sqlQuery and populate phenotypesGenesAssociations is : phenotype --> genes
* @return collection
*/
private Collection<GeneEvidenceValueObject> populateGenesWithPhenotypes(SQLQuery queryObject) {
StopWatch sw = new StopWatch();
sw.start();
// we accumulate the phenotypes for a gene in one VO
Map<Long, GeneEvidenceValueObject> genesWithPhenotypes = new HashMap<>();
ScrollableResults results = queryObject.scroll(ScrollMode.FORWARD_ONLY);
while (results.next()) {
/* 0: gene id 1: ncbi id 2: name 3: symbol 4: taxon id 5: taxon name 6: characteristic value URI */
Long geneId = ((BigInteger) results.get(0)).longValue();
Integer nbciGeneId = (Integer) results.get(1);
String officialName = (String) results.get(2);
String officialSymbol = (String) results.get(3);
Long taxonId = ((BigInteger) results.get(4)).longValue();
String taxonCommonName = (String) results.get(5);
String valueUri = (String) results.get(6);
if (genesWithPhenotypes.get(geneId) != null) {
genesWithPhenotypes.get(geneId).getPhenotypesValueUri().add(valueUri);
} else {
GeneEvidenceValueObject g = new GeneEvidenceValueObject(geneId);
g.setNcbiId(nbciGeneId);
g.setOfficialName(officialName);
g.setOfficialSymbol(officialSymbol);
g.setTaxonCommonName(taxonCommonName);
g.setTaxonId(taxonId);
g.getPhenotypesValueUri().add(valueUri);
genesWithPhenotypes.put(geneId, g);
}
}
results.close();
if (sw.getTime() > 500) {
PhenotypeAssociationDaoImpl.log.info("Get " + genesWithPhenotypes.size() + " genes with phenotypes: " + sw.getTime() + "ms");
}
return genesWithPhenotypes.values();
}
use of ubic.gemma.model.genome.gene.phenotype.valueObject.GeneEvidenceValueObject in project Gemma by PavlidisLab.
the class SearchServiceImpl method geneSearch.
/**
* Combines compass style search, the db style search, and the compositeSequence search and returns 1 combined list
* with no duplicates.
*
* @param returnOnDbHit if true and if there is a match for a gene from the database, return immediately - much
* faster
*/
private Collection<SearchResult> geneSearch(final SearchSettings settings, boolean returnOnDbHit) {
StopWatch watch = this.startTiming();
String searchString = settings.getQuery();
Collection<SearchResult> geneDbList = this.databaseGeneSearch(settings);
if (returnOnDbHit && geneDbList.size() > 0) {
return geneDbList;
}
Set<SearchResult> combinedGeneList = new HashSet<>(geneDbList);
Collection<SearchResult> geneCompassList = this.compassGeneSearch(settings);
combinedGeneList.addAll(geneCompassList);
if (combinedGeneList.isEmpty()) {
Collection<SearchResult> geneCsList = this.databaseCompositeSequenceSearch(settings);
for (SearchResult res : geneCsList) {
if (res.getResultClass().isAssignableFrom(Gene.class))
combinedGeneList.add(res);
}
}
/*
* Possibly search for genes linked via a phenotype, but only if we don't have anything here.
*
*/
if (combinedGeneList.isEmpty()) {
Collection<CharacteristicValueObject> phenotypeTermHits = this.phenotypeAssociationManagerService.searchInDatabaseForPhenotype(settings.getQuery());
for (CharacteristicValueObject phenotype : phenotypeTermHits) {
Set<String> phenotypeUris = new HashSet<>();
phenotypeUris.add(phenotype.getValueUri());
// DATABASE HIT!
Collection<GeneEvidenceValueObject> phenotypeGenes = phenotypeAssociationManagerService.findCandidateGenes(phenotypeUris, settings.getTaxon());
if (!phenotypeGenes.isEmpty()) {
SearchServiceImpl.log.info(phenotypeGenes.size() + " genes associated with " + phenotype + " (via query='" + settings.getQuery() + "')");
for (GeneEvidenceValueObject gvo : phenotypeGenes) {
Gene g = Gene.Factory.newInstance();
g.setId(gvo.getId());
g.setTaxon(settings.getTaxon());
SearchResult sr = new SearchResult(g);
sr.setHighlightedText(phenotype.getValue() + " (" + phenotype.getValueUri() + ")");
// if ( gvo.getScore() != null ) {
// TODO If we get evidence quality, use that in the score.
// }
// maybe lower, if we do this search when combinedGeneList is nonempty.
sr.setScore(1.0);
combinedGeneList.add(sr);
}
if (combinedGeneList.size() > 100) /* some limit */
{
break;
}
}
}
}
if (watch.getTime() > 1000)
SearchServiceImpl.log.info("Gene search for " + searchString + " took " + watch.getTime() + " ms; " + combinedGeneList.size() + " results.");
return combinedGeneList;
}
Aggregations