[Biopython] a parsing error
Bala subramanian
bala.biophysics at gmail.com
Tue May 25 16:47:17 UTC 2010
Hi,
Thank you very much. I just checked and in fact one of the files was a
corrupted one.
Thank you,
Bala
On Tue, May 25, 2010 at 6:41 PM, João Rodrigues <anaryin at gmail.com> wrote:
> Hello,
>
> I usually get that error when the parser finds an empty PDB file.
>
> Try outputting the name of the file you're currently parsing so you know
> when it breaks.
>
> Best
>
> João [...] Rodrigues
> @ http://stanford.edu/~joaor/ <http://stanford.edu/%7Ejoaor/>
>
>
>
> On Tue, May 25, 2010 at 9:29 AM, Bala subramanian <
> bala.biophysics at gmail.com> wrote:
>
>> Friends,
>>
>> The following code takes all the pdb's in the current directory and
>> creates
>> a matrix. I get a parsing error. Pls write what is going wrong.
>>
>> from numpy import zeros,savetxt,matrix
>> from Bio.PDB import *
>> import glob
>> donor=[ 'ARG','ASN', 'GLN', 'LYS', 'TRP' ]
>> ali=['ALA', 'ARG', 'CYS', 'ILE', 'LEU', 'LYS', 'MET', 'PRO', 'THR', 'VAL'
>> ]
>> parser=PDBParser()
>> X5_MAT=matrix(zeros((34,34),int))
>> files=glob.glob('*.pdb')
>> for i in range(len(files)):
>> strng=str(i)
>> structure=parser.get_structure(strng,files[i])
>> res=Selection.unfold_entities(structure,'R')
>>
>> for x in range(len(res)):
>> for y in range(len(res)):
>> if x <> y :
>> if not res[x].get_resname() in donor: continue
>>
>> else:
>> if res[y].get_resname() in ali:
>> X5_MAT[x,y] = X5_MAT[x,y] + 1
>>
>> else: pass
>>
>>
>> savetxt('myfile.txt', matrix(X5_MAT), fmt='%d')
>>
>>
>> *The error is pasted below*
>>
>> Traceback (most recent call last):
>> File "un_don_ali.py", line 14, in <module>
>> structure=parser.get_structure(' ',files[i])
>> File "/usr/lib/python2.5/site-packages/Bio/PDB/PDBParser.py", line 64, in
>> get_structure
>> self._parse(file.readlines())
>> File "/usr/lib/python2.5/site-packages/Bio/PDB/PDBParser.py", line 82, in
>> _parse
>> self.header, coords_trailer=self._get_header(header_coords_trailer)
>> File "/usr/lib/python2.5/site-packages/Bio/PDB/PDBParser.py", line 95, in
>> _get_header
>> header=header_coords_trailer[0:i]
>> UnboundLocalError: local variable 'i' referenced before assignment
>> _______________________________________________
>> Biopython mailing list - Biopython at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/biopython
>>
>
>
More information about the Biopython
mailing list