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