Search in sources :

Example 41 with Characteristic

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

the class CharacteristicDaoImpl method getParents.

@Override
public Map<Characteristic, Object> getParents(Class<?> parentClass, Collection<Characteristic> characteristics) {
    Map<Characteristic, Object> charToParent = new HashMap<>();
    if (characteristics == null || characteristics.size() == 0) {
        return charToParent;
    }
    if (AbstractDao.log.isDebugEnabled()) {
        Collection<String> uris = new HashSet<>();
        for (Characteristic c : characteristics) {
            if (c instanceof VocabCharacteristic) {
                VocabCharacteristic vc = (VocabCharacteristic) c;
                if (vc.getValueUri() == null)
                    continue;
                uris.add(vc.getValueUri());
            }
        }
        AbstractDao.log.debug("For class=" + parentClass.getSimpleName() + ": " + characteristics.size() + " Characteristics have URIS:\n" + StringUtils.join(uris, "\n"));
    }
    StopWatch timer = new StopWatch();
    timer.start();
    for (Collection<Characteristic> batch : new BatchIterator<>(characteristics, CharacteristicDaoImpl.BATCH_SIZE)) {
        this.batchGetParents(parentClass, batch, charToParent);
    }
    if (timer.getTime() > 1000) {
        AbstractDao.log.info("Fetch parents of characteristics: " + timer.getTime() + "ms for " + characteristics.size() + " elements for class=" + parentClass.getSimpleName());
    }
    return charToParent;
}
Also used : Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject) BatchIterator(ubic.basecode.util.BatchIterator) StopWatch(org.apache.commons.lang3.time.StopWatch)

Example 42 with Characteristic

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

the class ExpressionExperimentQCController method getCategories.

/**
 * Support method for writeDetailedFactorAnalysis
 *
 * @param categories map of factor ID to text value. Strings will be unique, but possibly abbreviated and/or munged.
 */
private void getCategories(Map<Long, ExperimentalFactor> efIdMap, Long efId, Map<Long, String> categories) {
    ExperimentalFactor ef = efIdMap.get(efId);
    if (ef == null)
        return;
    int maxCategoryLabelLength = 10;
    for (FactorValue fv : ef.getFactorValues()) {
        String value = fv.getValue();
        if (StringUtils.isBlank(value) || value.equals("null")) {
            for (Characteristic c : fv.getCharacteristics()) {
                if (StringUtils.isNotBlank(c.getValue())) {
                    if (StringUtils.isNotBlank(value)) {
                        value = value + "; " + c.getValue();
                    } else {
                        value = c.getValue();
                    }
                }
            }
        }
        if (StringUtils.isBlank(value)) {
            value = fv.toString() + "--??";
        }
        if (value.startsWith(ExperimentalDesignUtils.BATCH_FACTOR_NAME_PREFIX)) {
            value = value.replaceFirst(ExperimentalDesignUtils.BATCH_FACTOR_NAME_PREFIX, "");
        } else {
            value = StringUtils.abbreviate(value, maxCategoryLabelLength);
        }
        while (categories.values().contains(value)) {
            // make unique, kludge, will end up with string of ++++
            value = value + "+";
        }
        categories.put(fv.getId(), value);
    }
}
Also used : FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) Characteristic(ubic.gemma.model.common.description.Characteristic)

Example 43 with Characteristic

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

the class ExperimentalDesignControllerImpl method createFactorValue.

@Override
public void createFactorValue(EntityDelegator e) {
    if (e == null || e.getId() == null)
        return;
    ExperimentalFactor ef = experimentalFactorService.load(e.getId());
    if (ef == null) {
        throw new EntityNotFoundException("Experimental factor with ID=" + e.getId() + " could not be accessed for editing");
    }
    Collection<Characteristic> chars = new HashSet<>();
    for (FactorValue fv : ef.getFactorValues()) {
        // noinspection LoopStatementThatDoesntLoop // No, but its an effective way of doing this
        for (Characteristic c : fv.getCharacteristics()) {
            chars.add(this.createTemplateCharacteristic(c));
            break;
        }
    }
    if (chars.isEmpty()) {
        if (ef.getCategory() == null) {
            throw new IllegalArgumentException("You cannot create new factor values on a experimental factor that is not defined by a formal Category");
        }
        chars.add(this.createTemplateCharacteristic(ef.getCategory()));
    }
    FactorValue fv = FactorValue.Factory.newInstance();
    fv.setExperimentalFactor(ef);
    fv.setCharacteristics(chars);
    ExpressionExperiment ee = experimentalDesignService.getExpressionExperiment(ef.getExperimentalDesign());
    // this is just a placeholder factor value; use has to edit it.
    expressionExperimentService.addFactorValue(ee, fv);
}
Also used : Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException)

Example 44 with Characteristic

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

the class ExperimentalDesignControllerImpl method getFactorValuesWithCharacteristics.

@Override
public Collection<FactorValueValueObject> getFactorValuesWithCharacteristics(EntityDelegator e) {
    Collection<FactorValueValueObject> result = new HashSet<>();
    if (e == null || e.getId() == null) {
        return result;
    }
    ExperimentalFactor ef = this.experimentalFactorService.load(e.getId());
    if (ef == null) {
        return result;
    }
    for (FactorValue value : ef.getFactorValues()) {
        if (value.getCharacteristics().size() > 0) {
            for (Characteristic c : value.getCharacteristics()) {
                result.add(new FactorValueValueObject(value, c));
            }
        } else {
            // We just use the experimental factor's characteristic.
            Characteristic category = value.getExperimentalFactor().getCategory();
            if (category == null) {
                category = Characteristic.Factory.newInstance();
                category.setValue(value.getExperimentalFactor().getName());
            }
            result.add(new FactorValueValueObject(value));
        }
    }
    return result;
}
Also used : Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic)

Example 45 with Characteristic

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

the class ExperimentalDesignControllerImpl method getFactorValues.

@Override
public Collection<FactorValueValueObject> getFactorValues(EntityDelegator e) {
    // FIXME I'm not sure why this keeps getting called with empty fields.
    if (e == null || e.getId() == null)
        return new HashSet<>();
    ExperimentalFactor ef = this.experimentalFactorService.load(e.getId());
    if (ef == null)
        return new HashSet<>();
    Collection<FactorValueValueObject> result = new HashSet<>();
    for (FactorValue value : ef.getFactorValues()) {
        Characteristic efCategory = value.getExperimentalFactor().getCategory();
        if (efCategory == null) {
            efCategory = Characteristic.Factory.newInstance();
            efCategory.setValue(value.getExperimentalFactor().getName());
        }
        result.add(new FactorValueValueObject(value, efCategory));
    }
    return result;
}
Also used : Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic)

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