use of ubic.gemma.model.expression.bioAssay.BioAssay 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.bioAssay.BioAssay in project Gemma by PavlidisLab.
the class DiffExWithInvalidInteraction2Test method test.
@Test
public void test() {
ee = expressionExperimentService.thawLite(ee);
Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors();
// includes batch
assertEquals(3, factors.size());
for (BioAssay ba : ee.getBioAssays()) {
assertEquals(3, ba.getSampleUsed().getFactorValues().size());
}
ExperimentalFactor strain = null;
ExperimentalFactor cell_type = null;
for (ExperimentalFactor ef : factors) {
if (ef.getCategory().getValue().equals("strain")) {
strain = ef;
} else if (ef.getCategory().getValue().equals("cell type")) {
cell_type = ef;
}
}
assertNotNull(cell_type);
assertNotNull(strain);
DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
config.getFactorsToInclude().add(strain);
config.getFactorsToInclude().add(cell_type);
config.addInteractionToInclude(cell_type, strain);
Collection<DifferentialExpressionAnalysis> result = analyzer.runDifferentialExpressionAnalyses(ee, config);
assertEquals(1, result.size());
}
use of ubic.gemma.model.expression.bioAssay.BioAssay 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.bioAssay.BioAssay in project Gemma by PavlidisLab.
the class AuditAdviceTest method testCascadingCreateOnUpdate.
@Test
public void testCascadingCreateOnUpdate() {
ExpressionExperiment ee = this.getTestPersistentCompleteExpressionExperiment(false);
ee = this.expressionExperimentService.load(ee.getId());
ee = expressionExperimentService.thawLite(ee);
// should have create only
assertEquals(1, ee.getAuditTrail().getEvents().size());
BioAssay ba = BioAssay.Factory.newInstance();
String name = RandomStringUtils.randomAlphabetic(20);
ba.setName(name);
ba.setArrayDesignUsed(ee.getBioAssays().iterator().next().getArrayDesignUsed());
ee.getBioAssays().add(ba);
this.expressionExperimentService.update(ee);
assertNotNull(ee.getAuditTrail());
// should have create and 1 updates
assertEquals(2, ee.getAuditTrail().getEvents().size());
Session session = sessionFactory.openSession();
session.update(ee);
for (BioAssay bioa : ee.getBioAssays()) {
assertNotNull(bioa.getAuditTrail());
Collection<AuditEvent> events = bioa.getAuditTrail().getEvents();
assertEquals(1, events.size());
for (AuditEvent e : events) {
assertNotNull(e.getId());
assertNotNull(e.getAction());
}
}
session.close();
this.expressionExperimentService.update(ee);
this.expressionExperimentService.update(ee);
this.expressionExperimentService.update(ee);
assertEquals(5, ee.getAuditTrail().getEvents().size());
/*
* Check we didn't get any extra events added to children.
*/
for (BioAssay prod : ee.getBioAssays()) {
assertEquals(1, prod.getAuditTrail().getEvents().size());
}
}
use of ubic.gemma.model.expression.bioAssay.BioAssay in project Gemma by PavlidisLab.
the class SecurityServiceTest method testMakeExpressionExperimentPrivate.
@Test
public void testMakeExpressionExperimentPrivate() {
ExpressionExperiment ee = super.getTestPersistentBasicExpressionExperiment();
for (int i = 0; i < 5; i++) {
this.securityService.makePrivate(ee);
assertTrue("ExpressionExperiment not private, acl was: " + aclTestUtils.getAcl(ee), this.securityService.isPrivate(ee));
for (BioAssay ba : ee.getBioAssays()) {
assertTrue("BioAssay not private, acl of ee was: " + aclTestUtils.getAcl(ee) + "\nacl of bioassay was: " + aclTestUtils.getAcl(ba), this.securityService.isPrivate(ba));
}
this.securityService.makePublic(ee);
assertTrue("ExpressionExperiment still private, acl was: " + aclTestUtils.getAcl(ee), this.securityService.isPublic(ee));
for (BioAssay ba : ee.getBioAssays()) {
assertTrue("BioAssay not public, acl of ee was: " + aclTestUtils.getAcl(ee), this.securityService.isPublic(ba));
}
}
}
Aggregations