Search in sources :

Example 1 with GeneValueObject

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

the class TaxonArg method getGenesOnChromosome.

/**
 * Lists Genes overlapping a location on a specific chromosome on a taxon that this TaxonArg represents.
 *
 * @param taxonService      the service that will be used to retrieve the persistent Taxon object.
 * @param chromosomeService the service that will be used to find the Chromosome object.
 * @param geneService       the service that will be used to retrieve the Gene VOs
 * @param chromosomeName    name of the chromosome to look on
 * @param start             the start nucleotide denoting the location to look for genes at.
 * @param size              the size (in nucleotides) of the location from the 'start' nucleotide.
 * @return collection of Gene VOs overlapping the location defined by the 'start' and 'size' parameters.
 */
public Collection<GeneValueObject> getGenesOnChromosome(TaxonService taxonService, ChromosomeService chromosomeService, GeneService geneService, String chromosomeName, long start, int size) {
    // Taxon argument
    Taxon taxon = this.getPersistentObject(taxonService);
    // Chromosome argument
    Collection<Chromosome> chromosomes = chromosomeService.find(chromosomeName, taxon);
    if (chromosomes.isEmpty()) {
        WellComposedErrorBody errorBody = new WellComposedErrorBody(Response.Status.NOT_FOUND, "Chromosome " + chromosomeName + " not found for taxon " + taxon.getScientificName());
        throw new GemmaApiException(errorBody);
    }
    Chromosome chromosome = chromosomes.iterator().next();
    // Setup chromosome location
    PhysicalLocation region = PhysicalLocation.Factory.newInstance(chromosome);
    region.setNucleotide(start);
    region.setNucleotideLength(size);
    // region.setStrand( strand );
    Collection<GeneValueObject> GVOs = geneService.loadValueObjects(geneService.find(region));
    if (GVOs == null) {
        WellComposedErrorBody errorBody = new WellComposedErrorBody(Response.Status.NOT_FOUND, "No genes found on chromosome " + chromosomeName + " between positions " + start + " and " + start + size + ".");
        throw new GemmaApiException(errorBody);
    }
    return GVOs;
}
Also used : GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) Taxon(ubic.gemma.model.genome.Taxon) Chromosome(ubic.gemma.model.genome.Chromosome) WellComposedErrorBody(ubic.gemma.web.services.rest.util.WellComposedErrorBody) GemmaApiException(ubic.gemma.web.services.rest.util.GemmaApiException) PhysicalLocation(ubic.gemma.model.genome.PhysicalLocation)

Example 2 with GeneValueObject

use of ubic.gemma.model.genome.gene.GeneValueObject 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 3 with GeneValueObject

use of ubic.gemma.model.genome.gene.GeneValueObject 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)

Example 4 with GeneValueObject

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

the class ArrayDesignMapResultServiceImpl method getSummaryMapValueObjects.

@Override
public Collection<CompositeSequenceMapValueObject> getSummaryMapValueObjects(Collection<Object[]> sequenceData) {
    Map<Long, CompositeSequenceMapValueObject> summary = new HashMap<>();
    Map<Long, Set<Integer>> blatResultCount = new HashMap<>();
    for (Object o : sequenceData) {
        Object[] row = (Object[]) o;
        Long csId = ((BigInteger) row[0]).longValue();
        CompositeSequenceMapValueObject vo;
        if (summary.containsKey(csId)) {
            vo = summary.get(csId);
        } else {
            vo = new CompositeSequenceMapValueObject();
            summary.put(csId, vo);
        }
        String csName = (String) row[1];
        String bioSequenceName = (String) row[2];
        String bioSequenceNcbiId = (String) row[3];
        Long blatId = null;
        if (row[4] != null) {
            blatId = ((BigInteger) row[4]).longValue();
        }
        if (row[10] != null) {
            // When viewing array designs, many will not have a gene.
            Long geneProductId = ((BigInteger) row[5]).longValue();
            String geneProductName = (String) row[6];
            String geneProductAccession = (String) row[7];
            Object geneProductGeneId = row[8];
            String geneProductType = (String) row[9];
            Long geneId = ((BigInteger) row[10]).longValue();
            String geneName = (String) row[11];
            // NCBI
            Integer geneAccession = (Integer) row[12];
            // fill in value object for geneProducts
            Map<Long, GeneProductValueObject> geneProductSet = vo.getGeneProducts();
            // if it isn't there, put it in the map
            if (!geneProductSet.containsKey(geneProductId)) {
                GeneProductValueObject gpVo = new GeneProductValueObject(geneProductId);
                gpVo.setName(geneProductName);
                gpVo.setNcbiId(geneProductAccession);
                if (geneProductGeneId != null) {
                    gpVo.setGeneId(((BigInteger) geneProductGeneId).longValue());
                }
                gpVo.setType(geneProductType);
                geneProductSet.put(geneProductId, gpVo);
            }
            Map<Long, GeneValueObject> geneSet = vo.getGenes();
            if (!geneSet.containsKey(geneId)) {
                GeneValueObject gVo = new GeneValueObject(geneId);
                gVo.setOfficialSymbol(geneName);
                gVo.setNcbiId(geneAccession);
                geneSet.put(geneId, gVo);
            }
        }
        String arrayDesignShortName = (String) row[13];
        Long arrayDesignId = ((BigInteger) row[14]).longValue();
        String csDesc = (String) row[20];
        vo.setCompositeSequenceDescription(csDesc);
        vo.setArrayDesignId(arrayDesignId);
        vo.setCompositeSequenceId(csId.toString());
        vo.setCompositeSequenceName(csName);
        vo.setArrayDesignShortName(arrayDesignShortName);
        vo.setArrayDesignName((String) row[21]);
        // fill in value object
        if (bioSequenceName != null && vo.getBioSequenceName() == null) {
            vo.setBioSequenceName(bioSequenceName);
        }
        // fill in value object
        if (bioSequenceNcbiId != null && vo.getBioSequenceNcbiId() == null) {
            vo.setBioSequenceNcbiId(bioSequenceNcbiId);
        }
        if (blatId != null)
            this.countBlatHits(row, blatResultCount, csId, vo);
    }
    return summary.values();
}
Also used : GeneProductValueObject(ubic.gemma.model.genome.gene.GeneProductValueObject) BigInteger(java.math.BigInteger) GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) BigInteger(java.math.BigInteger) GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) GeneProductValueObject(ubic.gemma.model.genome.gene.GeneProductValueObject)

