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