[Biopython-dev] Bio.PDB - Missing values (was Moratorium on commits?)
Lenna Peterson
arklenna at gmail.com
Tue Aug 20 18:16:18 EDT 2013
On Thu, Aug 15, 2013 at 9:23 AM, Peter Cock <p.j.a.cock at googlemail.com>wrote:
>
>
> I didn't mean to suggest writing the string "None" in the field, and
> I'm not sure if João did - it would certainly be an invalid PDB file.
>
> I agree that where the data structure has None (e.g. from our parser)
> then the writer could use a blank string (of the appropriate width).
> For mandatory fields like occupancy, this should give a warning.
>
>
As I suspected, the writer currently fails on None (it's expecting a
float). Test-driven development!
However, I don't see a simple or elegant way to force writing of a blank
occupancy. ATOM lines are currently written using C-style string
formatting, and the occupancy field is `%6.2f`.
Off the top of my head, I'd:
1. Store the original format string
2. Modify the format string to have "%6s" at the appropriate position
3. Modify the occupancy to be an empty string or a space
4. Set the return value to the formatted string
5. Restore the original format string
6. Return the return value
However, this seems...ugly at best. I don't know that switching formatting
styles (e.g. to string.format() or others) will help. And in most
circumstances, the type checking of the format string is useful.
Any thoughts?
Cheers,
Lenna
More information about the Biopython-dev
mailing list