Search in sources :

Example 1 with ExperimentalDesign

use of ubic.gemma.model.expression.experiment.ExperimentalDesign in project Gemma by PavlidisLab.

the class CuratableValueObjectTest method setUp.

@Before
public void setUp() throws Exception {
    arrayDesign = ArrayDesign.Factory.newInstance();
    arrayDesign.setName("testing audit " + RandomStringUtils.randomAlphanumeric(32));
    arrayDesign.setShortName(RandomStringUtils.randomAlphanumeric(8));
    arrayDesign.setPrimaryTaxon(this.getTaxon("human"));
    arrayDesign = (ArrayDesign) this.persisterHelper.persist(arrayDesign);
    assertTrue(arrayDesign.getAuditTrail() != null);
    Taxon taxon = Taxon.Factory.newInstance("text taxon scientific name " + RandomStringUtils.randomAlphanumeric(8), RandomStringUtils.randomAlphanumeric(8), "ttxn", 0, false, true);
    this.persisterHelper.persist(taxon);
    BioMaterial bm = BioMaterial.Factory.newInstance();
    bm.setName(RandomStringUtils.randomAlphanumeric(8));
    bm.setSourceTaxon(taxon);
    this.persisterHelper.persist(bm);
    BioAssay bioAssay = BioAssay.Factory.newInstance();
    bioAssay.setArrayDesignUsed(arrayDesign);
    bioAssay.setSampleUsed(bm);
    this.persisterHelper.persist(bioAssay);
    ExperimentalDesign ed = ExperimentalDesign.Factory.newInstance();
    ed.setName(RandomStringUtils.randomAlphanumeric(8));
    expressionExperiment = super.getTestPersistentBasicExpressionExperiment();
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) ExperimentalDesign(ubic.gemma.model.expression.experiment.ExperimentalDesign) Taxon(ubic.gemma.model.genome.Taxon) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) Before(org.junit.Before)

Example 2 with ExperimentalDesign

use of ubic.gemma.model.expression.experiment.ExperimentalDesign in project Gemma by PavlidisLab.

the class BatchInfoPopulationServiceImpl method removeExistingBatchFactor.

/**
 * Remove an existing batch factor, if it exists. This is really only relevant in a 'force' situation.
 *
 * @param ee ee
 */
private void removeExistingBatchFactor(ExpressionExperiment ee) {
    ExperimentalDesign ed = ee.getExperimentalDesign();
    ExperimentalFactor toRemove = null;
    for (ExperimentalFactor ef : ed.getExperimentalFactors()) {
        if (BatchInfoPopulationServiceImpl.isBatchFactor(ef)) {
            toRemove = ef;
            break;
        /*
                 * FIXME handle the case where we somehow have two or more.
                 */
        }
    }
    if (toRemove == null) {
        return;
    }
    BatchInfoPopulationServiceImpl.log.info("Removing existing batch factor: " + toRemove);
    experimentalFactorService.delete(toRemove);
    ee.getExperimentalDesign().getExperimentalFactors().remove(toRemove);
    this.expressionExperimentService.update(ee);
}
Also used : ExperimentalDesign(ubic.gemma.model.expression.experiment.ExperimentalDesign) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor)

Example 3 with ExperimentalDesign

use of ubic.gemma.model.expression.experiment.ExperimentalDesign in project Gemma by PavlidisLab.

the class ExperimentalDesignDaoImpl method find.

@Override
public ExperimentalDesign find(ExperimentalDesign experimentalDesign) {
    Criteria queryObject = this.getSessionFactory().getCurrentSession().createCriteria(ExperimentalDesign.class);
    queryObject.add(Restrictions.eq("name", experimentalDesign.getName()));
    List<?> results = queryObject.list();
    Object result = null;
    if (results != null) {
        if (results.size() > 1) {
            throw new org.springframework.dao.InvalidDataAccessResourceUsageException("More than one instance of '" + ExperimentalDesign.class.getName() + "' was found when executing query");
        } else if (results.size() == 1) {
            result = results.iterator().next();
        }
    }
    return (ExperimentalDesign) result;
}
Also used : ExperimentalDesign(ubic.gemma.model.expression.experiment.ExperimentalDesign) Criteria(org.hibernate.Criteria)

