Search in sources :

Example 6 with BioMaterial

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;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial)

Example 7 with BioMaterial

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;
}
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 8 with BioMaterial

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

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

Example 10 with BioMaterial

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);
        }
    }
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) LocalFile(ubic.gemma.model.common.description.LocalFile) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Aggregations

BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)132 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)67 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)27 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)22 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)19 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)15 HashSet (java.util.HashSet)13 Test (org.junit.Test)13 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)12 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)12 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)10 InputStream (java.io.InputStream)7 DenseDoubleMatrix (ubic.basecode.dataStructure.matrix.DenseDoubleMatrix)7 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)7 QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)7 Characteristic (ubic.gemma.model.common.description.Characteristic)6 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)6 DoubleArrayList (cern.colt.list.DoubleArrayList)5 DoubleMatrix1D (cern.colt.matrix.DoubleMatrix1D)5 ArrayList (java.util.ArrayList)5