Search in sources :

Example 1 with GeneSet

use of ubic.gemma.model.genome.gene.GeneSet in project Gemma by PavlidisLab.

the class SessionListManagerImpl method getGenesInGroup.

@Override
public Collection<GeneValueObject> getGenesInGroup(Long groupId) {
    Collection<GeneValueObject> results;
    GeneSet gs = geneSetService.load(groupId);
    if (gs == null)
        // TODO: Send and error code/feedback?
        return null;
    results = GeneValueObject.convertMembers2GeneValueObjects(gs.getMembers());
    return results;
}
Also used : GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) GeneSet(ubic.gemma.model.genome.gene.GeneSet)

Example 2 with GeneSet

use of ubic.gemma.model.genome.gene.GeneSet in project Gemma by PavlidisLab.

the class GeneSetSearchImpl method goTermToGeneSets.

private Collection<GeneSet> goTermToGeneSets(OntologyTerm term, Integer maxGeneSetSize) {
    if (term == null)
        return null;
    if (term.getUri() == null)
        return null;
    Collection<OntologyResource> allMatches = new HashSet<>();
    allMatches.add(term);
    allMatches.addAll(this.geneOntologyService.getAllChildren(term));
    GeneSetSearchImpl.log.info(term);
    /*
         * Gather up uris
         */
    Collection<String> termsToFetch = new HashSet<>();
    for (OntologyResource t : allMatches) {
        String goId = this.uri2goid(t);
        termsToFetch.add(goId);
    }
    Map<Taxon, Collection<Gene>> genesByTaxon = this.gene2GoService.findByGOTermsPerTaxon(termsToFetch);
    Collection<GeneSet> results = new HashSet<>();
    for (Taxon t : genesByTaxon.keySet()) {
        Collection<Gene> genes = genesByTaxon.get(t);
        if (genes.isEmpty() || (maxGeneSetSize != null && genes.size() > maxGeneSetSize)) {
            continue;
        }
        GeneSet transientGeneSet = GeneSet.Factory.newInstance();
        transientGeneSet.setName(this.uri2goid(term));
        transientGeneSet.setDescription(term.getLabel());
        for (Gene gene : genes) {
            GeneSetMember gmember = GeneSetMember.Factory.newInstance();
            gmember.setGene(gene);
            transientGeneSet.getMembers().add(gmember);
        }
        results.add(transientGeneSet);
    }
    return results;
}
Also used : Taxon(ubic.gemma.model.genome.Taxon) GeneSetMember(ubic.gemma.model.genome.gene.GeneSetMember) Gene(ubic.gemma.model.genome.Gene) Collection(java.util.Collection) GeneSet(ubic.gemma.model.genome.gene.GeneSet) OntologyResource(ubic.basecode.ontology.model.OntologyResource) HashSet(java.util.HashSet)

Example 3 with GeneSet

use of ubic.gemma.model.genome.gene.GeneSet in project Gemma by PavlidisLab.

the class GeneSetSearchImpl method findGeneSetValueObjectByGoId.

@Override
public GOGroupValueObject findGeneSetValueObjectByGoId(String goId, Long taxonId) {
    // shouldn't need to set the taxon here, should be taken care of when creating the value object
    Taxon taxon;
    if (taxonId != null) {
        taxon = taxonService.load(taxonId);
        if (taxon == null) {
            GeneSetSearchImpl.log.warn("No such taxon with id=" + taxonId);
        } else {
            GeneSet result = this.findByGoId(goId, taxonService.load(taxonId));
            if (result == null) {
                GeneSetSearchImpl.log.warn("No matching gene set found for: " + goId);
                return null;
            }
            GOGroupValueObject ggvo = geneSetValueObjectHelper.convertToGOValueObject(result, goId, goId);
            ggvo.setTaxonId(taxon.getId());
            ggvo.setTaxonName(taxon.getCommonName());
            return ggvo;
        }
    }
    return null;
}
Also used : GOGroupValueObject(ubic.gemma.core.genome.gene.GOGroupValueObject) Taxon(ubic.gemma.model.genome.Taxon) GeneSet(ubic.gemma.model.genome.gene.GeneSet)

