use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.
the class PersistentDummyObjectHelper method getTestNonPersistentBioMaterial.
/**
* @return Slightly misleading, associations are persistent.
*/
private BioMaterial getTestNonPersistentBioMaterial() {
BioMaterial bm = BioMaterial.Factory.newInstance();
bm.setName(RandomStringUtils.randomNumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH) + "_testbiomaterial");
if (PersistentDummyObjectHelper.geo == null) {
PersistentDummyObjectHelper.geo = externalDatabaseService.findByName("GEO");
assert PersistentDummyObjectHelper.geo != null;
}
bm.setSourceTaxon(PersistentDummyObjectHelper.getTestNonPersistentTaxon());
bm.setExternalAccession(this.getTestPersistentDatabaseEntry(PersistentDummyObjectHelper.geo));
return bm;
}
use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.
the class PersistentDummyObjectHelper method getTestExpressionExperimentWithAllDependencies.
/**
* Add an expressionExperiment to the database for testing purposes. Includes associations
*
* @param doSequence Should the array design get all the sequence information filled in? (true = slower)
* @return EE
*/
public ExpressionExperiment getTestExpressionExperimentWithAllDependencies(boolean doSequence) {
ExpressionExperiment ee = ExpressionExperiment.Factory.newInstance();
ee.setShortName(RandomStringUtils.randomAlphanumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH));
ee.setName("Expression Experiment " + RandomStringUtils.randomNumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH));
ee.setDescription("A test expression experiment");
ee.setSource("https://www.ncbi.nlm.nih.gov/geo/");
DatabaseEntry de1 = this.getTestPersistentDatabaseEntry(PersistentDummyObjectHelper.geo);
ee.setAccession(de1);
LocalFile file = LocalFile.Factory.newInstance();
try {
file.setLocalURL(new URL("file:///just/a/placeholder/" + ee.getShortName()));
} catch (MalformedURLException e) {
log.error("Malformed URL");
}
ee.setRawDataFile(file);
ArrayDesign adA = this.getTestPersistentArrayDesign(this.getTestElementCollectionSize(), false, doSequence);
ArrayDesign adB = this.getTestPersistentArrayDesign(this.getTestElementCollectionSize(), false, doSequence);
Collection<FactorValue> allFactorValues = new HashSet<>();
ExperimentalDesign ed = this.getExperimentalDesign(allFactorValues);
ee.setExperimentalDesign(ed);
ee.setOwner(this.getTestPersistentContact());
Collection<BioAssay> bioAssays = new HashSet<>();
Collection<BioMaterial> bioMaterials = this.getBioMaterials(allFactorValues);
List<BioAssay> bioAssaysA = this.getBioAssays(bioMaterials, adA);
List<BioAssay> bioAssaysB = this.getBioAssays(bioMaterials, adB);
bioAssays.addAll(bioAssaysA);
bioAssays.addAll(bioAssaysB);
ee.setBioAssays(bioAssays);
log.debug("expression experiment => design element data vectors");
Collection<RawExpressionDataVector> vectors = new HashSet<>();
Collection<QuantitationType> quantitationTypes = this.addQuantitationTypes(new HashSet<QuantitationType>());
assert quantitationTypes.size() > 0;
vectors.addAll(this.getDesignElementDataVectors(ee, quantitationTypes, bioAssaysA, adA));
vectors.addAll(this.getDesignElementDataVectors(ee, quantitationTypes, bioAssaysB, adB));
ee.setQuantitationTypes(quantitationTypes);
ee.setRawExpressionDataVectors(vectors);
ArrayDesignsForExperimentCache c = persisterHelper.prepare(ee);
ee = persisterHelper.persist(ee, c);
return ee;
}
use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.
the class AuditAdviceTest method checkEEAuditTrails.
private void checkEEAuditTrails(ExpressionExperiment ee, Collection<Long> trailIds, Collection<Long> eventIds) {
this.checkAuditTrail(ee, trailIds, eventIds);
for (BioAssay ba : ee.getBioAssays()) {
this.checkAuditTrail(ba, trailIds, eventIds);
BioMaterial bm = ba.getSampleUsed();
this.checkAuditTrail(bm, trailIds, eventIds);
for (Characteristic c : bm.getCharacteristics()) {
this.checkAuditTrail(c, trailIds, eventIds);
}
for (Treatment t : bm.getTreatments()) {
this.checkAuditTrail(t, trailIds, eventIds);
this.checkAuditTrail(t.getAction(), trailIds, eventIds);
// for ( CompoundMeasurement cm : t.getCompoundMeasurements() ) {
// checkAuditTrail( cm.getCompound().getCompoundIndices(), trailIds, eventIds );
// }
}
}
Collection<ExperimentalFactor> experimentalFactors = ee.getExperimentalDesign().getExperimentalFactors();
assertTrue(experimentalFactors.size() > 0);
for (ExperimentalFactor ef : experimentalFactors) {
this.checkAuditTrail(ef, trailIds, eventIds);
for (FactorValue fv : ef.getFactorValues()) {
for (Characteristic c : fv.getCharacteristics()) {
this.checkAuditTrail(c, trailIds, eventIds);
}
}
}
}
use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.
the class AclTestUtils method checkDeleteEEAcls.
/**
* CHeck the entire entity graph of an ee for ACL deletion.
*
* @param ee ee
*/
public void checkDeleteEEAcls(ExpressionExperiment ee) {
this.checkDeletedAcl(ee);
this.checkDeletedAcl(ee.getRawDataFile());
this.checkDeletedAcl(ee.getExperimentalDesign());
for (ExperimentalFactor f : ee.getExperimentalDesign().getExperimentalFactors()) {
this.checkDeletedAcl(f);
for (FactorValue fv : f.getFactorValues()) {
this.checkDeletedAcl(fv);
}
}
assertTrue(ee.getBioAssays().size() > 0);
for (BioAssay ba : ee.getBioAssays()) {
this.checkDeletedAcl(ba);
LocalFile rawDataFile = ba.getRawDataFile();
for (LocalFile f : ba.getDerivedDataFiles()) {
this.checkDeletedAcl(f);
}
if (rawDataFile != null) {
this.checkDeletedAcl(rawDataFile);
}
BioMaterial bm = ba.getSampleUsed();
this.checkDeletedAcl(bm);
}
}
use of ubic.gemma.model.expression.biomaterial.BioMaterial 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);
}
}
}
Aggregations