use of ubic.gemma.model.common.description.Characteristic in project Gemma by PavlidisLab.
the class ExpressionPersister method persistBioMaterial.
private BioMaterial persistBioMaterial(BioMaterial entity) {
if (entity == null)
return null;
AbstractPersister.log.debug("Persisting " + entity);
if (!this.isTransient(entity))
return entity;
assert entity.getSourceTaxon() != null;
AbstractPersister.log.debug("Persisting " + entity);
this.fillInDatabaseEntry(entity.getExternalAccession());
AbstractPersister.log.debug("db entry done");
entity.setSourceTaxon(this.persistTaxon(entity.getSourceTaxon()));
AbstractPersister.log.debug("taxon done");
for (Treatment treatment : entity.getTreatments()) {
Characteristic action = treatment.getAction();
AbstractPersister.log.debug(treatment + " action: " + action);
AbstractPersister.log.debug("treatment done");
}
AbstractPersister.log.debug("start save");
BioMaterial bm = bioMaterialDao.findOrCreate(entity);
AbstractPersister.log.debug("save biomaterial done");
return bm;
}
use of ubic.gemma.model.common.description.Characteristic in project Gemma by PavlidisLab.
the class FactorValueValueObject method getSummaryString.
static String getSummaryString(FactorValue fv) {
StringBuilder buf = new StringBuilder();
if (fv.getCharacteristics().size() > 0) {
for (Iterator<Characteristic> iter = fv.getCharacteristics().iterator(); iter.hasNext(); ) {
Characteristic c = iter.next();
buf.append(c.getValue() == null ? "[Unassigned]" : c.getValue());
if (iter.hasNext())
buf.append(", ");
}
} else if (fv.getMeasurement() != null) {
buf.append(fv.getMeasurement().getValue());
} else if (StringUtils.isNotBlank(fv.getValue())) {
buf.append(fv.getValue());
} else {
buf.append("?");
}
return buf.toString();
}
use of ubic.gemma.model.common.description.Characteristic in project Gemma by PavlidisLab.
the class FactorValueValueObject method init.
private void init(FactorValue val, Characteristic c) {
this.setFactorValue(FactorValueValueObject.getSummaryString(val));
this.setFactorId(val.getExperimentalFactor().getId());
this.isBaseline = val.getIsBaseline() != null ? val.getIsBaseline() : this.isBaseline;
if (val.getMeasurement() != null) {
this.setMeasurement(true);
this.value = val.getMeasurement().getValue();
this.setCharId(val.getMeasurement().getId());
} else if (c != null && c.getId() != null) {
this.setCharId(c.getId());
} else {
this.value = val.getValue();
}
if (c != null) {
this.setCategory(c.getCategory());
// clobbers if we set it already
this.setValue(c.getValue());
if (c instanceof VocabCharacteristic) {
VocabCharacteristic vc = (VocabCharacteristic) c;
this.setCategoryUri(vc.getCategoryUri());
this.setValueUri(vc.getValueUri());
}
}
/*
* Make sure we fill in the Category for this.
*/
Characteristic factorCategory = val.getExperimentalFactor().getCategory();
if (this.getCategory() == null && factorCategory != null) {
this.setCategory(factorCategory.getCategory());
if (factorCategory instanceof VocabCharacteristic) {
VocabCharacteristic vc = (VocabCharacteristic) factorCategory;
this.setCategoryUri(vc.getCategoryUri());
}
}
}
use of ubic.gemma.model.common.description.Characteristic 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.common.description.Characteristic in project Gemma by PavlidisLab.
the class AnnotationController method removeExperimentTag.
public void removeExperimentTag(Collection<Long> characterIds, Long eeId) {
ExpressionExperiment ee = expressionExperimentService.load(eeId);
if (ee == null) {
return;
}
ee = expressionExperimentService.thawLite(ee);
Collection<Characteristic> current = ee.getCharacteristics();
Collection<Characteristic> found = new HashSet<>();
for (Characteristic characteristic : current) {
if (characterIds.contains(characteristic.getId()))
found.add(characteristic);
}
for (Characteristic characteristic : found) {
log.info("Removing characteristic from " + ee + " : " + characteristic);
}
current.removeAll(found);
ee.setCharacteristics(current);
expressionExperimentService.update(ee);
for (Long id : characterIds) {
characteristicService.remove(id);
}
}
Aggregations