[BioPython] BioPDB problem

Iddo Friedberg idoerg at burnham.org
Fri Jun 18 12:08:27 EDT 2004


Hua Wong wrote:
> I have a PDB file that count 3145 atoms [1...3145], and using BioPDB I try to get all the coordinate.
> 
> So I use the example:
> parser=PDBParser()
> structure=parser.get_structure('0b','0b.pdb')
> 
> liste=[]
> for model in structure.get_iterator():
> 	for chain in model.get_iterator():
> 		for residue in chain.get_iterator():
> 			for atom in residue.get_iterator():
> 				a=atom.get_coord()
> 				liste.append(a)
> To obtain a list of array representing the x y and z
> 
> But I can't have all the atoms. The liste[] list is 3144 which seems ok [0...3144]
> But when I want to display the 3144th atom I obtain:
> 
>>>>len(liste)
> 
> 3144
> 
>>>>liste[3144]
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> IndexError: list index out of range
> 
> The lastest atoms he accepts to display is 3143th.
> Am I doing something wrong?


Well, the list length is 3144, which means the last index is 3143,
because in Python indices start from 0. So a length 3144 list would have
indices 0 through 3143.

Iddo


-- 
Iddo Friedberg, Ph.D.
The Burnham Institute
10901 N. Torrey Pines Rd.
La Jolla, CA 92037
USA
Tel: +1 (858) 646 3100 x3516
Fax: +1 (858) 713 9930
http://ffas.ljcrf.edu/~iddo




More information about the BioPython mailing list