Search in sources :

Example 6 with AnnotationValueObject

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);
}
Also used : Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) AnnotationValueObject(ubic.gemma.model.common.description.AnnotationValueObject) TaskResult(ubic.gemma.core.job.TaskResult) AnnotationValueObject(ubic.gemma.model.common.description.AnnotationValueObject)

Example 7 with AnnotationValueObject

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);
}
Also used : Gene(ubic.gemma.model.genome.Gene) AnnotationValueObject(ubic.gemma.model.common.description.AnnotationValueObject) Gene2GOAssociation(ubic.gemma.model.association.Gene2GOAssociation) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with AnnotationValueObject

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));
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) AnnotationValueObject(ubic.gemma.model.common.description.AnnotationValueObject) ArrayList(java.util.ArrayList) PhenotypeAssociation(ubic.gemma.model.association.phenotype.PhenotypeAssociation) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) AnnotationValueObject(ubic.gemma.model.common.description.AnnotationValueObject)

Aggregations

AnnotationValueObject (ubic.gemma.model.common.description.AnnotationValueObject)8 VocabCharacteristic (ubic.gemma.model.common.description.VocabCharacteristic)7 Characteristic (ubic.gemma.model.common.description.Characteristic)6 ArrayList (java.util.ArrayList)3 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)3 HashSet (java.util.HashSet)2 TaskResult (ubic.gemma.core.job.TaskResult)2 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)2 StopWatch (org.apache.commons.lang3.time.StopWatch)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1 Transactional (org.springframework.transaction.annotation.Transactional)1 Gene2GOAssociation (ubic.gemma.model.association.Gene2GOAssociation)1 PhenotypeAssociation (ubic.gemma.model.association.phenotype.PhenotypeAssociation)1 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)1 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)1 Gene (ubic.gemma.model.genome.Gene)1 JsonReaderResponse (ubic.gemma.web.remote.JsonReaderResponse)1