use of ubic.gemma.model.common.description.AnnotationValueObject in project Gemma by PavlidisLab.
the class CharacteristicUpdateTaskImpl method doRemove.
private TaskResult doRemove() {
Collection<AnnotationValueObject> chars = taskCommand.getAnnotationValueObjects();
log.info("Delete " + chars.size() + " characteristics...");
Collection<Characteristic> asChars = convertToCharacteristic(chars);
if (asChars.size() == 0) {
log.info("No characteristic objects were received");
return new TaskResult(taskCommand, false);
}
Map<Characteristic, Object> charToParent = characteristicService.getParents(asChars);
for (Characteristic cFromClient : asChars) {
Characteristic cFromDatabase = characteristicService.load(cFromClient.getId());
Object parent = charToParent.get(cFromDatabase);
removeFromParent(cFromDatabase, parent);
characteristicService.remove(cFromDatabase);
log.info("Characteristic deleted: " + cFromDatabase + " (associated with " + parent + ")");
}
return new TaskResult(taskCommand, true);
}
use of ubic.gemma.model.common.description.AnnotationValueObject in project Gemma by PavlidisLab.
the class GeneServiceImpl method findGOTerms.
@Override
@Transactional(readOnly = true)
public Collection<AnnotationValueObject> findGOTerms(Long geneId) {
if (geneId == null)
throw new IllegalArgumentException("Null id for gene");
Collection<AnnotationValueObject> ontologies = new HashSet<>();
Gene g = this.load(geneId);
if (g == null) {
throw new IllegalArgumentException("No such gene could be loaded with id=" + geneId);
}
Collection<Gene2GOAssociation> associations = gene2GOAssociationService.findAssociationByGene(g);
for (Gene2GOAssociation assoc : associations) {
if (assoc.getOntologyEntry() == null)
continue;
AnnotationValueObject annotationValueObject = new AnnotationValueObject();
annotationValueObject.setId(assoc.getOntologyEntry().getId());
annotationValueObject.setTermName(geneOntologyService.getTermName(assoc.getOntologyEntry().getValue()));
annotationValueObject.setTermUri(assoc.getOntologyEntry().getValue());
annotationValueObject.setEvidenceCode(assoc.getEvidenceCode().getValue());
annotationValueObject.setDescription(assoc.getOntologyEntry().getDescription());
annotationValueObject.setClassUri(assoc.getOntologyEntry().getCategoryUri());
annotationValueObject.setClassName(assoc.getOntologyEntry().getCategory());
ontologies.add(annotationValueObject);
}
return annotationAssociationService.removeRootTerms(ontologies);
}
use of ubic.gemma.model.common.description.AnnotationValueObject in project Gemma by PavlidisLab.
the class CharacteristicBrowserController method findCharacteristicsCustom.
/**
* @param searchFVs Search factor values that lack characteristics -- that is, search the factorValue.value.
* @param searchCategories Should the Category be searched, not just the Value?
*/
public Collection<AnnotationValueObject> findCharacteristicsCustom(String valuePrefix, boolean searchNos, boolean searchEEs, boolean searchBMs, boolean searchFVs, boolean searchPAs, boolean searchFVVs, boolean searchCategories) {
List<AnnotationValueObject> results = new ArrayList<>();
if (StringUtils.isBlank(valuePrefix)) {
return results;
}
Collection<Characteristic> chars = characteristicService.findByValue(valuePrefix);
if (searchCategories) {
chars.addAll(characteristicService.findByCategory(valuePrefix));
}
Map<Characteristic, Object> charToParent = characteristicService.getParents(chars);
for (Object o : chars) {
Characteristic c = (Characteristic) o;
Object parent = charToParent.get(c);
if ((searchEEs && parent instanceof ExpressionExperiment) || (searchBMs && parent instanceof BioMaterial) || (searchFVs && (parent instanceof FactorValue || parent instanceof ExperimentalFactor)) || (searchNos && parent == null) || (searchPAs && parent instanceof PhenotypeAssociation)) {
AnnotationValueObject avo = new AnnotationValueObject();
avo.setId(c.getId());
avo.setClassName(c.getCategory());
avo.setTermName(c.getValue());
if (c.getEvidenceCode() != null)
avo.setEvidenceCode(c.getEvidenceCode().toString());
populateClassValues(c, avo);
if (parent != null) {
populateParentInformation(avo, parent);
}
results.add(avo);
}
}
if (searchFVVs) {
// non-characteristics.
Collection<FactorValue> factorValues = factorValueService.findByValue(valuePrefix);
for (FactorValue factorValue : factorValues) {
if (factorValue.getCharacteristics().size() > 0)
continue;
if (StringUtils.isBlank(factorValue.getValue()))
continue;
AnnotationValueObject avo = new AnnotationValueObject();
avo.setId(factorValue.getId());
avo.setTermName(factorValue.getValue());
avo.setObjectClass(FactorValue.class.getSimpleName());
populateParentInformation(avo, factorValue);
results.add(avo);
}
}
log.info("Characteristic search for: '" + valuePrefix + "*': " + results.size() + " results, returning up to " + MAX_RESULTS);
return results.subList(0, Math.min(results.size(), MAX_RESULTS));
}
Aggregations