Print

Print


> 
> #for line in open("PDBfile.pdb"):
> #    if "ATOM" in line:
> #        column=line.split()
> #        c4=column[4]

If you're dealing with a pdb that may have REMARK lines, you're better 
off using "if line.startswith('ATOM') or line.startswith('HETATM')" for 
your conditional here.

I'd also use the string slicing approach Ed recommended to handle the 
column formatting.  The default options for "line.split()" is equivalent 
to splitting on whitespace; if there's no whitespace between columns 
it'll fail.

> 
> 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
>