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);
}
}
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();
}
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;
}
Aggregations