use of ubic.gemma.model.common.description.VocabCharacteristic 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.VocabCharacteristic in project Gemma by PavlidisLab.
the class ExperimentalDesignControllerImpl method createCategoryCharacteristic.
private Characteristic createCategoryCharacteristic(String category, String categoryUri) {
Characteristic c;
if (categoryUri != null) {
VocabCharacteristic vc = VocabCharacteristic.Factory.newInstance();
vc.setCategoryUri(categoryUri);
vc.setValueUri(categoryUri);
c = vc;
} else {
c = Characteristic.Factory.newInstance();
}
c.setCategory(category);
c.setValue(category);
// manually added characteristic
c.setEvidenceCode(GOEvidenceCode.IC);
return c;
}
use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.
the class ExperimentalDesignControllerImpl method createTemplateCharacteristic.
private Characteristic createTemplateCharacteristic(Characteristic source) {
Characteristic template = (source instanceof VocabCharacteristic) ? VocabCharacteristic.Factory.newInstance() : Characteristic.Factory.newInstance();
template.setCategory(source.getCategory());
if (source instanceof VocabCharacteristic) {
template.setCategoryUri(source.getCategoryUri());
}
// automatically added characteristic
template.setEvidenceCode(GOEvidenceCode.IEA);
return template;
}
use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.
the class ExperimentalDesignControllerImpl method updateFactorValueCharacteristics.
@Override
public void updateFactorValueCharacteristics(FactorValueValueObject[] fvvos) {
if (fvvos == null || fvvos.length == 0)
return;
for (FactorValueValueObject fvvo : fvvos) {
Long fvID = fvvo.getId();
if (fvID == null) {
throw new IllegalArgumentException("Factor value id must be supplied");
}
FactorValue fv = this.factorValueService.load(fvID);
if (fv == null) {
throw new IllegalArgumentException("Could not load factorvalue with id=" + fvID);
}
if (!securityService.isEditable(fv)) {
/*
* We do this instead of the interceptor because Characteristics are not securable, and we really don't
* want them to be.
*/
throw new AccessDeniedException("Access is denied");
}
// this is optional. Maybe we're actually adding a characteristic for the
Long charId = fvvo.getCharId();
// first time.
Characteristic c;
if (charId != null) {
c = characteristicService.load(charId);
if (c == null) {
/*
* This shouldn't happen but just in case...
*/
throw new IllegalStateException("No characteristic with id " + fvvo.getCharId());
}
if (!fv.getCharacteristics().contains(c)) {
throw new IllegalArgumentException("Characteristic with id=" + charId + " does not belong to factorvalue with id=" + fvID);
}
} else {
if (StringUtils.isNotBlank(fvvo.getValueUri())) {
c = VocabCharacteristic.Factory.newInstance();
} else {
c = Characteristic.Factory.newInstance();
}
}
c.setCategory(fvvo.getCategory());
c.setValue(fvvo.getValue());
if (c instanceof VocabCharacteristic) {
VocabCharacteristic vc = (VocabCharacteristic) c;
vc.setCategoryUri(fvvo.getCategoryUri());
vc.setValueUri(fvvo.getValueUri());
}
// characteristic has been manually updated
c.setEvidenceCode(GOEvidenceCode.IC);
if (c.getId() != null) {
characteristicService.update(c);
} else {
fv.getCharacteristics().add(c);
factorValueService.update(fv);
}
}
FactorValue fv = this.factorValueService.load(fvvos[0].getId());
ExpressionExperiment ee = expressionExperimentService.findByFactorValue(fv);
// this.auditTrailService.addUpdateEvent( ee, ExperimentalDesignEvent.class,
// "FactorValue characteristics updated", StringUtils.join( fvvos, "\n" ) );
this.experimentReportService.evictFromCache(ee.getId());
}
use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.
the class BatchInfoPopulationHelperServiceImpl method createBatchFactor.
@Override
@Transactional
public ExperimentalFactor createBatchFactor(ExpressionExperiment ee, Map<BioMaterial, Date> dates) {
/*
* Go through the dates and convert to factor values.
*/
Collection<Date> allDates = new HashSet<>(dates.values());
Map<String, Collection<Date>> datesToBatch = this.convertDatesToBatches(allDates);
Map<Date, FactorValue> d2fv = new HashMap<>();
ExperimentalFactor ef = null;
if (datesToBatch == null || datesToBatch.size() < 2) {
if (datesToBatch != null) {
BatchInfoPopulationHelperServiceImpl.log.info("There is only one 'batch'");
}
// we still put the processing dates in, below.
} else {
ef = this.makeFactorForBatch(ee);
for (String batchId : datesToBatch.keySet()) {
FactorValue fv = FactorValue.Factory.newInstance();
fv.setIsBaseline(false);
/* we could set true for the first batch, but nobody cares. */
fv.setValue(batchId);
Collection<Characteristic> chars = new HashSet<>();
VocabCharacteristic c = VocabCharacteristic.Factory.newInstance();
c.setCategory(ExperimentalDesignUtils.BATCH_FACTOR_CATEGORY_NAME);
c.setValue(batchId);
c.setCategoryUri(ExperimentalDesignUtils.BATCH_FACTOR_CATEGORY_URI);
c.setEvidenceCode(GOEvidenceCode.IIA);
chars.add(c);
fv.setCharacteristics(chars);
fv.setExperimentalFactor(ef);
/*
* persist
*/
fv.setCharacteristics(chars);
experimentService.addFactorValue(ee, fv);
for (Date d : datesToBatch.get(batchId)) {
d2fv.put(d, fv);
}
}
}
bioMaterialService.associateBatchFactor(dates, d2fv);
return ef;
}
Aggregations