[Biopython] Passing sequence to local BLAST

Peter Cock p.j.a.cock at googlemail.com
Thu Jul 21 09:56:17 UTC 2011


On Thu, Jul 21, 2011 at 10:48 AM, Sheila the angel
<from.d.putto at gmail.com> wrote:
> Thanks Peter,
> Yes I understand that I can't use 'stdin' twice so this is not going to work
>
>>You have to use either two input files, or stdin and one file, (or one
>>file and stdin).
>
> But how can I specify two input files, or stdin
>

Two files is covered in the Tutorial example you originally started
with, isn't it?:

water_cline = WaterCommandline(asequence="alpha.fasta",
bsequence="beta.fasta", gapopen=10, gapextend=0.5,
outfile="water.txt")
stdout, stderr =water_cline()

You've already done stdin and file for a and b, and said that works:

seq_record = SeqIO.read(open("alpha.fasta"), "fasta")  #or a sequence object
water_cline = WaterCommandline(asequence="stdin",
bsequence="beta.fasta", gapopen=10, gapextend=0.5,
outfile="water.txt")
stdout, stderr =water_cline(stdin=seq_record.format("fasta"))

Doing it the other way round with a file and stdin for a and b would be just:

seq_record = SeqIO.read(open("beta.fasta"), "fasta")  #or a sequence object
water_cline = WaterCommandline(asequence="alpha.fasta",
bsequence="stdin", gapopen=10, gapextend=0.5, outfile="water.txt")
stdout, stderr =water_cline(stdin=seq_record.format("fasta"))

Obviously if you already have the sequences in FASTA files, then just give
the filenames to the EMBOSS tool (rather than needlessly loading them into
python just to write them to stdin).

Peter



More information about the Biopython mailing list