Search in sources :

Example 16 with ExpressionExperiment

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"));
}
Also used : ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) Collection(java.util.Collection) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 17 with ExpressionExperiment

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());
}
Also used : ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 18 with ExpressionExperiment

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!");
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 19 with ExpressionExperiment

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());
    }
}
Also used : AuditEvent(ubic.gemma.model.common.auditAndSecurity.AuditEvent) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) Session(org.hibernate.Session) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 20 with ExpressionExperiment

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));
        }
    }
}
Also used : ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Aggregations

ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)214 Test (org.junit.Test)71 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)42 InputStream (java.io.InputStream)36 GeoSeries (ubic.gemma.core.loader.expression.geo.model.GeoSeries)29 AlreadyExistsInSystemException (ubic.gemma.core.loader.util.AlreadyExistsInSystemException)29 GZIPInputStream (java.util.zip.GZIPInputStream)28 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)26 HashSet (java.util.HashSet)25 BioAssaySet (ubic.gemma.model.expression.experiment.BioAssaySet)25 GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)23 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)22 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)20 Collection (java.util.Collection)18 StopWatch (org.apache.commons.lang3.time.StopWatch)18 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)18 Taxon (ubic.gemma.model.genome.Taxon)14 Before (org.junit.Before)12 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11