use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.
the class ExpressionExperimentSetDaoImpl method populateAnalysisInformation.
private void populateAnalysisInformation(Collection<ExpressionExperimentSetValueObject> vo) {
if (vo.isEmpty()) {
return;
}
Map<Long, ExpressionExperimentSetValueObject> idMap = EntityUtils.getIdMap(vo);
StopWatch timer = new StopWatch();
timer.start();
// noinspection unchecked
List<Object[]> withCoexp = this.getSessionFactory().getCurrentSession().createQuery("select e.id, count(an) from ExpressionExperimentSet e, CoexpressionAnalysis an join e.experiments ea " + "where an.experimentAnalyzed = ea and e.id in (:ids) group by e.id").setParameterList("ids", idMap.keySet()).list();
for (Object[] oa : withCoexp) {
Long id = (Long) oa[0];
Integer c = ((Long) oa[1]).intValue();
idMap.get(id).setNumWithCoexpressionAnalysis(c);
}
/*
* We're counting the number of data sets that have analyses, not the number of analyses (since a data set can
* have more than one)
*/
// noinspection unchecked
List<Object[]> withDiffEx = this.getSessionFactory().getCurrentSession().createQuery("select e.id, count(distinct an.experimentAnalyzed) " + "from ExpressionExperimentSet e, DifferentialExpressionAnalysis an join e.experiments ea " + "where an.experimentAnalyzed = ea and e.id in (:ids) group by e.id").setParameterList("ids", idMap.keySet()).list();
for (Object[] oa : withDiffEx) {
Long id = (Long) oa[0];
Integer c = ((Long) oa[1]).intValue();
assert c <= idMap.get(id).getSize();
idMap.get(id).setNumWithDifferentialExpressionAnalysis(c);
}
if (timer.getTime() > 200) {
AbstractDao.log.info("Fetch analysis counts for " + vo.size() + " ee sets: " + timer.getTime() + "ms");
}
}
use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.
the class ExpressionExperimentSearchServiceImpl method getAllTaxonExperimentGroup.
@Override
public List<SearchResultDisplayObject> getAllTaxonExperimentGroup(Long taxonId) {
List<SearchResultDisplayObject> setResults = new LinkedList<>();
Taxon taxon = taxonService.load(taxonId);
Collection<ExpressionExperimentSet> sets = expressionExperimentSetService.findByName("Master set for " + taxon.getCommonName().toLowerCase());
SearchResultDisplayObject newSRDO;
for (ExpressionExperimentSet set : sets) {
expressionExperimentSetService.thaw(set);
if (set.getTaxon().getId().equals(taxonId)) {
ExpressionExperimentSetValueObject eevo = expressionExperimentSetService.loadValueObject(set);
newSRDO = new SearchResultDisplayObject(eevo);
newSRDO.setUserOwned(securityService.isPrivate(set));
((ExpressionExperimentSetValueObject) newSRDO.getResultValueObject()).setIsPublic(securityService.isPublic(set));
setResults.add(newSRDO);
}
}
Collections.sort(setResults);
return setResults;
}
use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.
the class ExpressionExperimentSearchServiceImpl method searchExperimentsAndExperimentGroupBlankQuery.
/**
* if query is blank, return list of public sets, user-owned sets (if logged in) and user's recent session-bound
* sets called by ubic.gemma.web.controller .expression.experiment.ExpressionExperimentController.
* searchExperimentsAndExperimentGroup(String, Long) does not include session bound sets
*/
private List<SearchResultDisplayObject> searchExperimentsAndExperimentGroupBlankQuery(Long taxonId) {
boolean taxonLimited = taxonId != null;
List<SearchResultDisplayObject> displayResults = new LinkedList<>();
// These are widely considered to be the most important results and
// therefore need to be at the top
List<SearchResultDisplayObject> masterResults = new LinkedList<>();
Collection<ExpressionExperimentSetValueObject> evos = expressionExperimentSetService.loadAllExperimentSetValueObjects(true);
for (ExpressionExperimentSetValueObject evo : evos) {
if (taxonLimited && !evo.getTaxonId().equals(taxonId)) {
continue;
}
SearchResultDisplayObject srdvo = new SearchResultDisplayObject(evo);
if (evo.getName().startsWith(ExpressionExperimentSearchServiceImpl.MASTER_SET_PREFIX)) {
masterResults.add(srdvo);
} else {
displayResults.add(srdvo);
}
}
Collections.sort(displayResults);
// should we also sort by which species is most important(humans obviously) or is that not politically
// correct???
displayResults.addAll(0, masterResults);
return displayResults;
}
use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.
the class SearchResultDisplayObject method setValues.
/**
* this method does not set the publik variable for the returned object (cannot autowire security service from here)
*
* @param searchResult search result
*/
private void setValues(SearchResult searchResult) {
// if it's a search result, grab the underlying object
Class<?> searchResultClass = searchResult.getResultClass();
// class-specific construction
if (searchResult.getResultObject() instanceof GeneValueObject) {
GeneValueObject gene = (GeneValueObject) searchResult.getResultObject();
this.setValues(gene);
} else if (searchResult.getResultObject() instanceof Gene) {
Gene gene = (Gene) searchResult.getResultObject();
this.setValues(gene);
} else if (searchResult.getResultObject() instanceof GeneSetValueObject) {
GeneSetValueObject geneSet = (GeneSetValueObject) searchResult.getResultObject();
this.setValues(geneSet);
} else if (searchResult.getResultObject() instanceof ExpressionExperimentValueObject) {
ExpressionExperimentValueObject ee = (ExpressionExperimentValueObject) searchResult.getResultObject();
this.setValues(ee);
} else if (searchResult.getResultObject() instanceof ExpressionExperimentSetValueObject) {
ExpressionExperimentSetValueObject eeSet = (ExpressionExperimentSetValueObject) searchResult.getResultObject();
this.setValues(eeSet);
} else {
this.isGroup = false;
this.size = -1;
this.taxonId = (long) -1;
this.taxonName = "unknown";
this.name = "Unhandled type";
this.description = "Unhandled result type: " + searchResultClass;
this.memberIds = null;
}
}
use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.
the class ExpressionExperimentSetController method load.
/**
* AJAX
*
* @param id of the set
* @return the ExpressionExperimentSetValueObject for the id param
* @throws IllegalArgumentException if the id param is null
* @throws AccessDeniedException if the id param is not null but the loading function returns a null value
*/
public ExpressionExperimentSetValueObject load(Long id) {
if (id == null) {
throw new IllegalArgumentException("Cannot load an experiment set with a null id.");
}
Collection<Long> ids = new ArrayList<>(1);
ids.add(id);
Collection<ExpressionExperimentSetValueObject> sets = expressionExperimentSetService.loadValueObjectsByIds(ids);
// security.
if (sets == null || sets.isEmpty()) {
throw new AccessDeniedException("No experiment set exists with id=" + id + " or you do not have permission to access it.");
} else if (sets.size() > 1) {
// this really shouldn't happen
throw new AccessDeniedException("More than one experiment set exists with id=" + id + ".");
}
return sets.iterator().next();
}
Aggregations