use of ubic.gemma.model.common.description.Characteristic in project Gemma by PavlidisLab.
the class CharacteristicValueObject method characteristic2CharacteristicVO.
public static Collection<CharacteristicValueObject> characteristic2CharacteristicVO(Collection<? extends Characteristic> characteristics) {
Collection<CharacteristicValueObject> characteristicValueObjects;
if (characteristics instanceof List)
characteristicValueObjects = new ArrayList<>();
else
characteristicValueObjects = new HashSet<>();
for (Characteristic characteristic : characteristics) {
CharacteristicValueObject characteristicValueObject = new CharacteristicValueObject(characteristic);
characteristicValueObjects.add(characteristicValueObject);
}
return characteristicValueObjects;
}
use of ubic.gemma.model.common.description.Characteristic in project Gemma by PavlidisLab.
the class ExpressionPersister method fillInExperimentalFactorAssociations.
private void fillInExperimentalFactorAssociations(ExperimentalFactor experimentalFactor) {
if (experimentalFactor == null)
return;
if (!this.isTransient(experimentalFactor))
return;
Collection<Characteristic> annotations = experimentalFactor.getAnnotations();
for (Characteristic c : annotations) {
// in case of retry.
c.setId(null);
if (c.getAuditTrail() != null && this.isTransient(c.getAuditTrail())) {
c.getAuditTrail().setId(null);
}
}
this.persistCollectionElements(annotations);
}
use of ubic.gemma.model.common.description.Characteristic in project Gemma by PavlidisLab.
the class FactorValue method toString.
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
// this can be null in tests or with half-setup transient objects
buf.append("FactorValue ").append(this.getId()).append(": ");
if (this.getExperimentalFactor() != null)
buf.append(this.getExperimentalFactor().getName()).append(":");
if (this.getCharacteristics().size() > 0) {
for (Characteristic c : this.getCharacteristics()) {
buf.append(c.getValue());
if (this.getCharacteristics().size() > 1)
buf.append(" | ");
}
} else if (this.getMeasurement() != null) {
buf.append(this.getMeasurement().getValue());
} else if (StringUtils.isNotBlank(this.getValue())) {
buf.append(this.getValue());
}
return buf.toString();
}
use of ubic.gemma.model.common.description.Characteristic in project Gemma by PavlidisLab.
the class GeneDifferentialExpressionServiceImpl method configExperimentalFactorValueObject.
@Override
public ExperimentalFactorValueObject configExperimentalFactorValueObject(ExperimentalFactor ef) {
ExperimentalFactorValueObject efvo = new ExperimentalFactorValueObject(ef.getId());
efvo.setName(ef.getName());
efvo.setDescription(ef.getDescription());
Characteristic category = ef.getCategory();
if (category != null) {
efvo.setCategory(category.getCategory());
if (category instanceof VocabCharacteristic) {
efvo.setCategoryUri(category.getCategoryUri());
}
}
Collection<FactorValue> fvs = ef.getFactorValues();
StringBuilder factorValuesAsString = new StringBuilder(StringUtils.EMPTY);
for (FactorValue fv : fvs) {
String fvName = fv.toString();
if (StringUtils.isNotBlank(fvName)) {
factorValuesAsString.append(fvName).append(GeneDifferentialExpressionServiceImpl.FV_SEP);
}
}
/* clean up the start and end of the string */
factorValuesAsString = new StringBuilder(StringUtils.remove(factorValuesAsString.toString(), ef.getName() + ":"));
factorValuesAsString = new StringBuilder(StringUtils.removeEnd(factorValuesAsString.toString(), GeneDifferentialExpressionServiceImpl.FV_SEP));
/*
* Preformat the factor name; due to Ext PropertyGrid limitations we can't do this on the client.
*/
efvo.setName(ef.getName() + " (" + StringUtils.abbreviate(factorValuesAsString.toString(), 50) + ")");
efvo.setFactorValues(factorValuesAsString.toString());
return efvo;
}
use of ubic.gemma.model.common.description.Characteristic in project Gemma by PavlidisLab.
the class CharacteristicBrowserController method findCharacteristicsCustom.
/**
* @param searchFVs Search factor values that lack characteristics -- that is, search the factorValue.value.
* @param searchCategories Should the Category be searched, not just the Value?
*/
public Collection<AnnotationValueObject> findCharacteristicsCustom(String valuePrefix, boolean searchNos, boolean searchEEs, boolean searchBMs, boolean searchFVs, boolean searchPAs, boolean searchFVVs, boolean searchCategories) {
List<AnnotationValueObject> results = new ArrayList<>();
if (StringUtils.isBlank(valuePrefix)) {
return results;
}
Collection<Characteristic> chars = characteristicService.findByValue(valuePrefix);
if (searchCategories) {
chars.addAll(characteristicService.findByCategory(valuePrefix));
}
Map<Characteristic, Object> charToParent = characteristicService.getParents(chars);
for (Object o : chars) {
Characteristic c = (Characteristic) o;
Object parent = charToParent.get(c);
if ((searchEEs && parent instanceof ExpressionExperiment) || (searchBMs && parent instanceof BioMaterial) || (searchFVs && (parent instanceof FactorValue || parent instanceof ExperimentalFactor)) || (searchNos && parent == null) || (searchPAs && parent instanceof PhenotypeAssociation)) {
AnnotationValueObject avo = new AnnotationValueObject();
avo.setId(c.getId());
avo.setClassName(c.getCategory());
avo.setTermName(c.getValue());
if (c.getEvidenceCode() != null)
avo.setEvidenceCode(c.getEvidenceCode().toString());
populateClassValues(c, avo);
if (parent != null) {
populateParentInformation(avo, parent);
}
results.add(avo);
}
}
if (searchFVVs) {
// non-characteristics.
Collection<FactorValue> factorValues = factorValueService.findByValue(valuePrefix);
for (FactorValue factorValue : factorValues) {
if (factorValue.getCharacteristics().size() > 0)
continue;
if (StringUtils.isBlank(factorValue.getValue()))
continue;
AnnotationValueObject avo = new AnnotationValueObject();
avo.setId(factorValue.getId());
avo.setTermName(factorValue.getValue());
avo.setObjectClass(FactorValue.class.getSimpleName());
populateParentInformation(avo, factorValue);
results.add(avo);
}
}
log.info("Characteristic search for: '" + valuePrefix + "*': " + results.size() + " results, returning up to " + MAX_RESULTS);
return results.subList(0, Math.min(results.size(), MAX_RESULTS));
}
Aggregations