Search in sources :

Example 16 with VocabCharacteristic

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

Example 17 with VocabCharacteristic

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

Example 18 with VocabCharacteristic

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

Example 19 with VocabCharacteristic

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());
}
Also used : AccessDeniedException(org.directwebremoting.extend.AccessDeniedException) Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic)

Example 20 with VocabCharacteristic

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;
}
Also used : Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

VocabCharacteristic (ubic.gemma.model.common.description.VocabCharacteristic)44 Characteristic (ubic.gemma.model.common.description.Characteristic)15 OntologyTerm (ubic.basecode.ontology.model.OntologyTerm)10 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)7 Test (org.junit.Test)6 AnnotationValueObject (ubic.gemma.model.common.description.AnnotationValueObject)4 Gene (ubic.gemma.model.genome.Gene)4 HashSet (java.util.HashSet)3 Gene2GOAssociation (ubic.gemma.model.association.Gene2GOAssociation)3 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)3 GZIPOutputStream (java.util.zip.GZIPOutputStream)2 StopWatch (org.apache.commons.lang3.time.StopWatch)2 ConcurrentHashSet (org.compass.core.util.concurrent.ConcurrentHashSet)2 OntologyIndividual (ubic.basecode.ontology.model.OntologyIndividual)2 OntologyResource (ubic.basecode.ontology.model.OntologyResource)2 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)2 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)2 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)2 AclObjectIdentity (gemma.gsec.acl.domain.AclObjectIdentity)1 InputStream (java.io.InputStream)1