Search in sources :

Example 41 with VocabCharacteristic

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

the class ExperimentalDesignControllerTest method testAddCharacteristicToFactorValue.

@Test
public void testAddCharacteristicToFactorValue() throws Exception {
    ExpressionExperiment ee = this.getTestPersistentCompleteExpressionExperiment(false);
    ee = this.eeService.thawLite(ee);
    ExperimentalFactor ef = ee.getExperimentalDesign().getExperimentalFactors().iterator().next();
    EntityDelegator e = new EntityDelegator(ef.getFactorValues().iterator().next());
    VocabCharacteristic vc = VocabCharacteristic.Factory.newInstance();
    vc.setValue("foo");
    vc.setCategory("bar");
    vc.setCategoryUri("bar");
    vc.setValueUri("foo");
    experimentalDesignController.createFactorValueCharacteristic(e, vc);
    assertEquals(2, ef.getFactorValues().size());
    // new empty
    experimentalDesignController.createFactorValue(new EntityDelegator(ef));
    experimentalDesignController.createFactorValue(new EntityDelegator(ef));
    experimentalDesignController.createFactorValue(new EntityDelegator(ef));
    ef = experimentalFactorService.load(ef.getId());
    assertEquals(5, ef.getFactorValues().size());
}
Also used : VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) EntityDelegator(ubic.gemma.web.remote.EntityDelegator) Test(org.junit.Test) BaseSpringWebTest(ubic.gemma.web.util.BaseSpringWebTest)

Example 42 with VocabCharacteristic

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

the class Gene2GOAssociationServiceImpl method findByGene.

@Override
public Collection<VocabCharacteristic> findByGene(Gene gene) {
    Element element = this.gene2goCache.get(gene);
    if (// noinspection unchecked
    element != null)
        return (Collection<VocabCharacteristic>) element.getObjectValue();
    Collection<VocabCharacteristic> re = this.gene2GOAssociationDao.findByGene(gene);
    this.gene2goCache.put(new Element(gene, re));
    return re;
}
Also used : Element(net.sf.ehcache.Element) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic)

Example 43 with VocabCharacteristic

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

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

the class ExperimentalDesignControllerImpl method updateExperimentalFactors.

@Override
public void updateExperimentalFactors(ExperimentalFactorValueObject[] efvos) {
    if (efvos == null || efvos.length == 0)
        return;
    for (ExperimentalFactorValueObject efvo : efvos) {
        ExperimentalFactor ef = experimentalFactorService.load(efvo.getId());
        ef.setName(efvo.getName());
        ef.setDescription(efvo.getDescription());
        FactorType newType = FactorType.fromString(efvo.getType());
        if (newType == null || !newType.equals(ef.getType())) {
            // we only allow this if there are no factors
            if (ef.getFactorValues().isEmpty()) {
                ef.setType(newType);
            } else {
                throw new IllegalArgumentException("You cannot change the 'type' of a factor once it has factor values. Delete the factor values first.");
            }
        }
        /*
             * at the moment, the characteristic is always going to be a VocabCharacteristic; if that changes, this will
             * have to...
             */
        VocabCharacteristic vc = (VocabCharacteristic) ef.getCategory();
        // VC can be null if this was imported from GEO etc.
        if (vc == null) {
            vc = VocabCharacteristic.Factory.newInstance();
        }
        // String originalCategoryUri = vc.getCategoryUri();
        vc.setCategory(efvo.getCategory());
        vc.setCategoryUri(efvo.getCategoryUri());
        vc.setValue(efvo.getCategory());
        vc.setValueUri(efvo.getCategoryUri());
        ef.setCategory(vc);
        experimentalFactorService.update(ef);
    }
    ExperimentalFactor ef = experimentalFactorService.load(efvos[0].getId());
    ExpressionExperiment ee = expressionExperimentService.findByFactor(ef);
    if (ee == null)
        throw new IllegalArgumentException("No experiment for factor: " + ef);
    this.experimentReportService.evictFromCache(ee.getId());
}
Also used : VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic)

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