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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations