【发布时间】:2020-02-11 12:33:02
【问题描述】:
我正在尝试从核糖体晶体结构的 cif 文件中挖掘出一些与配体的结合位点,但遇到了一个涉及类型错误的烦人问题。
TypeError: %c requires int or char
使用下面的代码,
from Bio.PDB import *
from Bio import PDB
class save_res(Select):
def accept_residue(self, residue):
if residue in keep_res_list:
print(residue)
return 1
else:
return 0
keep_res_list = []
parser = MMCIFParser()
structure = parser.get_structure("1vvj.cif", "./1vvj.cif")
structure = structure[0]
atom_list = Selection.unfold_entities(structure, "A") # A for atoms
ns = NeighborSearch(atom_list)
for residue in structure.get_residues():
if residue.get_resname() == "PAR":
for atom in residue:
center = atom.get_coord()
neighbors = ns.search(center, 5.0)
neighbor_residue_list = Selection.unfold_entities(neighbors, "R")
for res in neighbor_residue_list:
if res not in keep_res_list:
keep_res_list.append(res)
io = PDBIO()
io.set_structure(structure)
io.save("1vvj_bs.pdb", save_res())
给我错误:
File "/scratch/software/anaconda3/envs/my-devel-3.6/lib/python3.6/site-packages/Bio/PDB/PDBIO.py", line 112, in _get_atom_line
return _ATOM_FORMAT_STRING % args
TypeError: %c requires int or char
此代码在将 pdb-id 更改为 1fyb 时运行良好,它也具有相同的配体 id。 我认为问题源于原始文件中的大量链及其 ID。我在这个假设中完全错了还是有人知道如何解决这个问题?我一直在尝试找到一种方法来重命名链 ID,但还没有找到可行的方法来做到这一点。
感谢您的帮助。
【问题讨论】:
标签: casting bioinformatics biopython