[Biopython-dev] Python 2.4 / Adding QUIET argument to PDBParser()
Peter Cock
p.j.a.cock at googlemail.com
Fri May 6 09:25:50 UTC 2011
On Fri, May 6, 2011 at 8:54 AM, João Rodrigues <anaryin at gmail.com> wrote:
> Hello all,
>
> The PDBParser is sometimes a bit too loud, making meaningful output drown in
> dozens of warnings messages. This is partly (mostly) my fault because of the
> element guessing addition. Therefore, I'd suggest adding a QUIET argument
> (bool) to PDBParser that would supress all warnings. Of course, default is
> False. It might come handy for batch processing of proteins.
>
> I've added it to my pdb_enhancements branch so you can take a look:
>
> https://github.com/JoaoRodrigues/biopython/commit/5405d8a4cc555bcfce6ad0915db62a131cee9493
>
I had a look and Joao and I have been having a little
discussion with the github comments feature.
There are two ways to solve this,
(1) Have a flag which controls issuing the warning
(2) Filter out PDBConstructionWarning messages
The first approach is messy as the flag needs to passed
down to any relevant object (or done as a global which is
nasty).
The second approach requires a temporary warnings filter,
which I think would easily done with the context manager
warnings.catch_warnings() in Python 2.5+
I'd also like to use this in the unit tests, where currently
we have to save the filter list, add a temporary filter, then
restore the filter list. This generally works, but there are
some stray warnings that are not being silenced.
Given we've already officially dropped support for
Python 2.4, I don't anticipate any protests. I guess before
making such a change on the trunk, Tiago or I should
turn off the Python 2.4 buildbot buildslaves...
Peter
More information about the Biopython-dev
mailing list