Search in sources :

Example 1 with TaskResult

use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.

the class DiffExMetaAnalyzerTaskImpl method execute.

@Override
public TaskResult execute() {
    GeneDifferentialExpressionMetaAnalysis metaAnalysis = this.diffExMetaAnalyzerService.analyze(taskCommand.getAnalysisResultSetIds());
    if (metaAnalysis != null) {
        metaAnalysis.setName(taskCommand.getName());
        metaAnalysis.setDescription(taskCommand.getDescription());
        if (taskCommand.isPersist()) {
            metaAnalysis = this.diffExMetaAnalyzerService.persist(metaAnalysis);
        }
    }
    GeneDifferentialExpressionMetaAnalysisDetailValueObject metaAnalysisVO = (metaAnalysis == null ? null : this.geneDiffExMetaAnalysisHelperService.convertToValueObject(metaAnalysis));
    return new TaskResult(taskCommand, metaAnalysisVO);
}
Also used : GeneDifferentialExpressionMetaAnalysis(ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysis) TaskResult(ubic.gemma.core.job.TaskResult) GeneDifferentialExpressionMetaAnalysisDetailValueObject(ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysisDetailValueObject)

Example 2 with TaskResult

use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.

the class ProcessedExpressionDataVectorCreateTaskImpl method execute.

@Override
public TaskResult execute() {
    ExpressionExperiment ee = taskCommand.getExpressionExperiment();
    Collection<ProcessedExpressionDataVector> processedVectors;
    if (taskCommand.isCorrelationMatrixOnly()) {
        // only create them if necessary. This is sort of stupid, it's just so I didn't have to create a whole other
        // task for the correlation matrix computation.
        processedVectors = processedExpressionDataVectorService.getProcessedDataVectors(ee);
        if (processedVectors.isEmpty()) {
            processedVectors = processedExpressionDataVectorService.computeProcessedExpressionData(ee);
        }
    } else {
        processedVectors = processedExpressionDataVectorService.computeProcessedExpressionData(ee);
    }
    coexpressionMatrixService.create(ee);
    return new TaskResult(taskCommand, processedVectors.size());
}
Also used : ProcessedExpressionDataVector(ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector) TaskResult(ubic.gemma.core.job.TaskResult) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 3 with TaskResult

use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.

the class TwoChannelMissingValueTaskImpl method execute.

@Override
public TaskResult execute() {
    ExpressionExperiment ee = taskCommand.getExpressionExperiment();
    Collection<RawExpressionDataVector> missingValueVectors = twoChannelMissingValues.computeMissingValues(ee, taskCommand.getS2n(), taskCommand.getExtraMissingValueIndicators());
    System.out.println("MVs: " + missingValueVectors.size());
    return new TaskResult(taskCommand, missingValueVectors.size());
}
Also used : RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) TaskResult(ubic.gemma.core.job.TaskResult) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 4 with TaskResult

use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.

the class CharacteristicUpdateTaskImpl method doUpdate.

