Search in sources :

Example 1 with BioAssaySet

use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.

the class DifferentialExpressionProbeResultEndpoint 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) {
    StopWatch watch = new StopWatch();
    watch.start();
    setLocalName(LOCAL_NAME);
    // taxon input
    Collection<String> taxonInput = getSingleNodeValue(requestElement, "taxon_id");
    String taxonId = "";
    for (String id : taxonInput) {
        taxonId = id;
    }
    Taxon taxon = taxonService.load(Long.parseLong(taxonId));
    if (taxon == null) {
        String msg = "No taxon with id, " + taxonId + ", can be found.";
        return buildBadResponse(document, msg);
    }
    // gene ids input
    Collection<String> geneInput = getArrayValues(requestElement, "gene_ids");
    Collection<Long> geneIDLong = new HashSet<Long>();
    for (String id : geneInput) geneIDLong.add(Long.parseLong(id));
    Collection<Gene> rawGeneCol = geneService.loadThawed(geneIDLong);
    if (rawGeneCol.isEmpty()) {
        String msg = "None of the gene id's can be found.";
        return buildBadResponse(document, msg);
    }
    Collection<Gene> geneCol = retainGenesInCorrectTaxon(rawGeneCol, taxon);
    if (geneCol == null || geneCol.isEmpty()) {
        String msg = "Input genes do not match input taxon.";
        return buildBadResponse(document, msg);
    }
    // expression experiment set id input
    Collection<String> analysisInput = getSingleNodeValue(requestElement, "expression_experiment_set_id");
    String analysisId = "";
    for (String id : analysisInput) {
        analysisId = id;
    }
    ExpressionExperimentSet ees = expressionExperimentSetService.load(Long.parseLong(analysisId));
    if (ees == null) {
        String msg = "No matching expression experiment set can be found for id, " + analysisId;
        return buildBadResponse(document, msg);
    }
    if (!(ees.getTaxon().getId()).equals(taxon.getId())) {
        String msg = "Expression experiment set " + analysisId + " does not match input taxon " + taxon.getCommonName();
        return buildBadResponse(document, msg);
    }
    Collection<ExpressionExperiment> eeCol = getExperiments(ees);
    Collection<BioAssaySet> bioAssaySets = new HashSet<BioAssaySet>();
    bioAssaySets.addAll(eeCol);
    // threshold input
    Collection<String> thresholdInput = getSingleNodeValue(requestElement, "threshold");
    String threshold = "";
    for (String id : thresholdInput) {
        threshold = id;
    }
    log.info("XML input read: " + geneInput.size() + " gene ids,  & taxon id " + taxonId + ", & expression experiment set id " + analysisId + ", and threshold " + threshold);
    Element responseWrapper = document.createElementNS(NAMESPACE_URI, LOCAL_NAME);
    Element responseElement = document.createElementNS(NAMESPACE_URI, LOCAL_NAME + RESPONSE);
    responseWrapper.appendChild(responseElement);
    for (Gene gene : geneCol) {
        Map<ExpressionExperimentValueObject, List<DifferentialExpressionValueObject>> results = differentialExpressionResultService.find(gene, EntityUtils.getIds(bioAssaySets), Double.parseDouble(threshold), null);
        for (ExpressionExperimentValueObject ee : results.keySet()) {
            // main call to the DifferentialExpressionAnalysisService to retrieve
            // DifferentialExpressionAnalysisResultSet collection
            Collection<DifferentialExpressionValueObject> parCol = results.get(ee);
            // check that a DifferentialExpressionAnalysisResult is not null
            if (parCol == null || parCol.isEmpty()) {
                log.error("No probe analysis results can be found for gene: " + gene.getOfficialSymbol() + " & experiment: " + ee);
                buildXMLResponse(document, responseElement, gene.getId().toString(), ee.getId().toString(), null);
            } else
                buildXMLResponse(document, responseElement, gene.getId().toString(), ee.getId().toString(), parCol);
        }
    }
    watch.stop();
    Long time = watch.getTime();
    log.info("XML response for differential expression probe results built in " + time + "ms.");
    return responseWrapper;
}
Also used : Taxon(ubic.gemma.model.genome.Taxon) Element(org.w3c.dom.Element) DifferentialExpressionValueObject(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionValueObject) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) StopWatch(org.apache.commons.lang3.time.StopWatch) Gene(ubic.gemma.model.genome.Gene) BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet)

