Search in sources :

Example 61 with BioMaterial

use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.

the class BioMaterialController method addFactorValueTo.

/**
 * AJAX
 *
 * @param factorValueId given a collection of biomaterial ids, and a factor value id will add that factor value to
 *                      all of the biomaterials in the collection. If the factor is already defined for one of the biomaterials
 *                      will remove the previous one and add the new one.
 */
public void addFactorValueTo(Collection<Long> bmIds, EntityDelegator factorValueId) {
    Collection<BioMaterial> bms = this.getBioMaterials(bmIds);
    FactorValue factorVToAdd = factorValueService.load(factorValueId.getId());
    ExperimentalFactor eFactor = factorVToAdd.getExperimentalFactor();
    for (BioMaterial material : bms) {
        Collection<FactorValue> oldValues = material.getFactorValues();
        Collection<FactorValue> updatedValues = new HashSet<>();
        // we are adding already
        for (FactorValue value : oldValues) {
            if (value.getExperimentalFactor() != eFactor)
                updatedValues.add(value);
        }
        updatedValues.add(factorVToAdd);
        material.setFactorValues(updatedValues);
        bioMaterialService.update(material);
    }
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) HashSet(java.util.HashSet)

Example 62 with BioMaterial

use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.

the class BioMaterialController method getAnnotation.

public Collection<AnnotationValueObject> getAnnotation(EntityDelegator bm) {
    if (bm == null || bm.getId() == null)
        return null;
    BioMaterial bioM = bioMaterialService.load(bm.getId());
    Collection<AnnotationValueObject> annotation = new ArrayList<>();
    for (Characteristic c : bioM.getCharacteristics()) {
        AnnotationValueObject annotationValue = new AnnotationValueObject();
        annotationValue.setId(c.getId());
        annotationValue.setClassName(c.getCategory());
        annotationValue.setTermName(c.getValue());
        annotationValue.setObjectClass(BioMaterial.class.getSimpleName());
        if (c.getEvidenceCode() != null) {
            annotationValue.setEvidenceCode(c.getEvidenceCode().toString());
        }
        if (c instanceof VocabCharacteristic) {
            VocabCharacteristic vc = (VocabCharacteristic) c;
            annotationValue.setClassUri(vc.getCategoryUri());
            String className = getLabelFromUri(vc.getCategoryUri());
            if (className != null)
                annotationValue.setClassName(className);
            annotationValue.setTermUri(vc.getValueUri());
            String termName = getLabelFromUri(vc.getValueUri());
            if (termName != null)
                annotationValue.setTermName(termName);
        }
        annotation.add(annotationValue);
    }
    return annotation;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) AnnotationValueObject(ubic.gemma.model.common.description.AnnotationValueObject) ArrayList(java.util.ArrayList) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic)

Example 63 with BioMaterial

use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.

the class BioMaterialController method annot.

@RequestMapping("/annotate.html")
public ModelAndView annot(HttpServletRequest request, HttpServletResponse response) {
    log.debug(request.getParameter("eeid"));
    Long id = Long.parseLong(request.getParameter("eeid"));
    Collection<BioMaterial> bioMaterials = getBioMaterialsForEE(id);
    ModelAndView mav = new ModelAndView("bioMaterialAnnotator");
    if (AJAX) {
        mav.addObject("bioMaterialIdList", bioMaterialService.getBioMaterialIdList(bioMaterials));
    }
    Long numBioMaterials = (long) bioMaterials.size();
    mav.addObject("numBioMaterials", numBioMaterials);
    mav.addObject("bioMaterials", bioMaterials);
    return mav;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 64 with BioMaterial

use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.

the class BioMaterialController method getFactorValues.

public Collection<FactorValueValueObject> getFactorValues(EntityDelegator bm) {
    if (bm == null || bm.getId() == null)
        return null;
    BioMaterial bioM = bioMaterialService.load(bm.getId());
    bioMaterialService.thaw(bioM);
    Collection<FactorValueValueObject> results = new HashSet<>();
    Collection<FactorValue> factorValues = bioM.getFactorValues();
    for (FactorValue value : factorValues) results.add(new FactorValueValueObject(value));
    return results;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) HashSet(java.util.HashSet)

Example 65 with BioMaterial

use of ubic.gemma.model.expression.biomaterial.BioMaterial in project Gemma by PavlidisLab.

the class AnnotationController method createBiomaterialTag.

public void createBiomaterialTag(Characteristic vc, Long id) {
    BioMaterial bm = bioMaterialService.load(id);
    if (bm == null) {
        throw new IllegalArgumentException("No such BioMaterial with id=" + id);
    }
    bioMaterialService.thaw(bm);
    ontologyService.saveBioMaterialStatement(vc, bm);
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial)

Aggregations

BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)132 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)67 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)27 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)22 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)19 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)15 HashSet (java.util.HashSet)13 Test (org.junit.Test)13 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)12 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)12 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)10 InputStream (java.io.InputStream)7 DenseDoubleMatrix (ubic.basecode.dataStructure.matrix.DenseDoubleMatrix)7 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)7 QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)7 Characteristic (ubic.gemma.model.common.description.Characteristic)6 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)6 DoubleArrayList (cern.colt.list.DoubleArrayList)5 DoubleMatrix1D (cern.colt.matrix.DoubleMatrix1D)5 ArrayList (java.util.ArrayList)5