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);
}
}
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;
}
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;
}
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;
}
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);
}
Aggregations