Search in sources :

Example 1 with ShellDelegatingBlat

use of ubic.gemma.core.apps.ShellDelegatingBlat in project Gemma by PavlidisLab.

the class ProbeMapperImpl method processSequences.

@Override
public Map<String, Collection<BlatAssociation>> processSequences(GoldenPathSequenceAnalysis goldenpath, Collection<BioSequence> sequences, ProbeMapperConfig config) {
    Blat b = new ShellDelegatingBlat();
    b.setBlatScoreThreshold(config.getBlatScoreThreshold());
    try {
        Map<BioSequence, Collection<BlatResult>> results = b.blatQuery(sequences, goldenpath.getTaxon());
        Collection<BlatResult> blatRes = new HashSet<>();
        for (Collection<BlatResult> coll : results.values()) {
            blatRes.addAll(coll);
        }
        return this.processBlatResults(goldenpath, blatRes);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : Blat(ubic.gemma.core.apps.Blat) ShellDelegatingBlat(ubic.gemma.core.apps.ShellDelegatingBlat) BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) ShellDelegatingBlat(ubic.gemma.core.apps.ShellDelegatingBlat) Collection(java.util.Collection) IOException(java.io.IOException) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult) HashSet(java.util.HashSet)

Example 2 with ShellDelegatingBlat

use of ubic.gemma.core.apps.ShellDelegatingBlat 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)

Example 3 with ShellDelegatingBlat

use of ubic.gemma.core.apps.ShellDelegatingBlat in project Gemma by PavlidisLab.

the class ArrayDesignSequenceAlignmentServiceImpl method processArrayDesign.

private Collection<BlatResult> processArrayDesign(ArrayDesign ad, boolean sensitive, Blat blat) {
    if (blat == null)
        blat = new ShellDelegatingBlat();
    Collection<BlatResult> allResults = new HashSet<>();
    if (sensitive)
        ArrayDesignSequenceAlignmentServiceImpl.log.info("Running in 'sensitive' mode if possible");
    Collection<Taxon> taxa = arrayDesignService.getTaxa(ad.getId());
    boolean first = true;
    for (Taxon taxon : taxa) {
        Collection<BioSequence> sequencesToBlat = ArrayDesignSequenceAlignmentServiceImpl.getSequences(ad, taxon);
        Map<BioSequence, Collection<BlatResult>> results = this.getAlignments(sequencesToBlat, sensitive, taxon, blat);
        ArrayDesignSequenceAlignmentServiceImpl.log.info("Got BLAT results for " + results.keySet().size() + " query sequences");
        Map<String, BioSequence> nameMap = new HashMap<>();
        for (BioSequence bs : results.keySet()) {
            if (nameMap.containsKey(bs.getName())) {
                throw new IllegalStateException("All distinct sequences on the array must have unique names; found " + bs.getName() + " more than once.");
            }
            nameMap.put(bs.getName(), bs);
        }
        int noResults = 0;
        int count = 0;
        // We only remove the results here, after we have at least one set of blat results.
        if (first) {
            ArrayDesignSequenceAlignmentServiceImpl.log.info("Looking for old results to remove...");
            arrayDesignService.deleteAlignmentData(ad);
        }
        for (BioSequence sequence : sequencesToBlat) {
            if (sequence == null) {
                ArrayDesignSequenceAlignmentServiceImpl.log.warn("Null sequence!");
                continue;
            }
            Collection<BlatResult> brs = results.get(nameMap.get(sequence.getName()));
            if (brs == null) {
                ++noResults;
                continue;
            }
            for (BlatResult result : brs) {
                // must do this to replace
                result.setQuerySequence(sequence);
            // placeholder instance.
            }
            allResults.addAll(this.persistBlatResults(brs));
            if (++count % 2000 == 0) {
                ArrayDesignSequenceAlignmentServiceImpl.log.info("Checked results for " + count + " queries, " + allResults.size() + " blat results so far.");
            }
        }
        ArrayDesignSequenceAlignmentServiceImpl.log.info(noResults + "/" + sequencesToBlat.size() + " sequences had no blat results");
        first = false;
    }
    arrayDesignReportService.generateArrayDesignReport(ad.getId());
    return allResults;
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) HashMap(java.util.HashMap) Taxon(ubic.gemma.model.genome.Taxon) ShellDelegatingBlat(ubic.gemma.core.apps.ShellDelegatingBlat) Collection(java.util.Collection) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult) HashSet(java.util.HashSet)

Aggregations

Collection (java.util.Collection)3 ShellDelegatingBlat (ubic.gemma.core.apps.ShellDelegatingBlat)3 BlatResult (ubic.gemma.model.genome.sequenceAnalysis.BlatResult)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Blat (ubic.gemma.core.apps.Blat)2 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)2 HashMap (java.util.HashMap)1 Taxon (ubic.gemma.model.genome.Taxon)1