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