2014-01-08 4 views
0

나는 pdb 파일을 가지고 있는데, pdb를 파싱하고 싶습니다. Biopython을 동일하게 사용하고 있습니다. 모든 잔류 물에 대한 목록에 N-CA-C-CB의 좌표 목록이 필요합니다. 어떻게 그걸 얻을 수 있니?쉬운 방법으로 문자열을 파이썬으로 목록으로 변환합니다.

pdb = "1dly.pdb" 
name = pdb[:3] 

from Bio import PDB 
from ast import literal_eval 

p = PDB.PDBParser() 
s = p.get_structure(name, pdb) 
#print dir(s) 
#y = s.get_residues() 
z = s.get_atoms() 
for x in z: 
    print x, x.get_coord() 

나는이 형식으로 출력을 원하는 :

[[(coordinates of N - residue1), (coordinates of CA - residue1), (coordinates of C - residue1), (coordinates of CB - residue1)], [(coordinates of N - residue2), (coordinates of CA - residue2), (coordinates of C - residue2), (coordinates of CB - residue2)]] 

내가 어떻게 할 수 있습니까?

답변

1

테스트 할 pdb 파일이 없으므로이 방법이 작동합니다 (테스트되지 않았습니다). 여기에서 Generators을 사용하고 있습니다.

# first create a generator that parses your structure, one residue at time 

def createDesiredList(structure, desired_atoms): 
    residues = structure.get_residues() 

    for residue in residues: 
     return_list = [] 
     for atom_id in desired_atoms: 
      return_list.append((residue[atom_id].get_coord(), residue)) 
     yield return_list 


# then I copy and paste your code .... 

pdb = "1dly.pdb" 
name = pdb[:3] 

from Bio import PDB 
from ast import literal_eval 

p = PDB.PDBParser() 
s = p.get_structure(name, pdb) 

# then I decide which atoms I desire from every residue... 

wish_list = ['N', 'CA', 'C', 'CB'] 

# and finally I run my generator, putting the results in a list. 

your_coords_list = [x for x in createDesiredList(s, wish_list)] 
관련 문제