Search in sources :

Example 1 with ArrayDesignValueObject

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

the class ArrayDesignControllerImpl method getReportHtml.

@Override
public Map<String, String> getReportHtml(EntityDelegator ed) {
    assert ed.getId() != null;
    ArrayDesignValueObject summary = arrayDesignReportService.getSummaryObject(ed.getId());
    Map<String, String> result = new HashMap<>();
    result.put("id", ed.getId().toString());
    if (summary == null)
        result.put("html", "Not available");
    else
        result.put("html", ArrayDesignHtmlUtil.getSummaryHtml(summary));
    return result;
}
Also used : ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)

Example 2 with ArrayDesignValueObject

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

the class AssayViewTag method addNovelBiomaterialSlots.

/**
 * Add places for completely new biomaterials to be added. These are the row labels.
 */
private void addNovelBiomaterialSlots(StringBuilder buf, Set<ArrayDesignValueObject> designs, Map<String, String> assayToMaterial, int count, int emptyCount) {
    if (designs.size() == 1) {
        return;
    }
    for (int i = 1; i <= NUM_EXTRA_BIOMATERIALS; i++) {
        if (count % 2 == 0) {
            buf.append("<tr class='even' align=justify>");
        } else {
            buf.append("<tr class='odd' align=justify>");
        }
        // FIXME this is a kludge: use negative ids to distinguish the new biomaterials.
        BioMaterialValueObject material = new BioMaterialValueObject(0L - i);
        material.setName("[New biomaterial " + i + "]");
        buf.append("<td>" + material.getName() + "</td>");
        String image = "<img height=10 width=20 src='" + Settings.getRootContext() + "/images/arrow_out.png' />";
        for (ArrayDesignValueObject design : designs) {
            emptyCount = addEmpty(buf, assayToMaterial, emptyCount, material, image, design);
        }
        buf.append("</tr>");
        count++;
    }
}
Also used : ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) BioMaterialValueObject(ubic.gemma.model.expression.biomaterial.BioMaterialValueObject)

Example 3 with ArrayDesignValueObject

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

