Search in sources :

Example 26 with Characteristic

use of ubic.gemma.model.common.description.Characteristic in project Gemma by PavlidisLab.

the class DesignMatrixRowValueObject method getFactorValueString.

private String getFactorValueString(FactorValue factorValue) {
    // missing data.
    if (factorValue == null)
        return "";
    StringBuilder buf = new StringBuilder();
    if (!factorValue.getCharacteristics().isEmpty()) {
        for (Iterator<Characteristic> i = factorValue.getCharacteristics().iterator(); i.hasNext(); ) {
            Characteristic characteristic = i.next();
            /*
                 * Note we don't use toString here because it includes the category, uri, etc.
                 */
            buf.append(characteristic.getValue());
            if (i.hasNext())
                buf.append(" ");
        }
    } else if (StringUtils.isNotBlank(factorValue.getValue())) {
        buf.append(factorValue.getValue());
    } else if (factorValue.getMeasurement() != null) {
        buf.append(factorValue.getMeasurement().getValue());
    }
    return buf.toString();
}
Also used : Characteristic(ubic.gemma.model.common.description.Characteristic)

Example 27 with Characteristic

use of ubic.gemma.model.common.description.Characteristic 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 28 with Characteristic

use of ubic.gemma.model.common.description.Characteristic 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 29 with Characteristic

use of ubic.gemma.model.common.description.Characteristic 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 30 with Characteristic

use of ubic.gemma.model.common.description.Characteristic in project Gemma by PavlidisLab.

the class ExperimentalDesignViewCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception err = processCommandLine(args);
    if (err != null)
        return err;
    ExperimentalDesignService eds = getBean(ExperimentalDesignService.class);
    ExpressionExperimentService ees = getBean(ExpressionExperimentService.class);
    Collection<ExpressionExperimentValueObject> experiments = ees.loadValueObjects(EntityUtils.getIds(ees.loadAll()), false);
    Map<Long, ExpressionExperimentValueObject> ed2ee = new HashMap<>();
    for (ExpressionExperimentValueObject expressionExperiment : experiments) {
        ed2ee.put(expressionExperiment.getExperimentalDesign(), expressionExperiment);
    }
    Collection<ExperimentalDesign> designs = eds.loadAll();
    Map<Long, Long> factor2Design = new HashMap<>();
    Map<String, Map<String, Collection<FactorValueValueObject>>> categoryMap = new TreeMap<>();
    for (ExperimentalDesign experimentalDesign : designs) {
        if (!ed2ee.containsKey(experimentalDesign.getId()))
            continue;
        for (ExperimentalFactor factor : experimentalDesign.getExperimentalFactors()) {
            factor2Design.put(factor.getId(), experimentalDesign.getId());
            String category;
            if (factor.getCategory() != null)
                category = factor.getCategory().getValue();
            else
                category = " ** NO CATEGORY ** ";
            if (!categoryMap.containsKey(category)) {
                categoryMap.put(category, new TreeMap<String, Collection<FactorValueValueObject>>());
            }
            for (FactorValue f : factor.getFactorValues()) {
                // don't list individual quantitative values.
                if (f.getMeasurement() != null)
                    continue;
                if (f.getCharacteristics().size() > 0) {
                    for (Characteristic c : f.getCharacteristics()) {
                        if (c.getCategory().equals(category)) {
                            String value = c.getValue();
                            if (value == null)
                                continue;
                            if (!categoryMap.get(category).containsKey(value)) {
                                categoryMap.get(category).put(value, new HashSet<FactorValueValueObject>());
                            }
                            categoryMap.get(category).get(value).add(new FactorValueValueObject(f, c));
                        }
                    }
                } else if (f.getValue() != null) {
                    if (!categoryMap.get(category).containsKey(f.getValue())) {
                        categoryMap.get(category).put(f.getValue(), new HashSet<FactorValueValueObject>());
                    }
                    categoryMap.get(category).get(f.getValue()).add(new FactorValueValueObject(f));
                }
            }
        }
    }
    for (String category : categoryMap.keySet()) {
        log.info("Category: " + category);
        if (category.equals("Time") || category.equals("SamplingTimePoint") || category.equals("Age")) {
            log.info(" *****  Details not shown for this category");
        }
        for (String value : categoryMap.get(category).keySet()) {
            log.info("     Value: " + value);
            for (FactorValueValueObject fv : categoryMap.get(category).get(value)) {
                // don't list individual values.
                if (fv.isMeasurement())
                    continue;
                Long factor = fv.getFactorId();
                ExpressionExperimentValueObject expressionExperimentValueObject = ed2ee.get(factor2Design.get(factor));
                if (expressionExperimentValueObject == null) {
                    log.warn("       NO EE for Factor=" + factor);
                    continue;
                }
                String ee = expressionExperimentValueObject.getShortName();
                String uri = StringUtils.isBlank(fv.getValueUri()) ? "" : " [" + fv.getValueUri() + "]";
                log.info("           " + fv.getValue() + uri + " EE=" + ee);
            }
        }
    }
    return null;
}
Also used : Characteristic(ubic.gemma.model.common.description.Characteristic) ExperimentalDesignService(ubic.gemma.persistence.service.expression.experiment.ExperimentalDesignService) ExpressionExperimentService(ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService)

Aggregations

Characteristic (ubic.gemma.model.common.description.Characteristic)46 VocabCharacteristic (ubic.gemma.model.common.description.VocabCharacteristic)32 StopWatch (org.apache.commons.lang3.time.StopWatch)7 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)7 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)7 AnnotationValueObject (ubic.gemma.model.common.description.AnnotationValueObject)6 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)6 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)6 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 SearchSettingsValueObject (ubic.gemma.model.common.search.SearchSettingsValueObject)4 BioSequenceValueObject (ubic.gemma.model.genome.sequenceAnalysis.BioSequenceValueObject)4 OntologyTerm (ubic.basecode.ontology.model.OntologyTerm)3 BibliographicReferenceValueObject (ubic.gemma.model.common.description.BibliographicReferenceValueObject)3 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)3 GeneEvidenceValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.GeneEvidenceValueObject)3 ConcurrentHashSet (org.compass.core.util.concurrent.ConcurrentHashSet)2 TaskResult (ubic.gemma.core.job.TaskResult)2 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)2 Treatment (ubic.gemma.model.expression.biomaterial.Treatment)2