Search in sources :

Example 1 with BlatResultValueObject

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

Example 2 with BlatResultValueObject

use of ubic.gemma.model.genome.sequenceAnalysis.BlatResultValueObject in project Gemma by PavlidisLab.

the class CompositeSequenceServiceImpl method addBlatResultsLackingGenes.

/**
 * Note that duplicate hits will be ignored here. See bug 4037.
 */
private void addBlatResultsLackingGenes(CompositeSequence cs, Map<Integer, GeneMappingSummary> blatResults) {
    /*
         * Pick up blat results that didn't map to genes.
         */
    BioSequence biologicalCharacteristic = bioSequenceService.thaw(cs.getBiologicalCharacteristic());
    Collection<BlatResultValueObject> allBlatResultsForCs = blatResultService.loadValueObjects(blatResultService.thaw(blatResultService.findByBioSequence(biologicalCharacteristic)));
    for (BlatResultValueObject blatResult : allBlatResultsForCs) {
        if (!blatResults.containsKey(ProbeMapUtils.hashBlatResult(blatResult))) {
            GeneMappingSummary summary = new GeneMappingSummary();
            summary.setBlatResult(blatResult);
            summary.setCompositeSequence(this.loadValueObject(cs));
            // no gene...
            blatResults.put(ProbeMapUtils.hashBlatResult(blatResult), summary);
        }
    }
}
Also used : GeneMappingSummary(ubic.gemma.core.analysis.sequence.GeneMappingSummary) BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) BlatResultValueObject(ubic.gemma.model.genome.sequenceAnalysis.BlatResultValueObject)

Aggregations

GeneMappingSummary (ubic.gemma.core.analysis.sequence.GeneMappingSummary)2 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)2 BlatResultValueObject (ubic.gemma.model.genome.sequenceAnalysis.BlatResultValueObject)2 BioSequence2GeneProduct (ubic.gemma.model.association.BioSequence2GeneProduct)1 GeneProductValueObject (ubic.gemma.model.genome.gene.GeneProductValueObject)1 GeneValueObject (ubic.gemma.model.genome.gene.GeneValueObject)1 AnnotationAssociation (ubic.gemma.model.genome.sequenceAnalysis.AnnotationAssociation)1 BlatAssociation (ubic.gemma.model.genome.sequenceAnalysis.BlatAssociation)1