Search in sources :

Example 1 with PhenotypeAssociation

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);
}
Also used : PhenotypeAssociation(ubic.gemma.model.association.phenotype.PhenotypeAssociation) BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) JsonReaderResponse(ubic.gemma.web.remote.JsonReaderResponse) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) BibliographicPhenotypesValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.BibliographicPhenotypesValueObject)

Example 2 with PhenotypeAssociation

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;
}
Also used : CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject) Gene(ubic.gemma.model.genome.Gene) SearchSettingsImpl(ubic.gemma.model.common.search.SearchSettingsImpl) PhenotypeAssociation(ubic.gemma.model.association.phenotype.PhenotypeAssociation) SearchResult(ubic.gemma.core.search.SearchResult) GeneCoexpressionNodeDegreeValueObject(ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegreeValueObject) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with PhenotypeAssociation

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;
}
Also used : TreeSet(java.util.TreeSet) PhenotypeAssociation(ubic.gemma.model.association.phenotype.PhenotypeAssociation)

Example 4 with PhenotypeAssociation

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;
}
Also used : EvidenceValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.EvidenceValueObject) PhenotypeAssociation(ubic.gemma.model.association.phenotype.PhenotypeAssociation)

Example 5 with PhenotypeAssociation

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));
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) AnnotationValueObject(ubic.gemma.model.common.description.AnnotationValueObject) ArrayList(java.util.ArrayList) PhenotypeAssociation(ubic.gemma.model.association.phenotype.PhenotypeAssociation) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) AnnotationValueObject(ubic.gemma.model.common.description.AnnotationValueObject)

Aggregations

PhenotypeAssociation (ubic.gemma.model.association.phenotype.PhenotypeAssociation)7 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)2 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)2 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)2 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)2 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)2 EvidenceValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.EvidenceValueObject)2 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 Transactional (org.springframework.transaction.annotation.Transactional)1 SearchResult (ubic.gemma.core.search.SearchResult)1 GeneCoexpressionNodeDegreeValueObject (ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegreeValueObject)1 AnnotationValueObject (ubic.gemma.model.common.description.AnnotationValueObject)1 BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)1 BibliographicReferenceValueObject (ubic.gemma.model.common.description.BibliographicReferenceValueObject)1 Characteristic (ubic.gemma.model.common.description.Characteristic)1 VocabCharacteristic (ubic.gemma.model.common.description.VocabCharacteristic)1 SearchSettingsImpl (ubic.gemma.model.common.search.SearchSettingsImpl)1 Gene (ubic.gemma.model.genome.Gene)1 GeneValueObject (ubic.gemma.model.genome.gene.GeneValueObject)1