use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class DiffExWithInvalidInteraction2Test method setup.
@Before
public void setup() throws Exception {
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(FileTools.resourceToPath("/data/analysis/expression")));
try {
Collection<?> results = geoService.fetchAndLoad("GSE37301", false, true, false);
ee = (ExpressionExperiment) results.iterator().next();
} catch (AlreadyExistsInSystemException e) {
ee = (ExpressionExperiment) ((Collection<?>) e.getData()).iterator().next();
}
ee = expressionExperimentService.thawLite(ee);
Collection<ExperimentalFactor> toremove = new HashSet<>(ee.getExperimentalDesign().getExperimentalFactors());
for (ExperimentalFactor ef : toremove) {
experimentalFactorService.delete(ef);
ee.getExperimentalDesign().getExperimentalFactors().remove(ef);
}
expressionExperimentService.update(ee);
processedExpressionDataVectorService.computeProcessedExpressionData(ee);
ee = expressionExperimentService.thaw(ee);
designImporter.importDesign(ee, this.getClass().getResourceAsStream("/data/analysis/expression/7737_GSE37301_expdesign.data.txt"));
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class AuditAdviceTest method testSimpleAuditFindOrCreate.
@Test
public void testSimpleAuditFindOrCreate() {
ExpressionExperiment ee = ExpressionExperiment.Factory.newInstance();
ee.setDescription("From test");
ee.setName(RandomStringUtils.randomAlphabetic(20));
ee = expressionExperimentService.findOrCreate(ee);
assertNotNull(ee.getAuditTrail());
assertEquals(1, ee.getAuditTrail().getEvents().size());
assertNotNull(ee.getCurationDetails());
assertNotNull(ee.getCurationDetails().getId());
assertNotNull(ee.getCurationDetails().getLastUpdated());
assertNotNull(ee.getAuditTrail().getCreationEvent().getId());
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class AuditAdviceTest method testAuditFindOrCreateConcurrentTorture.
/*
* Torture test. Passes fine with a single thread.
*/
// Not in this project
@SuppressWarnings("Duplicates")
@Test
public void testAuditFindOrCreateConcurrentTorture() throws Exception {
// too high and we run out of connections, which is not what we're testing.
int numThreads = 14;
final int numExperimentsPerThread = 5;
final int numUpdates = 10;
final Random random = new Random();
final AtomicInteger c = new AtomicInteger(0);
final AtomicBoolean failed = new AtomicBoolean(false);
Collection<Thread> threads = new HashSet<>();
for (int i = 0; i < numThreads; i++) {
Thread.sleep(random.nextInt(100));
Thread k = new Thread(new Runnable() {
@Override
public void run() {
try {
for (int j = 0; j < numExperimentsPerThread; j++) {
log.debug("Starting experiment " + j);
ExpressionExperiment ee = ExpressionExperiment.Factory.newInstance();
ee.setDescription("From test");
ee.setShortName(RandomStringUtils.randomAlphabetic(20));
ee.setName(RandomStringUtils.randomAlphabetic(20));
ee = expressionExperimentService.findOrCreate(ee);
assertNotNull(ee.getAuditTrail());
assertEquals(1, ee.getAuditTrail().getEvents().size());
assertNotNull(ee.getCurationDetails());
assertNotNull(ee.getCurationDetails().getId());
assertNotNull(ee.getCurationDetails().getLastUpdated());
assertNotNull(ee.getAuditTrail().getCreationEvent().getId());
for (int q = 0; q < numUpdates; q++) {
Thread.sleep(random.nextInt(5));
log.debug("Update: experiment " + j);
expressionExperimentService.update(ee);
c.incrementAndGet();
}
log.debug("Done with experiment " + j);
}
} catch (Exception e) {
failed.set(true);
log.error("!!!!!!!!!!!!!!!!!!!!!! FAILED: " + e.getMessage());
log.debug(e, e);
throw new RuntimeException(e);
}
log.debug("Thread done.");
}
});
threads.add(k);
k.start();
}
int waits = 0;
int maxWaits = 20;
int expectedEventCount = numThreads * numExperimentsPerThread * numUpdates;
while (c.get() < expectedEventCount && !failed.get()) {
Thread.sleep(1000);
log.info("Waiting ...");
if (++waits > maxWaits) {
for (Thread t : threads) {
if (t.isAlive())
t.interrupt();
}
fail("Multithreaded failure: timed out.");
}
}
log.debug(" &&&&& DONE &&&&&");
for (Thread thread : threads) {
if (thread.isAlive())
thread.interrupt();
}
if (failed.get() || c.get() != expectedEventCount) {
fail("Multithreaded loading failure: check logs for failure to recover from deadlock?");
} else {
log.info("TORTURE TEST PASSED!");
}
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment 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.experiment.ExpressionExperiment 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