use of ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject in project Gemma by PavlidisLab.
the class ArrayDesignReportServiceImpl method generateArrayDesignReport.
@Override
@Secured({ "GROUP_AGENT" })
public void generateArrayDesignReport() {
this.initDirectories();
Collection<ArrayDesignValueObject> ads = arrayDesignService.loadAllValueObjects();
ArrayDesignReportServiceImpl.log.info("Creating reports for " + ads.size() + " platforms");
for (ArrayDesignValueObject ad : ads) {
this.generateArrayDesignReport(ad);
}
ArrayDesignReportServiceImpl.log.info("Generating global report");
this.generateAllArrayDesignReport();
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject in project Gemma by PavlidisLab.
the class ArrayDesignReportServiceImpl method fillEventInformation.
/**
* Fill in event information
*/
@Override
public void fillEventInformation(Collection<ArrayDesignValueObject> adVos) {
if (adVos == null || adVos.size() == 0)
return;
StopWatch watch = new StopWatch();
watch.start();
Collection<Long> ids = new ArrayList<>();
for (Object object : adVos) {
ArrayDesignValueObject adVo = (ArrayDesignValueObject) object;
Long id = adVo.getId();
if (id == null)
continue;
ids.add(id);
}
if (ids.size() == 0)
return;
Collection<Class<? extends AuditEventType>> typesToGet = Arrays.asList(eventTypes);
Collection<ArrayDesign> arrayDesigns = arrayDesignService.load(ids);
Map<Long, ArrayDesign> idMap = EntityUtils.getIdMap(arrayDesigns);
Map<Class<? extends AuditEventType>, Map<Auditable, AuditEvent>> events = auditEventService.getLastEvents(arrayDesigns, typesToGet);
Map<Auditable, AuditEvent> geneMappingEvents = events.get(ArrayDesignGeneMappingEvent.class);
Map<Auditable, AuditEvent> sequenceUpdateEvents = events.get(ArrayDesignSequenceUpdateEvent.class);
Map<Auditable, AuditEvent> sequenceAnalysisEvents = events.get(ArrayDesignSequenceAnalysisEvent.class);
Map<Auditable, AuditEvent> repeatAnalysisEvents = events.get(ArrayDesignRepeatAnalysisEvent.class);
for (ArrayDesignValueObject adVo : adVos) {
Long id = adVo.getId();
ArrayDesign ad = idMap.get(id);
if (geneMappingEvents.containsKey(ad)) {
AuditEvent event = geneMappingEvents.get(ad);
if (event != null) {
adVo.setLastGeneMapping(event.getDate());
}
}
if (sequenceUpdateEvents.containsKey(ad)) {
AuditEvent event = sequenceUpdateEvents.get(ad);
if (event != null) {
adVo.setLastSequenceUpdate(event.getDate());
}
}
if (sequenceAnalysisEvents.containsKey(ad)) {
AuditEvent event = sequenceAnalysisEvents.get(ad);
if (event != null) {
adVo.setLastSequenceAnalysis(event.getDate());
}
}
if (repeatAnalysisEvents.containsKey(ad)) {
AuditEvent event = repeatAnalysisEvents.get(ad);
if (event != null) {
adVo.setLastRepeatMask(event.getDate());
}
}
}
watch.stop();
if (watch.getTime() > 1000)
ArrayDesignReportServiceImpl.log.info("Added event information in " + watch.getTime() + "ms");
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject in project Gemma by PavlidisLab.
the class BioAssayDimensionValueObject method makeDummyBioAssayDimension.
private BioAssayDimension makeDummyBioAssayDimension() {
assert this.id == null;
BioAssayDimension fakeBd = BioAssayDimension.Factory.newInstance("Placeholder representing: " + name, description, new ArrayList<BioAssay>());
Map<Long, ExperimentalFactor> fakeEfs = new HashMap<>();
for (BioAssayValueObject bav : this.bioAssays) {
BioAssay ba = BioAssay.Factory.newInstance();
ba.setId(bav.getId());
ba.setName(bav.getName());
ba.setDescription("Fake placeholder");
BioMaterial sampleUsed = BioMaterial.Factory.newInstance();
BioMaterialValueObject bmVo = bav.getSample();
assert bmVo != null;
sampleUsed.setId(bmVo.getId());
sampleUsed.setName(bmVo.getName());
sampleUsed.setDescription("Fake placeholder");
for (IdentifiableValueObject iVo : bmVo.getFactorValueObjects()) {
FactorValueValueObject fvVo = (FactorValueValueObject) iVo;
FactorValue fv = FactorValue.Factory.newInstance();
assert fvVo.getId() != null;
fv.setId(fvVo.getId());
assert fvVo.getValue() != null;
fv.setValue(fvVo.getValue());
Long efId = fvVo.getFactorId();
ExperimentalFactor ef;
if (fakeEfs.containsKey(efId)) {
ef = fakeEfs.get(efId);
} else {
ef = ExperimentalFactor.Factory.newInstance();
ef.setId(efId);
ef.setName(fvVo.getCategory());
ef.setType(fvVo.isMeasurement() ? FactorType.CONTINUOUS : FactorType.CATEGORICAL);
fakeEfs.put(efId, ef);
}
ef.getFactorValues().add(fv);
fv.setExperimentalFactor(ef);
sampleUsed.getFactorValues().add(fv);
}
ba.setSampleUsed(sampleUsed);
ArrayDesign ad = ArrayDesign.Factory.newInstance();
ArrayDesignValueObject adVo = bav.getArrayDesign();
assert adVo != null;
ad.setId(adVo.getId());
ad.setShortName(adVo.getShortName());
ad.setDescription("Fake placeholder");
ba.setArrayDesignUsed(ad);
fakeBd.getBioAssays().add(ba);
}
return fakeBd;
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject in project Gemma by PavlidisLab.
the class DoubleVectorValueObject method addGaps.
private void addGaps(BioAssayDimension dimToMatch) {
BioAssayDimensionValueObject sourceBioAssayDimension = new BioAssayDimensionValueObject(dimToMatch);
List<BioAssayValueObject> dimToMatchBioAssays = sourceBioAssayDimension.getBioAssays();
double[] expandedData = new double[dimToMatch.getBioAssays().size()];
BioAssayDimension expandedDim = BioAssayDimension.Factory.newInstance();
expandedDim.setDescription("Expanded bioassay dimension based on " + this.getBioAssayDimension().getName());
expandedDim.setName("Expanded bioassay dimension based on " + this.getBioAssayDimension().getName());
Map<BioMaterialValueObject, BioAssayValueObject> bmap = new HashMap<>();
ArrayDesignValueObject arrayDesign = null;
for (BioAssayValueObject b : this.getBioAssays()) {
bmap.put(b.getSample(), b);
arrayDesign = b.getArrayDesign();
}
List<BioAssayValueObject> expandedBioAssays = new ArrayList<>();
int i = 0;
int indexInUngappedData = 0;
for (BioAssayValueObject b : dimToMatchBioAssays) {
BioMaterialValueObject bm = b.getSample();
if (!bmap.containsKey(bm)) {
/*
* This is one where we have to put in a gap.
*/
expandedData[i] = Double.NaN;
BioAssayValueObject placeholder = new BioAssayValueObject(-1L);
placeholder.setName("Missing bioassay for biomaterial=" + bm + " that was not run on " + arrayDesign);
placeholder.setDescription("This is to represent a biomaterial that was not run on the platform for the rest of the bioassay dimension.");
placeholder.setArrayDesign(arrayDesign);
placeholder.setSample(bm);
expandedBioAssays.add(placeholder);
} else {
expandedBioAssays.add(this.getBioAssays().get(indexInUngappedData));
expandedData[i] = data[indexInUngappedData];
indexInUngappedData++;
}
i++;
}
assert dimToMatchBioAssays.size() == expandedBioAssays.size();
this.data = expandedData;
this.setBioAssayDimension(new BioAssayDimensionValueObject(-1L));
this.getBioAssayDimension().setSourceBioAssayDimension(sourceBioAssayDimension);
// not exactly, but have to make clear it's not real.
this.getBioAssayDimension().setIsSubset(true);
this.getBioAssayDimension().clearBioAssays();
this.getBioAssayDimension().addBioAssays(expandedBioAssays);
this.getBioAssayDimension().setName("Expanded bioassay dimension based on " + this.getBioAssayDimension().getName());
assert this.getBioAssays() != null;
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject in project Gemma by PavlidisLab.
the class ExpressionExperimentDetailsValueObject method getTroubleDetails.
/**
* Checks trouble of this EE and all its Array Designs and returns compilation of trouble info.
* MAKE SURE to fill the Array Design variable first!
*
* @param htmlEscape whether to escape the returned string for html
* @return string with trouble info.
*/
@Override
public String getTroubleDetails(boolean htmlEscape) {
String eeTroubleDetails = null;
StringBuilder adTroubleDetails = null;
String finalTroubleDetails = "";
boolean adTroubled = false;
if (super.getTroubled())
eeTroubleDetails = super.getTroubleDetails(htmlEscape);
if (this.arrayDesigns != null) {
// Just because dwr accesses this even when arrayDesigns is not set.
for (ArrayDesignValueObject ad : this.arrayDesigns) {
if (ad.getTroubled()) {
adTroubled = true;
if (adTroubleDetails == null) {
adTroubleDetails = new StringBuilder(ExpressionExperimentDetailsValueObject.TROUBLE_DETAIL_PLATF);
} else {
adTroubleDetails.append(ExpressionExperimentDetailsValueObject.TROUBLE_DETAIL_SEPARATOR);
}
adTroubleDetails.append(ad.getTroubleDetails(false));
}
}
}
if (super.getTroubled()) {
finalTroubleDetails += eeTroubleDetails;
} else if (adTroubled) {
finalTroubleDetails += adTroubleDetails;
}
return htmlEscape ? StringEscapeUtils.escapeHtml4(finalTroubleDetails) : finalTroubleDetails;
}
Aggregations