prody python API 教程
介绍
结构集成分析
弹性网络模型
轨迹分析
可视化
如何开始
使用 ProDy
互动使用
使用文档
ProDy 基础知识
文件解析器
分析功能
绘图函数
蛋白质结构
原子团
ProDy 冗长
原子团
建立一个原子组
在 AtomGroup 中存储数据
原子选择
这部分提供了有关AtomGroup对象属性的更多信息。我们从进行必要的进口开始。请注意,每个文档页面都包含它们,以便可以独立执行其中的代码。如果您已经在 Python 会话中完成它们,则可以跳过它们。
In [1]: from prody import *
In [2]: from pylab import *
In [3]: ion()
原子选择
AtomGroup实例有一个简单的原子视图以提高效率,但它们与强大的原子选择引擎相结合。您可以通过传递简单的关键字或使用复合语句进行相当复杂的选择来获得定义明确的原子子集。选择关键字和语法与VMD中的非常相似。此处显示了一些示例
关键字选择
现在,我们解析一个结构。这可以是任何结构,例如您从研究中熟知的结构。
In [4]: structure = parsePDB('1p38')
In [5]: protein = structure.select('protein')
In [6]: protein
Out[6]: <Selection: 'protein' from 1p38 (2833 atoms)>
使用“protein”
关键字,我们从 2962 个原子中选择了 2833 个原子。 Atomic.select() 方法返回一个 Selection 实例。请注意,为 AtomGroup 对象定义的所有 get
和 set
方法也为 Selection 对象定义。例如:
In [7]: protein.getResnames()
Out[7]: array(['GLU', 'GLU', 'GLU', ..., 'ASP', 'ASP', 'ASP'], dtype='|S6')
按名称/类型选择
我们可以通过在“name”
关键字后面传递原子名称来选择骨架原子:
In [8]: backbone = structure.select('protein and name N CA C O')
In [9]: backbone
Out[9]: <Selection: 'protein and name N CA C O' from 1p38 (1404 atoms)>
或者,我们可以使用“backbone”
来进行相同的选择
In [10]: backbone = structure.select('backbone')
我们通过使用带有“resname”
关键字的残留物名称来选择酸性和碱性残留物
In [11]: charged = structure.select('resname ARG LYS HIS ASP GLU')
In [12]: charged
Out[12]: <Selection: 'resname ARG LYS HIS ASP GLU' from 1p38 (906 atoms)>
或者,我们可以使用预定义的关键字“acidic”
和“basic”
。
In [13]: charged = structure.select('acidic or basic')
In [14]: charged
Out[14]: <Selection: 'acidic or basic' from 1p38 (906 atoms)>
In [15]: set(charged.getResnames())
Out[15]: {'ARG', 'ASP', 'GLU', 'HIS', 'LYS'}
复合选择
让我们尝试更复杂的选择。我们首先使用 calcCenter() 函数计算蛋白质原子的几何中心。然后,我们选择距离几何中心 10 A 10A 10A以内至少有一个原子的残基的 C α C_α Cα和 C β C_β Cβ原子。
In [16]: center = calcCenter(protein).round(3)
In [17]: center
Out[17]: array([ 1.005, 17.533, 40.052])
In [18]: sel = structure.select('protein and name CA CB and same residue as '
....: '((x-1)**2 + (y-17.5)**2 + (z-40.0)**2)**0.5 < 10')
....:
In [19]: sel
Out[19]: <Selection: 'protein and nam...)**2)**0.5 < 10' from 1p38 (66 atoms)>
或者,这种选择可以如下所示
In [20]: sel = structure.select('protein and name CA CB and same residue as '
....: 'within 10 of center', center=center)
....:
In [21]: sel
Out[21]: <Selection: 'index 576 579 5... 1687 1707 1710' from 1p38 (66 atoms)>
简化选择
在交互式会话中,输入 .select('protein')
或 .select('backbone')
的替代方法是使用点运算符:
In [22]: protein = structure.protein
In [23]: protein
Out[23]: <Selection: 'protein' from 1p38 (2833 atoms)>
你可以多次使用点运算符
In [24]: bb = structure.protein.backbone
In [25]: bb
Out[25]: <Selection: '(backbone) and (protein)' from 1p38 (1404 atoms)>
这可能会继续:
In [26]: ala_ca = structure.protein.backbone.resname_ALA.calpha
In [27]: ala_ca
Out[27]: <Selection: '(calpha) and ((...and (protein)))' from 1p38 (26 atoms)>
使用这个灵活而快速的原子选择引擎,您可以做更多的事情,而不需要编写带有比较的嵌套循环或更改源代码。请参阅以下页面
- Atom Selections所有选择关键字的描述
- Intermolecular Contacts选择相互作用的原子
选择操作
对象可以与位操作符一起使用
Union
让我们分两步对非gly氨基酸残基选择β碳原子,对GLYs选择α碳原子
In [28]: betas = structure.select('name CB and protein')
In [29]: len(betas)
Out[29]: 336
In [30]: gly_alphas = structure.select('name CA and resname GLY')
In [31]: len(gly_alphas)
Out[31]: 15
以上显示p38结构包含15个GLY残基。
这两个选择可以组合如下:
In [32]: betas_gly_alphas = betas | gly_alphas
In [33]: betas_gly_alphas
Out[33]: <Selection: '(name CB and pr...nd resname GLY)' from 1p38 (351 atoms)>
In [34]: len(betas_gly_alphas)
Out[34]: 351
选择并集的选择字符串变为:
In [35]: betas_gly_alphas.getSelstr()
Out[35]: '(name CB and protein) or (name CA and resname GLY)'
注意,使用选择字符串也可以产生相同的选择
(name CB and protein) or (name CA and resname GLY).
交叉
得到两个选择的交集同样容易。让我们在蛋白质中找到带电的中性的残基
In [36]: charged = structure.select('charged')
In [37]: charged
Out[37]: <Selection: 'charged' from 1p38 (906 atoms)>
In [38]: medium = structure.select('medium')
In [39]: medium
Out[39]: <Selection: 'medium' from 1p38 (751 atoms)>
In [40]: medium_charged = medium & charged
In [41]: medium_charged
Out[41]: <Selection: '(medium) and (charged)' from 1p38 (216 atoms)>
In [42]: medium_charged.getSelstr()
Out[42]: '(medium) and (charged)'
让我们看看哪些氨基酸是带电的,哪些是中性的
In [43]: set(medium_charged.getResnames())
Out[43]: {'ASP'}
中性或带电的氨基酸呢
In [44]: set((medium | charged).getResnames())
Out[44]: {'ARG', 'ASN', 'ASP', 'CYS', 'GLU', 'HIS', 'LYS', 'PRO', 'THR', 'VAL'}
反转
也可以将所选内容反转
In [45]: only_protein = structure.select('protein')
In [46]: only_protein
Out[46]: <Selection: 'protein' from 1p38 (2833 atoms)>
In [47]: only_non_protein = ~only_protein
In [48]: only_non_protein
Out[48]: <Selection: 'not (protein)' from 1p38 (129 atoms)>
In [49]: water = structure.select('water')
In [50]: water
Out[50]: <Selection: 'water' from 1p38 (129 atoms)>
由此可见,1p38不含任何非水杂原子。
添加
在 Select 对象上定义的另一个操作是加法(也在其他 AtomPointer 派生类上)。
如果您想以特定顺序在 AtomGroup 中产生原子,这可能很有用。让我们考虑一个简单的情况,我们想要以特定顺序输出 1p38 中的原子:
In [51]: protein = structure.select('protein')
In [52]: water = structure.select('water')
In [53]: water_protein = water + protein
In [54]: writePDB('1p38_water_protein.pdb', water_protein)
Out[54]: '1p38_water_protein.pdb'
在生成的文件中,水原子将在蛋白质原子之前。
Membership(是否包含)
选择还允许成员测试操作
In [55]: backbone = structure.select('protein')
In [56]: calpha = structure.select('calpha')
In [57]: calpha in backbone
Out[57]: True
或者,水是否在蛋白中
In [58]: water in protein
Out[58]: False
其他测试包括
In [59]: protein in structure
Out[59]: True
In [60]: backbone in structure
Out[60]: True
In [61]: structure in structure
Out[61]: True
In [62]: calpha in calpha
Out[62]: True
相等
您还可以检查选择的相等性。如果两个选择都引用相同的原子,则比较将返回 True。
In [63]: calpha = structure.select('protein and name CA')
In [64]: calpha2 = structure.select('calpha')
In [65]: calpha == calpha2
Out[65]: True
分层视图
分层视图
链条
残留物
原子
状态变化
结构分析
测量几何特性
比较和对齐结构
编写 PDB 文件
动力学分析
PCA 计算
ANM 计算
对比分析
输出数据文件
外部数据
绘制数据
更多例子
序列分析
访问 Pfam
解析 MSA
序列
分析
应用教程
对齐 PDB 文件
ANM计算
PCA 计算
参考
http://prody.csb.pitt.edu/tutorials/prody_tutorial/