如何使用Biopython从PDB文件计算蛋白质残基接触图,最终的接触图作为.npy文件存储在Numpy数组中。
如果可以的话,请给我一些明确的指导或例子。感谢您的帮助。
好吧,我的尝试,给出为联系地图(来自联系地图):
蛋白质接触图以矩阵的形式表示所有可能的氨基酸残基对之间的距离。通常接触图以二进制方式定义:如果两个残基的距离低于某个阈值,则它们接触,否则不接触..
和
calc_dist_matrix
来自使用 Biopython 的 蛋白质接触图
输入
1rei.pdb
,1REI:
代码:
import Bio
print('Biopython version : ', Bio.__version__)
from Bio import PDB
import numpy as np
def calc_dist_matrix(chain_one, chain_two , cutoff) :
"""Returns a matrix of C-alpha distances between two chains"""
answer = np.zeros((len(chain_one), len(chain_two)), np.intc)
for row, residue_one in enumerate(chain_one) :
for col, residue_two in enumerate(chain_two) :
if (residue_one['CA'] - residue_two['CA']) <= cutoff :
distance = 1
else :
distance = 0
answer[row, col] = distance
return answer
parser = PDB.PDBParser(QUIET = True)
pdb1 ='1rei.pdb'
print(pdb1.split('.pdb')[0])
structure = parser.get_structure(pdb1.split('.pdb')[0], pdb1)
resi1 = []
for chain in structure[0]:
resi1.extend([res for res in chain.get_residues() if res.id[0] == ' '])
print(resi1, len(resi1))
resi2 = resi1.copy()
cutoff = 20.0
contact_map = calc_dist_matrix(resi1 , resi2 , cutoff)
print('contact map : ', contact_map.shape, contact_map.size,contact_map.dtype,
np.min(contact_map), np.max(contact_map), type(contact_map) )
from PIL import Image, ImageOps
import time
img = Image.fromarray(contact_map* 255, mode='L').convert('1')
img.show()
time.sleep(4)
img_inv = ImageOps.invert(img)
img_inv.show()
使用 20.0 A 和 Cα-Cα 的截止值作为残基之间的距离
这是使用
PIL
输出的图像,我的地图是:
`contact map : (214, 214) 45796 int32 0 1 <class 'numpy.ndarray'>` ;
灰度(0或255)
倒置