The generic_run function was present up to and including Biopython 1.57. Given a Bio.Application style wrapper object, say primer_cl based on the primer_pick.py example you linked to, the application was run like this:
from Bio.Application import generic_run
result, messages, errors = generic_run(primer_cl)
Here there are three return values. First an ApplicationResult object holding the return code, then stdout and stderr output (in memory as StringIO handles).
As of Biopython 1.55, you can execute the command directly using the command line wrapper object itself:
stdout, stderr = primer_cl()
This time you just get the stdout and stderr from the command (in memory as strings), but the return code was checked and if non-zero an exception would be raised (which would tell you the return code).
This is what the DEPRECATED file supplied with Biopython is trying to tell you:
Bio.Application.generic_run and ApplicationResult
Declared obsolete in Release 1.51,
deprecated in Release 1.53, and
removed in Release 1.57. Please use
the Python subprocess module instead,
or as of Release 1.55 the application
wrappers can be used directly to
execute the command.
So, to summarize, to update the primer_pick.py example, probably all you need to do is delete this line:
from Bio.Application import generic_run
and replace this:
result, messages, errors = generic_run(primer_cl)
print result
with this:
stdout, stderr = primer_cl()
The script doesn't actually use these return values at all as far as I can see.
P.S. You didn't ask about it directly, but the functionality of Bio.Fasta is now in Bio.SeqIO along with many other file formats. Please see the Biopython Tutorial for details.
thank you Peter - great answer. This is the sort of answer that helps the transition from newbie to not-so-newbie.
Hi Peter,
I just came across this thread since I was looking for ideas of how to approach primer design using Biophyton and Primer3.
My understanding is that Biopython Bio.Emboss.Primer3 module is designed to work with Emboss eprimer as a proxy to Primer3. So after introducing the suggested above changes into the
primer_pick.py
example, I'm getting the following error -etc
My OS is win7. The Primer3 is in the PATH, Python 2.7, Biopython is 1.65.
I'm not clear about whether or not the eprimer wrapper needs to be additionally installed? But also do you know of any more direct approach to Primer3 from Python?
Thanks
Not sure, but you'd be best off asking this as a new question on BioStars.