Search in sources :

Example 16 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class SecurityServiceTest method testMakeEEGroupReadWrite.

@Test
public void testMakeEEGroupReadWrite() {
    ArrayDesign entity = super.getTestPersistentArrayDesign(2, true);
    this.securityService.makePrivate(entity);
    String username = "first_" + this.randomName();
    String usertwo = "second_" + this.randomName();
    this.makeUser(username);
    this.makeUser(usertwo);
    this.securityService.makeOwnedByUser(entity, username);
    assertTrue(this.securityService.isEditableByUser(entity, username));
    this.runAsUser(username);
    /*
         * Create a group, do stuff...
         */
    String groupName = this.randomName();
    this.securityService.createGroup(groupName);
    this.securityService.makeWriteableByGroup(entity, groupName);
    /*
         * Add another user to the group, which is owned by username
         */
    this.securityService.addUserToGroup(usertwo, groupName);
    /*
         * Now, log in as another user.
         */
    this.runAsUser(usertwo);
    entity = this.arrayDesignService.load(entity.getId());
    entity.setDescription("woohoo, I can edit");
    this.arrayDesignService.update(entity);
    // no exception == happy.
    this.runAsUser(username);
    this.securityService.makeUnreadableByGroup(entity, groupName);
    // should still work.
    entity = this.arrayDesignService.load(entity.getId());
    this.runAsUser(usertwo);
    // should be locked out.
    entity = this.arrayDesignService.load(entity.getId());
    assertNull(entity);
    try {
        this.userManager.deleteGroup(groupName);
        fail("Should have gotten 'access denied'");
    } catch (AccessDeniedException ok) {
    // expected behaviour
    }
    this.runAsUser(username);
    this.userManager.deleteGroup(groupName);
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 17 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class AclTestUtils method checkEEAcls.

/**
 * Validate ACLs on EE
 *
 * @param ee ee
 */
public void checkEEAcls(ExpressionExperiment ee) {
    ee = expressionExperimentService.thawLite(ee);
    this.checkHasAcl(ee);
    this.checkHasAces(ee);
    ExperimentalDesign experimentalDesign = ee.getExperimentalDesign();
    this.checkHasAcl(experimentalDesign);
    this.checkHasAclParent(experimentalDesign, ee);
    this.checkLacksAces(experimentalDesign);
    if (ee.getRawDataFile() != null) {
        this.checkHasAcl(ee.getRawDataFile());
        this.checkHasAclParent(ee.getRawDataFile(), ee);
        this.checkLacksAces(ee.getRawDataFile());
    }
    for (ExperimentalFactor f : experimentalDesign.getExperimentalFactors()) {
        this.checkHasAcl(f);
        this.checkHasAclParent(f, ee);
        this.checkLacksAces(f);
        for (FactorValue fv : f.getFactorValues()) {
            this.checkHasAcl(fv);
            this.checkHasAclParent(fv, ee);
            this.checkLacksAces(fv);
        }
    }
    // make sure ACLs for the child objects are there
    assertTrue(ee.getBioAssays().size() > 0);
    for (BioAssay ba : ee.getBioAssays()) {
        this.checkHasAcl(ba);
        this.checkHasAclParent(ba, ee);
        this.checkLacksAces(ba);
        LocalFile rawDataFile = ba.getRawDataFile();
        if (rawDataFile != null) {
            this.checkHasAcl(rawDataFile);
            this.checkHasAclParent(rawDataFile, null);
            this.checkLacksAces(rawDataFile);
        }
        for (LocalFile f : ba.getDerivedDataFiles()) {
            this.checkHasAcl(f);
            this.checkHasAclParent(f, null);
            this.checkLacksAces(f);
        }
        BioMaterial bm = ba.getSampleUsed();
        this.checkHasAcl(bm);
        this.checkHasAclParent(bm, ee);
        this.checkLacksAces(bm);
        ArrayDesign arrayDesign = ba.getArrayDesignUsed();
        this.checkHasAcl(arrayDesign);
        assertTrue(this.getParentAcl(arrayDesign) == null);
        // make sure the localfiles are associated with the array design, not the ee.
        arrayDesign = arrayDesignService.thawLite(arrayDesign);
        for (LocalFile lf : arrayDesign.getLocalFiles()) {
            this.checkHasAcl(lf);
            this.checkLacksAces(lf);
            this.checkHasAclParent(lf, arrayDesign);
        }
    }
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) LocalFile(ubic.gemma.model.common.description.LocalFile) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 18 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class AuditEventDaoImplTest method setup.

@Before
public void setup() {
    for (int i = 0; i < 5; i++) {
        ArrayDesign ad = ArrayDesign.Factory.newInstance();
        ad.setName("ffoo " + i);
        ad.setPrimaryTaxon(this.getTaxon("mouse"));
        ad = (ArrayDesign) persisterHelper.persist(ad);
        ad.setDescription("arrrgh");
        ads.update(ad);
    }
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Before(org.junit.Before)

Example 19 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class CompositeSequenceGeneMapperServiceTest method setup.

@Before
public void setup() throws Exception {
    this.cleanup();
    geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("platform")));
    @SuppressWarnings("unchecked") final Collection<ArrayDesign> ads = (Collection<ArrayDesign>) geoService.fetchAndLoad(arrayAccession, true, true, false);
    ad = ads.iterator().next();
    ad = arrayDesignService.thaw(ad);
    this.loadData();
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Collection(java.util.Collection) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) Before(org.junit.Before)

