Search in sources :

Example 6 with ArrayDesignValueObject

use of ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject in project Gemma by PavlidisLab.

the class GeneralSearchControllerImpl method fillValueObjects.

@SuppressWarnings("unchecked")
private void fillValueObjects(Class<?> entityClass, List<SearchResult> results, SearchSettings settings) {
    StopWatch timer = new StopWatch();
    timer.start();
    Collection<?> vos;
    if (ExpressionExperiment.class.isAssignableFrom(entityClass)) {
        vos = this.filterEE(expressionExperimentService.loadValueObjects(EntityUtils.getIds(results), false), settings);
        if (!SecurityUtil.isUserAdmin()) {
            auditableUtil.removeTroubledEes((Collection<ExpressionExperimentValueObject>) vos);
        }
    } else if (ArrayDesign.class.isAssignableFrom(entityClass)) {
        vos = this.filterAD(arrayDesignService.loadValueObjectsByIds(EntityUtils.getIds(results)), settings);
        if (!SecurityUtil.isUserAdmin()) {
            auditableUtil.removeTroubledArrayDesigns((Collection<ArrayDesignValueObject>) vos);
        }
    } else if (CompositeSequence.class.isAssignableFrom(entityClass)) {
        Collection<CompositeSequenceValueObject> css = new ArrayList<>();
        for (SearchResult sr : results) {
            CompositeSequenceValueObject csvo = compositeSequenceService.loadValueObject((CompositeSequence) sr.getResultObject());
            css.add(csvo);
        }
        vos = css;
    } else if (BibliographicReference.class.isAssignableFrom(entityClass)) {
        Collection<BibliographicReference> bss = bibliographicReferenceService.load(EntityUtils.getIds(results));
        bss = bibliographicReferenceService.thaw(bss);
        vos = bibliographicReferenceService.loadValueObjects(bss);
    } else if (Gene.class.isAssignableFrom(entityClass)) {
        Collection<Gene> genes = geneService.load(EntityUtils.getIds(results));
        genes = geneService.thawLite(genes);
        vos = geneService.loadValueObjects(genes);
    } else if (Characteristic.class.isAssignableFrom(entityClass)) {
        Collection<CharacteristicValueObject> cvos = new ArrayList<>();
        for (SearchResult sr : results) {
            Characteristic ch = (Characteristic) sr.getResultObject();
            cvos.add(new CharacteristicValueObject(ch));
        }
        vos = cvos;
    } else if (CharacteristicValueObject.class.isAssignableFrom(entityClass)) {
        Collection<CharacteristicValueObject> cvos = new ArrayList<>();
        for (SearchResult sr : results) {
            CharacteristicValueObject ch = (CharacteristicValueObject) sr.getResultObject();
            cvos.add(ch);
        }
        vos = cvos;
    } else if (BioSequenceValueObject.class.isAssignableFrom(entityClass)) {
        return;
    } else if (GeneSet.class.isAssignableFrom(entityClass)) {
        vos = geneSetService.getValueObjects(EntityUtils.getIds(results));
    } else if (ExpressionExperimentSet.class.isAssignableFrom(entityClass)) {
        vos = experimentSetService.loadValueObjects(experimentSetService.load(EntityUtils.getIds(results)));
    } else if (FactorValue.class.isAssignableFrom(entityClass)) {
        Collection<FactorValueValueObject> fvo = new ArrayList<>();
        for (SearchResult sr : results) {
            fvo.add(new FactorValueValueObject((FactorValue) sr.getResultObject()));
        }
        vos = fvo;
    } else {
        throw new UnsupportedOperationException("Don't know how to make value objects for class=" + entityClass);
    }
    if (vos == null || vos.isEmpty()) {
        // it causing front end errors, if vos is empty make sure to get rid of all search results
        for (Iterator<SearchResult> it = results.iterator(); it.hasNext(); ) {
            it.next();
            it.remove();
        }
        return;
    }
    // retained objects...
    Map<Long, Object> idMap = EntityUtils.getIdMap(vos);
    for (Iterator<SearchResult> it = results.iterator(); it.hasNext(); ) {
        SearchResult sr = it.next();
        if (!idMap.containsKey(sr.getId())) {
            it.remove();
            continue;
        }
        sr.setResultObject(idMap.get(sr.getId()));
    }
    if (timer.getTime() > 1000) {
        BaseFormController.log.info("Value object conversion after search: " + timer.getTime() + "ms");
    }
}
Also used : CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject) CompositeSequenceValueObject(ubic.gemma.model.expression.designElement.CompositeSequenceValueObject) Gene(ubic.gemma.model.genome.Gene) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) BioSequenceValueObject(ubic.gemma.model.genome.sequenceAnalysis.BioSequenceValueObject) FactorValueValueObject(ubic.gemma.model.expression.experiment.FactorValueValueObject) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Characteristic(ubic.gemma.model.common.description.Characteristic) SearchResult(ubic.gemma.core.search.SearchResult) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) StopWatch(org.apache.commons.lang3.time.StopWatch) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) SearchSettingsValueObject(ubic.gemma.model.common.search.SearchSettingsValueObject) FactorValueValueObject(ubic.gemma.model.expression.experiment.FactorValueValueObject) BioSequenceValueObject(ubic.gemma.model.genome.sequenceAnalysis.BioSequenceValueObject) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) CompositeSequenceValueObject(ubic.gemma.model.expression.designElement.CompositeSequenceValueObject) CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)

