use of ubic.gemma.model.genome.sequenceAnalysis.BlatResult in project Gemma by PavlidisLab.
the class ShellDelegatingBlat method blatQuery.
@Override
public Collection<BlatResult> blatQuery(BioSequence b, Taxon taxon, boolean sensitive) throws IOException {
assert seqDir != null;
// write the sequence to a temporary file.
String seqName = b.getName().replaceAll(" ", "_");
File querySequenceFile = File.createTempFile(seqName, ".fa");
try (BufferedWriter out = new BufferedWriter(new FileWriter(querySequenceFile))) {
String trimmed = SequenceManipulation.stripPolyAorT(b.getSequence(), ShellDelegatingBlat.POLY_AT_THRESHOLD);
out.write(">" + seqName + "\n" + trimmed);
ShellDelegatingBlat.log.info("Wrote sequence to " + querySequenceFile.getPath());
}
String outputPath = this.getTmpPslFilePath(seqName);
Collection<BlatResult> results = this.gfClient(querySequenceFile, outputPath, this.choosePortForQuery(taxon, sensitive));
ExternalDatabase searchedDatabase = ShellDelegatingBlat.getSearchedGenome(taxon);
for (BlatResult result : results) {
result.setSearchedDatabase(searchedDatabase);
}
this.cleanUpTmpFiles(querySequenceFile, outputPath);
return results;
}
use of ubic.gemma.model.genome.sequenceAnalysis.BlatResult in project Gemma by PavlidisLab.
the class ShellDelegatingBlat method blatQuery.
@Override
public Map<BioSequence, Collection<BlatResult>> blatQuery(Collection<BioSequence> sequences, boolean sensitive, Taxon taxon) throws IOException {
Map<BioSequence, Collection<BlatResult>> results = new HashMap<>();
File querySequenceFile = File.createTempFile("sequences-for-blat", ".fa");
int count = SequenceWriter.writeSequencesToFile(sequences, querySequenceFile);
if (count == 0) {
EntityUtils.deleteFile(querySequenceFile);
throw new IllegalArgumentException("No sequences!");
}
String outputPath = this.getTmpPslFilePath("blat-output");
Integer port = this.choosePortForQuery(taxon, sensitive);
if (port == null) {
throw new IllegalStateException("Could not locate port for BLAT with settings taxon=" + taxon + ", sensitive=" + sensitive + ", check your configuration.");
}
Collection<BlatResult> rawResults = this.gfClient(querySequenceFile, outputPath, port);
ShellDelegatingBlat.log.info("Got " + rawResults.size() + " raw blat results");
ExternalDatabase searchedDatabase = ShellDelegatingBlat.getSearchedGenome(taxon);
for (BlatResult blatResult : rawResults) {
blatResult.setSearchedDatabase(searchedDatabase);
BioSequence query = blatResult.getQuerySequence();
if (!results.containsKey(query)) {
results.put(query, new HashSet<BlatResult>());
}
results.get(query).add(blatResult);
}
EntityUtils.deleteFile(querySequenceFile);
return results;
}
use of ubic.gemma.model.genome.sequenceAnalysis.BlatResult in project Gemma by PavlidisLab.
the class PersistentDummyObjectHelper method getTestPersistentBlatResult.
public BlatResult getTestPersistentBlatResult(BioSequence querySequence, Taxon taxon) {
BlatResult br = BlatResult.Factory.newInstance();
if (taxon == null) {
taxon = this.getTestPersistentTaxon();
}
Chromosome chromosome = new Chromosome("XXX", null, this.getTestPersistentBioSequence(taxon), taxon);
assert chromosome.getSequence() != null;
chromosome = (Chromosome) persisterHelper.persist(chromosome);
assert chromosome != null;
assert chromosome.getSequence() != null;
br.setTargetChromosome(chromosome);
assert br.getTargetChromosome().getSequence() != null;
br.setQuerySequence(querySequence);
br.setTargetStart(1L);
br.setTargetEnd(1000L);
PhysicalLocation targetAlignedRegion = PhysicalLocation.Factory.newInstance();
targetAlignedRegion.setChromosome(br.getTargetChromosome());
targetAlignedRegion.setNucleotide(10000010L);
targetAlignedRegion.setNucleotideLength(1001);
targetAlignedRegion.setStrand("-");
return (BlatResult) persisterHelper.persist(br);
}
Aggregations