use of ubic.gemma.model.genome.gene.GeneSetValueObject in project Gemma by PavlidisLab.
the class CoexpressionSearchController method doSearch.
/**
* Important entry point - called by the CoexpressionSearchTask
*
* @param searchOptions search options
* @return coexp. meta VO
*/
public CoexpressionMetaValueObject doSearch(CoexpressionSearchCommand searchOptions) {
Collection<ExpressionExperiment> myEE = null;
CoexpressionMetaValueObject result = new CoexpressionMetaValueObject();
if (searchOptions.getGeneIds() == null || searchOptions.getGeneIds().isEmpty()) {
if (searchOptions.getGeneSetId() != null) {
searchOptions.setGeneIds(geneSetService.getGeneIdsInGroup(new GeneSetValueObject(searchOptions.getGeneSetId())));
}
if (searchOptions.getGeneIds().isEmpty()) {
result.setErrorState("No genes were selected");
return result;
}
}
if (searchOptions.getGeneIds().size() > CoexpressionSearchController.MAX_GENES_FOR_QUERY_GENES_ONLY_QUERY) {
result.setErrorState("Too many genes selected, please limit searches to " + CoexpressionSearchController.MAX_GENES_FOR_QUERY_GENES_ONLY_QUERY + " genes");
return result;
}
if (searchOptions.getGeneIds().size() == 0) {
result.setErrorState("Invalid gene id(s) - no genes found");
return result;
}
// Add the user's datasets to the selected datasets
if (searchOptions.isUseMyDatasets()) {
myEE = expressionExperimentService.loadAll();
}
Collection<Long> eeIds = this.chooseExperimentsToQuery(searchOptions, result);
if (StringUtils.isNotBlank(result.getErrorState()))
return result;
if (myEE != null && !myEE.isEmpty()) {
eeIds.addAll(EntityUtils.getIds(myEE));
} else {
CoexpressionSearchController.log.info("No user data to add");
}
if (eeIds.isEmpty()) {
// search all available experiments.
} else {
searchOptions.setEeIds(eeIds);
}
CoexpressionSearchController.log.info("Starting coexpression search: " + searchOptions);
result = geneCoexpressionService.coexpressionSearch(searchOptions.getEeIds(), searchOptions.getGeneIds(), searchOptions.getStringency(), CoexpressionSearchController.MAX_RESULTS_PER_GENE, searchOptions.getQueryGenesOnly());
// make sure to create an empty list instead of null for front-end
if (result.getResults() == null) {
List<CoexpressionValueObjectExt> res = new ArrayList<>();
result.setResults(res);
}
if (result.getResults().isEmpty()) {
result.setErrorState(CoexpressionSearchController.NOTHING_FOUND_MESSAGE);
CoexpressionSearchController.log.info("No search results for query: " + searchOptions);
}
return result;
}
use of ubic.gemma.model.genome.gene.GeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetDaoImpl method loadValueObjects.
@Override
public Collection<DatabaseBackedGeneSetValueObject> loadValueObjects(Collection<Long> ids) {
Collection<DatabaseBackedGeneSetValueObject> result = this.loadValueObjectsLite(ids);
for (GeneSetValueObject res : result) {
res.setGeneIds(new HashSet<Long>());
// noinspection unchecked
res.getGeneIds().addAll(this.getSessionFactory().getCurrentSession().createQuery("select genes.id from GeneSet g join g.members m join m.gene genes where g.id = :id").setParameter("id", res.getId()).list());
}
return result;
}
use of ubic.gemma.model.genome.gene.GeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetValueObjectHelperImpl method fillSessionBoundValueObject.
private void fillSessionBoundValueObject(SessionBoundGeneSetValueObject sbgsvo, GeneSet gs) {
sbgsvo.setName(gs.getName());
sbgsvo.setDescription(gs.getDescription());
// GO group gene sets don't have ids
if (gs.getId() == null) {
sbgsvo.setSize(gs.getMembers() != null ? gs.getMembers().size() : 0);
} else {
// this case may never happen as this is only called from convertToGoValueObject() leaving here in case
// this method is ever called from somewhere else
sbgsvo.setSize(this.geneSetService.getSize(new GeneSetValueObject(gs.getId())));
}
Collection<Long> gids = new HashSet<>();
for (GeneSetMember gm : gs.getMembers()) {
gids.add(gm.getGene().getId());
}
sbgsvo.setGeneIds(gids);
Taxon tax = this.geneSetService.getTaxon(gs);
if (tax != null) {
while (tax.getParentTaxon() != null) {
tax = tax.getParentTaxon();
}
sbgsvo.setTaxonId(tax.getId());
sbgsvo.setTaxonName(tax.getCommonName());
}
sbgsvo.setId(new Long(-1));
sbgsvo.setModified(false);
}
use of ubic.gemma.model.genome.gene.GeneSetValueObject in project Gemma by PavlidisLab.
the class GeneController method handleRequestInternal.
@RequestMapping("/downloadGeneList.html")
protected ModelAndView handleRequestInternal(HttpServletRequest request) {
StopWatch watch = new StopWatch();
watch.start();
// might not be any
Collection<Long> geneIds = ControllerUtils.extractIds(request.getParameter("g"));
// might not be there
Collection<Long> geneSetIds = ControllerUtils.extractIds(request.getParameter("gs"));
// might not be there
String geneSetName = request.getParameter("gsn");
ModelAndView mav = new ModelAndView(new TextView());
if ((geneIds == null || geneIds.isEmpty()) && (geneSetIds == null || geneSetIds.isEmpty())) {
mav.addObject("text", "Could not find genes to match gene ids: {" + geneIds + "} or gene set ids {" + geneSetIds + "}");
return mav;
}
Collection<GeneValueObject> genes = new ArrayList<>();
if (geneIds != null) {
for (Long id : geneIds) {
genes.add(geneService.loadValueObjectById(id));
}
}
if (geneSetIds != null) {
for (Long id : geneSetIds) {
genes.addAll(geneSetService.getGenesInGroup(new GeneSetValueObject(id)));
}
}
mav.addObject("text", format4File(genes, geneSetName));
watch.stop();
Long time = watch.getTime();
if (time > 100) {
log.info("Retrieved and Formated" + genes.size() + " genes in : " + time + " ms.");
}
return mav;
}
use of ubic.gemma.model.genome.gene.GeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetValueObjectHelperImpl method convertToValueObject.
@Override
public DatabaseBackedGeneSetValueObject convertToValueObject(GeneSet gs) {
if (gs == null)
return null;
DatabaseBackedGeneSetValueObject dbgsvo = convertToLightValueObject(gs);
Collection<Long> ids = EntityUtils.getIds(this.geneSetService.getGenesInGroup(new GeneSetValueObject(gs.getId())));
dbgsvo.getGeneIds().addAll(ids);
dbgsvo.setSize(ids.size());
return dbgsvo;
}
Aggregations