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());
}
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;
}
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;
}
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());
}
Aggregations