Search in sources :

Example 31 with BlatResult

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

Example 32 with BlatResult

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;
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) HashMap(java.util.HashMap) ExternalDatabase(ubic.gemma.model.common.description.ExternalDatabase) Collection(java.util.Collection) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult)

Example 33 with BlatResult

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

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