Search in sources :

Example 1 with GeneSetValueObject

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;
}
Also used : DatabaseBackedGeneSetValueObject(ubic.gemma.model.genome.gene.DatabaseBackedGeneSetValueObject) GeneSetValueObject(ubic.gemma.model.genome.gene.GeneSetValueObject) DatabaseBackedGeneSetValueObject(ubic.gemma.model.genome.gene.DatabaseBackedGeneSetValueObject) SessionBoundGeneSetValueObject(ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject) HashSet(java.util.HashSet) SessionBoundGeneSetValueObject(ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject)

Example 2 with GeneSetValueObject

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;
}
Also used : GeneSetValueObject(ubic.gemma.model.genome.gene.GeneSetValueObject) DatabaseBackedGeneSetValueObject(ubic.gemma.model.genome.gene.DatabaseBackedGeneSetValueObject) SessionBoundGeneSetValueObject(ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject)

Example 3 with GeneSetValueObject

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;
}
Also used : DatabaseBackedGeneSetValueObject(ubic.gemma.model.genome.gene.DatabaseBackedGeneSetValueObject) GeneSetValueObject(ubic.gemma.model.genome.gene.GeneSetValueObject) DatabaseBackedGeneSetValueObject(ubic.gemma.model.genome.gene.DatabaseBackedGeneSetValueObject) SessionBoundGeneSetValueObject(ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject) HashSet(java.util.HashSet) SessionBoundGeneSetValueObject(ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject)

Example 4 with GeneSetValueObject

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;
}
Also used : GeneSetValueObject(ubic.gemma.model.genome.gene.GeneSetValueObject) DatabaseBackedGeneSetValueObject(ubic.gemma.model.genome.gene.DatabaseBackedGeneSetValueObject) SessionBoundGeneSetValueObject(ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject) HashSet(java.util.HashSet) SessionBoundGeneSetValueObject(ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject)

Example 5 with GeneSetValueObject

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;
}
Also used : CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject) HashMap(java.util.HashMap) StopWatch(org.apache.commons.lang3.time.StopWatch) GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) Collection(java.util.Collection) GeneSetValueObject(ubic.gemma.model.genome.gene.GeneSetValueObject) HashSet(java.util.HashSet)

Aggregations

GeneSetValueObject (ubic.gemma.model.genome.gene.GeneSetValueObject)12 DatabaseBackedGeneSetValueObject (ubic.gemma.model.genome.gene.DatabaseBackedGeneSetValueObject)8 SessionBoundGeneSetValueObject (ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject)6 HashSet (java.util.HashSet)4 GeneValueObject (ubic.gemma.model.genome.gene.GeneValueObject)3 StopWatch (org.apache.commons.lang3.time.StopWatch)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 CoexpressionMetaValueObject (ubic.gemma.core.analysis.expression.coexpression.CoexpressionMetaValueObject)1 CoexpressionValueObjectExt (ubic.gemma.core.analysis.expression.coexpression.CoexpressionValueObjectExt)1 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)1 ExpressionExperimentSetValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject)1 ExpressionExperimentValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject)1 Gene (ubic.gemma.model.genome.Gene)1 Taxon (ubic.gemma.model.genome.Taxon)1 GeneSetMember (ubic.gemma.model.genome.gene.GeneSetMember)1 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)1