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();
}
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);
}
}
}
Aggregations