Search in sources :

Example 1 with GeneDifferentialExpressionMetaAnalysis

use of ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysis 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 GeneDifferentialExpressionMetaAnalysis

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

the class GeneDiffExMetaAnalysisServiceTest method test.

@Test
public void test() {
    /*
         * create the analysis object
         */
    GeneDifferentialExpressionMetaAnalysis metaAnalysis = GeneDifferentialExpressionMetaAnalysis.Factory.newInstance();
    metaAnalysis.setNumGenesAnalyzed(100);
    metaAnalysis.setQvalueThresholdForStorage(0.05);
    geneDiffExMetaAnalysisService.create(metaAnalysis);
    List<Long> ids = new Vector<>();
    ids.add(metaAnalysis.getId());
    assertTrue(geneDiffExMetaAnalysisService.loadAll().size() > 0);
    assertEquals(1, geneDiffExMetaAnalysisService.findMetaAnalyses(ids).size());
}
Also used : GeneDifferentialExpressionMetaAnalysis(ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysis) Vector(java.util.Vector) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 3 with GeneDifferentialExpressionMetaAnalysis

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

the class PhenotypeAssociationManagerServiceImpl method convertDifferentialExpressionEvidence2ValueObject.

private DiffExpressionEvidenceValueObject convertDifferentialExpressionEvidence2ValueObject(DifferentialExpressionEvidence differentialExpressionEvidence) {
    DiffExpressionEvidenceValueObject diffExpressionEvidenceValueObject = null;
    if (differentialExpressionEvidence != null) {
        GeneDifferentialExpressionMetaAnalysis geneDifferentialExpressionMetaAnalysis = this.geneDiffExMetaAnalysisService.loadWithResultId(differentialExpressionEvidence.getGeneDifferentialExpressionMetaAnalysisResult().getId());
        Collection<Long> ids = new HashSet<>();
        ids.add(geneDifferentialExpressionMetaAnalysis.getId());
        GeneDifferentialExpressionMetaAnalysisSummaryValueObject geneDiffExMetaAnalysisSummaryValueObject = this.geneDiffExMetaAnalysisService.findMetaAnalyses(ids).iterator().next();
        diffExpressionEvidenceValueObject = new DiffExpressionEvidenceValueObject(differentialExpressionEvidence, geneDiffExMetaAnalysisSummaryValueObject);
        // set the count, how many evidences where created from the specific meta analysis
        diffExpressionEvidenceValueObject.setNumEvidenceFromSameMetaAnalysis(this.phenoAssocService.countEvidenceWithGeneDifferentialExpressionMetaAnalysis(geneDifferentialExpressionMetaAnalysis.getId()));
    }
    return diffExpressionEvidenceValueObject;
}
Also used : GeneDifferentialExpressionMetaAnalysis(ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysis) GeneDifferentialExpressionMetaAnalysisSummaryValueObject(ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysisSummaryValueObject)

Example 4 with GeneDifferentialExpressionMetaAnalysis

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

the class SecurityControllerImpl method updatePermission.

@Override
public SecurityInfoValueObject updatePermission(SecurityInfoValueObject settings) {
    EntityDelegator sd = new EntityDelegator();
    sd.setId(settings.getEntityId());
    sd.setClassDelegatingFor(settings.getEntityClazz());
    Securable s = this.getSecurable(sd);
    if (settings.isPubliclyReadable()) {
        securityService.makePublic(s);
    } else {
        securityService.makePrivate(s);
    }
    try {
        if (settings.getOwner().isPrincipal()) {
            securityService.makeOwnedByUser(s, settings.getOwner().getAuthority());
        } else {
            // this warning is not even worth issuing if we are not an administrator.
            if (SecurityUtil.isUserAdmin())
                SecurityControllerImpl.log.warn("Can't make groupauthority " + settings.getOwner().getAuthority() + " owner, not implemented");
        }
    } catch (AccessDeniedException e) {
        SecurityControllerImpl.log.warn("Non-administrators cannot change the owner of an entity");
    // okay, only works if you are administrator.
    }
    /*
         * This works in one of two ways. If settings.currentGroup is non-null, we just update the permissions for that
         * group - this may leave them unchanged. Otherwise, we update them all based on
         * groupsThatCanRead/groupsThatCanWrite
         */
    String currentGroupName = settings.getCurrentGroup();
    if (StringUtils.isNotBlank(currentGroupName) && !(currentGroupName.equals(AuthorityConstants.ADMIN_GROUP_NAME) || currentGroupName.equals(AuthorityConstants.AGENT_GROUP_NAME))) {
        // this test only makes sense for changing the group's name, not for changing the permissions
        // of potentially shared entities
        // if ( !getGroupsUserCanEdit().contains( currentGroupName ) ) {
        // throw new AccessDeniedException( "Access denied to permissions for group=" + currentGroupName );
        // }
        Boolean readable = settings.isCurrentGroupCanRead();
        Boolean writeable = settings.isCurrentGroupCanWrite();
        if (readable) {
            securityService.makeReadableByGroup(s, currentGroupName);
        } else {
            securityService.makeUnreadableByGroup(s, currentGroupName);
        }
        if (writeable) {
            // if writable should be readable
            securityService.makeReadableByGroup(s, currentGroupName);
            securityService.makeWriteableByGroup(s, currentGroupName);
        } else {
            securityService.makeUnwriteableByGroup(s, currentGroupName);
        }
    } else {
        /*
             * Remove all group permissions - we'll set them back to what was requested. Exception: we don't allow
             * changes to admin or agent permissions by this route.
             */
        for (String groupName : this.getGroupsUserCanEdit()) {
            if (groupName.equals(AuthorityConstants.ADMIN_GROUP_NAME) || groupName.equals(AuthorityConstants.AGENT_GROUP_NAME)) {
                // never changes this.
                continue;
            }
            securityService.makeUnreadableByGroup(s, groupName);
            securityService.makeUnwriteableByGroup(s, groupName);
        }
        /*
             * Add selected ones back
             */
        for (String reader : settings.getGroupsThatCanRead()) {
            if (reader.equals(AuthorityConstants.ADMIN_GROUP_NAME) || reader.equals(AuthorityConstants.AGENT_GROUP_NAME)) {
                // never changes this.
                continue;
            }
            securityService.makeReadableByGroup(s, reader);
        }
        for (String writer : settings.getGroupsThatCanWrite()) {
            if (writer.equals(AuthorityConstants.ADMIN_GROUP_NAME) || writer.equals(AuthorityConstants.AGENT_GROUP_NAME)) {
                // never changes this.
                continue;
            }
            // when it is writable it should be readable
            securityService.makeReadableByGroup(s, writer);
            securityService.makeWriteableByGroup(s, writer);
        }
    }
    // special case for Phenocarta, changing the meta analysis, changes the permissions of all evidence linked
    if (s instanceof GeneDifferentialExpressionMetaAnalysis) {
        Collection<DifferentialExpressionEvidence> differentialExpressionEvidence = this.phenotypeAssociationService.loadEvidenceWithGeneDifferentialExpressionMetaAnalysis(s.getId(), -1);
        for (DifferentialExpressionEvidence d : differentialExpressionEvidence) {
            settings.setEntityId(d.getId());
            settings.setEntityClazz(d.getClass().getName());
            this.updatePermission(settings);
        }
    }
    SecurityControllerImpl.log.info("Updated permissions on " + s);
    return this.securable2VO(s);
}
Also used : DifferentialExpressionEvidence(ubic.gemma.model.association.phenotype.DifferentialExpressionEvidence) Securable(gemma.gsec.model.Securable) AccessDeniedException(org.springframework.security.access.AccessDeniedException) GeneDifferentialExpressionMetaAnalysis(ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysis) EntityDelegator(ubic.gemma.web.remote.EntityDelegator)