the class AssayViewTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    StringBuilder buf = new StringBuilder();
    buf.append("<div>");
    // create table
    Map<BioMaterialValueObject, Map<ArrayDesignValueObject, Collection<BioAssayValueObject>>> bioAssayMap = new HashMap<>();
    Set<ArrayDesignValueObject> designs = new HashSet<>();
    Map<ArrayDesignValueObject, Long> arrayMaterialCount = new HashMap<>();
    // package all of this information into JSON for javascript dynamic retrieval
    Map<String, String> assayToMaterial = new HashMap<>();
    for (BioAssayValueObject assay : bioAssays) {
        // map for bioassays linked to a specific arraydesign
        // map for the bioassays linked to a specific biomaterial
        BioMaterialValueObject material = assay.getSample();
        ArrayDesignValueObject design = assay.getArrayDesign();
        designs.add(design);
        // check if the assay list is initialized yet
        Map<ArrayDesignValueObject, Collection<BioAssayValueObject>> assayMap;
        if (bioAssayMap.containsKey(material)) {
            assayMap = bioAssayMap.get(material);
        } else {
            assayMap = new HashMap<>();
            bioAssayMap.put(material, assayMap);
        }
        if (assayMap.containsKey(design)) {
            assayMap.get(design).add(assay);
        } else {
            Collection<BioAssayValueObject> assayList = new ArrayList<>();
            assayList.add(assay);
            assayMap.put(design, assayList);
        }
        if (arrayMaterialCount.containsKey(design)) {
            Long count = arrayMaterialCount.get(design);
            count++;
            arrayMaterialCount.put(design, count);
        } else {
            Long count = new Long(1);
            arrayMaterialCount.put(design, count);
        }
    }
    int materialCount = bioAssayMap.keySet().size();
    buf.append("<table class='detail row-separated odd-gray'><tr>");
    buf.append("<th>" + materialCount + " BioMaterials</th>");
    // display arraydesigns
    for (ArrayDesignValueObject design : designs) {
        Long count = arrayMaterialCount.get(design);
        buf.append("<th>" + count + " BioAssays on<br /><a target='_blank' href=\"" + Settings.getRootContext() + "/arrays/showArrayDesign.html?id=" + design.getId() + "\" title=\"" + design.getName() + "\" >" + (design.getShortName() == null ? design.getName() : design.getShortName()) + "</a></th>");
    }
    buf.append("</tr>");
    // display bioMaterials and the corresponding bioAssays
    int count = 1;
    Iterator<BioMaterialValueObject> iter = bioAssayMap.keySet().iterator();
    List<BioMaterialValueObject> materials = new ArrayList<>();
    while (iter.hasNext()) {
        materials.add(iter.next());
    }
    Comparator<BioMaterialValueObject> comparator = new BioMaterialComparator();
    Collections.sort(materials, comparator);
    int elementCount = 1;
    int emptyCount = 0;
    for (BioMaterialValueObject material : materials) {
        if (count % 2 == 0) {
            buf.append("<tr class='even' align=justify>");
        } else {
            buf.append("<tr class='odd' align=justify>");
        }
        String bmLink = "<a href='" + Settings.getRootContext() + "/bioMaterial/showBioMaterial.html?id=" + material.getId() + "'> " + material.getName() + "</a>";
        buf.append("<td>" + bmLink + "</td>");
        Map<ArrayDesignValueObject, Collection<BioAssayValueObject>> assayMap = bioAssayMap.get(material);
        String image = "&nbsp;&nbsp;&nbsp;<img height=16 width=16 src='" + Settings.getRootContext() + "/images/icons/arrow_switch.png' />&nbsp;&nbsp;&nbsp;";
        for (ArrayDesignValueObject design : designs) {
            if (assayMap.containsKey(design)) {
                Collection<BioAssayValueObject> assays = assayMap.get(design);
                Collection<Long> ids = new ArrayList<>();
                Collection<String> tooltips = new ArrayList<>();
                for (BioAssayValueObject assay : assays) {
                    ids.add(assay.getId());
                    tooltips.add(StringUtils.abbreviate(assay.getName() + assay.getDescription(), 120));
                    this.addMaterial(assayToMaterial, assay.getId(), material.getId());
                }
                if (assayMap.get(design).size() > 1) {
                    String link = "<a title='" + StringUtils.join(tooltips.toArray(), "\n") + "' href='" + Settings.getRootContext() + "/bioAssay/showAllBioAssays.html?id=" + StringUtils.join(ids.toArray(), ",") + "'> (list) </a>";
                    buf.append("<td>" + assayMap.get(design).size() + link + "&nbsp;" + elementCount + "</td>\n");
                } else {
                    /*
                         * Each bioassay has a unique id; the div it sits in is identified by the class 'dragitem'. See
                         * expressionExperiment.edit.jsp.
                         */
                    BioAssayValueObject assay = ((List<BioAssayValueObject>) assayMap.get(design)).get(0);
                    String shortDesc = StringUtils.abbreviate(assay.getDescription(), 60);
                    String link = "<a target=\"_blank\" title='" + shortDesc + "' href='" + Settings.getRootContext() + "/bioAssay/showBioAssay.html?id=" + assay.getId() + "'>" + assay.getName() + "</a>";
                    String editAttributes = " align='left' class='dragItem' id='bioassay." + assay.getId() + "' material='" + material.getId() + "' assay='" + assay.getId() + "' arrayDesign='" + design.getId() + "'";
                    if (edit && designs.size() > 1) {
                        buf.append("\n<td><span " + editAttributes + ">" + image + link);
                    } else {
                        buf.append("\n<td ><span>" + link + "&nbsp;");
                    }
                    buf.append("</span></td>\n");
                }
            } else {
                emptyCount = addEmpty(buf, assayToMaterial, emptyCount, material, image, design);
            }
        }
        buf.append("</tr>");
        count++;
        elementCount++;
    }
    // add a few blanks, but only if we are editing.
    if (edit) {
        addNovelBiomaterialSlots(buf, designs, assayToMaterial, count, emptyCount);
    }
    buf.append("</table>");
    if (edit) {
        // append JSON serialization
        try {
            String jsonSerialization = JSONMapper.toJSON(assayToMaterial).render(false);
            buf.append("<input type='hidden' id='assayToMaterialMap' name='assayToMaterialMap' value='" + jsonSerialization + "'/>");
        } catch (MapperException e) {
        // cannot serialize
        }
    }
    buf.append("</div>");
    try {
        pageContext.getOut().print(buf.toString());
    } catch (Exception ex) {
        throw new JspException("assayViewTag: " + ex.getMessage());
    }
    return SKIP_BODY;
}
Also used : JspException(javax.servlet.jsp.JspException) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) MapperException(com.sdicons.json.mapper.MapperException) MapperException(com.sdicons.json.mapper.MapperException) JspException(javax.servlet.jsp.JspException) BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject) BioMaterialValueObject(ubic.gemma.model.expression.biomaterial.BioMaterialValueObject)

Example 4 with ArrayDesignValueObject

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

the class ArrayDesignReportServiceImpl method getSummaryObject.

/**
 * Get a specific cached summary object
 *
 * @return arrayDesignValueObject the specified summary object
 */
@Override
public ArrayDesignValueObject getSummaryObject(Long id) {
    ArrayDesignValueObject adVo = null;
    File f = new File(ArrayDesignReportServiceImpl.HOME_DIR + "/" + ArrayDesignReportServiceImpl.ARRAY_DESIGN_REPORT_DIR + File.separatorChar + ArrayDesignReportServiceImpl.ARRAY_DESIGN_REPORT_FILE_NAME_PREFIX + "." + id);
    if (f.exists()) {
        try (FileInputStream fis = new FileInputStream(f);
            ObjectInputStream ois = new ObjectInputStream(fis)) {
            adVo = (ArrayDesignValueObject) ois.readObject();
        } catch (Throwable e) {
            return null;
        }
    }
    return adVo;
}
Also used : ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)

Example 5 with ArrayDesignValueObject

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

the class ArrayDesignReportServiceImpl method getSummaryObject.

/**
 * Get the cached summary object that represents all platforms.
 *
 * @return arrayDesignValueObject the summary object that represents the grand total of all array designs
 */
@Override
public ArrayDesignValueObject getSummaryObject() {
    ArrayDesignValueObject adVo = null;
    File f = new File(ArrayDesignReportServiceImpl.HOME_DIR + File.separatorChar + ArrayDesignReportServiceImpl.ARRAY_DESIGN_REPORT_DIR + File.separatorChar + ArrayDesignReportServiceImpl.ARRAY_DESIGN_SUMMARY);
    if (f.exists()) {
        try (FileInputStream fis = new FileInputStream(f);
            ObjectInputStream ois = new ObjectInputStream(fis)) {
            adVo = (ArrayDesignValueObject) ois.readObject();
        } catch (Throwable e) {
            return null;
        }
    }
    return adVo;
}
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