[BioPython] PDBConstructionException message

Gad Abraham g.abraham at ms.unimelb.edu.au
Mon Jul 10 13:00:41 UTC 2006


Peter (BioPython List) wrote:

<snip>

> I think you want to use the permissive parser (i.e. accept this invalid
> but understandable file) WITHOUT printing the warning to screen.

That's right.

>
> This isn't currently possible - you will have to edit the module to do
> this yourself.  Open /Bio/PDB/PDBParser.py and find the section
> _handle_PDB_exception and change this bit (edited for line widths):
>
> if self.PERMISSIVE:
>     # just print a warning - some residues/atoms will be missing
>     print "PDBConstructionException: %s" % message
>     print "Exception ignored.\nSome atoms or residues will be ..."
> else:
>     # exceptions are fatal - raise again with new message (...)
>     raise PDBConstructionException, message
>
> To something like this:
>
> if self.PERMISSIVE:
>     #QUICK HACK, don't print a warning - just carry on.
>     #Note some residues/atoms will be missing
>     pass
> else:
>     # exceptions are fatal - raise again with new message (...)
>     raise PDBConstructionException, message
>
> Thinking long term, maybe we should add an option not to print these
> warnings... or send to stderr instead of stdout perhaps?
>

I was just about to send off a message suggesting using sys.stderr.write
instead of print in PDBParser :)

After editing PDBParser.py as you suggested, I still get the same
behaviour (under Ubuntu it's at
/usr/lib/python2.4/site-packages/Bio/PDB/PDBParser.py).
Do I need to generate new pyc/pyo files?

Thanks,
Gad

-- 
Gad Abraham
Department of Mathematics and Statistics
University of Melbourne
Victoria 3010, Australia
email: g.abraham at ms.unimelb.edu.au
web: http://www.ms.unimelb.edu.au/~gabraham




More information about the Biopython mailing list