Search in sources :

Example 16 with ExpressionExperimentSet

use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.

the class ExpressionExperimentSetController method create.

public Collection<ExpressionExperimentSetValueObject> create(Collection<ExpressionExperimentSetValueObject> entities) {
    Collection<Long> eeSetIds = new HashSet<>();
    for (ExpressionExperimentSetValueObject ees : entities) {
        if (ees.getExpressionExperimentIds() == null || ees.getExpressionExperimentIds().isEmpty()) {
            throw new IllegalArgumentException("No expression experiment ids provided. Cannot save an empty set.");
        }
        ExpressionExperimentSet newEESet = this.create(ees);
        eeSetIds.add(newEESet.getId());
    }
    return this.expressionExperimentSetService.loadValueObjectsByIds(eeSetIds);
}
Also used : SessionBoundExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.SessionBoundExpressionExperimentSetValueObject) ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) HashSet(java.util.HashSet)

Example 17 with ExpressionExperimentSet

use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.

the class GeneCoexpressionSearchEndpoint method invokeInternal.

/**
 * Reads the given <code>requestElement</code>, and sends a the response back.
 *
 * @param requestElement the contents of the SOAP message as DOM elements
 * @param document       a DOM document to be used for constructing <code>Node</code>s
 * @return the response element
 */
@Override
protected Element invokeInternal(Element requestElement, Document document) {
    try {
        StopWatch watch = new StopWatch();
        watch.start();
        setLocalName(LOCAL_NAME);
        String queryGeneId = getNodeValue(requestElement, "query_gene_id");
        String pairQueryGeneId = getOptionalNodeValue(requestElement, "pair_query_gene_id");
        String stringency = getNodeValue(requestElement, "stringency");
        Collection<Gene> queryGenes = new LinkedList<>();
        Gene queryGene = geneService.findByNCBIId(Integer.parseInt(queryGeneId));
        if (queryGene == null) {
            String msg = "Query gene with id [" + queryGeneId + "] cannot be found.";
            return buildBadResponse(document, msg);
        }
        queryGenes.add(queryGene);
        if (pairQueryGeneId != null) {
            Gene queryGene2 = geneService.findByNCBIId(Integer.parseInt(pairQueryGeneId));
            if (queryGene2 == null) {
                String msg = "Query gene with id [" + pairQueryGeneId + "] cannot be found.";
                return buildBadResponse(document, msg);
            }
            queryGenes.add(queryGene2);
        }
        Collection<ExpressionExperimentSet> eeSets = expressionExperimentSetService.findByName("All mouse");
        // .load(5662l); // uses 'All mouse' by default.
        ExpressionExperimentSet eeSet = eeSets.iterator().next();
        Collection<BioAssaySet> experiments = eeSet.getExperiments();
        Collection<Long> inputEeIds = new ArrayList<>();
        for (BioAssaySet e : experiments) {
            inputEeIds.add(e.getId());
        }
        CoexpressionMetaValueObject metaVO;
        if (pairQueryGeneId == null) {
            metaVO = geneCoexpressionSearchService.coexpressionSearch(inputEeIds, EntityUtils.getIds(queryGenes), Integer.valueOf(stringency), MAX_RESULTS, false);
        } else {
            metaVO = geneCoexpressionSearchService.coexpressionSearch(inputEeIds, EntityUtils.getIds(queryGenes), Integer.valueOf(stringency), MAX_RESULTS, true);
        }
        Collection<CoexpressionValueObjectExt> coexpressedGenes = metaVO.getResults();
        if (coexpressedGenes.isEmpty()) {
            String msg = "No coexpressed genes found.";
            return buildBadResponse(document, msg);
        }
        Element responseWrapper = document.createElementNS(NAMESPACE_URI, LOCAL_NAME);
        Element responseElement = document.createElementNS(NAMESPACE_URI, LOCAL_NAME + RESPONSE);
        responseWrapper.appendChild(responseElement);
        for (CoexpressionValueObjectExt cvo : coexpressedGenes) {
            Element item = document.createElement("CoexpressionSearchResult");
            Element foundGeneElement = document.createElement("found_gene_id");
            foundGeneElement.appendChild(document.createTextNode(cvo.getFoundGene().getNcbiId() == null ? "" : cvo.getFoundGene().getNcbiId().toString()));
            item.appendChild(foundGeneElement);
            Element numExperimentsElement = document.createElement("num_experiments_tested");
            numExperimentsElement.appendChild(document.createTextNode(cvo.getNumTestedIn().toString()));
            item.appendChild(numExperimentsElement);
            Element numCoexpressedElement = document.createElement("num_experiments_coexpressed");
            numCoexpressedElement.appendChild(document.createTextNode(String.valueOf(cvo.getSupportingExperiments().size())));
            item.appendChild(numCoexpressedElement);
            Element gemmaURL = document.createElement("gemma_details_url");
            gemmaURL.appendChild(document.createTextNode(Settings.getBaseUrl() + "searchCoexpression.html?g=" + queryGene.getId() + "," + cvo.getFoundGene().getId() + "&s=" + stringency + "&t=2&q&a=5662&an=All%20mouse"));
            item.appendChild(gemmaURL);
            responseElement.appendChild(item);
        }
        watch.stop();
        Long time = watch.getTime();
        if (time > 1000) {
            log.info("XML response for " + coexpressedGenes.size() + " results built in " + time + "ms.");
        }
        return responseWrapper;
    } catch (Exception e) {
        return buildBadResponse(document, e.getMessage());
    }
}
Also used : Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) StopWatch(org.apache.commons.lang3.time.StopWatch) CoexpressionMetaValueObject(ubic.gemma.core.analysis.expression.coexpression.CoexpressionMetaValueObject) Gene(ubic.gemma.model.genome.Gene) BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) CoexpressionValueObjectExt(ubic.gemma.core.analysis.expression.coexpression.CoexpressionValueObjectExt)

Example 18 with ExpressionExperimentSet

use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.

the class SessionListManagerImpl method getExperimentIdsInSet.

@Override
public Collection<Long> getExperimentIdsInSet(Long id) {
    // secure
    ExpressionExperimentSet eeSet = expressionExperimentSetService.load(id);
    // Not secure.
    Collection<BioAssaySet> datasets = eeSet.getExperiments();
    Collection<Long> eeids = new HashSet<>();
    for (BioAssaySet ee : datasets) {
        eeids.add(ee.getId());
    }
    return eeids;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) HashSet(java.util.HashSet)

Aggregations

ExpressionExperimentSet (ubic.gemma.model.analysis.expression.ExpressionExperimentSet)18 HashSet (java.util.HashSet)6 Transactional (org.springframework.transaction.annotation.Transactional)6 BioAssaySet (ubic.gemma.model.expression.experiment.BioAssaySet)6 Taxon (ubic.gemma.model.genome.Taxon)6 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)4 Test (org.junit.Test)3 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)3 Gene (ubic.gemma.model.genome.Gene)3 ArrayList (java.util.ArrayList)2 StopWatch (org.apache.commons.lang3.time.StopWatch)2 Element (org.w3c.dom.Element)2 ExpressionExperimentSetValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject)2 AclObjectIdentity (gemma.gsec.acl.domain.AclObjectIdentity)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 LinkedList (java.util.LinkedList)1 Acl (org.springframework.security.acls.model.Acl)1 CoexpressionMetaValueObject (ubic.gemma.core.analysis.expression.coexpression.CoexpressionMetaValueObject)1 CoexpressionValueObjectExt (ubic.gemma.core.analysis.expression.coexpression.CoexpressionValueObjectExt)1