Search in sources :

Example 6 with ExpressionExperimentSetValueObject

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");
    }
}
Also used : ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) StopWatch(org.apache.commons.lang3.time.StopWatch)

Example 7 with ExpressionExperimentSetValueObject

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;
}
Also used : ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) Taxon(ubic.gemma.model.genome.Taxon) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) SearchResultDisplayObject(ubic.gemma.core.search.SearchResultDisplayObject)

Example 8 with ExpressionExperimentSetValueObject

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;
}
Also used : ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) SearchResultDisplayObject(ubic.gemma.core.search.SearchResultDisplayObject)

Example 9 with ExpressionExperimentSetValueObject

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;
    }
}
Also used : ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) Gene(ubic.gemma.model.genome.Gene) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) SessionBoundGeneSetValueObject(ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject) GeneSetValueObject(ubic.gemma.model.genome.gene.GeneSetValueObject)

Example 10 with ExpressionExperimentSetValueObject

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();
}
Also used : SessionBoundExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.SessionBoundExpressionExperimentSetValueObject) ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) AccessDeniedException(org.springframework.security.access.AccessDeniedException) ArrayList(java.util.ArrayList)

Aggregations

ExpressionExperimentSetValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject)15 SessionBoundExpressionExperimentSetValueObject (ubic.gemma.model.expression.experiment.SessionBoundExpressionExperimentSetValueObject)8 HashSet (java.util.HashSet)5 ExpressionExperimentValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject)4 StopWatch (org.apache.commons.lang3.time.StopWatch)3 SearchResultDisplayObject (ubic.gemma.core.search.SearchResultDisplayObject)3 ExpressionExperimentSet (ubic.gemma.model.analysis.expression.ExpressionExperimentSet)3 AccessDeniedException (org.springframework.security.access.AccessDeniedException)2 Taxon (ubic.gemma.model.genome.Taxon)2 ArrayList (java.util.ArrayList)1 Query (org.hibernate.Query)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 Element (org.w3c.dom.Element)1 SessionBoundGeneSetValueObject (ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject)1 FreeTextExpressionExperimentResultsValueObject (ubic.gemma.model.expression.experiment.FreeTextExpressionExperimentResultsValueObject)1 Gene (ubic.gemma.model.genome.Gene)1 GeneSetValueObject (ubic.gemma.model.genome.gene.GeneSetValueObject)1 GeneValueObject (ubic.gemma.model.genome.gene.GeneValueObject)1