Search in sources :

Example 11 with BlatResult

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;
}
Also used : PersistentCollection(org.hibernate.collection.PersistentCollection) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult)

Example 12 with BlatResult

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;
}
Also used : Chromosome(ubic.gemma.model.genome.Chromosome) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult)

Example 13 with BlatResult

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);
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) TextView(ubic.gemma.web.view.TextView) HashSet(java.util.HashSet) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult)

Example 14 with BlatResult

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);
}
Also used : BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult)

Example 15 with BlatResult

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();
}
Also used : Blat(ubic.gemma.core.apps.Blat) ShellDelegatingBlat(ubic.gemma.core.apps.ShellDelegatingBlat) ShellDelegatingBlat(ubic.gemma.core.apps.ShellDelegatingBlat) Collection(java.util.Collection) IOException(java.io.IOException) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult)

Aggregations

BlatResult (ubic.gemma.model.genome.sequenceAnalysis.BlatResult)33 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)12 HashSet (java.util.HashSet)10 Collection (java.util.Collection)9 Taxon (ubic.gemma.model.genome.Taxon)6 Chromosome (ubic.gemma.model.genome.Chromosome)5 BlatAssociation (ubic.gemma.model.genome.sequenceAnalysis.BlatAssociation)5 HashMap (java.util.HashMap)4 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)4 PhysicalLocation (ubic.gemma.model.genome.PhysicalLocation)4 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Blat (ubic.gemma.core.apps.Blat)3 ShellDelegatingBlat (ubic.gemma.core.apps.ShellDelegatingBlat)3 ExternalDatabase (ubic.gemma.model.common.description.ExternalDatabase)3 Test (org.junit.Test)2 BioSequence2GeneProduct (ubic.gemma.model.association.BioSequence2GeneProduct)2 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1