Example 4 with GeneSet

use of ubic.gemma.model.genome.gene.GeneSet in project Gemma by PavlidisLab.

the class GeneSetSearchImpl method findByGoTermName.

@Override
public Collection<GeneSet> findByGoTermName(String goTermName, Taxon taxon, Integer maxGoTermsProcessed, Integer maxGeneSetSize) {
    Collection<? extends OntologyResource> matches = this.geneOntologyService.findTerm(StringUtils.strip(goTermName));
    Collection<GeneSet> results = new HashSet<>();
    for (OntologyResource t : matches) {
        assert t instanceof OntologyTerm;
        if (taxon == null) {
            Collection<GeneSet> sets = this.goTermToGeneSets((OntologyTerm) t, maxGeneSetSize);
            results.addAll(sets);
            // noinspection StatementWithEmptyBody // FIXME should we count each species as one go?
            if (maxGoTermsProcessed != null && results.size() > maxGoTermsProcessed) {
            // return results;
            }
        } else {
            GeneSet converted = this.goTermToGeneSet(t, taxon, maxGeneSetSize);
            // converted will be null if its size is more than maxGeneSetSize
            if (converted != null) {
                results.add(converted);
            }
        }
        if (maxGoTermsProcessed != null && results.size() > maxGoTermsProcessed) {
            return results;
        }
    }
    return results;
}
Also used : OntologyTerm(ubic.basecode.ontology.model.OntologyTerm) GeneSet(ubic.gemma.model.genome.gene.GeneSet) OntologyResource(ubic.basecode.ontology.model.OntologyResource) HashSet(java.util.HashSet)

Example 5 with GeneSet

use of ubic.gemma.model.genome.gene.GeneSet in project Gemma by PavlidisLab.

the class NCBIGeneLoadingTest method clean.

private void clean() {
    if (g != null) {
        try {
            g = geneService.load(g.getId());
            geneService.remove(g);
        } catch (Exception e) {
        // ignore
        }
    }
    Collection<GeneSet> allgs = geneSetService.loadAll();
    for (GeneSet geneSet : allgs) {
        try {
            geneSetService.remove(geneSet);
        } catch (Exception e) {
        // ignore
        }
    }
    Collection<Gene> allGenes = geneService.loadAll();
    for (Gene gene : allGenes) {
        try {
            geneService.remove(gene);
        } catch (Exception e) {
        // ignore
        }
    }
}
Also used : Gene(ubic.gemma.model.genome.Gene) GeneSet(ubic.gemma.model.genome.gene.GeneSet)

Aggregations

GeneSet (ubic.gemma.model.genome.gene.GeneSet)8 HashSet (java.util.HashSet)4 Gene (ubic.gemma.model.genome.Gene)4 Taxon (ubic.gemma.model.genome.Taxon)4 OntologyResource (ubic.basecode.ontology.model.OntologyResource)3 OntologyTerm (ubic.basecode.ontology.model.OntologyTerm)2 GeneSetMember (ubic.gemma.model.genome.gene.GeneSetMember)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Collection (java.util.Collection)1 GOGroupValueObject (ubic.gemma.core.genome.gene.GOGroupValueObject)1 ExpressionExperimentSet (ubic.gemma.model.analysis.expression.ExpressionExperimentSet)1 BibliographicReferenceValueObject (ubic.gemma.model.common.description.BibliographicReferenceValueObject)1 SearchSettingsValueObject (ubic.gemma.model.common.search.SearchSettingsValueObject)1 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)1 GeneValueObject (ubic.gemma.model.genome.gene.GeneValueObject)1 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)1 GeneEvidenceValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.GeneEvidenceValueObject)1 BioSequenceValueObject (ubic.gemma.model.genome.sequenceAnalysis.BioSequenceValueObject)1