[Biopython] Passing sequence to local BLAST

Sheila the angel from.d.putto at gmail.com
Thu Jul 7 10:53:28 UTC 2011


Great !!!! It works
Thanks a lot :)

On Thu, Jul 7, 2011 at 12:43 PM, Peter Cock <p.j.a.cock at googlemail.com>wrote:

> On Thu, Jul 7, 2011 at 11:26 AM, Sheila the angel
> <from.d.putto at gmail.com> wrote:
> > Hi All,
> >
> > I want to download genbank file from NCBI and pass the protein sequence
> > directly to the local BLAST. But I am getting error in BLAST step
> >
> #-------------------------------------------------------------------------------------------
> > from Bio import SeqIO
> > from Bio import Entrez
> > from Bio.Blast.Applications import NcbiblastpCommandline
> > id='200203'
> > handle = Entrez.efetch(db="protein", id=id, rettype="gp")
> > seq_record = SeqIO.read(handle, "gb")
> > x=seq_record.seq                                            #getting the
> > sequence in a variable x
> > blastp_cline = NcbiblastpCommandline(query=x, db="protein_database",
> > evalue=0.001)    # My BLAST command
> > result_handle, stderr = blastp_cline()                    #Running BLAST
> and
> > getting error :(
> >
> >
> #-------------------------------------------------------------------------------------------
> >
> > At this last step I am getting error.....
> > I sort-of understand the problem.....it is taking value of x as a file
> name
> > while its a variable which contains the sequence.
> > Is there any way out to this problem without making temporary file.
>
> With the standalone blast tools you generally need to prepare an input
> FASTA file with your query sequence(s).
>
> However, in principle you can give the input filename as - (default),
> and instead pipe the query FASTA record in as stdin (standard input).
> Try something like this (untested):
>
> ...
> blastp_cline = NcbiblastpCommandline(query="-", db="protein_database",
> evalue=0.001)
> stdout, stderr = blastp_cline(stdin=seq_record.format("fasta"))
>
> Peter
>



More information about the Biopython mailing list