use of ubic.gemma.model.genome.gene.GeneSetMember 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.GeneSetMember in project Gemma by PavlidisLab.
the class GeneSetValueObjectHelperImpl method fillSessionBoundValueObject.
private void fillSessionBoundValueObject(SessionBoundGeneSetValueObject sbgsvo, GeneSet gs) {
sbgsvo.setName(gs.getName());
sbgsvo.setDescription(gs.getDescription());
// GO group gene sets don't have ids
if (gs.getId() == null) {
sbgsvo.setSize(gs.getMembers() != null ? gs.getMembers().size() : 0);
} else {
// this case may never happen as this is only called from convertToGoValueObject() leaving here in case
// this method is ever called from somewhere else
sbgsvo.setSize(this.geneSetService.getSize(new GeneSetValueObject(gs.getId())));
}
Collection<Long> gids = new HashSet<>();
for (GeneSetMember gm : gs.getMembers()) {
gids.add(gm.getGene().getId());
}
sbgsvo.setGeneIds(gids);
Taxon tax = this.geneSetService.getTaxon(gs);
if (tax != null) {
while (tax.getParentTaxon() != null) {
tax = tax.getParentTaxon();
}
sbgsvo.setTaxonId(tax.getId());
sbgsvo.setTaxonName(tax.getCommonName());
}
sbgsvo.setId(new Long(-1));
sbgsvo.setModified(false);
}
use of ubic.gemma.model.genome.gene.GeneSetMember in project Gemma by PavlidisLab.
the class GeneSetSearchImpl method goTermToGeneSet.
/**
* Convert a GO term to a 'GeneSet', including genes from all child terms. Divide up by taxon.
*/
private GeneSet goTermToGeneSet(OntologyResource term, Taxon taxon, Integer maxGeneSetSize) {
assert taxon != null;
if (term == null)
return null;
if (term.getUri() == null)
return null;
Collection<OntologyResource> allMatches = new HashSet<>();
allMatches.add(term);
assert term instanceof OntologyTerm;
allMatches.addAll(this.geneOntologyService.getAllChildren((OntologyTerm) 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);
}
Collection<Gene> genes = this.gene2GoService.findByGOTerms(termsToFetch, taxon);
if (genes.isEmpty() || (maxGeneSetSize != null && genes.size() > maxGeneSetSize)) {
return null;
}
GeneSet transientGeneSet = GeneSet.Factory.newInstance();
transientGeneSet.setName(this.uri2goid(term));
if (term.getLabel() == null) {
GeneSetSearchImpl.log.warn(" Label for term " + term.getUri() + " was null");
}
// noinspection StatementWithEmptyBody // FIXME this is an individual or a 'resource', not a 'class', but it's a real GO term. How to get the text.
if (term.getLabel() != null && term.getLabel().toUpperCase().startsWith("GO_")) {
}
transientGeneSet.setDescription(term.getLabel());
for (Gene gene : genes) {
GeneSetMember gmember = GeneSetMember.Factory.newInstance();
gmember.setGene(gene);
transientGeneSet.getMembers().add(gmember);
}
return transientGeneSet;
}
Aggregations