Search in sources :

Example 11 with ArrayDesignValueObject

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();
}
Also used : ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) Secured(org.springframework.security.access.annotation.Secured)

Example 12 with ArrayDesignValueObject

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");
}
Also used : Auditable(ubic.gemma.model.common.Auditable) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) StopWatch(org.apache.commons.lang3.time.StopWatch) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) AuditEvent(ubic.gemma.model.common.auditAndSecurity.AuditEvent)

Example 13 with ArrayDesignValueObject

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;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) FactorValueValueObject(ubic.gemma.model.expression.experiment.FactorValueValueObject) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject) IdentifiableValueObject(ubic.gemma.model.IdentifiableValueObject) BioMaterialValueObject(ubic.gemma.model.expression.biomaterial.BioMaterialValueObject) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 14 with ArrayDesignValueObject

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;
}
Also used : BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) DoubleArrayList(cern.colt.list.DoubleArrayList) BioMaterialValueObject(ubic.gemma.model.expression.biomaterial.BioMaterialValueObject)

Example 15 with ArrayDesignValueObject

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

Aggregations

ArrayDesignValueObject (ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)26 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)7 BioMaterialValueObject (ubic.gemma.model.expression.biomaterial.BioMaterialValueObject)4 BioAssayValueObject (ubic.gemma.model.expression.bioAssay.BioAssayValueObject)3 StopWatch (org.apache.commons.lang3.time.StopWatch)2 Test (org.junit.Test)2 ExpressionExperimentDetailsValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject)2 ExpressionExperimentValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject)2 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)2 FactorValueValueObject (ubic.gemma.model.expression.experiment.FactorValueValueObject)2 BaseSpringWebTest (ubic.gemma.web.util.BaseSpringWebTest)2 DoubleArrayList (cern.colt.list.DoubleArrayList)1 MapperException (com.sdicons.json.mapper.MapperException)1 Date (java.util.Date)1 JspException (javax.servlet.jsp.JspException)1 Secured (org.springframework.security.access.annotation.Secured)1 ObjectError (org.springframework.validation.ObjectError)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 RedirectView (org.springframework.web.servlet.view.RedirectView)1 SearchResult (ubic.gemma.core.search.SearchResult)1