Search in sources :

Example 11 with AuditEventType

use of ubic.gemma.model.common.auditAndSecurity.eventType.AuditEventType in project Gemma by PavlidisLab.

the class ExperimentPlatformSwitchHelperServiceImpl method audit.

private void audit(ExpressionExperiment ee, String note) {
    AuditEventType eventType = ExpressionExperimentPlatformSwitchEvent.Factory.newInstance();
    auditTrailService.addUpdateEvent(ee, eventType, note);
}
Also used : AuditEventType(ubic.gemma.model.common.auditAndSecurity.eventType.AuditEventType)

Example 12 with AuditEventType

use of ubic.gemma.model.common.auditAndSecurity.eventType.AuditEventType in project Gemma by PavlidisLab.

the class DataUpdater method addAffyExonArrayData.

/**
 * Use when we want to avoid downloading the CEL files etc. For example if GEO doesn't have them and we ran
 * apt-probeset-summarize ourselves. Must be single-platform
 *
 * @param ee                  ee
 * @param pathToAptOutputFile file
 */
public void addAffyExonArrayData(ExpressionExperiment ee, String pathToAptOutputFile) throws IOException {
    Collection<ArrayDesign> ads = experimentService.getArrayDesignsUsed(ee);
    if (ads.size() > 1) {
        throw new IllegalArgumentException("Can't handle experiments with more than one platform when passing APT output file");
    }
    ArrayDesign ad = ads.iterator().next();
    ad = arrayDesignService.thaw(ad);
    ee = experimentService.thawLite(ee);
    Taxon primaryTaxon = ad.getPrimaryTaxon();
    ArrayDesign targetPlatform = this.prepareTargetPlatformForExonArrays(primaryTaxon);
    AffyPowerToolsProbesetSummarize apt = new AffyPowerToolsProbesetSummarize();
    Collection<RawExpressionDataVector> vectors = apt.processData(ee, pathToAptOutputFile, targetPlatform);
    if (vectors.isEmpty()) {
        throw new IllegalStateException("No vectors were returned for " + ee);
    }
    experimentService.replaceRawVectors(ee, vectors);
    if (!targetPlatform.equals(ad)) {
        AuditEventType eventType = ExpressionExperimentPlatformSwitchEvent.Factory.newInstance();
        auditTrailService.addUpdateEvent(ee, eventType, "Switched in course of updating vectors using AffyPowerTools (from " + ad.getShortName() + " to " + targetPlatform.getShortName() + ")");
    }
    this.audit(ee, "Data vector input from APT output file " + pathToAptOutputFile + " on " + targetPlatform, true);
    this.postprocess(ee);
}
Also used : RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) AuditEventType(ubic.gemma.model.common.auditAndSecurity.eventType.AuditEventType) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Taxon(ubic.gemma.model.genome.Taxon) AffyPowerToolsProbesetSummarize(ubic.gemma.core.loader.expression.AffyPowerToolsProbesetSummarize)

Example 13 with AuditEventType

use of ubic.gemma.model.common.auditAndSecurity.eventType.AuditEventType in project Gemma by PavlidisLab.

the class DataUpdater method addAffyExonArrayData.

/**
 * Replaces any existing "preferred" data. Must be a single-platform study
 *
 * @param ee ee
 * @param ad ad
 */
// Possible external use
@SuppressWarnings({ "unused", "WeakerAccess" })
public void addAffyExonArrayData(ExpressionExperiment ee, ArrayDesign ad) {
    RawDataFetcher f = new RawDataFetcher();
    Collection<LocalFile> files = f.fetch(ee.getAccession().getAccession());
    if (files.isEmpty()) {
        throw new RuntimeException("Data was apparently not available");
    }
    ad = arrayDesignService.thaw(ad);
    ee = experimentService.thawLite(ee);
    Taxon primaryTaxon = ad.getPrimaryTaxon();
    ArrayDesign targetPlatform = this.prepareTargetPlatformForExonArrays(primaryTaxon);
    assert !targetPlatform.getCompositeSequences().isEmpty();
    AffyPowerToolsProbesetSummarize apt = new AffyPowerToolsProbesetSummarize();
    Collection<RawExpressionDataVector> vectors = apt.processExonArrayData(ee, targetPlatform, files);
    if (vectors.isEmpty()) {
        throw new IllegalStateException("No vectors were returned for " + ee);
    }
    ee = experimentService.replaceRawVectors(ee, vectors);
    if (!targetPlatform.equals(ad)) {
        AuditEventType eventType = ExpressionExperimentPlatformSwitchEvent.Factory.newInstance();
        auditTrailService.addUpdateEvent(ee, eventType, "Switched in course of updating vectors using AffyPowerTools (from " + ad.getShortName() + " to " + targetPlatform.getShortName() + ")");
    }
    this.audit(ee, "Data vector computation from CEL files using AffyPowerTools for " + targetPlatform, true);
    this.postprocess(ee);
}
Also used : LocalFile(ubic.gemma.model.common.description.LocalFile) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) AuditEventType(ubic.gemma.model.common.auditAndSecurity.eventType.AuditEventType) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Taxon(ubic.gemma.model.genome.Taxon) AffyPowerToolsProbesetSummarize(ubic.gemma.core.loader.expression.AffyPowerToolsProbesetSummarize) RawDataFetcher(ubic.gemma.core.loader.expression.geo.fetcher.RawDataFetcher)

