use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ArrayDesignDaoImpl method thaw.
@Override
public ArrayDesign thaw(final ArrayDesign arrayDesign) {
if (arrayDesign.getId() == null) {
throw new IllegalArgumentException("Cannot thawRawAndProcessed a non-persistent array design");
}
/*
* Thaw basic stuff
*/
StopWatch timer = new StopWatch();
timer.start();
ArrayDesign result = this.thawLite(arrayDesign);
if (timer.getTime() > 1000) {
AbstractDao.log.info("Thaw array design stage 1: " + timer.getTime() + "ms");
}
timer.stop();
timer.reset();
timer.start();
/*
* Thaw the composite sequences.
*/
AbstractDao.log.info("Start initialize composite sequences");
Hibernate.initialize(result.getCompositeSequences());
if (timer.getTime() > 1000) {
AbstractDao.log.info("Thaw array design stage 2: " + timer.getTime() + "ms");
}
timer.stop();
timer.reset();
timer.start();
/*
* Thaw the biosequences in batches
*/
Collection<CompositeSequence> thawed = new HashSet<>();
Collection<CompositeSequence> batch = new HashSet<>();
long lastTime = timer.getTime();
for (CompositeSequence cs : result.getCompositeSequences()) {
batch.add(cs);
if (batch.size() == 1000) {
long t = timer.getTime();
if (t > 10000 && t - lastTime > 1000) {
AbstractDao.log.info("Thaw Batch : " + t);
}
List bb = this.thawBatchOfProbes(batch);
// noinspection unchecked
thawed.addAll((Collection<? extends CompositeSequence>) bb);
lastTime = timer.getTime();
batch.clear();
}
this.getSessionFactory().getCurrentSession().evict(cs);
}
if (!batch.isEmpty()) {
// tail end
List bb = this.thawBatchOfProbes(batch);
// noinspection unchecked
thawed.addAll((Collection<? extends CompositeSequence>) bb);
}
result.getCompositeSequences().clear();
result.getCompositeSequences().addAll(thawed);
/*
* This is a bit ugly, but necessary to avoid 'dirty collection' errors later.
*/
if (result.getCompositeSequences() instanceof PersistentCollection)
((PersistentCollection) result.getCompositeSequences()).clearDirty();
if (timer.getTime() > 1000) {
AbstractDao.log.info("Thaw array design stage 3: " + timer.getTime());
}
return result;
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class QuantitationTypeData method getBioAssayDimensions.
/**
* @return a single BioAssayDimension except if there are multiple array designs used in the experiment.
*/
public List<BioAssayDimension> getBioAssayDimensions() {
List<BioAssayDimension> result = new ArrayList<>();
if (dimMap.keySet().size() > 0) {
result.addAll(dimMap.values());
return result;
}
if (this.vectors.isEmpty()) {
throw new IllegalStateException("No vectors, no bioassay dimensions");
}
ExpressionDataMatrixBuilder.log.debug("Checking all vectors to get bioAssayDimensions");
Collection<BioAssayDimension> dimensions = new HashSet<>();
for (DesignElementDataVector vector : vectors) {
ArrayDesign adUsed = this.arrayDesignForVector(vector);
if (!dimMap.containsKey(adUsed)) {
dimMap.put(adUsed, vector.getBioAssayDimension());
}
dimensions.add(vector.getBioAssayDimension());
}
ExpressionDataMatrixBuilder.log.debug("got " + dimensions.size() + " bioAssayDimensions");
result.addAll(dimensions);
return result;
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class PersistentDummyObjectHelper method getTestPersistentExpressionExperiment.
/**
* Convenience method to provide an ExpressionExperiment that can be used to fill non-nullable associations in test
* objects. This implementation does NOT fill in associations of the created object except for the creation of
* persistent BioMaterials and BioAssays so that database taxon lookups for this experiment will work.
*
* @param taxon the experiment will have this taxon
* @return EE
*/
public ExpressionExperiment getTestPersistentExpressionExperiment(Taxon taxon) {
BioAssay ba;
BioMaterial bm;
ArrayDesign ad;
bm = this.getTestPersistentBioMaterial(taxon);
ad = this.getTestPersistentArrayDesign(4, true, true);
ba = this.getTestPersistentBioAssay(ad, bm);
Set<BioAssay> bas1 = new HashSet<>();
bas1.add(ba);
ExpressionExperiment ee = ExpressionExperiment.Factory.newInstance();
ee.setName(RandomStringUtils.randomNumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH) + "_testee");
ee.setShortName(RandomStringUtils.randomNumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH) + "_testee");
ee.setBioAssays(bas1);
Collection<FactorValue> allFactorValues = new HashSet<>();
ExperimentalDesign ed = this.getExperimentalDesign(allFactorValues);
ee.setExperimentalDesign(ed);
ee.setOwner(this.getTestPersistentContact());
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;
ee.setQuantitationTypes(quantitationTypes);
ee.setRawExpressionDataVectors(vectors);
ArrayDesignsForExperimentCache c = persisterHelper.prepare(ee);
return persisterHelper.persist(ee, c);
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ArrayDesignMergeServiceImpl method createMerged.
/**
* @param mergeWithExisting i.e., "add", assuming arrayDesign is already a merged design.
*/
private ArrayDesign createMerged(ArrayDesign arrayDesign, Collection<ArrayDesign> otherArrayDesigns, Map<BioSequence, Collection<CompositeSequence>> globalBsMap, String newName, String newShortName, boolean mergeWithExisting) {
ArrayDesign result = this.formMergedDesign(arrayDesign, otherArrayDesigns, newName, newShortName, mergeWithExisting);
Collection<CompositeSequence> newProbes = this.makeNewProbes(result, globalBsMap, mergeWithExisting);
result = mergeServiceHelper.persistMerging(result, arrayDesign, otherArrayDesigns, mergeWithExisting, newProbes);
arrayDesignReportService.generateArrayDesignReport(result.getId());
return result;
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ArrayDesignMergeServiceImpl method formMergedDesign.
/**
* Populate the initial skeleton of the merged design. If mergeWithExisting=true, then the description of
* arrayDesign is updated
*
* @return either a new non-persistent arrayDesign ready to be populated, or arrayDesign with an updated
* description.
*/
private ArrayDesign formMergedDesign(ArrayDesign arrayDesign, Collection<ArrayDesign> otherArrayDesigns, String newName, String newShortName, boolean mergeWithExisting) {
String mergeeListString = StringUtils.join(otherArrayDesigns, ",");
ArrayDesign result;
if (mergeWithExisting) {
if (arrayDesign.getMergees().isEmpty()) {
throw new IllegalArgumentException("Cannot use 'add' unless the array design is already a merged design: " + arrayDesign);
}
assert arrayDesign.getId() != null;
ArrayDesignMergeServiceImpl.log.info(arrayDesign + " is already a merged design, others will be added in");
result = arrayDesign;
result.setDescription(result.getDescription() + "; Additional designs merged in: " + mergeeListString);
} else {
result = ArrayDesign.Factory.newInstance();
result.setName(newName);
// assume this is ok.
result.setPrimaryTaxon(arrayDesign.getPrimaryTaxon());
result.setShortName(newShortName);
result.setTechnologyType(arrayDesign.getTechnologyType());
result.setDesignProvider(arrayDesign.getDesignProvider());
mergeeListString = mergeeListString + "," + arrayDesign.getShortName();
result.setDescription("Created by merging the following array designs: " + mergeeListString);
}
return result;
}
Aggregations