Search in sources :

Example 6 with Characteristic

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

the class OntologyServiceImpl method countOccurrences.

// Possible external use
@SuppressWarnings({ "unused", "WeakerAccess" })
public void countOccurrences(Collection<CharacteristicValueObject> searchResults, Map<String, CharacteristicValueObject> previouslyUsedInSystem) {
    StopWatch watch = new StopWatch();
    watch.start();
    Set<String> uris = new HashSet<>();
    for (CharacteristicValueObject cvo : searchResults) {
        uris.add(cvo.getValueUri());
    }
    Collection<Characteristic> existingCharacteristicsUsingTheseTerms = characteristicService.findByUri(uris);
    for (Characteristic c : existingCharacteristicsUsingTheseTerms) {
        // count up number of usages; see bug 3897
        String key = this.foundValueKey(c);
        if (previouslyUsedInSystem.containsKey(key)) {
            previouslyUsedInSystem.get(key).incrementOccurrenceCount();
            continue;
        }
        if (OntologyServiceImpl.log.isDebugEnabled())
            OntologyServiceImpl.log.debug("saw " + key + " (" + key + ")");
        CharacteristicValueObject vo = new CharacteristicValueObject(c);
        vo.setCategory(null);
        // to avoid us counting separately by category.
        vo.setCategoryUri(null);
        vo.setAlreadyPresentInDatabase(true);
        vo.incrementOccurrenceCount();
        previouslyUsedInSystem.put(key, vo);
    }
    if (OntologyServiceImpl.log.isDebugEnabled() || (watch.getTime() > 100 && previouslyUsedInSystem.size() > 0))
        OntologyServiceImpl.log.info("found " + previouslyUsedInSystem.size() + " matching characteristics used in the database" + " in " + watch.getTime() + " ms " + " Filtered from initial set of " + existingCharacteristicsUsingTheseTerms.size());
}
Also used : CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject) Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) StopWatch(org.apache.commons.lang3.time.StopWatch) ConcurrentHashSet(org.compass.core.util.concurrent.ConcurrentHashSet)

Example 7 with Characteristic

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

the class OntologyServiceImpl method countOccurrences.

private void countOccurrences(String queryString, Map<String, CharacteristicValueObject> previouslyUsedInSystem) {
    StopWatch watch = new StopWatch();
    watch.start();
    Collection<Characteristic> foundChars = characteristicService.findByValue(queryString);
    /*
         * Want to flag in the web interface that these are already used by Gemma (also ignore capitalization; category
         * is always ignored; remove duplicates.)
         */
    for (Characteristic characteristic : foundChars) {
        // count up number of usages; see bug 3897
        String key = this.foundValueKey(characteristic);
        if (previouslyUsedInSystem.containsKey(key)) {
            previouslyUsedInSystem.get(key).incrementOccurrenceCount();
            continue;
        }
        if (OntologyServiceImpl.log.isDebugEnabled())
            OntologyServiceImpl.log.debug("saw " + key + " (" + key + ") for " + characteristic);
        CharacteristicValueObject vo = new CharacteristicValueObject(characteristic);
        vo.setCategory(null);
        // to avoid us counting separately by category.
        vo.setCategoryUri(null);
        vo.setAlreadyPresentInDatabase(true);
        vo.incrementOccurrenceCount();
        previouslyUsedInSystem.put(key, vo);
    }
    if (OntologyServiceImpl.log.isDebugEnabled() || (watch.getTime() > 100 && previouslyUsedInSystem.size() > 0))
        OntologyServiceImpl.log.info("found " + previouslyUsedInSystem.size() + " matching characteristics used in the database" + " in " + watch.getTime() + " ms " + " Filtered from initial set of " + foundChars.size());
}
Also used : CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject) Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) StopWatch(org.apache.commons.lang3.time.StopWatch)

Example 8 with Characteristic

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

the class OntologyServiceImpl method removeBioMaterialStatement.

@Override
public void removeBioMaterialStatement(Long characterId, BioMaterial bm) {
    Characteristic vc = characteristicService.load(characterId);
    if (vc == null)
        throw new IllegalArgumentException("No characteristic with id=" + characterId + " was foundF");
    bm.getCharacteristics().remove(vc);
    characteristicService.remove(characterId);
}
Also used : Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic)

Example 9 with Characteristic

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

the class OntologyServiceImpl method saveBioMaterialStatement.

@Override
public void saveBioMaterialStatement(Characteristic vc, BioMaterial bm) {
    OntologyServiceImpl.log.debug("Vocab Characteristic: " + vc);
    // manually added characteristic
    vc.setEvidenceCode(GOEvidenceCode.IC);
    Set<Characteristic> chars = new HashSet<>();
    chars.add(vc);
    Collection<Characteristic> current = bm.getCharacteristics();
    if (current == null)
        current = new HashSet<>(chars);
    else
        current.addAll(chars);
    for (Characteristic characteristic : chars) {
        OntologyServiceImpl.log.info("Adding characteristic to " + bm + " : " + characteristic);
    }
    bm.setCharacteristics(current);
    bioMaterialService.update(bm);
}
Also used : Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) ConcurrentHashSet(org.compass.core.util.concurrent.ConcurrentHashSet)

Example 10 with Characteristic

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

the class AuditAdviceTest method checkEEAuditTrails.

private void checkEEAuditTrails(ExpressionExperiment ee, Collection<Long> trailIds, Collection<Long> eventIds) {
    this.checkAuditTrail(ee, trailIds, eventIds);
    for (BioAssay ba : ee.getBioAssays()) {
        this.checkAuditTrail(ba, trailIds, eventIds);
        BioMaterial bm = ba.getSampleUsed();
        this.checkAuditTrail(bm, trailIds, eventIds);
        for (Characteristic c : bm.getCharacteristics()) {
            this.checkAuditTrail(c, trailIds, eventIds);
        }
        for (Treatment t : bm.getTreatments()) {
            this.checkAuditTrail(t, trailIds, eventIds);
            this.checkAuditTrail(t.getAction(), trailIds, eventIds);
        // for ( CompoundMeasurement cm : t.getCompoundMeasurements() ) {
        // checkAuditTrail( cm.getCompound().getCompoundIndices(), trailIds, eventIds );
        // }
        }
    }
    Collection<ExperimentalFactor> experimentalFactors = ee.getExperimentalDesign().getExperimentalFactors();
    assertTrue(experimentalFactors.size() > 0);
    for (ExperimentalFactor ef : experimentalFactors) {
        this.checkAuditTrail(ef, trailIds, eventIds);
        for (FactorValue fv : ef.getFactorValues()) {
            for (Characteristic c : fv.getCharacteristics()) {
                this.checkAuditTrail(c, trailIds, eventIds);
            }
        }
    }
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) Treatment(ubic.gemma.model.expression.biomaterial.Treatment) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) Characteristic(ubic.gemma.model.common.description.Characteristic) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

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