Example 20 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class ExpressionDataDoubleMatrixTest method testConstructExpressionDataDoubleMatrixWithGeoValues.

/**
 * This is a self-contained test. That is, it does not depend on the setup in onSetUpInTransaction}. It tests
 * creating an {@link ExpressionDataDoubleMatrix} using real values from the Gene Expression Omnibus (GEO). That is,
 * we have obtained information from GSE994. The probe sets used are 218120_s_at and 121_at, and the samples used
 * are GSM15697 and GSM15744. Specifically, we the Gemma objects that correspond to the GEO objects are:
 * DesignElement 1 = 218120_s_at, DesignElement 2 = 121_at
 * BioAssay 1 = "Current Smoker 73", BioAssay 2 = "Former Smoker 34"
 * BioMaterial 1 = "GSM15697", BioMaterial 2 = "GSM15744"
 * BioAssayDimension = "GSM15697, GSM15744" (the names of all the biomaterials).
 */
@Test
public void testConstructExpressionDataDoubleMatrixWithGeoValues() {
    ByteArrayConverter bac = new ByteArrayConverter();
    ee = ExpressionExperiment.Factory.newInstance();
    QuantitationType qt = QuantitationType.Factory.newInstance();
    qt.setName("VALUE");
    qt.setIsBackgroundSubtracted(false);
    qt.setIsNormalized(false);
    qt.setIsBackground(false);
    qt.setIsRatio(false);
    qt.setIsPreferred(true);
    qt.setIsMaskedPreferred(false);
    qt.setRepresentation(PrimitiveType.DOUBLE);
    BioAssayDimension bioAssayDimension = BioAssayDimension.Factory.newInstance();
    bioAssayDimension.setName("GSM15697, GSM15744");
    List<BioAssay> assays = new ArrayList<>();
    BioAssay assay1 = BioAssay.Factory.newInstance();
    assay1.setName("Current Smoker 73");
    BioMaterial sample1 = BioMaterial.Factory.newInstance();
    sample1.setName("GSM15697");
    assay1.setSampleUsed(sample1);
    assays.add(assay1);
    BioAssay assay2 = BioAssay.Factory.newInstance();
    assay2.setName("Former Smoker 34");
    BioMaterial sample2 = BioMaterial.Factory.newInstance();
    sample2.setName("GSM15744");
    assay2.setSampleUsed(sample2);
    assays.add(assay2);
    bioAssayDimension.setBioAssays(assays);
    RawExpressionDataVector vector1 = RawExpressionDataVector.Factory.newInstance();
    double[] ddata1 = { 74.9, 101.7 };
    byte[] bdata1 = bac.doubleArrayToBytes(ddata1);
    vector1.setData(bdata1);
    vector1.setQuantitationType(qt);
    vector1.setBioAssayDimension(bioAssayDimension);
    RawExpressionDataVector vector2 = RawExpressionDataVector.Factory.newInstance();
    double[] ddata2 = { 404.6, 318.7 };
    byte[] bdata2 = bac.doubleArrayToBytes(ddata2);
    vector2.setData(bdata2);
    vector2.setQuantitationType(qt);
    vector2.setBioAssayDimension(bioAssayDimension);
    ArrayDesign ad = ArrayDesign.Factory.newInstance();
    ad.setName("test ar");
    CompositeSequence de1 = CompositeSequence.Factory.newInstance();
    de1.setName("218120_s_at");
    vector1.setDesignElement(de1);
    BioSequence bs1 = BioSequence.Factory.newInstance();
    bs1.setName("test1");
    de1.setBiologicalCharacteristic(bs1);
    de1.setArrayDesign(ad);
    CompositeSequence de2 = CompositeSequence.Factory.newInstance();
    de2.setName("121_at");
    BioSequence bs2 = BioSequence.Factory.newInstance();
    bs2.setName("test2");
    de2.setBiologicalCharacteristic(bs2);
    de2.setArrayDesign(ad);
    vector2.setDesignElement(de2);
    Collection<RawExpressionDataVector> eeVectors = new LinkedHashSet<>();
    eeVectors.add(vector1);
    eeVectors.add(vector2);
    ee.setRawExpressionDataVectors(eeVectors);
    ExpressionDataDoubleMatrix expressionDataMatrix = new ExpressionDataDoubleMatrix(eeVectors);
    assertNotNull(expressionDataMatrix);
    assertEquals(expressionDataMatrix.rows(), 2);
    assertEquals(expressionDataMatrix.columns(), 2);
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Aggregations

ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)186 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)43 Test (org.junit.Test)32 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)26 InputStream (java.io.InputStream)25 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)24 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)24 Taxon (ubic.gemma.model.genome.Taxon)23 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)19 HashSet (java.util.HashSet)16 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)16 Collection (java.util.Collection)14 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)13 StopWatch (org.apache.commons.lang3.time.StopWatch)12 Before (org.junit.Before)12 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)12 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)9 GZIPInputStream (java.util.zip.GZIPInputStream)8 SimpleExpressionExperimentMetaData (ubic.gemma.core.loader.expression.simple.model.SimpleExpressionExperimentMetaData)8 File (java.io.File)7