private TaskResult doUpdate() {
    Collection<AnnotationValueObject> avos = taskCommand.getAnnotationValueObjects();
    if (avos.size() == 0)
        return new TaskResult(taskCommand, false);
    log.info("Updating " + avos.size() + " characteristics or uncharacterized factor values...");
    StopWatch timer = new StopWatch();
    timer.start();
    Collection<Characteristic> asChars = convertToCharacteristic(avos);
    Collection<FactorValue> factorValues = convertToFactorValuesWithCharacteristics(avos);
    if (asChars.size() == 0 && factorValues.size() == 0) {
        log.info("Nothing to update");
        return new TaskResult(taskCommand, false);
    }
    for (FactorValue factorValue : factorValues) {
        factorValueService.update(factorValue);
    }
    if (asChars.size() == 0)
        return new TaskResult(taskCommand, true);
    Map<Characteristic, Object> charToParent = characteristicService.getParents(asChars);
    for (Characteristic cFromClient : asChars) {
        Long characteristicId = cFromClient.getId();
        if (characteristicId == null) {
            continue;
        }
        Characteristic cFromDatabase = characteristicService.load(characteristicId);
        if (cFromDatabase == null) {
            log.warn("No such characteristic with id=" + characteristicId);
            continue;
        }
        VocabCharacteristic vcFromClient = (cFromClient instanceof VocabCharacteristic) ? (VocabCharacteristic) cFromClient : null;
        VocabCharacteristic vcFromDatabase = (cFromDatabase instanceof VocabCharacteristic) ? (VocabCharacteristic) cFromDatabase : null;
        /*
             * if one of the characteristics is a VocabCharacteristic and the other is not, we have to change the
             * characteristic in the database so that it matches the one from the client; since we can't change the
             * class of the object, we have to remove the old characteristic and make a new one of the appropriate
             * class.
             */
        Object parent = charToParent.get(cFromDatabase);
        /*
             * Check needed because Characteristics are not securable.
             */
        if (parent != null && Securable.class.isAssignableFrom(parent.getClass()) && !securityService.isEditable((Securable) parent)) {
            throw new AccessDeniedException("Access is denied");
        }
        if (vcFromClient != null && vcFromDatabase == null) {
            VocabCharacteristic vc = VocabCharacteristic.Factory.newInstance();
            vc.setValue(StringUtils.strip(cFromDatabase.getValue()));
            vc.setEvidenceCode(cFromDatabase.getEvidenceCode());
            vc.setDescription(cFromDatabase.getDescription());
            vc.setCategory(cFromDatabase.getCategory());
            vc.setName(cFromDatabase.getName());
            vcFromDatabase = (VocabCharacteristic) characteristicService.create(vc);
            removeFromParent(cFromDatabase, parent);
            characteristicService.remove(cFromDatabase);
            addToParent(vcFromDatabase, parent);
            cFromDatabase = vcFromDatabase;
        } else if (vcFromClient == null && vcFromDatabase != null) {
            // don't copy AuditTrail or Status to avoid cascade error... vcFromDatabase.getAuditTrail()
            cFromDatabase = characteristicService.create(Characteristic.Factory.newInstance(vcFromDatabase.getName(), vcFromDatabase.getDescription(), null, StringUtils.strip(vcFromDatabase.getValue()), vcFromDatabase.getCategory(), vcFromDatabase.getCategoryUri(), vcFromDatabase.getEvidenceCode()));
            removeFromParent(vcFromDatabase, parent);
            characteristicService.remove(vcFromDatabase);
            addToParent(cFromDatabase, parent);
        }
        /*
             * at this point, cFromDatabase points to the class-corrected characteristic in the database that must be
             * updated with the information coming from the client.
             */
        assert cFromDatabase != null;
        cFromDatabase.setValue(cFromClient.getValue());
        cFromDatabase.setCategory(cFromClient.getCategory());
        if (cFromDatabase instanceof VocabCharacteristic) {
            vcFromDatabase = (VocabCharacteristic) cFromDatabase;
            if (vcFromClient != null) {
                if (vcFromDatabase.getValueUri() == null || vcFromDatabase.getValueUri() == null || !vcFromDatabase.getValueUri().equals(vcFromClient.getValueUri())) {
                    log.info("Characteristic value update: " + vcFromDatabase + " " + vcFromDatabase.getValueUri() + " -> " + vcFromClient.getValueUri() + " associated with " + parent);
                    vcFromDatabase.setValueUri(vcFromClient.getValueUri());
                }
                if (vcFromDatabase.getCategory() == null || vcFromDatabase.getCategoryUri() == null || !vcFromDatabase.getCategoryUri().equals(vcFromClient.getCategoryUri())) {
                    log.info("Characteristic category update: " + vcFromDatabase + " " + vcFromDatabase.getCategoryUri() + " -> " + vcFromClient.getCategoryUri() + " associated with " + parent);
                    vcFromDatabase.setCategoryUri(vcFromClient.getCategoryUri());
                }
            }
        }
        if (cFromClient.getEvidenceCode() == null) {
            // characteristic has been manually updated
            cFromDatabase.setEvidenceCode(GOEvidenceCode.IC);
        } else {
            if (!cFromDatabase.getEvidenceCode().equals(cFromClient.getEvidenceCode())) {
                log.info("Characteristic evidence code update: " + cFromDatabase + " " + cFromDatabase.getEvidenceCode() + " -> " + cFromClient.getEvidenceCode());
            }
            // let them change it.
            cFromDatabase.setEvidenceCode(cFromClient.getEvidenceCode());
        }
        characteristicService.update(cFromDatabase);
    }
    timer.stop();
    if (timer.getTime() > 1000) {
        log.info("Update took: " + timer.getTime());
    }
    return new TaskResult(taskCommand, true);
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) AnnotationValueObject(ubic.gemma.model.common.description.AnnotationValueObject) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) StopWatch(org.apache.commons.lang3.time.StopWatch) TaskResult(ubic.gemma.core.job.TaskResult) AnnotationValueObject(ubic.gemma.model.common.description.AnnotationValueObject)

Example 5 with TaskResult

use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.

the class ArrayDesignProbeMapperTaskImpl method execute.

@Override
public TaskResult execute() {
    ArrayDesign ad = taskCommand.getArrayDesign();
    arrayDesignProbeMapperService.processArrayDesign(ad);
    return new TaskResult(taskCommand, null);
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) TaskResult(ubic.gemma.core.job.TaskResult)

Aggregations

TaskResult (ubic.gemma.core.job.TaskResult)14 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)3 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)3 Date (java.util.Date)2 HashSet (java.util.HashSet)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 RedirectView (org.springframework.web.servlet.view.RedirectView)2 AnnotationValueObject (ubic.gemma.model.common.description.AnnotationValueObject)2 Characteristic (ubic.gemma.model.common.description.Characteristic)2 VocabCharacteristic (ubic.gemma.model.common.description.VocabCharacteristic)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Queue (java.util.Queue)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1 View (org.springframework.web.servlet.View)1 RepeatScan (ubic.gemma.core.analysis.sequence.RepeatScan)1 EmailNotificationContext (ubic.gemma.core.job.EmailNotificationContext)1 SubmittedTask (ubic.gemma.core.job.SubmittedTask)1