Example 14 with AuditEventType

use of ubic.gemma.model.common.auditAndSecurity.eventType.AuditEventType in project Gemma by PavlidisLab.

the class DataUpdater method replaceData.

/**
 * Replace the data associated with the experiment (or add it if there is none). These data become the 'preferred'
 * quantitation type. Note that this replaces the "raw" data.
 * Similar to AffyPowerToolsProbesetSummarize.convertDesignElementDataVectors and code in
 * SimpleExpressionDataLoaderService.
 *
 * @param ee             the experiment to be modified
 * @param targetPlatform the platform for the new data (this can only be used for single-platform data sets)
 * @param data           the data to be used
 * @return ee
 */
public ExpressionExperiment replaceData(ExpressionExperiment ee, ArrayDesign targetPlatform, ExpressionDataDoubleMatrix data) {
    Collection<ArrayDesign> ads = experimentService.getArrayDesignsUsed(ee);
    if (ads.size() > 1) {
        throw new IllegalArgumentException("Can only replace data for an experiment that uses one platform; " + "you must switch/merge first and then provide appropriate replacement data.");
    }
    if (data.rows() == 0) {
        throw new IllegalArgumentException("Data had no rows");
    }
    ArrayDesign originalArrayDesign = ads.iterator().next();
    Collection<QuantitationType> qts = data.getQuantitationTypes();
    if (qts.size() > 1) {
        throw new IllegalArgumentException("Only supports a single quantitation type");
    }
    if (qts.isEmpty()) {
        throw new IllegalArgumentException("Please supply a quantitation type with the data");
    }
    QuantitationType qt = qts.iterator().next();
    qt.setIsPreferred(true);
    Collection<RawExpressionDataVector> vectors = this.makeNewVectors(ee, targetPlatform, data, qt);
    if (vectors.isEmpty()) {
        throw new IllegalStateException("no vectors!");
    }
    /*
         * remove all analyses, etc.
         */
    analysisUtilService.deleteOldAnalyses(ee);
    ee = experimentService.replaceRawVectors(ee, vectors);
    // audit if we switched platforms.
    if (!targetPlatform.equals(originalArrayDesign)) {
        AuditEventType eventType = ExpressionExperimentPlatformSwitchEvent.Factory.newInstance();
        auditTrailService.addUpdateEvent(ee, eventType, "Switched in course of updating vectors using data input (from " + originalArrayDesign.getShortName() + " to " + targetPlatform.getShortName() + ")");
    }
    this.audit(ee, "Data vector replacement for " + targetPlatform, true);
    experimentService.update(ee);
    ee = this.postprocess(ee);
    assert ee.getNumberOfDataVectors() != null;
    // debug code.
    for (BioAssay ba : ee.getBioAssays()) {
        assert ba.getArrayDesignUsed().equals(targetPlatform);
    }
    return ee;
}
Also used : RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) AuditEventType(ubic.gemma.model.common.auditAndSecurity.eventType.AuditEventType) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 15 with AuditEventType

use of ubic.gemma.model.common.auditAndSecurity.eventType.AuditEventType in project Gemma by PavlidisLab.

the class DataUpdater method audit.

/**
 * @param replace if true, use a DataReplacedEvent; otherwise DataAddedEvent.
 * @param ee      ee
 * @param note    note
 */
private void audit(ExpressionExperiment ee, String note, boolean replace) {
    AuditEventType eventType;
    if (replace) {
        eventType = DataReplacedEvent.Factory.newInstance();
    } else {
        eventType = DataAddedEvent.Factory.newInstance();
    }
    auditTrailService.addUpdateEvent(ee, eventType, note);
}
Also used : AuditEventType(ubic.gemma.model.common.auditAndSecurity.eventType.AuditEventType)

Aggregations

AuditEventType (ubic.gemma.model.common.auditAndSecurity.eventType.AuditEventType)22 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)5 AuditEvent (ubic.gemma.model.common.auditAndSecurity.AuditEvent)3 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)3 AffyPowerToolsProbesetSummarize (ubic.gemma.core.loader.expression.AffyPowerToolsProbesetSummarize)2 AuditTrail (ubic.gemma.model.common.auditAndSecurity.AuditTrail)2 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)2 Taxon (ubic.gemma.model.genome.Taxon)2 AuditTrailService (ubic.gemma.persistence.service.common.auditAndSecurity.AuditTrailService)2 SecurityService (gemma.gsec.SecurityService)1 Method (java.lang.reflect.Method)1 Date (java.util.Date)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1 Query (org.hibernate.Query)1 Test (org.junit.Test)1 Transactional (org.springframework.transaction.annotation.Transactional)1 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)1 RawDataFetcher (ubic.gemma.core.loader.expression.geo.fetcher.RawDataFetcher)1 Auditable (ubic.gemma.model.common.Auditable)1 AuditEventValueObject (ubic.gemma.model.common.auditAndSecurity.AuditEventValueObject)1