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