beginner in python

Beema shafreen beema.shafreen at gmail.com
Thu Aug 2 06:27:27 CEST 2007


hi everybody,
   I am beginner in python
 I have to calculate the euclidean distance between the atoms from a pdb
file
i have written the the code and its shows me some error ,
the code:
import re
import string
import math
ab =[]
x_value = []
y_value = []
z_value = []
fh = open("1K5N.pdb",'r')
for atom in fh.readlines():
   a = atom.strip()
   pattern= re.compile('^ATOM.*')
   atom_file= pattern.search(a)
   if  atom_file:
       atom_data = atom_file.group()
       x_coordinate = atom_data[31:38]
       y_coordinate = atom_data[39:46]
       z_coordinate = atom_data[47:54]
       x_value.append(x_coordinate)
       y_value.append(y_coordinate)
       z_value.append(z_coordinate)
for x in range(len(x_value)):
             x_co = float(x_value[x])-float(x_value[x+1])
             y_co = float(y_value[x])-float(y_value[x+1])
             z_co = float(z_value[x])-float(z_value[x+1])
             data = math.sqrt(x_co)*(x_co)+(y_co)*(y_co)+(z_co)*(z_co)
             print data
~
and the error ,message
 File "pdb_fetching.py", line 22, in ?
    x_co = float(x_value[x])-float(x_value[x+1])
IndexError: list index out of range


can you suggest me the mistake i have made



regards
shafreen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070802/8760a780/attachment.html>


More information about the Python-list mailing list