Example 7 with ArrayDesignValueObject

use of ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject in project Gemma by PavlidisLab.

the class ArrayDesignFormController method formBackingObject.

/**
 * Case = GET: Step 1 - return instance of command class (from database). This is not called in the POST case
 * because the sessionForm is set to 'true' in the constructor. This means the command object was already bound to
 * the session in the GET case.
 *
 * @param request http request
 * @return Object
 */
@Override
protected Object formBackingObject(HttpServletRequest request) {
    String idString = request.getParameter("id");
    Long id;
    ArrayDesignValueObject arrayDesign = null;
    // should be caught by validation.
    if (idString != null) {
        try {
            id = Long.parseLong(idString);
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException();
        }
        Collection<Long> ids = new HashSet<Long>();
        ids.add(id);
        Collection<ArrayDesignValueObject> arrayDesigns = arrayDesignService.loadValueObjectsByIds(ids);
        if (arrayDesigns.size() > 0)
            arrayDesign = arrayDesigns.iterator().next();
    }
    if (arrayDesign == null) {
        return new ArrayDesignValueObject(-1L);
    }
    return arrayDesign;
}
Also used : ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)

Example 8 with ArrayDesignValueObject

use of ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject in project Gemma by PavlidisLab.

the class ArrayDesignReportServiceImpl method fillInSubsumptionInfo.

@Override
public void fillInSubsumptionInfo(Collection<ArrayDesignValueObject> valueObjects) {
    Collection<Long> ids = new ArrayList<>();
    for (Object object : valueObjects) {
        if (object == null)
            continue;
        ArrayDesignValueObject adVo = (ArrayDesignValueObject) object;
        ids.add(adVo.getId());
    }
    Map<Long, Boolean> isSubsumed = arrayDesignService.isSubsumed(ids);
    Map<Long, Boolean> hasSubsumees = arrayDesignService.isSubsumer(ids);
    Map<Long, Boolean> isMergee = arrayDesignService.isMergee(ids);
    Map<Long, Boolean> isMerged = arrayDesignService.isMerged(ids);
    for (ArrayDesignValueObject adVo : valueObjects) {
        Long id = adVo.getId();
        if (isSubsumed.containsKey(id)) {
            adVo.setIsSubsumed(isSubsumed.get(id));
        }
        if (hasSubsumees.containsKey(id)) {
            adVo.setIsSubsumer(hasSubsumees.get(id));
        }
        if (isMergee.containsKey(id)) {
            adVo.setIsMergee(isMergee.get(id));
        }
        if (isMerged.containsKey(id)) {
            adVo.setIsMerged(isMerged.get(id));
        }
    }
}
Also used : ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)

