<div dir="ltr">Hi Islam,<div><br></div><div>If you need to avoid writing the sequence to disk for whatever reason, you could create an in-memory file using StringIO: <a href="https://docs.python.org/2/library/stringio.html">https://docs.python.org/2/library/stringio.html</a></div><div><br></div><div>Lenna</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 9, 2017 at 6:15 PM, Islam Amin <span dir="ltr"><<a href="mailto:eng.islamamin@gmail.com" target="_blank">eng.islamamin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Many thanks Peter, I thought that It may be possible to pass raw sequences instead of passing fasta file.</div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Fri, Mar 10, 2017 at 9:43 AM, Peter Cock <span dir="ltr"><<a href="mailto:p.j.a.cock@googlemail.com" target="_blank">p.j.a.cock@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The NCBI BLAST+ arguments query and subject should be filenames, not<br>
raw sequences.<br>
<br>
The example you linked to on BioStars had an example by Ryan showing<br>
how to first create two temp files which he called "seq1.fasta" and<br>
"seq2.fasta" using Biopython's SeqIO.<br>
<br>
Peter<br>
<div><div class="m_1086710081215640939h5"><br>
<br>
On Thu, Mar 9, 2017 at 7:42 AM, Islam Amin <<a href="mailto:eng.islamamin@gmail.com" target="_blank">eng.islamamin@gmail.com</a>> wrote:<br>
> Dear All,<br>
> I got a script from the following link : <a href="https://www.biostars.org/p/42687/" rel="noreferrer" target="_blank">https://www.biostars.org/p/426<wbr>87/</a><br>
> about how to blast two sequences in biopython, I wonder if is it possible to<br>
> pass the sequences direct to as following:<br>
> NcbiblastpCommandline(query="F<wbr>QTWEEFSRAAEKLYLADPMKVRV",subje<wbr>ct="FQTWEEFSRAEKLYLADPMK",<br>
> outfmt=5)()[0]<br>
> unfortunately, I got the error when I'm trying to pass the sequence direct<br>
> instead of read fasta file, is there any way to pass sequences direct.<br>
><br>
> the script is:<br>
><br>
> from Bio.Blast.Applications import NcbiblastpCommandline<br>
> from StringIO import StringIO<br>
> from Bio.Blast import NCBIXML<br>
> from Bio.Seq import Seq<br>
> from Bio.SeqRecord import SeqRecord<br>
> from Bio import SeqIO<br>
><br>
> # Create two sequence files<br>
> seq1 =<br>
> SeqRecord(Seq("FQTWEEFSRAAEKLY<wbr>LADPMKVRVVLKYRHVDGNLCIKVTDDLVC<wbr>LVYRTDQAQDVKKIEKF"),<br>
> id="seq1")<br>
> seq2 =<br>
> SeqRecord(Seq("FQTWEEFSRAEKLYL<wbr>ADPMKVRVVLRYRHVDGNLCIKVTDDLICL<wbr>VYRTDQAQDVKKIEKF"),<br>
> id="seq2")<br>
> SeqIO.write(seq1, "seq1.fasta", "fasta")<br>
> SeqIO.write(seq2, "seq2.fasta", "fasta")<br>
><br>
> # Run BLAST and parse the output as XML<br>
> output = NcbiblastpCommandline(query="s<wbr>eq1.fasta", subject="seq2.fasta",<br>
> outfmt=5)()[0]<br>
> blast_result_record = NCBIXML.read(StringIO(output))<br>
><br>
> # Print some information on the result<br>
> for alignment in blast_result_record.alignments<wbr>:<br>
> for hsp in alignment.hsps:<br>
> print '****Alignment****'<br>
> print 'sequence:', alignment.title<br>
> print 'length:', alignment.length<br>
> print 'e value:', hsp.expect<br>
> print hsp.query<br>
> print hsp.match<br>
> print hsp.sbjct<br>
><br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> Biopython mailing list - <a href="mailto:Biopython@mailman.open-bio.org" target="_blank">Biopython@mailman.open-bio.org</a><br>
> <a href="http://mailman.open-bio.org/mailman/listinfo/biopython" rel="noreferrer" target="_blank">http://mailman.open-bio.org/ma<wbr>ilman/listinfo/biopython</a><br>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_1086710081215640939gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span>Best Regards,<br>Islam Amin.<br><br><a href="http://www.egyptscience.net/" rel="nofollow nofollow" target="_blank">www.egyptscience.net</a><br></span><div>Scientific Research Group in EGYPT</div></div></div>
</font></span></div>
<br>______________________________<wbr>_________________<br>
Biopython mailing list - <a href="mailto:Biopython@mailman.open-bio.org">Biopython@mailman.open-bio.org</a><br>
<a href="http://mailman.open-bio.org/mailman/listinfo/biopython" rel="noreferrer" target="_blank">http://mailman.open-bio.org/<wbr>mailman/listinfo/biopython</a><br></blockquote></div><br></div>