Example 4 with ExperimentalDesign

use of ubic.gemma.model.expression.experiment.ExperimentalDesign in project Gemma by PavlidisLab.

the class SimpleExpressionDataLoaderServiceImpl method convert.

@Override
public ExpressionExperiment convert(SimpleExpressionExperimentMetaData metaData, DoubleMatrix<String, String> matrix) {
    if (matrix == null || metaData == null) {
        throw new IllegalArgumentException("One or all of method arguments was null");
    }
    ExpressionExperiment experiment = ExpressionExperiment.Factory.newInstance();
    Taxon taxon = this.convertTaxon(metaData.getTaxon());
    experiment.setName(metaData.getName());
    experiment.setShortName(metaData.getShortName());
    experiment.setDescription(metaData.getDescription());
    experiment.setSource("Import via matrix flat file." + (StringUtils.isBlank(metaData.getSourceUrl()) ? "" : "Downloaded from " + metaData.getSourceUrl()));
    ExperimentalDesign ed = ExperimentalDesign.Factory.newInstance();
    experiment.setExperimentalDesign(ed);
    if (metaData.getPubMedId() != null) {
        PubMedXMLFetcher pubfetch = new PubMedXMLFetcher();
        BibliographicReference ref = pubfetch.retrieveByHTTP(metaData.getPubMedId());
        experiment.setPrimaryPublication(ref);
    }
    QuantitationType quantitationType = this.convertQuantitationType(metaData);
    /* set the quantitation types on the experiment */
    Collection<QuantitationType> qTypes = new HashSet<>();
    qTypes.add(quantitationType);
    experiment.setQuantitationTypes(qTypes);
    Collection<ArrayDesign> arrayDesigns = this.convertArrayDesigns(metaData, matrix);
    // Divide up multiple array designs into multiple BioAssayDimensions.
    Collection<RawExpressionDataVector> allVectors = new HashSet<>();
    Collection<BioAssay> allBioAssays = new HashSet<>();
    Collection<Object> usedDesignElements = new HashSet<>();
    for (ArrayDesign design : arrayDesigns) {
        SimpleExpressionDataLoaderServiceImpl.log.info("Processing " + design);
        DoubleMatrix<String, String> subMatrix = this.getSubMatrixForArrayDesign(matrix, usedDesignElements, design);
        if (subMatrix == null) {
            throw new IllegalStateException("Got a null matix");
        }
        BioAssayDimension bad = this.convertBioAssayDimension(experiment, design, taxon, subMatrix);
        Collection<RawExpressionDataVector> vectors = this.convertDesignElementDataVectors(experiment, bad, design, quantitationType, subMatrix);
        allVectors.addAll(vectors);
        allBioAssays.addAll(bad.getBioAssays());
    }
    // sanity
    if (usedDesignElements.size() != matrix.rows()) {
        SimpleExpressionDataLoaderServiceImpl.log.warn("Some rows of matrix were not matched to any of the given platforms (" + matrix.rows() + " rows, " + usedDesignElements.size() + " found");
    }
    experiment.setRawExpressionDataVectors(allVectors);
    experiment.setBioAssays(allBioAssays);
    return experiment;
}
Also used : ExperimentalDesign(ubic.gemma.model.expression.experiment.ExperimentalDesign) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Taxon(ubic.gemma.model.genome.Taxon) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) PubMedXMLFetcher(ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Aggregations

ExperimentalDesign (ubic.gemma.model.expression.experiment.ExperimentalDesign)4 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)2 Taxon (ubic.gemma.model.genome.Taxon)2 Criteria (org.hibernate.Criteria)1 Before (org.junit.Before)1 PubMedXMLFetcher (ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher)1 BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)1 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)1 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)1 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)1 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)1 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)1 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)1