Example 5 with GeneValueObject

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

the class CompositeSequenceServiceImpl method getGeneMappingSummary.

@Override
public Collection<GeneMappingSummary> getGeneMappingSummary(CompositeSequence cs) {
    BioSequence biologicalCharacteristic = cs.getBiologicalCharacteristic();
    biologicalCharacteristic = bioSequenceService.thaw(biologicalCharacteristic);
    Map<Integer, GeneMappingSummary> results = new HashMap<>();
    if (biologicalCharacteristic == null || biologicalCharacteristic.getBioSequence2GeneProduct() == null) {
        return results.values();
    }
    Collection<BioSequence2GeneProduct> bs2gps = biologicalCharacteristic.getBioSequence2GeneProduct();
    for (BioSequence2GeneProduct bs2gp : bs2gps) {
        GeneProductValueObject geneProduct = new GeneProductValueObject(geneProductService.thaw(bs2gp.getGeneProduct()));
        GeneValueObject gene = new GeneValueObject(bs2gp.getGeneProduct().getGene());
        BlatResultValueObject blatResult = null;
        if ((bs2gp instanceof BlatAssociation)) {
            BlatAssociation blatAssociation = (BlatAssociation) bs2gp;
            blatResult = new BlatResultValueObject(blatResultService.thaw(blatAssociation.getBlatResult()));
        } else if (bs2gp instanceof AnnotationAssociation) {
            /*
                 * Make a dummy blat result
                 */
            blatResult = new BlatResultValueObject();
            blatResult.setQuerySequence(BioSequenceValueObject.fromEntity(biologicalCharacteristic));
            blatResult.setId(biologicalCharacteristic.getId());
        }
        if (blatResult == null) {
            continue;
        }
        if (results.containsKey(ProbeMapUtils.hashBlatResult(blatResult))) {
            results.get(ProbeMapUtils.hashBlatResult(blatResult)).addGene(geneProduct, gene);
        } else {
            GeneMappingSummary summary = new GeneMappingSummary();
            summary.addGene(geneProduct, gene);
            summary.setBlatResult(blatResult);
            summary.setCompositeSequence(this.loadValueObject(cs));
            results.put(ProbeMapUtils.hashBlatResult(blatResult), summary);
        }
    }
    this.addBlatResultsLackingGenes(cs, results);
    if (results.size() == 0) {
        // add a 'dummy' that at least contains the information about the CS. This is a bit of a hack...
        GeneMappingSummary summary = new GeneMappingSummary();
        summary.setCompositeSequence(this.loadValueObject(cs));
        BlatResultValueObject newInstance = new BlatResultValueObject(-1L);
        newInstance.setQuerySequence(BioSequenceValueObject.fromEntity(biologicalCharacteristic));
        summary.setBlatResult(newInstance);
        results.put(ProbeMapUtils.hashBlatResult(newInstance), summary);
    }
    return results.values();
}
Also used : GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) AnnotationAssociation(ubic.gemma.model.genome.sequenceAnalysis.AnnotationAssociation) GeneProductValueObject(ubic.gemma.model.genome.gene.GeneProductValueObject) GeneMappingSummary(ubic.gemma.core.analysis.sequence.GeneMappingSummary) BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) BlatResultValueObject(ubic.gemma.model.genome.sequenceAnalysis.BlatResultValueObject) BioSequence2GeneProduct(ubic.gemma.model.association.BioSequence2GeneProduct) BlatAssociation(ubic.gemma.model.genome.sequenceAnalysis.BlatAssociation)

Aggregations

GeneValueObject (ubic.gemma.model.genome.gene.GeneValueObject)31 StopWatch (org.apache.commons.lang3.time.StopWatch)6 Gene (ubic.gemma.model.genome.Gene)6 Taxon (ubic.gemma.model.genome.Taxon)5 DoubleVectorValueObject (ubic.gemma.model.expression.bioAssayData.DoubleVectorValueObject)4 GeneSetValueObject (ubic.gemma.model.genome.gene.GeneSetValueObject)4 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 GeneProductValueObject (ubic.gemma.model.genome.gene.GeneProductValueObject)3 HashSet (java.util.HashSet)2 OntologyTerm (ubic.basecode.ontology.model.OntologyTerm)2 DifferentialExpressionValueObject (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionValueObject)2 BioAssayValueObject (ubic.gemma.model.expression.bioAssay.BioAssayValueObject)2 ExpressionExperimentValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject)2 EvidenceValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.EvidenceValueObject)2 CoexpressionValueObject (ubic.gemma.persistence.service.association.coexpression.CoexpressionValueObject)2 VisualizationValueObject (ubic.gemma.web.controller.visualization.VisualizationValueObject)2 ImageValueObject (ubic.gemma.web.image.aba.ImageValueObject)2 DoubleArrayList (cern.colt.list.DoubleArrayList)1