use of ubic.gemma.model.association.phenotype.PhenotypeAssociation in project Gemma by PavlidisLab.
the class BibliographicReferenceControllerImpl method browse.
@Override
public JsonReaderResponse<BibliographicReferenceValueObject> browse(ListBatchCommand batch) {
Integer count = this.bibliographicReferenceService.countAll();
List<BibliographicReference> records = this.getBatch(batch);
Map<BibliographicReference, Collection<ExpressionExperiment>> relatedExperiments = this.bibliographicReferenceService.getRelatedExperiments(records);
List<BibliographicReferenceValueObject> valueObjects = new ArrayList<>();
for (BibliographicReference ref : records) {
ref = this.bibliographicReferenceService.thaw(ref);
BibliographicReferenceValueObject vo = new BibliographicReferenceValueObject(ref);
if (relatedExperiments.containsKey(ref)) {
vo.setExperiments(expressionExperimentService.loadValueObjects(relatedExperiments.get(ref)));
}
valueObjects.add(vo);
// adding phenotype information to the Bibliographic Reference
Collection<PhenotypeAssociation> phenotypeAssociations = this.phenotypeAssociationService.findPhenotypesForBibliographicReference(vo.getPubAccession());
Collection<BibliographicPhenotypesValueObject> bibliographicPhenotypesValueObjects = BibliographicPhenotypesValueObject.phenotypeAssociations2BibliographicPhenotypesValueObjects(phenotypeAssociations);
vo.setBibliographicPhenotypes(bibliographicPhenotypesValueObjects);
}
return new JsonReaderResponse<>(valueObjects, count);
}
use of ubic.gemma.model.association.phenotype.PhenotypeAssociation in project Gemma by PavlidisLab.
the class GeneServiceImpl method loadFullyPopulatedValueObject.
@Override
@Transactional(readOnly = true)
public GeneValueObject loadFullyPopulatedValueObject(Long id) {
Gene gene = this.geneDao.load(id);
if (gene == null) {
return null;
}
gene = this.geneDao.thaw(gene);
GeneValueObject gvo = GeneValueObject.convert2ValueObject(gene);
Collection<GeneAlias> aliasObjects = gene.getAliases();
Collection<String> aliasStrings = new ArrayList<>();
for (GeneAlias ga : aliasObjects) {
aliasStrings.add(ga.getAlias());
}
gvo.setAliases(aliasStrings);
if (gene.getMultifunctionality() != null) {
gvo.setMultifunctionalityRank(gene.getMultifunctionality().getRank());
}
Long compositeSequenceCount = this.getCompositeSequenceCountById(id);
gvo.setCompositeSequenceCount(compositeSequenceCount.intValue());
Integer platformCount = this.geneDao.getPlatformCountById(id);
gvo.setPlatformCount(platformCount);
Collection<GeneSet> geneSets = this.geneSetSearch.findByGene(gene);
Collection<GeneSetValueObject> gsVos = new ArrayList<>();
// noinspection CollectionAddAllCanBeReplacedWithConstructor // Constructor can't handle subclasses
gsVos.addAll(geneSetValueObjectHelper.convertToLightValueObjects(geneSets, false));
gvo.setGeneSets(gsVos);
Collection<Gene> geneHomologues = this.homologeneService.getHomologues(gene);
geneHomologues = this.thawLite(geneHomologues);
Collection<GeneValueObject> homologues = this.loadValueObjects(geneHomologues);
gvo.setHomologues(homologues);
Collection<PhenotypeAssociation> pas = gene.getPhenotypeAssociations();
Collection<CharacteristicValueObject> cVos = new HashSet<>();
for (PhenotypeAssociation pa : pas) {
cVos.addAll(CharacteristicValueObject.characteristic2CharacteristicVO(pa.getPhenotypes()));
}
gvo.setPhenotypes(cVos);
if (gvo.getNcbiId() != null) {
SearchSettingsImpl s = new SearchSettingsImpl();
s.setTermUri("http://purl.org/commons/record/ncbi_gene/" + gvo.getNcbiId());
s.noSearches();
s.setSearchExperiments(true);
Map<Class<?>, List<SearchResult>> r = searchService.search(s);
if (r.containsKey(ExpressionExperiment.class)) {
List<SearchResult> hits = r.get(ExpressionExperiment.class);
gvo.setAssociatedExperimentCount(hits.size());
}
}
GeneCoexpressionNodeDegreeValueObject nodeDegree = coexpressionService.getNodeDegree(gene);
if (nodeDegree != null) {
gvo.setNodeDegreesPos(nodeDegree.asIntArrayPos());
gvo.setNodeDegreesNeg(nodeDegree.asIntArrayNeg());
gvo.setNodeDegreePosRanks(nodeDegree.asDoubleArrayPosRanks());
gvo.setNodeDegreeNegRanks(nodeDegree.asDoubleArrayNegRanks());
}
return gvo;
}
use of ubic.gemma.model.association.phenotype.PhenotypeAssociation in project Gemma by PavlidisLab.
the class BibliographicPhenotypesValueObject method phenotypeAssociations2BibliographicPhenotypesValueObjects.
public static Collection<BibliographicPhenotypesValueObject> phenotypeAssociations2BibliographicPhenotypesValueObjects(Collection<PhenotypeAssociation> phenotypeAssociations) {
Collection<BibliographicPhenotypesValueObject> bibliographicPhenotypesValueObjects = new TreeSet<>();
for (PhenotypeAssociation phenotypeAssociation : phenotypeAssociations) {
BibliographicPhenotypesValueObject bibli = new BibliographicPhenotypesValueObject(phenotypeAssociation);
bibliographicPhenotypesValueObjects.add(bibli);
}
return bibliographicPhenotypesValueObjects;
}
use of ubic.gemma.model.association.phenotype.PhenotypeAssociation in project Gemma by PavlidisLab.
the class DeleteEvidenceCLI method doWork.
@Override
protected Exception doWork(String[] args) {
Exception err = this.processCommandLine(args);
if (err != null)
return err;
try {
this.loadServices();
} catch (Exception e) {
AbstractCLI.log.info(e.getMessage());
}
Integer limit = 1000;
AbstractCLI.log.info("Loading " + limit + " evidence (this takes some time)");
Collection<EvidenceValueObject<? extends PhenotypeAssociation>> evidenceToDelete = this.phenotypeAssociationService.loadEvidenceWithExternalDatabaseName(externalDatabaseName, limit, 0);
int i = 0;
while (evidenceToDelete.size() > 0) {
for (EvidenceValueObject e : evidenceToDelete) {
this.phenotypeAssociationService.remove(e.getId());
AbstractCLI.log.info(i++);
}
evidenceToDelete = this.phenotypeAssociationService.loadEvidenceWithExternalDatabaseName(externalDatabaseName, limit, 0);
}
System.exit(-1);
return null;
}
use of ubic.gemma.model.association.phenotype.PhenotypeAssociation 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