-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear Grant,

computer programs split fields based on a 'field separator', usually
e.g. a space or tab or end-of-line. There is nothing to separate
"1.00201.10" into two fields, and you as a human only can read this
because you know that
a) these should be two numbers
b) the occupancy has a precision of two digits.

You need to read in the line as fixed format - in C this is
the family of scanf-function which might also exist in python.

You can use 'cut' with the '-c' option to split the fields as
preparation for your python program.

Cheers,
Tim

On 06/06/2013 06:37 AM, GRANT MILLS wrote:
> Dear CCP4BB,
> 
> I'm trying to write a simple python script to retrieve and 
> manipulate PDB data using the following code:
> 
> #for line in open("PDBfile.pdb"): #    if "ATOM" in line: # 
> column=line.split() #        c4=column[4]
> 
> and then writing to a new document with:
> 
> #with open("selection.pdb", "a") as myfile: # 
> myfile.write(c4+"\n")
> 
> Except for if the PDB contains columns which run together such as 
> the occupancy and B-factor in the following:
> 
> ATOM    608  SG  CYS A  47      12.866 -28.741  -1.611  1.00201.10 
> S ATOM    609  OXT CYS A  47      14.622 -24.151  -1.842 1.00100.24
> O
> 
> My script seems to miscount the columns and read the two as one 
> column, does anyone know how to avoid this? (PS, I've googled this 
> like crazy but I either don't understand or the link is 
> irrelevant)
> 
> Any advice would help. Thanks for your time, Grant
> 

- -- 
- --
Dr Tim Gruene
Institut fuer anorganische Chemie
Tammannstr. 4
D-37077 Goettingen

GPG Key ID = A46BEE1A

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFRsE5wUxlJ7aRr7hoRApqOAJ4gccUdx6Scsc7yPZ00cgLYWGL4gQCfdqMi
h/mIBMsqQBy87fd7el38oV8=
=IEp3
-----END PGP SIGNATURE-----

Reply via email to