Example 9 with ArrayDesignValueObject

use of ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject in project Gemma by PavlidisLab.

the class ArrayDesignReportServiceImpl method fillInValueObjects.

/**
 * Fill in the probe summary statistics
 */
@Override
public void fillInValueObjects(Collection<ArrayDesignValueObject> adVos) {
    for (ArrayDesignValueObject origVo : adVos) {
        if (origVo == null)
            continue;
        ArrayDesignValueObject cachedVo = this.getSummaryObject(origVo.getId());
        if (cachedVo != null) {
            origVo.setNumProbeSequences(cachedVo.getNumProbeSequences());
            origVo.setNumProbeAlignments(cachedVo.getNumProbeAlignments());
            origVo.setNumProbesToGenes(cachedVo.getNumProbesToGenes());
            origVo.setNumGenes(cachedVo.getNumGenes());
            origVo.setDateCached(cachedVo.getDateCached());
            origVo.setDesignElementCount(cachedVo.getDesignElementCount());
        }
    }
}
Also used : ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)

Example 10 with ArrayDesignValueObject

use of ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject in project Gemma by PavlidisLab.

the class ArrayDesignReportServiceImpl method generateAllArrayDesignReport.

@Override
public void generateAllArrayDesignReport() {
    ArrayDesignReportServiceImpl.log.info("Generating report summarizing all platforms ... ");
    // obtain time information (for timestamp)
    Date d = new Date(System.currentTimeMillis());
    String timestamp = DateFormatUtils.format(d, "yyyy.MM.dd HH:mm");
    long numCsBioSequences = arrayDesignService.numAllCompositeSequenceWithBioSequences();
    long numCsBlatResults = arrayDesignService.numAllCompositeSequenceWithBlatResults();
    long numCsGenes = arrayDesignService.numAllCompositeSequenceWithGenes();
    long numGenes = arrayDesignService.numAllGenes();
    // create a surrogate ArrayDesignValue object to represent the total of all platforms
    ArrayDesignValueObject adVo = new ArrayDesignValueObject(-1L);
    adVo.setNumProbeSequences(Long.toString(numCsBioSequences));
    adVo.setNumProbeAlignments(Long.toString(numCsBlatResults));
    adVo.setNumProbesToGenes(Long.toString(numCsGenes));
    adVo.setNumGenes(Long.toString(numGenes));
    adVo.setDateCached(timestamp);
    // remove file first
    File f = new File(ArrayDesignReportServiceImpl.HOME_DIR + File.separatorChar + ArrayDesignReportServiceImpl.ARRAY_DESIGN_REPORT_DIR + File.separatorChar + ArrayDesignReportServiceImpl.ARRAY_DESIGN_SUMMARY);
    if (f.exists()) {
        if (!f.canWrite() || !f.delete()) {
            ArrayDesignReportServiceImpl.log.warn("Cannot write to file.");
            return;
        }
    }
    try (FileOutputStream fos = new FileOutputStream(ArrayDesignReportServiceImpl.HOME_DIR + File.separatorChar + ArrayDesignReportServiceImpl.ARRAY_DESIGN_REPORT_DIR + File.separatorChar + ArrayDesignReportServiceImpl.ARRAY_DESIGN_SUMMARY);
        ObjectOutputStream oos = new ObjectOutputStream(fos)) {
        oos.writeObject(adVo);
    } catch (Throwable e) {
        // cannot write to file. Just fail gracefully.
        ArrayDesignReportServiceImpl.log.error("Cannot write to file.");
    }
    ArrayDesignReportServiceImpl.log.info("Done making reports");
}
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