use of ubic.gemma.model.genome.sequenceAnalysis.BlatResult in project Gemma by PavlidisLab.
the class ArrayDesignDaoImpl method loadAlignments.
@Override
public Map<CompositeSequence, Collection<BlatResult>> loadAlignments(ArrayDesign arrayDesign) {
// noinspection unchecked,JpaQlInspection - blatResult not visible because it is in a sub-class (BlatAssociation)
List<Object[]> m = this.getSessionFactory().getCurrentSession().createQuery("select cs, br from CompositeSequence cs " + " join cs.biologicalCharacteristic bs join bs.bioSequence2GeneProduct bs2gp" + " join bs2gp.blatResult br " + " where bs2gp.class='BlatAssociation' and cs.arrayDesign=:ad").setParameter("ad", arrayDesign).list();
Map<CompositeSequence, Collection<BlatResult>> result = new HashMap<>();
for (Object[] objects : m) {
CompositeSequence cs = (CompositeSequence) objects[0];
BlatResult br = (BlatResult) objects[1];
if (!result.containsKey(cs)) {
result.put(cs, new HashSet<BlatResult>());
}
result.get(cs).add(br);
}
return result;
}
use of ubic.gemma.model.genome.sequenceAnalysis.BlatResult in project Gemma by PavlidisLab.
the class GoldenPathQuery method convertResult.
private BlatResult convertResult(ResultSet rs) throws SQLException {
BlatResult result = BlatResult.Factory.newInstance();
result.setQuerySequence(BioSequence.Factory.newInstance());
Long queryLength = rs.getLong("qSize");
result.getQuerySequence().setLength(queryLength);
result.setMatches(rs.getInt("matches"));
result.setMismatches(rs.getInt("misMatches"));
result.setRepMatches(rs.getInt("repMatches"));
result.setNs(rs.getInt("nCount"));
result.setQueryGapCount(rs.getInt("qNumInsert"));
result.setQueryGapBases(rs.getInt("qBaseInsert"));
result.setTargetGapCount(rs.getInt("tNumInsert"));
result.setTargetGapBases(rs.getInt("tBaseInsert"));
result.setStrand(rs.getString("strand"));
result.setQueryStart(rs.getInt("qStart"));
result.setQueryEnd(rs.getInt("qEnd"));
result.setTargetStart(rs.getLong("tStart"));
result.setTargetEnd(rs.getLong("tEnd"));
result.setBlockCount(rs.getInt("blockCount"));
result.setBlockSizes(SQLUtils.blobToString(rs.getBlob("blockSizes")));
result.setQueryStarts(SQLUtils.blobToString(rs.getBlob("qStarts")));
result.setTargetStarts(SQLUtils.blobToString(rs.getBlob("tStarts")));
String queryName = rs.getString("qName");
queryName = BlatResultParser.cleanUpQueryName(queryName);
result.getQuerySequence().setName(queryName);
String chrom = rs.getString("tName");
if (chrom.startsWith("chr")) {
chrom = chrom.substring(chrom.indexOf("chr") + 3);
if (chrom.endsWith(".fa")) {
chrom = chrom.substring(0, chrom.indexOf(".fa"));
}
}
result.setTargetChromosome(new Chromosome(chrom, null, BioSequence.Factory.newInstance(), this.getTaxon()));
result.getTargetChromosome().getSequence().setName(chrom);
result.getTargetChromosome().getSequence().setLength(rs.getLong("tSize"));
result.getTargetChromosome().getSequence().setTaxon(this.getTaxon());
result.setSearchedDatabase(this.getSearchedDatabase());
return result;
}
use of ubic.gemma.model.genome.sequenceAnalysis.BlatResult in project Gemma by PavlidisLab.
the class BlatResultTrackController method handleRequestInternal.
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
String idS = request.getParameter("id");
Long id = null;
try {
id = Long.parseLong(idS);
} catch (NumberFormatException e) {
// return error view.
}
Collection<Long> ids = new HashSet<Long>();
ids.add(id);
Collection<BlatResult> res = blatResultService.load(ids);
if (res.size() == 0) {
// should be an error.
}
assert res.size() == 1;
BlatResult toView = res.iterator().next();
toView = blatResultService.thaw(toView);
String val = BlatResult2Psl.blatResult2PslTrack(toView);
return new ModelAndView(new TextView(), "text", val);
}
use of ubic.gemma.model.genome.sequenceAnalysis.BlatResult in project Gemma by PavlidisLab.
the class BlatAssociationScorer method computeScore.
private static void computeScore(BlatAssociation blatAssociation) {
BlatResult br = blatAssociation.getBlatResult();
assert br.getQuerySequence().getLength() > 0;
double blatScore = br.score();
double overlap = BlatAssociationScorer.computeOverlapFraction(blatAssociation);
double score = BlatAssociationScorer.computeScore(blatScore, overlap);
blatAssociation.setScore(score);
}
use of ubic.gemma.model.genome.sequenceAnalysis.BlatResult in project Gemma by PavlidisLab.
the class ProbeMapperImpl method processSequence.
@Override
public Collection<BlatAssociation> processSequence(GoldenPathSequenceAnalysis goldenPath, BioSequence sequence) {
Blat b = new ShellDelegatingBlat();
b.setBlatScoreThreshold((new ProbeMapperConfig()).getBlatScoreThreshold());
Collection<BlatResult> results;
try {
results = b.blatQuery(sequence, goldenPath.getTaxon(), false);
} catch (IOException e) {
throw new RuntimeException("Error running blat", e);
}
Map<String, Collection<BlatAssociation>> allRes = this.processBlatResults(goldenPath, results);
assert allRes.keySet().size() == 1;
return allRes.values().iterator().next();
}
Aggregations