Search in sources :

Example 1 with GoldenPathQuery

use of ubic.gemma.core.externalDb.GoldenPathQuery in project Gemma by PavlidisLab.

the class ArrayDesignSequenceAlignmentServiceImpl method getGoldenPathAlignments.

/**
 * Check if there are alignment results in the goldenpath database, in which case we do not reanalyze the sequences.
 *
 * @param sequencesToBlat The full set of sequences that need analysis.
 * @param results         Will be stored here.
 * @return the sequences which ARE NOT found in goldenpath and which therefore DO need blat.
 */
private Collection<BioSequence> getGoldenPathAlignments(Collection<BioSequence> sequencesToBlat, Taxon taxon, Map<BioSequence, Collection<BlatResult>> results) {
    GoldenPathQuery gpq = new GoldenPathQuery(taxon);
    Collection<BioSequence> needBlat = new HashSet<>();
    int count = 0;
    int totalFound = 0;
    for (BioSequence sequence : sequencesToBlat) {
        boolean found = false;
        if (sequence.getSequenceDatabaseEntry() != null) {
            Collection<BlatResult> brs = gpq.findAlignments(sequence.getSequenceDatabaseEntry().getAccession());
            if (brs != null && brs.size() > 0) {
                for (BlatResult result : brs) {
                    this.copyLengthInformation(sequence, result);
                    result.setQuerySequence(sequence);
                }
                results.put(sequence, brs);
                found = true;
                totalFound++;
            }
        }
        if (++count % 1000 == 0 && totalFound > 0) {
            ArrayDesignSequenceAlignmentServiceImpl.log.info("Alignments in Golden Path database for " + totalFound + "/" + count + " checked so far.");
        }
        if (!found) {
            needBlat.add(sequence);
        }
    }
    if (totalFound > 0) {
        ArrayDesignSequenceAlignmentServiceImpl.log.info("Found " + totalFound + "/" + count + " alignments in Golden Path database");
    }
    return needBlat;
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) GoldenPathQuery(ubic.gemma.core.externalDb.GoldenPathQuery) HashSet(java.util.HashSet) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult)

Aggregations

HashSet (java.util.HashSet)1 GoldenPathQuery (ubic.gemma.core.externalDb.GoldenPathQuery)1 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)1 BlatResult (ubic.gemma.model.genome.sequenceAnalysis.BlatResult)1