use of ubic.gemma.model.genome.sequenceAnalysis.BlatAssociation in project Gemma by PavlidisLab.
the class BlatAssociationDaoImpl method thaw.
@Override
public void thaw(final Collection<BlatAssociation> blatAssociations) {
if (blatAssociations == null)
return;
HibernateTemplate templ = this.getHibernateTemplate();
templ.executeWithNativeSession(new org.springframework.orm.hibernate3.HibernateCallback<Object>() {
@Override
public Object doInHibernate(org.hibernate.Session session) throws org.hibernate.HibernateException {
for (Object object : blatAssociations) {
BlatAssociation blatAssociation = (BlatAssociation) object;
if ((blatAssociation).getId() == null)
continue;
BlatAssociationDaoImpl.this.thawBlatAssociation(session, blatAssociation);
session.evict(blatAssociation);
}
return null;
}
});
}
use of ubic.gemma.model.genome.sequenceAnalysis.BlatAssociation in project Gemma by PavlidisLab.
the class BlatAssociationScorerTest method testScoreResults.
@Test
public void testScoreResults() {
// there's only one gene product that is aligned to two different regions
GeneProduct geneProduct = this.createGeneProduct();
BlatResult blatResult_1 = this.createBlatResult("6_cox_hap2");
BlatResult blatResult_2 = this.createBlatResult("6");
// this has the highest score but located on a non-canonical chromosome
// so this should be ignored
BlatAssociation association_1 = BlatAssociation.Factory.newInstance();
association_1.setGeneProduct(geneProduct);
association_1.setBlatResult(blatResult_1);
association_1.setScore(50.0);
association_1.setOverlap(50);
association_1.setBioSequence(BioSequence.Factory.newInstance());
BlatAssociation association_2 = BlatAssociation.Factory.newInstance();
association_2.setGeneProduct(geneProduct);
association_2.setBlatResult(blatResult_2);
association_2.setScore(30.0);
association_2.setOverlap(30);
association_2.setBioSequence(BioSequence.Factory.newInstance());
Collection<BlatAssociation> blatAssociations = new ArrayList<>();
blatAssociations.add(association_1);
blatAssociations.add(association_2);
ProbeMapperConfig config = new ProbeMapperConfig();
config.setTrimNonCanonicalChromosomeHits(true);
// BlatAssociation expected = association_2;
BlatAssociation actual = BlatAssociationScorer.scoreResults(blatAssociations);
assertFalse(ChromosomeUtil.isCanonical(blatResult_1.getTargetChromosome()));
assertTrue(ChromosomeUtil.isCanonical(blatResult_2.getTargetChromosome()));
assertEquals(940.0, association_1.getScore(), 0);
assertEquals(564.0, association_2.getScore(), 0);
assertEquals(1.0, actual.getSpecificity(), 0);
// assertEquals( expected, actual );
}
use of ubic.gemma.model.genome.sequenceAnalysis.BlatAssociation in project Gemma by PavlidisLab.
the class GoldenPathSequenceAnalysis method computeLocationInGene.
/**
* Given a location and a gene product, compute the distance from the 3' end of the gene product as well as the
* amount of overlap. If the location has low overlaps with known exons (threshold set by
* RECHECK_OVERLAP_THRESHOLD), we optionally search for mRNAs in the region. If there are overlapping mRNAs, we use
* the best overlap value. If the overlap is still not high enough we optionally check ESTs.
*
* @param chromosome chromosome
* @param queryStart start
* @param queryEnd end
* @param starts Start locations of alignments of the query (target coordinates)
* @param sizes Sizes of alignments of the query.
* @param geneProduct GeneProduct with which the overlap and distance is to be computed.
* @param method method
* @param config The useEsts and useRNA options are relevant
* @return a ThreePrimeData object containing the results.
*/
private BlatAssociation computeLocationInGene(String chromosome, Long queryStart, Long queryEnd, String starts, String sizes, GeneProduct geneProduct, ThreePrimeDistanceMethod method, ProbeMapperConfig config) {
assert geneProduct != null : "GeneProduct is null";
BlatAssociation blatAssociation = BlatAssociation.Factory.newInstance();
blatAssociation.setGeneProduct(geneProduct);
blatAssociation.setThreePrimeDistanceMeasurementMethod(method);
PhysicalLocation geneLoc = geneProduct.getPhysicalLocation();
assert geneLoc != null : "PhysicalLocation for GeneProduct " + geneProduct + " is null";
assert geneLoc.getNucleotide() != null;
int geneStart = geneLoc.getNucleotide().intValue();
int geneEnd = geneLoc.getNucleotide().intValue() + geneLoc.getNucleotideLength();
int exonOverlap = 0;
if (starts != null & sizes != null) {
exonOverlap = SequenceManipulation.getGeneProductExonOverlap(starts, sizes, geneLoc.getStrand(), geneProduct);
int totalSize = SequenceManipulation.totalSize(sizes);
if (config.isUseMrnas() && exonOverlap / (double) (totalSize) < GoldenPathSequenceAnalysis.RECHECK_OVERLAP_THRESHOLD) {
int newOverlap = this.checkRNAs(chromosome, queryStart, queryEnd, starts, sizes, exonOverlap, geneLoc.getStrand(), geneProduct.getGene());
if (newOverlap > exonOverlap) {
GoldenPath.log.debug("mRNA overlap was higher than primary transcript");
exonOverlap = newOverlap;
}
}
if (config.isUseEsts() && exonOverlap / (double) (totalSize) < GoldenPathSequenceAnalysis.RECHECK_OVERLAP_THRESHOLD) {
int newOverlap = this.checkESTs(chromosome, queryStart, queryEnd, starts, sizes, exonOverlap, geneLoc.getStrand());
if (newOverlap > exonOverlap) {
GoldenPath.log.debug("Exon overlap was higher than mrna or primary transcript");
exonOverlap = newOverlap;
}
}
assert exonOverlap <= totalSize;
}
blatAssociation.setOverlap(exonOverlap);
if (method == ThreePrimeDistanceMethod.MIDDLE) {
int center = SequenceManipulation.findCenter(starts, sizes);
if (geneLoc.getStrand().equals("+")) {
// then the 3' end is at the 'end'. : >>>>>>>>>>>>>>>>>>>>>*>>>>> (* is where we might be)
blatAssociation.setThreePrimeDistance((long) Math.max(0, geneEnd - center));
} else if (geneProduct.getPhysicalLocation().getStrand().equals("-")) {
// then the 3' end is at the 'start'. : <<<*<<<<<<<<<<<<<<<<<<<<<<<
blatAssociation.setThreePrimeDistance((long) Math.max(0, center - geneStart));
} else {
throw new IllegalArgumentException("Strand wasn't '+' or '-'");
}
} else if (method == ThreePrimeDistanceMethod.RIGHT) {
if (geneLoc.getStrand().equals("+")) {
// then the 3' end is at the 'end'. : >>>>>>>>>>>>>>>>>>>>>*>>>>> (* is where we might be)
blatAssociation.setThreePrimeDistance(Math.max(0, geneEnd - queryEnd));
} else if (geneProduct.getPhysicalLocation().getStrand().equals("-")) {
// then the 3' end is at the 'start'. : <<<*<<<<<<<<<<<<<<<<<<<<<<<
blatAssociation.setThreePrimeDistance(Math.max(0, queryStart - geneStart));
} else {
throw new IllegalArgumentException("Strand wasn't '+' or '-'");
}
} else if (method == ThreePrimeDistanceMethod.LEFT) {
throw new UnsupportedOperationException("Left edge measure not supported");
} else {
throw new IllegalArgumentException("Unknown method");
}
return blatAssociation;
}
use of ubic.gemma.model.genome.sequenceAnalysis.BlatAssociation in project Gemma by PavlidisLab.
the class PersistentDummyObjectHelper method getTestPersistentBioSequence2GeneProducts.
/**
* @param bioSequence bio sequence
* @return bio sequence to gene products
*/
public Collection<BioSequence2GeneProduct> getTestPersistentBioSequence2GeneProducts(BioSequence bioSequence) {
Collection<BioSequence2GeneProduct> b2gCol = new HashSet<>();
BlatAssociation b2g = BlatAssociation.Factory.newInstance();
b2g.setScore(new Random().nextDouble());
b2g.setBioSequence(bioSequence);
b2g.setGeneProduct(this.getTestPersistentGeneProduct(this.getTestPersistentGene()));
b2g.setBlatResult(this.getTestPersistentBlatResult(bioSequence, null));
b2gCol.add(b2g);
// noinspection unchecked
return (Collection<BioSequence2GeneProduct>) persisterHelper.persist(b2gCol);
}
Aggregations