use of ubic.gemma.model.genome.gene.GeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetController method removeUserAndSessionGroups.
/**
* AJAX Given valid gene groups will remove them from the session or the database appropriately.
*
* @param vos vos
* @return gene set vos
*/
public Collection<GeneSetValueObject> removeUserAndSessionGroups(Collection<GeneSetValueObject> vos) {
Collection<GeneSetValueObject> removedSets = new HashSet<>();
Collection<DatabaseBackedGeneSetValueObject> databaseCollection = new HashSet<>();
Collection<SessionBoundGeneSetValueObject> sessionCollection = new HashSet<>();
for (GeneSetValueObject geneSetValueObject : vos) {
if (geneSetValueObject instanceof SessionBoundGeneSetValueObject) {
sessionCollection.add((SessionBoundGeneSetValueObject) geneSetValueObject);
} else if (geneSetValueObject instanceof DatabaseBackedGeneSetValueObject) {
databaseCollection.add((DatabaseBackedGeneSetValueObject) geneSetValueObject);
}
}
sessionCollection = this.removeSessionGroups(sessionCollection);
databaseCollection = this.remove(databaseCollection);
removedSets.addAll(sessionCollection);
removedSets.addAll(databaseCollection);
return removedSets;
}
use of ubic.gemma.model.genome.gene.GeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetController method getGeneSetFromRequest.
/**
* @param request request
* @return gene set vo
* @throws IllegalArgumentException if a matching EE can't be loaded
*/
private GeneSetValueObject getGeneSetFromRequest(HttpServletRequest request) {
GeneSetValueObject geneSet;
Long id;
if (request.getParameter("id") != null) {
try {
id = Long.parseLong(request.getParameter("id"));
} catch (NumberFormatException e) {
throw new IllegalArgumentException("You must provide a valid numerical identifier");
}
geneSet = geneSetService.getValueObject(id);
if (geneSet == null) {
throw new IllegalArgumentException("Unable to access gene set with id=" + id);
}
} else {
throw new IllegalArgumentException("You must provide an id");
}
return geneSet;
}
use of ubic.gemma.model.genome.gene.GeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetController method updateUserAndSessionGroups.
/**
* AJAX Updates the session group and user database groups.
*
* @param vos vos
* @return gene set vos
*/
public Collection<GeneSetValueObject> updateUserAndSessionGroups(Collection<GeneSetValueObject> vos) {
Collection<GeneSetValueObject> updatedSets = new HashSet<>();
Collection<DatabaseBackedGeneSetValueObject> databaseCollection = new HashSet<>();
Collection<SessionBoundGeneSetValueObject> sessionCollection = new HashSet<>();
for (GeneSetValueObject geneSetValueObject : vos) {
if (geneSetValueObject instanceof SessionBoundGeneSetValueObject) {
sessionCollection.add((SessionBoundGeneSetValueObject) geneSetValueObject);
} else if (geneSetValueObject instanceof DatabaseBackedGeneSetValueObject) {
databaseCollection.add((DatabaseBackedGeneSetValueObject) geneSetValueObject);
}
}
sessionCollection = this.updateSessionGroups(sessionCollection);
databaseCollection = this.update(databaseCollection);
updatedSets.addAll(sessionCollection);
updatedSets.addAll(databaseCollection);
return updatedSets;
}
use of ubic.gemma.model.genome.gene.GeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetController method addUserAndSessionGroups.
/**
* AJAX adds the gene group to the session
*
* @param geneSetVos value object constructed on the client.
* @return id of the new gene group
*/
public Collection<GeneSetValueObject> addUserAndSessionGroups(Collection<GeneSetValueObject> geneSetVos) {
Collection<GeneSetValueObject> result = new HashSet<>();
Collection<SessionBoundGeneSetValueObject> sessionResult = new HashSet<>();
for (GeneSetValueObject gsvo : geneSetVos) {
if (gsvo instanceof SessionBoundGeneSetValueObject) {
sessionResult.add((SessionBoundGeneSetValueObject) gsvo);
} else {
result.add(gsvo);
}
}
result = this.create(result);
result.addAll(this.addSessionGroups(sessionResult, true));
return result;
}
use of ubic.gemma.model.genome.gene.GeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetSearchImpl method findByPhenotypeName.
@Override
public Collection<GeneSetValueObject> findByPhenotypeName(String phenotypeQuery, Taxon taxon) {
StopWatch timer = new StopWatch();
timer.start();
Collection<CharacteristicValueObject> phenotypes = phenotypeAssociationManagerService.searchOntologyForPhenotypes(StringUtils.strip(phenotypeQuery), null);
Collection<GeneSetValueObject> results = new HashSet<>();
if (phenotypes.isEmpty()) {
return results;
}
if (timer.getTime() > 200) {
GeneSetSearchImpl.log.info("Find phenotypes: " + timer.getTime() + "ms");
}
GeneSetSearchImpl.log.debug(" Converting CharacteristicValueObjects collection(size:" + phenotypes.size() + ") into GeneSets for phenotype query " + phenotypeQuery);
Map<String, CharacteristicValueObject> uris = new HashMap<>();
for (CharacteristicValueObject cvo : phenotypes) {
uris.put(cvo.getValueUri(), cvo);
}
Map<String, Collection<? extends GeneValueObject>> genes = phenotypeAssociationManagerService.findCandidateGenesForEach(uris.keySet(), taxon);
if (timer.getTime() > 500) {
GeneSetSearchImpl.log.info("Find phenotype genes done at " + timer.getTime() + "ms");
}
for (String uri : genes.keySet()) {
Collection<? extends GeneValueObject> gvos = genes.get(uri);
if (gvos.isEmpty())
continue;
Collection<Long> geneIds = EntityUtils.getIds(gvos);
GeneSetValueObject transientGeneSet = new GeneSetValueObject();
transientGeneSet.setName(this.uri2phenoID(uris.get(uri)));
transientGeneSet.setDescription(uris.get(uri).getValue());
transientGeneSet.setGeneIds(geneIds);
transientGeneSet.setTaxonId(gvos.iterator().next().getTaxonId());
transientGeneSet.setTaxonName(gvos.iterator().next().getTaxonCommonName());
results.add(transientGeneSet);
}
if (timer.getTime() > 1000) {
GeneSetSearchImpl.log.info("Loaded " + phenotypes.size() + " phenotype gene sets for query " + phenotypeQuery + " in " + timer.getTime() + "ms");
}
return results;
}
Aggregations