[Biopython-dev] ApplicationResult and generic_run obsolete?

Peter biopython at maubp.freeserve.co.uk
Thu Jul 9 09:18:49 UTC 2009


On Wed, Jul 8, 2009 at 2:06 PM, Brad Chapman<chapmanb at 50mail.com> wrote:
> Hi Peter;
>
>> I started trying to rewrite the tutorial sections using generic_run, and
>> unfortunately it looks like a reasonably cross platform replacement for
>> generic_run when all you want is the return code but you don't want
>> the tool's output printed on screen becomes quite complex, e.g.
>>
>> import subprocess
>> return_code = subprocess.call(str(cline),
>>                               stdin=subprocess.PIPE,
>>                               stdout=subprocess.PIPE,
>>                               stderr=subprocess.PIPE,
>>                               shell=(sys.platform!="win32"))
>>
>> We need to use pipes for stdout (and stderr) to stop the tool's output
>> being printed to screen. Just using os.system(str(cline)) has the same
>> problem.
>
> How about adding a function like "run_arguments" to the
> commandlines that returns the commandline as a list.

That would be a simple alternative to my vague idea "Maybe we
can make the command line wrapper object more list like to make
subprocess happy without needing to create a string?", which may
not be possible. Either way, this will require a bit of work on the
Bio.Application parameter objects...

> It sounds like we can drop the stdin workaround and provide a
> documentation item for older Windows versions from a GUI.

Yes, as I noted, this is a corner case. It is something any
replacement for generic_run would still have to cater to, but it
would just complicate an example.

> It might be better to use Popen and wait to make it
> straightforward to learn to get stdout and stderr.

Yes, using subprocess.Popen explicitly rather than their helper
function subprocess.call makes sense for our docs

Peter

P.S. Thanks Cymon for those minor corrections to the tutorial.
The master file is a LaTeX document, Doc/Tutorial.tex, the
command line tools pdflatex and hevea turn it into PDF and
HTML which we include with the Biopython archives, and
manually copy onto the website as well.




More information about the Biopython-dev mailing list