[Biopython] Read and Parse EMBOSS primer3-eprimer32

Peter Cock p.j.a.cock at googlemail.com
Thu Oct 11 11:05:51 UTC 2012


Hello Ivaylo,

On Wed, Oct 10, 2012 at 12:00 PM, Ivaylo Stoimenov
<ivaylo.stoimenov at gmail.com> wrote:
> Hi,
>
> I have a problem of using Read and Parse functions when it comes to
> EMBOSS Primer3 (or eprimer32 wrapper). I would like to skip writing files but
> hijacking the output of Primer3 to a variable (object). Here is some part
> of the code, which does not work:
>
> from Bio.Emboss import Primer3
> from Bio.Emboss.Applications import Primer3Commandline
> import sys
> ...
> cline = Primer3Commandline(sequence=combined_frame, auto=True, task =1)
> cline.explainflag = True
> cline.prange="100-150"
> cline.outfile = "stdout"

I think that will just write to a file called stdout (unless Primer3
does something special). I think should use cline.stdout = True
instead, which will add the switch -stdout to the EMBOSS
tool's command line.

Once you have told EMBOSS to write the output to stdout
instead of to a file, you must get Python to parse this.
Either use subprocess and the child process's stdout handle
(see examples of this in the Biopython Tutorial), or if you
capture stdout as a string turn the string into a pretend
handle using StringIO. e.g.

cline = Primer3Commandline(...)
stdout, stderr = cline() #Runs it, captures output as strings
from StringIO import StringIO
handle = StringIO(stdout) #Turns string into pretend handle

Peter



More information about the Biopython mailing list