Search in sources :

Example 6 with BioAssay

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;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) MalformedURLException(java.net.MalformedURLException) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ArrayDesignsForExperimentCache(ubic.gemma.persistence.util.ArrayDesignsForExperimentCache) URL(java.net.URL) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 7 with BioAssay

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());
}
Also used : ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 8 with BioAssay

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);
            }
        }
    }
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) Treatment(ubic.gemma.model.expression.biomaterial.Treatment) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) Characteristic(ubic.gemma.model.common.description.Characteristic) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 9 with BioAssay

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());
    }
}
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 10 with BioAssay

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

BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)144 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)67 Test (org.junit.Test)29 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)29 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)24 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)20 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)18 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)16 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)15 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)14 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)14 InputStream (java.io.InputStream)11 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)10 HashSet (java.util.HashSet)9 AlreadyExistsInSystemException (ubic.gemma.core.loader.util.AlreadyExistsInSystemException)8 DesignElementDataVector (ubic.gemma.model.expression.bioAssayData.DesignElementDataVector)8 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ModelAndView (org.springframework.web.servlet.ModelAndView)7 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)7