Example 5 with GeneDifferentialExpressionMetaAnalysis

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

the class PhenotypeAssociationManagerServiceImpl method makeDifferentialExpressionEvidencesFromDiffExpressionMetaAnalysis.

@Override
public ValidateEvidenceValueObject makeDifferentialExpressionEvidencesFromDiffExpressionMetaAnalysis(Long geneDifferentialExpressionMetaAnalysisId, SortedSet<CharacteristicValueObject> phenotypes, Double selectionThreshold) {
    GeneDifferentialExpressionMetaAnalysis geneDifferentialExpressionMetaAnalysis = this.geneDiffExMetaAnalysisService.load(geneDifferentialExpressionMetaAnalysisId);
    // check that no evidence already exists with that metaAnalysis
    Collection<DifferentialExpressionEvidence> differentialExpressionEvidence = this.phenoAssocService.loadEvidenceWithGeneDifferentialExpressionMetaAnalysis(geneDifferentialExpressionMetaAnalysisId, 1);
    if (!differentialExpressionEvidence.isEmpty()) {
        ValidateEvidenceValueObject validateEvidenceValueObject = new ValidateEvidenceValueObject();
        validateEvidenceValueObject.setSameEvidenceFound(true);
        return validateEvidenceValueObject;
    }
    for (GeneDifferentialExpressionMetaAnalysisResult geneDifferentialExpressionMetaAnalysisResult : geneDifferentialExpressionMetaAnalysis.getResults()) {
        if (geneDifferentialExpressionMetaAnalysisResult.getMetaQvalue() <= selectionThreshold) {
            DiffExpressionEvidenceValueObject diffExpressionEvidenceValueObject = new DiffExpressionEvidenceValueObject(-1L, geneDifferentialExpressionMetaAnalysis, geneDifferentialExpressionMetaAnalysisResult, phenotypes, "IEP", selectionThreshold);
            // set the score
            ScoreValueObject scoreValueObject = new ScoreValueObject(null, geneDifferentialExpressionMetaAnalysisResult.getMetaPvalue().toString(), "P-value");
            diffExpressionEvidenceValueObject.setScoreValueObject(scoreValueObject);
            ValidateEvidenceValueObject validateEvidenceValueObject = this.makeEvidence(diffExpressionEvidenceValueObject);
            if (validateEvidenceValueObject != null) {
                // since this method created multiple evidence, if a problem is detected stop the transaction
                throw new RuntimeException("makeDifferentialExpressionEvidencesFromDiffExpressionMetaAnalysis() problem detected");
            }
        }
    }
    return null;
}
Also used : GeneDifferentialExpressionMetaAnalysis(ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysis) GeneDifferentialExpressionMetaAnalysisResult(ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysisResult)

Aggregations

GeneDifferentialExpressionMetaAnalysis (ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysis)5 Securable (gemma.gsec.model.Securable)1 Vector (java.util.Vector)1 Test (org.junit.Test)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1 TaskResult (ubic.gemma.core.job.TaskResult)1 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)1 GeneDifferentialExpressionMetaAnalysisDetailValueObject (ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysisDetailValueObject)1 GeneDifferentialExpressionMetaAnalysisResult (ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysisResult)1 GeneDifferentialExpressionMetaAnalysisSummaryValueObject (ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysisSummaryValueObject)1 DifferentialExpressionEvidence (ubic.gemma.model.association.phenotype.DifferentialExpressionEvidence)1 EntityDelegator (ubic.gemma.web.remote.EntityDelegator)1