使用biopython库,我想删除列表中列出的残留物,如下所示。这个线程(http://pelican.rsvs.ulaval.ca/mediawiki/index.php/Manipulating_PDB_files_using_BioPython)提供了一个移除残留物的示例。我有以下代码来清除残留物
residue_ids_to_remove = [105, 5, 8, 10, 25, 48]
structure = pdbparser.get_structure("3chy", "./3chy.pdb")
first_model = structure[0]
for chain in first_model:
for residue in chain:
id = residue.id
if id[1] in residue_ids_to_remove:
chain.detach_child(id[1])
modified_first_model = first_model
但这段代码不起作用并引发了错误
^{pr2}$这个密码怎么了?在
或者,我可以使用accept_remainment()并将其写入PDB。我不想这样做,因为我想在内存中进行下一步处理。在
Biopython无法在内部字典中找到链的密钥,因为您提供的是随机密钥。dict看起来像这样:
即:使用元组作为dict键。您可以看到dict正在
print chain.child_dict
。在一旦你知道了这一点,错误/解决方案就一目了然了。向
^{pr2}$detach_child
传递一个有效密钥,即删除[1]
:正确的方法
将子级与链级分离,不要直接循环残留物:
或列表理解:
相关问题 更多 >
编程相关推荐