use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.
the class ExpressionExperimentSearchServiceImpl method searchExperimentsAndExperimentGroups.
@Override
public List<SearchResultDisplayObject> searchExperimentsAndExperimentGroups(String query, Long taxonId) {
List<SearchResultDisplayObject> displayResults = new LinkedList<>();
// session-bound sets (not autogen sets until handling of large searches is fixed)
if (StringUtils.isBlank(query)) {
return this.searchExperimentsAndExperimentGroupBlankQuery(taxonId);
}
Map<Class<?>, List<SearchResult>> results = this.initialSearch(query, taxonId);
List<SearchResultDisplayObject> experimentSets = this.getExpressionExperimentSetResults(results);
List<SearchResultDisplayObject> experiments = this.getExpressionExperimentResults(results);
if (experimentSets.isEmpty() && experiments.isEmpty()) {
return displayResults;
}
/*
* ALL RESULTS BY TAXON GROUPS
*/
// if >1 result, add a group whose members are all experiments returned from search
Map<Long, Set<Long>> eeIdsByTaxonId = new HashMap<>();
// add every individual experiment to the set, grouped by taxon and also altogether.
for (SearchResultDisplayObject srdo : experiments) {
// group by the Parent Taxon, for things like salmonid - see bug 3286
Long taxId;
if (srdo.getParentTaxonId() != null) {
taxId = srdo.getParentTaxonId();
} else {
taxId = srdo.getTaxonId();
}
if (!eeIdsByTaxonId.containsKey(taxId)) {
eeIdsByTaxonId.put(taxId, new HashSet<Long>());
}
ExpressionExperimentValueObject eevo = (ExpressionExperimentValueObject) srdo.getResultValueObject();
eeIdsByTaxonId.get(taxId).add(eevo.getId());
}
// for each group
for (SearchResultDisplayObject eesSRO : experimentSets) {
ExpressionExperimentSetValueObject set = (ExpressionExperimentSetValueObject) eesSRO.getResultValueObject();
/*
* This is security filtered.
*/
Collection<Long> ids = EntityUtils.getIds(expressionExperimentSetService.getExperimentValueObjectsInSet(set.getId()));
// to account for security filtering.
set.setSize(ids.size());
if (!eeIdsByTaxonId.containsKey(set.getTaxonId())) {
eeIdsByTaxonId.put(set.getTaxonId(), new HashSet<Long>());
}
eeIdsByTaxonId.get(set.getTaxonId()).addAll(ids);
}
// make an entry for each taxon
Long taxonId2;
for (Map.Entry<Long, Set<Long>> entry : eeIdsByTaxonId.entrySet()) {
taxonId2 = entry.getKey();
Taxon taxon = taxonService.load(taxonId2);
if (taxon != null && entry.getValue().size() > 0) {
FreeTextExpressionExperimentResultsValueObject ftvo = new FreeTextExpressionExperimentResultsValueObject("All " + taxon.getCommonName() + " results for '" + query + "'", "All " + taxon.getCommonName() + " experiments found for your query", taxon.getId(), taxon.getCommonName(), entry.getValue(), query);
int numWithDifferentialExpressionAnalysis = differentialExpressionAnalysisService.getExperimentsWithAnalysis(entry.getValue()).size();
assert numWithDifferentialExpressionAnalysis <= entry.getValue().size();
int numWithCoexpressionAnalysis = coexpressionAnalysisService.getExperimentsWithAnalysis(entry.getValue()).size();
ftvo.setNumWithCoexpressionAnalysis(numWithCoexpressionAnalysis);
ftvo.setNumWithDifferentialExpressionAnalysis(numWithDifferentialExpressionAnalysis);
displayResults.add(new SearchResultDisplayObject(ftvo));
}
}
displayResults.addAll(experimentSets);
displayResults.addAll(experiments);
if (displayResults.isEmpty()) {
ExpressionExperimentSearchServiceImpl.log.info("No results for search: " + query);
} else {
ExpressionExperimentSearchServiceImpl.log.info("Results for search: " + query + " size=" + displayResults.size() + " entry0: " + ((SearchResultDisplayObject) (displayResults.toArray())[0]).getName() + " valueObject:" + ((SearchResultDisplayObject) (displayResults.toArray())[0]).getResultValueObject().toString());
}
return displayResults;
}
use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.
the class ExpressionExperimentSetController method updateUserAndSessionGroups.
/**
* AJAX Updates the session group and user database groups.
*/
public Collection<ExpressionExperimentSetValueObject> updateUserAndSessionGroups(Collection<ExpressionExperimentSetValueObject> vos) {
Collection<ExpressionExperimentSetValueObject> updatedSets = new HashSet<>();
Collection<ExpressionExperimentSetValueObject> databaseCollection = new HashSet<>();
Collection<SessionBoundExpressionExperimentSetValueObject> sessionCollection = new HashSet<>();
for (ExpressionExperimentSetValueObject experimentSetValueObject : vos) {
if (experimentSetValueObject instanceof SessionBoundExpressionExperimentSetValueObject) {
sessionCollection.add((SessionBoundExpressionExperimentSetValueObject) experimentSetValueObject);
} else {
databaseCollection.add(experimentSetValueObject);
}
}
sessionCollection = this.updateSessionGroups(sessionCollection);
databaseCollection = this.update(databaseCollection);
updatedSets.addAll(sessionCollection);
updatedSets.addAll(databaseCollection);
return updatedSets;
}
use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.
the class ExpressionExperimentSetController method getExpressionExperimentSetFromRequest.
/**
* @throws IllegalArgumentException if a matching EE can't be loaded
*/
private ExpressionExperimentSetValueObject getExpressionExperimentSetFromRequest(HttpServletRequest request) {
ExpressionExperimentSetValueObject set;
Long id;
if (request.getParameter("id") != null) {
try {
id = Long.parseLong(request.getParameter("id"));
} catch (NumberFormatException e) {
throw new IllegalArgumentException("You must provide a valid numerical identifier");
}
set = expressionExperimentSetService.loadValueObjectById(id);
if (set == null) {
throw new IllegalArgumentException("Unable to access experiment set with id=" + id);
}
} else {
throw new IllegalArgumentException("You must provide an id");
}
return set;
}
use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.
the class ExpressionExperimentSetController method showExpressionExperimentSet.
@RequestMapping(value = "/showExpressionExperimentSet.html", method = RequestMethod.GET)
public ModelAndView showExpressionExperimentSet(HttpServletRequest request, HttpServletResponse response) {
ModelAndView mav = new ModelAndView("expressionExperimentSet.detail");
StopWatch timer = new StopWatch();
timer.start();
ExpressionExperimentSetValueObject eesvo = this.getExpressionExperimentSetFromRequest(request);
mav.addObject("eeSetId", eesvo.getId());
mav.addObject("eeSetName", eesvo.getName());
if (timer.getTime() > 200) {
log.info("Show experiment set was slow: id=" + eesvo.getId() + " " + timer.getTime() + "ms");
}
return mav;
}
use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.
the class ExpressionExperimentSetDaoImpl method fetchValueObjects.
/**
* @param ids, if null fetch all.
* @param loadEEIds whether the returned value object should have the ExpressionExperimentIds collection populated.
* This might be a useful information, but loading the IDs takes slightly longer, so for larger amount of
* EESets this might want to be avoided.
* @return EE set VOs
*/
private Collection<ExpressionExperimentSetValueObject> fetchValueObjects(Collection<Long> ids, boolean loadEEIds) {
Map<Long, ExpressionExperimentSetValueObject> vo = new LinkedHashMap<>();
Query queryObject = this.getLoadValueObjectsQueryString(ids);
List<?> list = queryObject.list();
for (Object object : list) {
Object[] res = (Object[]) object;
Long eeId = (Long) res[0];
assert eeId != null;
ExpressionExperimentSetValueObject v;
if (vo.containsKey(eeId)) {
v = vo.get(eeId);
} else {
v = new ExpressionExperimentSetValueObject(eeId);
vo.put(eeId, v);
}
v.setName((String) res[1]);
v.setDescription((String) res[2]);
v.setTaxonName((String) res[3]);
v.setTaxonId((Long) res[4]);
/*
* FIXME this is not adequate because these are not security filtered, so the count could be too high for
* the current user. We can avoid a lot of problems by not putting private data sets in public EE sets.
*/
v.setSize(((Long) res[5]).intValue());
// Add experiment ids
if (loadEEIds) {
v.setExpressionExperimentIds(this.getExperimentIdsInSet(eeId));
}
vo.put(eeId, v);
}
Collection<ExpressionExperimentSetValueObject> result = vo.values();
this.populateAnalysisInformation(result);
return result;
}
Aggregations