Biopython教程

Biopython PDB模块

Biopython PDB模块详细操作教程
Biopython提供了Bio.PDB模块来操纵多肽结构。PDB(蛋白质数据库)是在线上最大的蛋白质结构资源。它具有许多不同的蛋白质结构,包括蛋白质-蛋白质,蛋白质-DNA,蛋白质-RNA复合物。
要加载PDB,请键入以下命令 -
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
from Bio.PDB import *

1. 蛋白质结构文件格式

PDB以三种不同的格式分布蛋白质结构 -
Biopython不支持基于XML的文件格式。 pdb文件格式,这是一种特殊格式的文本文件。 PDBx/mmCIF文件格式。
Protein Data Bank分发的PDB文件可能包含格式错误,这会使它们模棱两可或难以解析。Bio.PDB模块尝试自动处理这些错误。Bio.PDB模块实现两种不同的解析器,一种是mmCIF格式,另一种是pdb格式。
下面我们来学习如何详细解析每种格式 -

1.1. mmCIF解析器

使用以下命令从pdb服务器下载mmCIF格式的示例数据库 -
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> pdbl = PDBList()
>>> pdbl.retrieve_pdb_file('2FAT', pdir = '.', file_format = 'mmCif')
它将从服务器下载指定的文件(2fat.cif)并将其存储在当前工作目录中。
在这里,PDBList提供了从联机PDB FTP服务器列出和下载文件的选项。resolve_pdb_file方法需要下载的文件名称,不带扩展名。resolve_pdb_file也可以选择指定下载目录 -pdir和文件格式 - file_format。文件格式的可能值如下-
mmCif (默认, PDBx/mmCif文件) pdb (PDB格式) xml (PMDML/XML格式) mmtf (高度压缩) bundle (适用于大型结构的PDB格式存档)
要加载CIF文件,请使用Bio.MMCIF.MMCIFParser,如下所示-
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> parser = MMCIFParser(QUIET = True)
>>> data = parser.get_structure("2FAT", "2FAT.cif")
在此,QUIET会在分析文件时禁止显示警告。get_structure将解析文件并返回ID为2FAT(第一个参数)的结构。运行上述命令后,它将解析文件并打印可能的警告(如果有的话)。现在,使用以下命令检查结构 -
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> data
<Structure id = 2FAT>
To get the type, use type method as specified below,
>>> print(type(data))
<class 'Bio.PDB.Structure.Structure'>
这样就已经成功解析了文件并获得了蛋白质的结构。在下一章中,我们将学习蛋白质结构的详细信息以及如何获得它。

1.2. PDB解析器

使用以下命令从pdb服务器下载PDB格式的示例数据库 -
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> pdbl = PDBList()
>>> pdbl.retrieve_pdb_file('2FAT', pdir = '.', file_format = 'pdb')
这将从服务器下载指定的文件(pdb2fat.ent)并将其存储在当前工作目录中。要加载pdb文件,请使用Bio.PDB.PDBParser,如下所示-
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> parser = PDBParser(PERMISSIVE = True, QUIET = True)
>>> data = parser.get_structure("2fat","pdb2fat.ent")
此处,get_structure与MMCIFParser相似。PERMISSIVE选项尝试尽可能灵活地解析蛋白质数据。
现在,使用下面给出的代码片段检查结构及其类型-
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> data
<Structure id = 2fat>
>>> print(type(data))
<class 'Bio.PDB.Structure.Structure'>
好了,头部结构存储了字典信息。要执行此操作,请键入以下命令-
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> print(data.header.keys()) dict_keys([
   'name', 'head', 'deposition_date', 'release_date', 'structure_method', 'resolution',
   'structure_reference', 'journal_reference', 'author', 'compound', 'source',
   'keywords', 'journal'])
>>>
要获取名称,请使用以下代码-
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> print(data.header["name"])
an anti-urokinase plasminogen activator receptor (upar) antibody: crystal
structure and binding epitope
>>>
还可以使用以下代码检查日期和解决方案-
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> print(data.header["release_date"]) 2006-11-14
>>> print(data.header["resolution"]) 1.77

2. PDB结构

PDB结构由包含两个链的单个模型组成。
L链,含残基数 H链,含残基数
每个残基由多个原子组成,每个原子都有一个由(x,y,z)坐标表示的3D位置。在以下部分中详细了解如何获得原子的结构 -

2.1. 模型

Structure.get_models()方法返回模型上的迭代器。它定义如下 -
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> model = data.get_models()
>>> model
<generator object get_models at 0x103fa1c80>
>>> models = list(model)
>>> models [<Model id = 0>]
>>> type(models[0])
<class 'Bio.PDB.Model.Model'>
在此,模型精确地描述了一个3D构象。它包含一个或多个链。

2.2. 链

Model.get_chain()方法返回链上的迭代器。它定义如下-
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> chains = list(models[0].get_chains())
>>> chains
[<Chain id = L>, <Chain id = H>]
>>> type(chains[0])
<class 'Bio.PDB.Chain.Chain'>
在此,链描述了适当的多肽结构,即结合残基的连续序列。

2.3. 残基

Chain.get_residues()方法返回残基上的迭代器。它定义如下-
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> residue = list(chains[0].get_residues())
>>> len(residue)
293
>>> residue1 = list(chains[1].get_residues())
>>> len(residue1)
311
残基保留着属于氨基酸的原子。

2.4. 原子

Residue.get_atom()返回原子上的迭代器,如下所示:
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> atoms = list(residue[0].get_atoms())
>>> atoms
[<Atom N>, <Atom CA>, <Atom C>, <Atom Ov, <Atom CB>, <Atom CG>, <Atom OD1>, <Atom OD2>]
原子拥有原子的3D坐标,称为向量。定义如下 -
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-25
>>> atoms[0].get_vector()
<Vector 18.49, 73.26, 44.16>
它表示x,y和z的坐标值。
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4