Example 2 with BioAssaySet

use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.

the class AclAdvice method createOrUpdateAclSpecialCases.

@Override
protected void createOrUpdateAclSpecialCases(MutableAcl acl, Acl parentAcl, Sid sid, Securable object) {
    // If aclParent is passed to this method we overwrite it.
    if (SingleExperimentAnalysis.class.isAssignableFrom(object.getClass())) {
        SingleExperimentAnalysis experimentAnalysis = (SingleExperimentAnalysis) object;
        BioAssaySet bioAssaySet = experimentAnalysis.getExperimentAnalyzed();
        ObjectIdentity oi_temp = this.makeObjectIdentity(bioAssaySet);
        try {
            parentAcl = this.getAclService().readAclById(oi_temp);
        } catch (NotFoundException nfe) {
            // This is possible if making an EESubSet is part of the transaction.
            parentAcl = this.getAclService().createAcl(oi_temp);
        }
        acl.setEntriesInheriting(true);
        acl.setParent(parentAcl);
        // noinspection UnusedAssignment //Owner of the experiment owns analyses even if administrator ran them.
        sid = parentAcl.getOwner();
    }
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) SingleExperimentAnalysis(ubic.gemma.model.analysis.SingleExperimentAnalysis)

Example 3 with BioAssaySet

use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.

the class AffyDataFromCelCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception e = super.processCommandLine(args);
    if (e != null)
        return e;
    DataUpdater serv = this.getBean(DataUpdater.class);
    // This can be done for multiple experiments under some conditions; we get this one just  to test for some multi-platform situations
    Collection<ArrayDesign> arrayDesignsUsed = this.eeService.getArrayDesignsUsed(this.expressionExperiments.iterator().next());
    if (StringUtils.isNotBlank(aptFile)) {
        if (this.expressionExperiments.size() > 1) {
            throw new IllegalArgumentException("Can't use " + AffyDataFromCelCli.APT_FILE_OPT + " unless you are doing just one experiment");
        }
        ExpressionExperiment thawedEe = (ExpressionExperiment) this.expressionExperiments.iterator().next();
        thawedEe = this.eeService.thawLite(thawedEe);
        if (arrayDesignsUsed.size() > 1) {
            throw new IllegalArgumentException("Cannot use " + AffyDataFromCelCli.APT_FILE_OPT + " for experiment that uses multiple platforms");
        }
        ArrayDesign ad = arrayDesignsUsed.iterator().next();
        try {
            AbstractCLI.log.info("Loading data from " + aptFile);
            if ((ad.getTechnologyType().equals(TechnologyType.ONECOLOR) && GeoPlatform.isAffymetrixExonArray(ad.getShortName())) || ad.getName().toLowerCase().contains("exon")) {
                serv.addAffyExonArrayData(thawedEe, aptFile);
            } else if (ad.getTechnologyType().equals(TechnologyType.ONECOLOR) && ad.getName().toLowerCase().contains("affy")) {
                serv.addAffyData(thawedEe, aptFile);
            } else {
                throw new IllegalArgumentException("Option " + AffyDataFromCelCli.APT_FILE_OPT + " only valid if you are using an exon array.");
            }
        } catch (Exception exception) {
            return exception;
        }
        return null;
    }
    if (StringUtils.isNotBlank(cdfFile)) {
        if (arrayDesignsUsed.size() > 1) {
            throw new IllegalArgumentException("Cannot use " + AffyDataFromCelCli.CDF_FILE_OPT + " for experiment that uses multiple platforms");
        }
    }
    for (BioAssaySet ee : this.expressionExperiments) {
        try {
            Collection<ArrayDesign> adsUsed = this.eeService.getArrayDesignsUsed(ee);
            /*
                 * if the audit trail already has a DataReplacedEvent, skip it, unless --force. Ignore this for
                 * multiplatform studies (at our peril)
                 */
            if (adsUsed.size() == 1 && !force && this.checkForAlreadyDone(ee)) {
                AbstractCLI.log.warn(ee + ": Already has been recomputed from raw data, skipping (use 'force' to override')");
                this.errorObjects.add(ee + ": Already has been computed from raw data");
                continue;
            }
            ExpressionExperiment thawedEe = (ExpressionExperiment) ee;
            thawedEe = this.eeService.thawLite(thawedEe);
            ArrayDesign ad = adsUsed.iterator().next();
            /*
                 * Even if there are multiple platforms, we assume they are all the same type. If not, that's your
                 * problem :) (seriously, we could check...)
                 */
            if ((ad.getTechnologyType().equals(TechnologyType.ONECOLOR) && GeoPlatform.isAffymetrixExonArray(ad.getShortName())) || ad.getName().toLowerCase().contains("exon")) {
                AbstractCLI.log.info(thawedEe + " looks like affy exon array");
                serv.addAffyExonArrayData(thawedEe);
                this.successObjects.add(thawedEe.toString());
                AbstractCLI.log.info("Successfully processed: " + thawedEe);
            } else if (ad.getTechnologyType().equals(TechnologyType.ONECOLOR) && ad.getName().toLowerCase().contains("affy")) {
                AbstractCLI.log.info(thawedEe + " looks like a affy 3-prime array");
                serv.reprocessAffyThreePrimeArrayData(thawedEe);
                this.successObjects.add(thawedEe.toString());
                AbstractCLI.log.info("Successfully processed: " + thawedEe);
            } else {
                AbstractCLI.log.warn(ee + ": This CLI can only deal with Affymetrix platforms (exon or 3' probe designs)");
                this.errorObjects.add(ee + ": This CLI can only deal with Affymetrix platforms (exon or 3' probe designs)");
            }
        } catch (Exception exception) {
            AbstractCLI.log.error(exception, exception);
            this.errorObjects.add(ee + " " + exception.getLocalizedMessage());
        }
    }
    super.summarizeProcessing();
    return null;
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) DataUpdater(ubic.gemma.core.loader.expression.geo.DataUpdater) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 4 with BioAssaySet

