Float + min/max?

Andrew Dalke adalke at mindspring.com
Wed Aug 20 04:17:12 EDT 2003


Shu-Hsien Sheu:
> I am new to Python, and just wrote a small program to generate the maximum
> number of the cartisian coordinates among all atoms in a given molecule.

Have you looked at tools like MMTK, PyMol, VMD, Biopython, and
OEChem?  All of those have Python APIs for dealing with molecules
with 3D coordinates.


> x = []
> for i in (0, length-2):
>     slines[i] =  lines[i].split()
>     if slines[i][0] == "ATOM":
>         x.append(slines[i][6])

I so desparately hope you aren't parsing PDB files with this code.
It will break, and break silently, because the format definition is
column oriented and might not have spaces between the fields,
so you'll include the beta or occupancy fields in your code.
Those are also floats, so no error will be raised.

> The original data file apparantly does not have those decimals. May I ask
> how does it happend? Thank!

As for that, take Terry's suggestion and read the FAQ.  Then
look at some of the existing tools to see if they meet your needs.
If they don't, look again - you've probably missed it.  If they still
don't, dig up old posts on parsing the PDB files and all the dangers
you might run into, then look for old posts from me, and from Gert
Vriend (of WHATIF fame) and from others on all the problems
you will run into.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list