use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.

the class DifferentialExpressionAnalysisCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception err = this.processCommandLine(args);
    if (err != null) {
        return err;
    }
    SecurityService securityService = this.getBean(SecurityService.class);
    for (BioAssaySet ee : expressionExperiments) {
        if (!(ee instanceof ExpressionExperiment)) {
            continue;
        }
        if (expressionExperiments.size() > 1) {
            AbstractCLI.log.info(">>>>>> Begin processing: " + ee);
        }
        /*
             * This is really only important when running as admin and in a batch mode.
             */
        AbstractCLI.log.debug(securityService.getOwner(ee));
        if (!securityService.isOwnedByCurrentUser(ee) && this.expressionExperiments.size() > 1) {
            AbstractCLI.log.warn("Experiment is not owned by current user, skipping: " + ee);
            continue;
        }
        this.processExperiment((ExpressionExperiment) ee);
    }
    this.summarizeProcessing();
    return null;
}
Also used : SecurityService(gemma.gsec.SecurityService) BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 5 with BioAssaySet

use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.

the class ProcessedDataComputeCLI method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception err = this.processCommandLine(args);
    if (err != null) {
        return err;
    }
    if (expressionExperiments.size() == 0) {
        AbstractCLI.log.error("You did not select any usable expression experiments");
        return null;
    }
    for (BioAssaySet ee : expressionExperiments) {
        this.processExperiment((ExpressionExperiment) ee);
    }
    this.summarizeProcessing();
    return null;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) PreprocessingException(ubic.gemma.core.analysis.preprocess.PreprocessingException)

Aggregations

BioAssaySet (ubic.gemma.model.expression.experiment.BioAssaySet)39 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)25 HashSet (java.util.HashSet)6 ExpressionExperimentSet (ubic.gemma.model.analysis.expression.ExpressionExperimentSet)6 Taxon (ubic.gemma.model.genome.Taxon)6 IOException (java.io.IOException)4 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)4 ArrayList (java.util.ArrayList)3 StopWatch (org.apache.commons.lang3.time.StopWatch)3 Transactional (org.springframework.transaction.annotation.Transactional)3 SecurityService (gemma.gsec.SecurityService)2 Element (org.w3c.dom.Element)2 PreprocessingException (ubic.gemma.core.analysis.preprocess.PreprocessingException)2 DataUpdater (ubic.gemma.core.loader.expression.geo.DataUpdater)2 DifferentialExpressionValueObject (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionValueObject)2 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)2 ExpressionExperimentSubSet (ubic.gemma.model.expression.experiment.ExpressionExperimentSubSet)2 ExpressionExperimentValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1