11.2.2. 核心对象:容器 MDAnalysis.core.groups
这个 Universe
实例包含系统中的所有粒子(MDAnalysis调用 Atom
)。几组人 atoms
被处理为 AtomGroup
实例。这个 AtomGroup
可能是MDAnalysis中最重要的对象,因为几乎所有东西都可以通过它访问。 AtomGroup
可以轻松地创建实例(例如,从 AtomGroup.select_atoms()
选择或简单地通过切片)。
为方便起见,化学上有意义的 Atoms
例如, Residue
或者是 Segment
(通常是整个分子或所有溶剂)也以容器形式存在,以及这些单元的基团 (ResidueGroup
, SegmentGroup
)。
11.2.2.1. 班级
11.2.2.1.1. 收藏
- class MDAnalysis.core.groups.AtomGroup(*args, **kwargs)[源代码]
原子的有序排列。
可以从可迭代的
Atoms
::ag = AtomGroup([Atom1, Atom2, Atom3])
或通过提供索引列表和
Universe
它应该属于:ag = AtomGroup([72, 14, 25], u)
或者,一个
AtomGroup
是通过索引/切片另一个AtomGroup
,例如所有人的集团Atoms
在Universe
在…MDAnalysis.core.universe.Universe.atoms
。一个
AtomGroup
可以像列表一样编制索引和切片::ag[0], ag[-1]
将返回第一个和最后一个
Atom
在组中,而切片::ag[0:6:2]
返回一个
AtomGroup
每隔一个元素,对应于索引0、2和4。它还支持当参数为
numpy.ndarray
或者是list
::aslice = [0, 3, -1, 10, 3] ag[aslice]
将返回一个新的
AtomGroup
的Atoms
随着这些指数在旧的AtomGroup
。最后,
AtomGroups
可以从所选内容创建。看见select_atoms()
。备注
AtomGroups
对源自选定内容的元素进行排序,并删除重复的元素。这并不适用于AtomGroups
通过切片生产的。因此,当原子的顺序至关重要时(例如,为了定义角度或二面体),可以使用切片。AtomGroups
可以使用组运算符进行比较和组合。例如,AtomGroups
可以使用以下命令串联 + 或concatenate()
::ag_concat = ag1 + ag2 # or ag_concat = ag1.concatenate(ag2)
当将组连接起来时,
Atoms
是保守的。如果Atoms
在其中一个组中出现多次,则副本保留在结果组中。与…相反concatenate()
,union()
对待那些AtomGroups
作为集合,以便从结果组中删除重复项,以及Atoms
是有秩序的。这个 | 运算符与union()
::ag_union = ag1 | ag2 # or ag_union = ag1.union(ag2)
与之相反的操作
concatenate()
是subtract()
。此方法创建一个新组,其中包含所有Atoms
不在给定其他组中的组的顺序;Atoms
被保存着,复制品也是如此。difference()
是的设置版本subtract()
。对生成的组进行排序和重复数据消除。下表列出了所有设置的方法。这些方法将组视为已排序并已消除重复数据的
Atoms
。运营
等价物
结果
s.isdisjoint(t)
True
如果s
和t
不共享元素s.issubset(t)
测试是否所有元素
s
是以下的一部分t
s.is_strict_subset(t)
测试是否所有元素
s
是以下的一部分t
,以及s != t
s.issuperset(t)
测试是否所有元素
t
是以下的一部分s
s.is_strict_superset(t)
测试是否所有元素
t
是以下的一部分s
,以及s != t
s.union(t)
s | t
包含来自这两个元素的新组
s
和t
s.intersection(t)
s & t
包含共有元素的新组
s
和t
s.difference(t)
s - t
具有以下元素的新组
s
不在其中的t
s.symmetric_difference(t)
s ^ t
包含属于的元素的新组
s
或t
但不能两者兼而有之下面的方法保持原子和复制品的顺序。
运营
等价物
结果
len(s)
组中元素(原子、残基或链段)的数量
s == t
测试是否
s
和t
以相同的顺序包含相同的元素s.concatenate(t)
s + t
具有来自的元素的新组
s
以及来自t
s.subtract(t)
具有来自的元素的新组
s
不在其中的t
这个 in 运算符允许测试一个
Atom
是在AtomGroup
。AtomGroup
实例始终绑定到MDAnalysis.core.universe.Universe
。它们不能孤立地存在。在串行化期间,
AtomGroup
将与它的捆绑在一起MDAnalysis.core.universe.Universe
这意味着在解酸之后,一种新的MDAnalysis.core.universe.Universe
将被创建并由新的AtomGroup
。如果宇宙是用它的AtomGroup
之后,它们仍将被捆绑在一起:>>> u = mda.Universe(PSF, DCD) >>> g = u.atoms >>> g_pickled = pickle.loads(pickle.dumps(g)) >>> print("g_pickled.universe is u: ", u is g_pickled.universe) g_pickled.universe is u: False >>> g_pickled, u_pickled = pickle.load(pickle.dumps(g, u)) >>> print("g_pickled.universe is u_pickled: ", >>> u_pickle is g_pickled.universe) g_pickled.universe is u_pickled: True
如果有多个
AtomGroup
都绑定到相同的MDAnalysis.core.universe.Universe
,它们将在序列化后绑定到同一个:>>> u = mda.Universe(PSF, DCD) >>> g = u.atoms >>> h = u.atoms >>> g_pickled = pickle.loads(pickle.dumps(g)) >>> h_pickled = pickle.loads(pickle.dumps(h)) >>> print("g_pickled.universe is h_pickled.universe : ", >>> g_pickled.universe is h_pickled.universe) g_pickled.universe is h_pickled.universe: False >>> g_pickled, h_pickled = pickle.load(pickle.dumps(g, h)) >>> print("g_pickled.universe is h_pickled.universe: ", >>> g_pickle.universe is h_pickled.universe) g_pickled.universe is h_pickled.universe: True
上述两种情况对于实现并行分析基类很有用。首先,你总是得到一个独立的
MDAnalysis.core.universe.Universe
在新的流程中,您不必担心拆分和重新连接宇宙AtomGroup
。这也意味着新的已酸洗原子组的状态不会随着旧的宇宙而改变,因此宇宙必须与原子组一起进行酸洗(例如,作为一个元组,或作为要酸洗的对象的属性),或者隐含的新宇宙 (AtomGroup.Universe )需要使用。其次,当需要对多个原子组进行腌制时,它们会识别它们是否属于同一个Univese。还要记住,它们需要一起腌制。自 0.16.2 版本弃用: 即时选择器 的
AtomGroup
将在1.0版本中删除。在 1.0.0 版本发生变更: 删除即时选择器,使用SELECT_ATOMERS(‘NAME...’)按名称选择原子。
在 2.0.0 版本发生变更:
AtomGroup
无论有没有它的宇宙,它总是可以被腌制,而不是在找不到它的锚定的宇宙时失败。在 2.1.0 版本发生变更: 使用为原子组编制索引
None
引发了一个TypeError
。- accumulate(attribute, function=<function sum>, compound='group')
累加与组相关联的属性(组的化合物)。
累积的属性
Atoms
在这群人中。每一个人的累积Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。默认情况下,该方法对每个复合体的所有属性求和,但可以使用任何接受数组并返回给定轴上的累积的函数。对于多维输入阵列,沿着第一轴执行累加。- 参数:
attribute (str or array_like) -- 要累加的属性或值数组。如果一个
numpy.ndarray
(或相容的),则其第一维度必须与该群中的原子总数具有相同的长度。function (callable, optional) -- 执行累加的函数。它必须将要累积的属性值数组作为其唯一位置参数,并接受(可选)关键字参数
axis
从而允许指定沿其执行累加的轴。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional If
'group'
, the accumulation of all attributes associated with atoms in the group will be returned as a single value. Otherwise, the accumulation of the attributes perSegment
,Residue
, molecule, or fragment will be returned as a 1d array. Note that, in any case, only theAtoms
belonging to the group will be taken into account.
- 返回:
针灸的针灸 attribute 。如果 compound 设置为
'group'
的第一个维度。 attribute 数组将收缩为单个值。如果 compound 设置为'segments'
,'residues'
,'molecules'
,或'fragments'
,第一维的长度将对应于化合物的数量。在所有情况下,返回的数组的其他维度都将是原始形状(不包括第一个维度)。- 返回类型:
- 抛出:
ValueError -- 如果提供的长度为 attribute 数组与组中的原子数不对应。
ValueError -- 如果 compound 不是
'group'
,'segments'
,'residues'
,'molecules'
,或'fragments'
。NoDataError -- 如果 compound 是
'molecule'
但拓扑不包含分子信息(分子数),或者如果 compound 是'fragments'
但这种拓扑结构并不包含键。
示例
求出给定的总电荷量
AtomGroup
::>>> sel = u.select_atoms('prop mass > 4.0') >>> sel.accumulate('charges')
求出所有CA的每残基总质量
Atoms
::>>> sel = u.select_atoms('name CA') >>> sel.accumulate('masses', compound='residues')
找出给定的每个碎片的最大原子电荷
AtomGroup
::>>> sel.accumulate('charges', compound="fragments", function=np.max)
在 0.20.0 版本加入.
- align_principal_axis(axis, vector)
将主轴与索引对齐 axis 使用 vector 。
- 参数:
axis ({0, 1, 2}) -- 主轴的索引(0、1或2),由
principal_axes()
。vector (array_like) -- 要与主轴对齐的矢量。
备注
要对齐通道的长轴(第一主轴,即 axis =0)与z轴::
u.atoms.align_principal_axis(0, [0,0,1]) u.atoms.write("aligned.pdb")
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- property angle
这
AtomGroup
表示为MDAnalysis.core.topologyobjects.Angle
对象- 抛出:
ValueError -- 如果
AtomGroup
不是长度为3
在 0.11.0 版本加入.
- asphericity(wrap=False, unwrap=False, compound='group')
非球形性。
看见 [Dima2004b] 获取背景信息。
- 参数:
在 0.7.7 版本加入.
在 0.8 版本发生变更: 已添加 pbc 关键字
在 0.20.0 版本发生变更: 已添加 展开 和 化合物 参数
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
在 2.5.0 版本发生变更: 添加了对任何 compound 类型
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- asunique(sorted=False)[源代码]
返回一个
AtomGroup
包含唯一Atoms
仅限,具有可选排序。如果
AtomGroup
是独一无二的,这就是群体本身。示例
>>> import MDAnalysis as mda >>> from MDAnalysis.tests.datafiles import PSF, DCD >>> u = mda.Universe(PSF, DCD) >>> ag = u.atoms[[2, 1, 0]] >>> ag2 = ag.asunique(sorted=False) >>> ag2 is ag True >>> ag2.ix array([2, 1, 0], dtype=int64) >>> ag3 = ag.asunique(sorted=True) >>> ag3 is ag False >>> ag3.ix array([0, 1, 2], dtype=int64) >>> u.atoms[[2, 1, 1, 0, 1]].asunique(sorted=False).ix array([2, 1, 0], dtype=int64)
在 2.0.0 版本加入.
- property atoms
这个
AtomGroup
它本身。在 0.19.0 版本发生变更: 在以前的版本中,这返回一个副本,但现在
AtomGroup
本身被返回。这应该不会影响任何代码,但只会加快计算速度。
- bbox(wrap=False)
返回所选内容的边框。
该正交框的长度A、B、C为:
L = AtomGroup.bbox() A,B,C = L[1] - L[0]
- 参数:
wrap (bool, optional) -- 如果
True
,全部移动Atoms
到计算前的主单位单元格。 [False
]- 返回:
转角 --2x3数组,将边框的角点指定为
[[xmin, ymin, zmin], [xmax, ymax, zmax]]
。- 返回类型:
在 0.7.2 版本加入.
在 0.8 版本发生变更: 已添加 pbc 关键字
在 1.0.0 版本发生变更: 删除了影响默认行为的标志
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- property bfactors
带有警告的B因子别名
备注
这要求底层拓扑具有临时因素。否则,一个
NoDataError
都被养大了。
- property bond
这
AtomGroup
表示为MDAnalysis.core.topologyobjects.Bond
对象- 抛出:
ValueError -- 如果
AtomGroup
不是长度为2
在 0.11.0 版本加入.
- bsphere(wrap=False)
返回所选内容的边界球体。
球体是相对于
center of geometry
。- 参数:
wrap (bool, optional) -- 如果
True
,在计算之前,将所有原子移到主单元格中。 [False
]- 返回:
R ( 浮动 )--边界球体的半径。
居中 ( numpy.ndarray )-球体中心的坐标为
[xcen, ycen, zcen]
。
在 0.7.3 版本加入.
在 0.8 版本发生变更: 已添加 pbc 关键字
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- center(weights, wrap=False, unwrap=False, compound='group')
群的(化合物)的加权中心
计算的加权中心
Atoms
在这群人中。每个加权中心数Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。如果一个复合体的权重和为零,则该复合体的权重中心的坐标将为nan
(不是一个数字)。- 参数:
weights (array_like or None) -- 要使用的权重。设置 weights=None 相当于为群中的所有原子传递相同的权重。
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是'group'
每个化合物的中心将在不移动任何Atoms
以保持化合物的完整性。相反,生成的位置向量将在计算后移动到主单位单元格。默认 [False
] 。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'}, optional) -- If
'group'
, the weighted center of all atoms in the group will be returned as a single position vector. Else, the weighted centers of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
居中 --组的加权中心的位置向量。如果 compound 设置为
'group'
,则输出将是单个位置向量。如果 compound 设置为'segments'
,'residues'
,'molecules'
,或'fragments'
,则输出将是二维形状数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
- 抛出:
ValueError -- 如果 compound 不是
'group'
,'segments'
,'residues'
,'molecules'
,或'fragments'
。ValueError -- 如果‘WRAP’和‘UNWRAP’都设置为TRUE。
NoDataError -- 如果 compound 是
'molecule'
但拓扑结构不包含分子信息(分子数),或者如果 compound 是'fragments'
但这种拓扑结构并不包含键。
示例
找出一个给定的电荷中心
AtomGroup
::>>> sel = u.select_atoms('prop mass > 4.0') >>> sel.center(sel.charges)
求出所有CA的每个残基的质心
Atoms
::>>> sel = u.select_atoms('name CA') >>> sel.center(sel.masses, compound='residues')
在 0.19.0 版本发生变更: 已添加 compound 参数
在 0.20.0 版本发生变更: 已添加
'molecules'
和'fragments'
化合物在 0.20.0 版本发生变更: 已添加 unwrap 参数
在 1.0.0 版本发生变更: 删除了影响默认行为的标志
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- center_of_charge(wrap=False, unwrap=False, compound='group')
基团(化合物)的(绝对)电荷中心
\[\boldsymbol R = \frac{\sum_i \vert q_i \vert \boldsymbol r_i} {\sum_i \vert q_i \vert}\]哪里 \(q_i\) 就是指控和 \(\boldsymbol r_i\) 原子的位置 \(i\) 在给定的情况下
MDAnalysis.core.groups.AtomGroup
。每个收费中心Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。如果化合物的电荷之和为零,则该化合物的质心坐标为nan
(不是一个数字)。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。相反,生成的质心位置向量将在计算后移动到主单元格。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, the center of mass of all atoms in the group will be returned as a single position vector. Otherwise, the centers of mass of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
center --集团负责中锋(S)位置向量(S)。如果 compound 被设置为
'group'
,则输出将是单个位置向量。如果 compound 被设置为'segments'
或'residues'
,则输出将是形状的二维坐标数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
备注
只有当底层拓扑具有有关原子电荷的信息时,才能访问此方法。
在 2.2.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- center_of_geometry(wrap=False, unwrap=False, compound='group')
群的(化合物)的几何中心
\[\boldsymbol R = \frac{\sum_i \boldsymbol r_i}{\sum_i 1}\]哪里 \(\boldsymbol r_i\) 的
Atoms
\(i\) 。每个几何图形的中心Residue
或PerSegment
可以通过设置 compound 相应的参数。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 是'segments'
或'residues'
,将计算每个化合物的中心,而不移动任何Atoms
以保持化合物的完整性。相反,生成的位置向量将在计算后移动到主单位单元格。默认为FALSE。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'}, optional) -- If
'group'
, the center of geometry of allAtoms
in the group will be returned as a single position vector. Else, the centers of geometry of eachSegment
orResidue
will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
居中 --组几何中心的位置向量。如果 compound 设置为
'group'
,则输出将是单个位置向量。如果 compound 设置为'segments'
或'residues'
,则输出将是二维形状数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
在 0.8 版本发生变更: 已添加 pbc 关键字
在 0.19.0 版本发生变更: 已添加 compound 参数
在 0.20.0 版本发生变更: 已添加
'molecules'
和'fragments'
化合物在 0.20.0 版本发生变更: 已添加 unwrap 参数
在 1.0.0 版本发生变更: 删除了影响默认行为的标志
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- center_of_mass(wrap=False, unwrap=False, compound='group')
基团(化合物)的质心
\[\boldsymbol R = \frac{\sum_i m_i \boldsymbol r_i}{\sum m_i}\]哪里 \(m_i\) 是质量和质量 \(\boldsymbol r_i\) 原子的位置 \(i\) 在给定的情况下
MDAnalysis.core.groups.AtomGroup
。每个质心Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。如果化合物的质量之和为零,则该化合物的质心坐标为nan
(不是一个数字)。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。相反,生成的质心位置向量将在计算后移动到主单元格。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional If
'group'
, the center of mass of all atoms in the group will be returned as a single position vector. Otherwise, the centers of mass of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
居中 --群质心的位置向量。如果 compound 设置为
'group'
,则输出将是单个位置向量。如果 compound 设置为'segments'
或'residues'
,则输出将是形状的二维坐标数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
备注
只有当底层拓扑具有有关原子质量的信息时,才能访问此方法。
在 0.8 版本发生变更: 已添加 pbc 参数
在 0.19.0 版本发生变更: 已添加 compound 参数
在 0.20.0 版本发生变更: 已添加
'molecules'
和'fragments'
化合物;添加 unwrap 参数在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- centroid(wrap=False, unwrap=False, compound='group')
群的(化合物)的几何中心
\[\boldsymbol R = \frac{\sum_i \boldsymbol r_i}{\sum_i 1}\]哪里 \(\boldsymbol r_i\) 的
Atoms
\(i\) 。每个几何图形的中心Residue
或PerSegment
可以通过设置 compound 相应的参数。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 是'segments'
或'residues'
,将计算每个化合物的中心,而不移动任何Atoms
以保持化合物的完整性。相反,生成的位置向量将在计算后移动到主单位单元格。默认为FALSE。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'}, optional) -- If
'group'
, the center of geometry of allAtoms
in the group will be returned as a single position vector. Else, the centers of geometry of eachSegment
orResidue
will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
居中 --组几何中心的位置向量。如果 compound 设置为
'group'
,则输出将是单个位置向量。如果 compound 设置为'segments'
或'residues'
,则输出将是二维形状数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
在 0.8 版本发生变更: 已添加 pbc 关键字
在 0.19.0 版本发生变更: 已添加 compound 参数
在 0.20.0 版本发生变更: 已添加
'molecules'
和'fragments'
化合物在 0.20.0 版本发生变更: 已添加 unwrap 参数
在 1.0.0 版本发生变更: 删除了影响默认行为的标志
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- property cmap
这
AtomGroup
表示为MDAnalysis.core.topologyobjects.CMap
对象- 抛出:
ValueError -- 如果
AtomGroup
不是长度为5
在 1.0.0 版本加入.
- concatenate(other)
与同一级别的另一个组或组件串联。
保留重复条目和原始顺序。它与 + 接线员。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下元素的群 self 和 other 串接在一起
- 返回类型:
Group
示例
执行串联时保留原始内容(包括副本)的顺序。
>>> ag1 = u.select_atoms('name O') >>> ag2 = u.select_atoms('name N') >>> ag3 = ag1 + ag2 # or ag1.concatenate(ag2) >>> ag3[:3].names array(['O', 'O', 'O'], dtype=object) >>> ag3[-3:].names array(['N', 'N', 'N'], dtype=object)
在 0.16.0 版本加入.
- convert_to
ConverterWrapper
的别名
- copy()
找另一组和这组一模一样的。
在 0.19.0 版本加入.
- difference(other)
此组中未出现在其他组中的元素
此方法删除重复元素并对结果进行排序。因此,它不同于
subtract()
。difference()
是与 - 接线员。- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下元素的组 self 不在其中的 other ,没有重复的元素
- 返回类型:
Group
在 0.16 版本加入.
- property dihedral
-
- 抛出:
ValueError -- 如果
AtomGroup
不是长度为4
在 0.11.0 版本加入.
- property dimensions
获取当前加载的时间步长的维度副本
- dipole_moment(**kwargs)
基团或基团中化合物的偶极矩。
\[\mu = |\boldsymbol{\mu}| = \sqrt{ \sum_{i=1}^{D} \mu^2 }\]哪里 \(D\) 是维度的数量,在本例中为3。
计算分子的偶极矩
Atoms
在这群人中。偶极子PERResidue
,Segment
、分子或片段可以通过设置 compound 相应的参数。请注意,当有净电荷时,偶极矩的大小取决于 center 被选中了。看见
dipole_vector()
。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, a single dipole vector returns. Otherwise, an array of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.center ({'mass', 'charge'}, optional) -- 选择偶极向量是在“质量”的中心还是“电荷”的中心计算,默认为“质量”。
- 返回:
群的(化合物)的偶极矩(S) \(eÅ\) 。如果 compound 被设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,)
哪里n
是化合物的数量。- 返回类型:
在 2.4.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- dipole_vector(wrap=False, unwrap=False, compound='group', center='mass')
群的偶极向量。
\[\boldsymbol{\mu} = \sum_{i=1}^{N} q_{i} ( \mathbf{r}_{i} - \mathbf{r}_{COM} )\]计算的偶极向量
Atoms
在这群人中。偶极向量PERResidue
,Segment
、分子或片段可以通过设置 compound 相应的参数。请注意,偶极矩的大小与
center
除非该物种有净电荷,否则选择。在带电基团的情况下,偶极矩稍后可以通过以下方式进行调整:\[\boldsymbol{\mu}_{COC} = \boldsymbol{\mu}_{COM} + q_{ag}\mathbf{r}_{COM} - q_{ag}\boldsymbol{r}_{COC}\]哪里 \(\mathbf{r}_{COM}\) 是质心, \(\mathbf{r}_{COC}\) 是指控的中心。
- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, a single dipole vector returns. Otherwise, an array of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.center ({'mass', 'charge'}, optional) -- 选择偶极向量是在“质量”的中心还是“电荷”的中心计算,默认为“质量”。
- 返回:
群的(化合物)的偶极向量(S) \(eÅ\) 。如果 compound 被设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,3)
哪里n
是化合物的数量。- 返回类型:
在 2.4.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- property forces
-
A
numpy.ndarray
使用shape
=(
n_atoms
, 3)
和dtype
=numpy.float32
。可以通过分配适当形状的数组来改变力,即
(
n_atoms
, 3)
派遣单独的部队或(3,)
要将 same 强制所有人Atoms
(例如ag.forces = array([0,0,0])
我会付出一切Atoms
零分force
)。- 抛出:
NoDataError -- 如果
Timestep
不包含forces
。
- property fragindices
这个
fragment indices
在所有的Atoms
在这里面AtomGroup
。A
numpy.ndarray
使用shape
=(
n_atoms
,)
和dtype
=numpy.int64
。在 0.20.0 版本加入.
备注
这要求底层拓扑具有绑定。否则,一个
NoDataError
都被养大了。
- property fragments
-
片段是一个
group of atoms
它们通过以下方式互连Bonds
即,存在沿着一个或多个Bonds
在任何一对Atoms
在一个片段中。因此,一个片段通常对应于一个分子。备注
片段的内容可能超出本文件的内容范围
AtomGroup
。
在 0.9.0 版本加入.
备注
这要求底层拓扑具有绑定。否则,一个
NoDataError
都被养大了。
- get_connections(typename, outside=True)
将原子之间的键合连接作为
TopologyGroup
。
- groupby(topattrs)
根据的值将此组中的项目组合在一起 头像
- 参数:
topattrs (str or list) -- 用于对组件进行分组的一个或多个拓扑属性。单个参数作为字符串传递。多个参数作为列表传递。
- 返回:
拓扑属性的多个组合的唯一值作为键,组作为值。
- 返回类型:
示例
将相同质量的原子组合在一起:
>>> ag.groupby('masses') {12.010999999999999: <AtomGroup with 462 atoms>, 14.007: <AtomGroup with 116 atoms>, 15.999000000000001: <AtomGroup with 134 atoms>}
要将具有相同残基名称和质量的原子组合在一起,请执行以下操作:
>>> ag.groupby(['resnames', 'masses']) {('ALA', 1.008): <AtomGroup with 95 atoms>, ('ALA', 12.011): <AtomGroup with 57 atoms>, ('ALA', 14.007): <AtomGroup with 19 atoms>, ('ALA', 15.999): <AtomGroup with 19 atoms>}, ('ARG', 1.008): <AtomGroup with 169 atoms>, ...}
>>> ag.groupby(['resnames', 'masses'])('ALA', 15.999) <AtomGroup with 19 atoms>
在 0.16.0 版本加入.
在 0.18.0 版本发生变更: 该函数接受多个属性
- guess_bonds(vdwradii=None, fudge_factor=0.55, lower_bound=0.1)[源代码]
猜猜这个原子之间的键、角和二面体
AtomGroup
并将它们添加到基础universe
。- 参数:
参见
MDAnalysis.topology.guessers.guess_bonds()
,MDAnalysis.topology.guessers.guess_angles()
,MDAnalysis.topology.guessers.guess_dihedrals()
在 0.10.0 版本加入.
在 0.20.2 版本发生变更: 现在在猜测债券时应用周期性边界条件。
在 2.5.0 版本发生变更: 更正了误导性文档,现在允许通过 fudge_factor 和 lower_bound 争论。
- gyration_moments(wrap=False, unwrap=False, compound='group')
旋转张量的力矩。
力矩定义为回转张量的特征值。
\[\mathsf{T} = \frac{1}{N} \sum_{i=1}^{N} (\mathbf{r}_\mathrm{i} - \mathbf{r}_\mathrm{COM})(\mathbf{r}_\mathrm{i} - \mathbf{r}_\mathrm{COM})\]哪里 \(\mathbf{r}_\mathrm{COM}\) 是质心。
看见 [Dima2004a] 获取背景信息。
- 参数:
- 返回:
principle_moments_of_gyration --中(化合物)基团的回转向量(S) \(Å^2\) 。如果 compound 被设置为
'group'
,则输出将是长度为3的单个向量。否则,输出将是形状的2D数组(n,3)
哪里n
是化合物的数量。- 返回类型:
在 2.5.0 版本加入.
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- property improper
这
AtomGroup
表示为MDAnalysis.core.topologyobjects.ImproperDihedral
对象- 抛出:
ValueError -- 如果
AtomGroup
不是长度为4
在 0.11.0 版本加入.
- intersection(other)
既在这个组中又在另一个组中的一组元素
此方法删除重复元素并对结果进行排序。它与 & 接线员。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下共同元素的组 self 和 other ,没有重复的元素
- 返回类型:
Group
示例
当选择原子字符串变得太复杂时,可以使用交叉点。例如,要找到两个区段的4.0A以内的水原子:
>>> shell1 = u.select_atoms('resname SOL and around 4.0 segid 1') >>> shell2 = u.select_atoms('resname SOL and around 4.0 segid 2') >>> common = shell1 & shell2 # or shell1.intersection(shell2)
参见
在 0.16 版本加入.
- is_strict_subset(other)
如果此组是另一个组的子集,但不相同
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果此组是另一个组的严格子集- 返回类型:
在 0.16 版本加入.
- is_strict_superset(other)
如果此组是另一个组的超集,但不相同
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果这个组是另一个组的严格超集- 返回类型:
在 0.16 版本加入.
- isdisjoint(other)
如果组中没有与其他组相同的元素
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果这两个组没有共同的元素- 返回类型:
在 0.16 版本加入.
- issubset(other)
如果此组的所有元素都是其他组的一部分
请注意,空组是同一级别的任何组的子集。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果此组是另一个组的子集- 返回类型:
在 0.16 版本加入.
- issuperset(other)
如果其他组的所有元素都是此组的一部分
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果此组是另一个组的子集- 返回类型:
在 0.16 版本加入.
- property isunique
指示该组的所有组件是否唯一的布尔值,即该组不包含重复项。
示例
>>> ag = u.atoms[[2, 1, 2, 2, 1, 0]] >>> ag <AtomGroup with 6 atoms> >>> ag.isunique False >>> ag2 = ag.unique >>> ag2 <AtomGroup with 3 atoms> >>> ag2.isunique True
参见
在 0.19.0 版本加入.
- property ix
集团中各成分股的唯一指数。
如果它是一个
ResidueGroup
,这些是该指数Residue
实例。如果它是一个
SegmentGroup
,这些是该指数Segment
实例。
- moment_of_inertia(wrap=False, unwrap=False, compound='group')
相对于质心的转动惯量张量。
- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。相反,生成的质心位置向量将在计算后移动到主单元格。unwrap (bool, optional) -- 如果
True
,化合物将在计算它们的中心和惯性张量之前被展开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional compound determines the behavior of wrap. Note that, in any case, only the positions of
Atoms
belonging to the group will be taken into account.
- 返回:
moment_of_inertia --转动惯量张量为3x3数值数组。
- 返回类型:
备注
转动惯量张量 \(\mathsf{{I}}\) 是为一组 \(N\) 具有坐标的原子 \(\mathbf{{r}}_i,\ 1 \le i \le N\) 相对于其质心的相对坐标
\[\mathbf{r}‘_i=\mathbf{r}_i-\frac{1}{\sum_{i=1}^{N}m_i}\sum_{i=1}^{N}m_i\mathbf{r}_i\]作为
\[\mathsf{i}=\sum_{i=1}^{N}m_i\Big[(\mathbf{r}‘_i\cot\mathbf{r}’_i)\sum_{\pha=1}^{3} \HAT{\mathbf{e}}_\Alpha\oTimes\HAT{\mathbf{e}}_\Alpha-\mathbf{r}‘_i\oTimes\mathbf{r}’_i\Big]\]哪里 \(\hat{{\mathbf{{e}}}}_\alpha\) 是笛卡尔单位向量,还是笛卡尔坐标
\[I_{\α,\beta}=\sum_{k=1}^{N}m_k \BIG(\BIG(\sum_{\Gamma=1}^3(x‘^{(K)}_{\Gamma})^2\BIG)\Delta_{\Alpha,\beta} -x‘^{(K)}_{\Alpha}x’^{(K)}_{\beta}\Big)。\]哪里 \(x'^{{(k)}}_{{\alpha}}\) 是相对坐标的笛卡尔坐标 \(\mathbf{{r}}'_k\) 。
在 0.8 版本发生变更: 已添加 pbc 关键字
在 0.20.0 版本发生变更: 已添加 unwrap 参数
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- property n_fragments
唯一的数量
fragments
这个Atoms
其中之一AtomGroup
都是。在 0.20.0 版本加入.
备注
这要求底层拓扑具有绑定。否则,一个
NoDataError
都被养大了。
- pack_into_box(box=None, inplace=True)
全部移位
Atoms
在这一组中到主单位单元。- 参数:
box (array_like) -- 长方体尺寸,可以是正交信息,也可以是三斜信息。单元格维度的格式必须与返回的格式相同
MDAnalysis.coordinates.timestep.Timestep.dimensions
,[lx, ly, lz, alpha, beta, gamma]
。如果None
,使用这些时间步长维度。inplace (bool) --
True
改变坐标的位置。
- 返回:
余弦 --原子坐标移位。
- 返回类型:
备注
所有原子都将被移动,以使它们位于0到盒长度之间 \(L_i\) 在所有维度中,即模拟框的左下角被视为位于(0,0,0):
\[X_i‘=x_i-\Left\lFloor\Frc{x_i}{L_i}\Right\r Floor\]默认情况下,从基础的
Timestep
举个例子。可选参数 box 可用于提供替代像元信息(采用MDAnalysis标准格式[Lx, Ly, Lz, alpha, beta, gamma]
)。适用于正交或三斜长方体类型。
备注
pack_into_box()
等同于wrap()
使用所有默认关键字。在 0.8 版本加入.
- property positions
-
A
numpy.ndarray
使用shape
=(
n_atoms
, 3)
和dtype
=numpy.float32
。可以通过分配适当形状的数组来改变位置,即
(
n_atoms
, 3)
指定单独的坐标,或(3,)
要将 same 与所有人协调Atoms
(例如,ag.positions = array([0,0,0])
将移动所有Atoms
追溯到原点)。备注
更改位置不会反映在任何文件中;从
trajectory
将用文件中的更改替换更改 除 如果trajectory
保存在内存中,例如,当transfer_to_memory()
方法:采用化学发光法。- 抛出:
NoDataError -- 如果潜在的
Timestep
不包含positions
。
- principal_axes(wrap=False)
根据转动惯量计算主轴。
E1,e2,e3=原子组.主体_轴()
特征向量按特征值排序,即第一个对应于最高特征值,因此是第一主轴。
特征向量构成右手坐标系。
- 参数:
wrap (bool, optional) -- 如果
True
,在计算前移动主单元格内的所有原子。 [False
]- 返回:
axis_vectors --3 x 3阵列,带
v[0]
作为第一个,v[1]
作为第二名,以及v[2]
作为第三特征向量。- 返回类型:
array
在 0.8 版本发生变更: 已添加 pbc 关键字
在 1.0.0 版本发生变更: 始终在右手惯例中返回主轴。
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- quadrupole_moment(**kwargs)
基团的四极矩 [Gray1984] 。
\[Q = \sqrt{\frac{2}{3}{\hat{\mathsf{Q}}}:{\hat{\mathsf{Q}}}}\]其中,四极矩是由无迹四极张量的张量双重收缩计算的 \(\hat{\mathsf{Q}}\)
计算四极矩
Atoms
在这群人中。四极PERResidue
,Segment
、分子或片段可以通过设置 compound 相应的参数。注意,当分子或基团中有一个不对称的平面时,四极矩的大小取决于
center
已选择且无法翻译。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, a single quadrupole value returns. Otherwise, an array of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 1d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.center ({'mass', 'charge'}, optional) -- 选择偶极向量是在“质量”的中心还是“电荷”的中心计算,默认为“质量”。
- 返回:
群的(化合物)的四极矩(S) \(eÅ^2\) 。如果 compound 被设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,)
哪里n
是化合物的数量。- 返回类型:
在 2.4.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- quadrupole_tensor(wrap=False, unwrap=False, compound='group', center='mass')
基团或化合物的无迹四极张量。
这个张量首先被计算为从参考点到某个原子的矢量的外积,然后乘以原子电荷。然后将每个原子的张量相加,以产生该群的四极张量:
\[\mathsf{Q} = \sum_{i=1}^{N} q_{i} ( \mathbf{r}_{i} - \mathbf{r}_{COM} ) \otimes ( \mathbf{r}_{i} - \mathbf{r}_{COM} )\]无迹四极张量, \(\hat{\mathsf{Q}}\) ,然后取自:
\[\hat{\mathsf{Q}} = \frac{3}{2} \mathsf{Q} - \frac{1}{2} tr(\mathsf{Q})\]计算四极张量
Atoms
在这群人中。张量PERResidue
,Segment
、分子或片段可以通过设置 compound 相应的参数。请注意,当分子或基团中存在不对称平面时,四极张量的大小取决于
center
(例如, \(\mathbf{r}_{COM}\) ),并且不能翻译。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, a single quadrupole value returns. Otherwise, an array of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 1d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.center ({'mass', 'charge'}, optional) -- 选择偶极向量是在“质量”的中心还是“电荷”的中心计算,默认为“质量”。
- 返回:
群的(化合物)的四极张量(S) \(eÅ^2\) 。如果 compound 被设置为
'group'
,则输出将是形状的单个张量(3,3)
。否则,输出将是一维形状数组(n,3,3)
哪里n
是化合物的数量。- 返回类型:
在 2.4.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- radius_of_gyration(wrap=False, **kwargs)
回转半径。
- 参数:
wrap (bool, optional) -- 如果
True
,在计算前移动主单元格内的所有原子。 [False
]
在 0.8 版本发生变更: 已添加 pbc 关键字
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- property residues
A已排序
ResidueGroup
独一无二的Residues
出现在AtomGroup
。
- rotate(R, point=(0, 0, 0))
应用旋转矩阵 R 设置为选定的坐标。 \(\mathsf{{R}}\) 是一个3x3正交矩阵,它将向量 \(\mathbf{{x}} \rightarrow \mathbf{{x}}'\) :
\[\mathbf{x}‘=\mathsf{R}\mathbf{x}\]Atom
坐标将进行在位旋转。- 参数:
R (array_like) -- 3x3旋转矩阵
point (array_like, optional) -- 旋转中心
- 返回类型:
self
备注
默认情况下,绕原点旋转
point=(0, 0, 0)
。旋转组的步骤g
围绕其几何体中心,使用g.rotate(R, point=g.center_of_geometry())
。参见
rotateby
绕给定轴和角度旋转
MDAnalysis.lib.transformations
所有坐标变换的模
- rotateby(angle, axis, point=None)
对选区的坐标应用旋转。
- 参数:
angle (float) -- 以度为单位的旋转角度。
axis (array_like) -- 旋转轴向量。
point (array_like, optional) -- 旋转中心。如果
None
然后使用该组的几何中心。
- 返回类型:
self
备注
从当前坐标的变换 \(\mathbf{{x}}\) 到新的坐标 \(\mathbf{{x}}'\) 是
\[\mathbf{x}‘=\mathsf{R}\,(\mathbf{x}-\mathbf{p})+\mathbf{p}\]哪里 \(\mathsf{{R}}\) 是按以下方式旋转 angle 围绕着 axis 正在通过 point \(\mathbf{{p}}\) 。
参见
MDAnalysis.lib.transformations.rotation_matrix
calculate
数学:mathsf{R}
- property segments
A已排序
SegmentGroup
中存在的唯一段的AtomGroup
。
- select_atoms(sel, *othersel, periodic=True, rtol=1e-05, atol=1e-08, updating=False, sorted=True, rdkit_kwargs=None, smarts_kwargs=None, **selgroups)[源代码]
使用选择字符串从该组中选择原子。
返回一个
AtomGroup
根据它们在拓扑中的索引进行排序(这是为了确保不存在重复项,复杂的选择可能会发生这种情况)。- 参数:
sel (str) -- 所选内容的字符串,例如“姓名CA”,请参见下面的可能性。
othersel (iterable of str) -- 要执行的进一步选择。这些选择的结果将被附加到第一个选择的结果上。
periodic (bool (optional)) -- 对于几何选择,在搜索时是否考虑不同周期图像中的原子
atol (float, optional) -- 浮点数比较的绝对公差参数。已传递给 :func:``numpy.isclose` `。
rtol (float, optional) -- 浮点数比较的相对公差参数。已传递给 :func:``numpy.isclose` `。
updating (bool (optional)) -- 每次更改轨迹的时间步长时,强制重新计算选择。请参阅上的部分 动态选择 下面。 [
True
]sorted (bool, optional) -- 是否按索引对输出原子组进行排序。
rdkit_kwargs (dict (optional)) -- 传递给
RDKitConverter
使用基于Smarts查询的选择时smarts_kwargs (dict (optional)) -- 在内部传递给RDKit的 GetSubstructMatches 。
**selgroups (keyword arguments of str: AtomGroup (optional)) -- 在选择中使用“group”关键字时,通过将组作为关键字参数传递来定义组。请参阅上的部分 预先存在的选择 下面。
- 抛出:
TypeError -- 如果传递的任意组不是
MDAnalysis.core.groups.AtomGroup
示例
下面列出的所有简单选择都支持与或运算符隐式组合的多个参数。例如
>>> sel = universe.select_atoms('resname MET GLY')
相当于
>>> sel = universe.select_atoms('resname MET or resname GLY')
将选择残基名称为MET或GLY的所有原子。
子选择可以用圆括号进行分组。
>>> sel = universe.select_atoms("segid DMPC and not ( name H* O* )") >>> sel <AtomGroup with 3420 atoms>
现有
AtomGroup
对象可以作为命名参数传递,然后可供选择解析器使用。>>> universe.select_atoms("around 10 group notHO", notHO=sel) <AtomGroup with 1250 atoms>
可以将选定内容设置为在框架更改时自动更新,方法是设置 updating 关键字参数为 True 。这将返回一个
UpdatingAtomGroup
它可以代表另一个物体周围的溶剂化壳层。>>> universe.select_atoms("resname SOL and around 2.0 protein", updating=True) <Updating AtomGroup with 100 atoms>
备注
如果需要原子的精确排序(例如,
angle()
或dihedral()
计算),然后提供选择 分别 按照要求的顺序。此外,当多个AtomGroup
实例与+
运算符,则顺序为Atom
实例被保留,副本被 not 已删除。参见
选择语法
选择解析器理解以下区分大小写 关键词 :
简单选择
- 蛋白质、骨架、核骨架、核骨架
选择属于一组标准残基的所有原子;蛋白质通过一组硬编码的残基名称来标识,因此它可能不适用于深奥的残基。
- 塞吉德 seg-name
按segid选择(如拓扑中所示),例如
segid 4AKE
或segid DMPC
- 残存 residue-number-range
RESID可以接受单个残数或一系列数字。范围由两个用冒号(包括)分隔的数字组成,例如
resid 1:5
。残数(“REID”)直接取自拓扑。如果拓扑中存在icodes,则将考虑这些。即‘RESD 163b’将仅选择带有icode B的REST 163,而‘RESD 163’将仅选择残基163。范围选择也将考虑icodes,因此‘RESID 162-163b’将选择162中的所有残基和163中直到icode B的残基。- 重新编号 resnum-number-range
Resnum是典型的残基编号;通常它被设置为原始PDB结构中的残基id。
- 重命名 residue-name
按残留物名称选择,例如
resname LYS
- 名字 atom-name
按原子名称选择(如拓扑图中所示)。通常,这是由力场决定的。示例:
name CA
(对于C&α;原子)或name OW
(适用于SPC水氧)- 类型 atom-type
按原子类型选择;这可以是字符串或数字,取决于力场;它是从拓扑文件中读取的(例如,CHARMM PSF文件包含数字原子类型)。将PDB或GRO文件用作拓扑时,它具有无意义的值
- atom seg-name residue-number atom-name
一种用于单个原子的选择器,该选择器由segid残留原子名组成,例如
DMPC 1 C2
选择DMPC片段的第一个残基的C2碳- Altloc alternative-location
对于有替代位置的原子的选择,这通常是高分辨率晶体结构的情况,例如 resid 4 and resname ALA and altloc B 仅选择Ala-4中具有Altloc B记录的原子。
- 摩尔型 molecule-type
按分子类型选择,例如
moltype Protein_A
。目前,只有TPR格式定义了分子类型。- record_type record_type
用于从类似PDB的文件中选择ATOM或HETATM。例如:
select_atoms('name CA and not record_type HETATM')
- 聪明人 SMARTS-query
使用Daylight的Smarts查询选择原子,例如
smarts [#7;R]
找到环中的氮原子。需要RDKit。所有匹配项都组合为单个唯一匹配项。这个 smarts selection accepts two sets of key word arguments from select_atoms(): therdkit_kwargs
are passed internally to RDKitConverter.convert() and thesmarts_kwargs
are passed to RDKit's GetSubstructMatches 。默认情况下, useChirality Kwarg inrdkit_kwargs
被设置为True,并且在smarts_kwargs
是max(1000, 10 * n_atoms)
,在哪里n_atoms
要么是len(AtomGroup)
或len(Universe.atoms)
,以适用者为准。请注意,匹配的数量有时可能会超过MaxMatches的缺省值,从而导致返回的原子太少。如果发生这种情况,将发出警告。可以通过增加MaxMatches的值来修复该问题。此行为可能会在将来更新。>>> universe.select_atoms("C", smarts_kwargs={"maxMatches": 100}) <AtomGroup with 100 atoms>
- 手性 R|S
选择特定的立体中心。例如:
name C and chirality S
只选择S-手性碳原子。仅限R
和S
将是可能的选项,但其他值不会引发错误。- 正式收费 formal-charge
根据原子的形式电荷选择原子,例如
name O and formalcharge -1
选择所有带负1正式电荷的氧。
Boolean
- 不
所有不在选择中的原子,例如
not protein
选择不是蛋白质一部分的所有原子- 和,或者
根据布尔代数的规则组合两个选项,例如
protein and not resname ALA LYS
选择属于蛋白质但不在赖氨酸或丙氨酸残基中的所有原子
Geometric
- around distance selection
选择与另一个选择相隔一定界限的所有原子,例如
around 3.5 protein
选择所有不属于蛋白质的原子,这些原子与蛋白质的距离不超过3.5埃- point x y z distance
选择空间点截止点内的所有原子,确保坐标由空格分隔,例如
point 5.0 5.0 5.0 3.5
选择坐标(5.0、5.0、5.0)3.5埃范围内的所有原子- prop [abs] property operator value
selects atoms based on position, using property x, y, or z coordinate. Supports the abs keyword (for absolute value) and the following operators: <, >, <=, >=, ==, !=. For example,
prop z >= 5.0
selects all atoms with z coordinate greater than 5.0;prop abs z <= 5.0
selects all atoms within -5.0 <= z <= 5.0.- sphzone radius selection
选择其中的所有原子 半径 的几何中心的 选择
- sphlayer inner radius outer radius selection
类似于sphzone,但也排除了 内径 选择COG的
- isolayer inner radius outer radius selection
类似于sphlayer,但将在所有参考层周围找到层,从而创建等值面。
- cyzone externalRadius zMax zMin selection
选择以给定选择的几何中心(COG)为中心的圆柱形区域内的所有原子,例如
cyzone 15 4 -8 protein and resid 42
选择蛋白质的几何中心和残留物42,并创建以COG为中心、外径为15的圆柱体。在z中,圆柱体从COG上方的4延伸到下方的8。的正值 zMin ,或负面的 zMax ,是允许的。- cylayer innerRadius externalRadius zMax zMin selection
选择以给定选择的几何中心(COG)为中心的圆柱层内的所有原子,例如
cylayer 5 10 10 -8 protein
选择蛋白质的几何体中心,并以COG为中心创建内半径为5、外半径为10的圆柱层。在z中,圆柱体从COG上方的10延伸到下方的8。的正值 zMin ,或负面的 zMax ,是允许的。
Connectivity
- 拜尔斯 选择
选择相同片段和残基中的所有原子作为选择,例如在Byres关键字后指定部分选择
- 捆绑在一起的 选择
选择与选择绑定的所有原子,例如:
select name H and bonded name O
只选择与氧基键相连的氢
Index
预先存在的选择
- 组 group-name
选择元素中的原子
AtomGroup
作为名为的关键字参数传递给函数 group-name 。只有原子间共有的 group-name 和实例select_atoms()
从Will中调用,除非group
在前面有global
关键字。 group-name 将仅通过比较原子索引而被包括在解析中。这意味着要由用户来确保 group-name 组是在适当的Universe
。- 全球 选择
默认情况下,在发出
select_atoms()
从一个AtomGroup
,则返回与该实例的原子相交的选择和子选择。为选择项添加前缀global
使其所选内容全部返回。作为一个例子,global
关键字允许lipids.select_atoms("around 10 global protein")
-在哪里lipids
是一个不含任何蛋白质的基团。是global
否则,结果将是空的选择,因为protein
部分选择本身将为空。在发布时select_atoms()
从一个Universe
,global
被忽略。
- 动态选择
如果
select_atoms()
使用命名参数调用 updating 设置为 True ,一个UpdatingAtomGroup
实例,而不是常规的AtomGroup
。它的行为与后者类似,不同之处在于每次轨迹帧更改时都会重新计算选择表达式(这种情况会延迟发生,仅当UpdatingAtomGroup
被访问,从而不存在正在进行的冗余更新)。从已更新的组发出更新选择将导致稍后的更新也反映基本组的更新。对象上进行的非更新选择或切片操作UpdatingAtomGroup
将返回一个静态的AtomGroup
,它将不再在帧之间更新。
在 0.7.4 版本发生变更: 已添加 重新编号 选择。
在 0.8.1 版本发生变更: 已添加 组 和 完整组 选择。
在 0.13.0 版本发生变更: 已添加 捆绑在一起的 选择。
在 0.16.0 版本发生变更: Resid选择现在将icodes考虑到存在的位置。
在 0.16.0 版本发生变更: 现在可以通过设置 updating 论点。
在 0.17.0 版本发生变更: 已添加 摩尔型 和 羊肚菌 选择。
在 0.19.0 版本发生变更: 添加了对通过的组的严格类型检查。添加了周期性Kwarg(默认为True)
在 0.19.2 版本发生变更: 空的sel字符串现在返回一个空的Atom组。
在 1.0.0 版本发生变更: 这个
fullgroup
选项现在已被删除,取而代之的是同等的global group
选择。删除了影响定期选择的默认行为的标志;现在默认情况下启用定期(与默认标志一样)在 2.0.0 版本发生变更: 添加了 聪明人 选择。增列 atol 和 rtol 关键字来选择浮点值。添加了
sort
关键字。增列 rdkit_kwargs 将参数传递给RDKitConverter。在 2.2.0 版本发生变更: 增列 smarts_kwargs 将参数传递给RDKit GetSubstructMatch smarts 选择。
- shape_parameter(wrap=False, unwrap=False, compound='group')
形状参数。
看见 [Dima2004a] 获取背景信息。
- 参数:
在 0.7.7 版本加入.
在 0.8 版本发生变更: 已添加 pbc 关键字
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。多余的粗鲁人被移除了。
在 2.5.0 版本发生变更: 添加了对任何 compound 类型
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- sort(key='ix', keyfunc=None)[源代码]
返回已排序的
AtomGroup
使用指定的属性作为键。- 参数:
key (str, optional) -- 的名称
AtomGroup
属性进行排序(例如ids
,ix
。默认设置=ix
)。keyfunc (callable, optional) -- 将多维数组转换为一维的函数。此一维数组将用作排序关键字,并且在使用
AtomGroup
具有多个维度的属性键。注意:如果属性是一维的,则忽略此参数。
- 返回:
已排序
AtomGroup
。- 返回类型:
示例
>>> import MDAnalysis as mda >>> from MDAnalysisTests.datafiles import PDB_small >>> u = mda.Universe(PDB_small) >>> ag = u.atoms[[3, 2, 1, 0]] >>> ag.ix array([3 2 1 0]) >>> ag = ag.sort() >>> ag.ix array([0 1 2 3]) >>> ag.positions array([[-11.921, 26.307, 10.41 ], [-11.447, 26.741, 9.595], [-12.44 , 27.042, 10.926], [-12.632, 25.619, 10.046]], dtype=float32) >>> ag = ag.sort("positions", lambda x: x[:, 1]) >>> ag.positions array([[-12.632, 25.619, 10.046], [-11.921, 26.307, 10.41 ], [-11.447, 26.741, 9.595], [-12.44 , 27.042, 10.926]], dtype=float32)
备注
这使用了一个稳定的排序,由 numpy.argsort(kind='stable') 。
在 2.0.0 版本加入.
- split(level)[源代码]
拆分
AtomGroup
变成一个list
的AtomGroups
通过 level 。- 参数:
level ({'atom', 'residue', 'molecule', 'segment'}) --
在 0.9.0 版本加入.
在 0.17.0 版本发生变更: 增加了‘分子’水平。
- subtract(other)
使用此组中未出现在其他组中的元素进行分组
该组的原始顺序以及任何重复的元素都将保留。如果此组中的某个元素被复制并出现在其他组或组件中,则该元素的所有匹配项都将从返回的组中删除。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下元素的组 self 不在其中的 other ,保持秩序和重复。
- 返回类型:
Group
示例
不像
difference()
此方法不会对重复项进行排序或删除。>>> ag1 = u.atoms[[3, 3, 2, 2, 1, 1]] >>> ag2 = u.atoms[2] >>> ag3 = ag1 - ag2 # or ag1.subtract(ag2) >>> ag1.indices array([3, 3, 1, 1])
在 0.16 版本加入.
- symmetric_difference(other)
仅属于这一组或另一组中的一组元素
此方法删除重复的元素,并对结果进行排序。它是与 ^ 接线员。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
使用中的元素分组 self 或在 other 但不是在两者中,没有重复的元素
- 返回类型:
Group
示例
>>> ag1 = u.atoms[[0, 1, 5, 3, 3, 2]] >>> ag2 = u.atoms[[4, 4, 6, 2, 3, 5]] >>> ag3 = ag1 ^ ag2 # or ag1.symmetric_difference(ag2) >>> ag3.indices # 0 and 1 are only in ag1, 4 and 6 are only in ag2 [0, 1, 4, 6]
参见
在 0.16 版本加入.
- total_charge(compound='group')
该族(化合物)的总电荷。
计算的总费用
Atoms
在这群人中。每项收费合计Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。- 参数:
compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional If 'group', the total charge of all atoms in the group will be returned as a single value. Otherwise, the total charges per
Segment
,Residue
, molecule, or fragment will be returned as a 1d array. Note that, in any case, only the charges ofAtoms
belonging to the group will be taken into account.- 返回:
该族(化合物)的总电荷。如果 compound 设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,)
哪里n
是化合物的数量。- 返回类型:
在 0.20.0 版本发生变更: 已添加 compound 参数
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- total_mass(compound='group')
该族(化合物)的总质量。
计算行星的总质量
Atoms
在这群人中。每单位总质量Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。- 参数:
compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional If
'group'
, the total mass of all atoms in the group will be returned as a single value. Otherwise, the total masses perSegment
,Residue
, molecule, or fragment will be returned as a 1d array. Note that, in any case, only the masses ofAtoms
belonging to the group will be taken into account.- 返回:
该族(化合物)的总质量。如果 compound 设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,)
哪里n
是化合物的数量。- 返回类型:
在 0.20.0 版本发生变更: 已添加 compound 参数
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- transform(M)
应用齐次变换矩阵 M 到坐标。
Atom
坐标将进行旋转和在位平移。- 参数:
M (array_like) -- 4x4矩阵,带旋转
R = M[:3, :3]
和中的翻译t = M[:3, 3]
。- 返回类型:
self
参见
MDAnalysis.lib.transformations
所有坐标变换的模
备注
轮换 \(\mathsf{{R}}\) 是关于原点的,并在翻译之前应用 \(\mathbf{{t}}\) :
\[\mathbf{x}‘=\mathsf{R}\mathbf{x}+\mathbf{t}\]
- translate(t)
应用平移向量 t 设置为选定的坐标。
Atom
坐标将进行在位转换。- 参数:
t (array_like) -- 要用来转换坐标的矢量
- 返回类型:
self
参见
MDAnalysis.lib.transformations
所有坐标变换的模
备注
该方法将翻译应用于
AtomGroup
从当前坐标 \(\mathbf{{x}}\) 到新的坐标 \(\mathbf{{x}}'\) :\[\mathbf{x}‘=\mathbf{x}+\mathbf{t}\]
- property ts
包含选择坐标的临时时间步长。
A
Timestep
实例,该实例可以传递给轨迹编写器。如果
ts
则这些修改将一直存在,直到帧编号更改(这通常发生在基础trajectory
帧更改)。不能将一个新的
Timestep
发送到AtomGroup.ts
属性;更改对象的属性。
- union(other)
此组或另一组中的元素组
与串联相反,此方法对元素进行排序并删除重复的元素。它与 | 接线员。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下组合元素的组 self 和 other ,没有重复的元素
- 返回类型:
Group
示例
与之形成鲜明对比的是
concatenate()
,则丢弃所有重复项,并对结果进行排序。>>> ag1 = u.select_atoms('name O') >>> ag2 = u.select_atoms('name N') >>> ag3 = ag1 | ag2 # or ag1.union(ag2) >>> ag3[:3].names array(['N', 'O', 'N'], dtype=object)
在 0.16 版本加入.
- property unique
一个
AtomGroup
包含已排序和唯一的Atoms
只有这样。示例
>>> import MDAnalysis as mda >>> from MDAnalysis.tests.datafiles import PSF, DCD >>> u = mda.Universe(PSF, DCD) >>> ag = u.atoms[[2, 1, 2, 2, 1, 0]] >>> ag <AtomGroup with 6 atoms> >>> ag.ix array([2, 1, 2, 2, 1, 0], dtype=int64) >>> ag2 = ag.unique >>> ag2 <AtomGroup with 3 atoms> >>> ag2.ix array([0, 1, 2], dtype=int64) >>> ag2.unique is ag2 False
- unwrap(compound='fragments', reference='com', inplace=True)
移动这个基团的原子,这样该基团化合物中的键就不会跨越周期边界分裂。
当原子被填充到初级单胞中,导致分子中间断裂时,这种功能最有用,然后分子出现在单胞的两边。这对于计算分子的质心等操作是有问题的。**
+-----------+ +-----------+ | | | | | 6 3 | | 3 | 6 | ! ! | | ! | ! |-5-8 1-2-| ==> | 1-2-|-5-8 | ! ! | | ! | ! | 7 4 | | 4 | 7 | | | | +-----------+ +-----------+
- 参数:
compound ({'group', 'segments', 'residues', 'molecules', ) -- ‘Fragments’},可选要解开哪种类型的化合物。注意,在任何情况下,每个化合物中的所有原子都必须通过键相互连接,即化合物必须对应于分子(的一部分)。
reference ({'com', 'cog', None}, optional) -- 如果
'com'
(质心)或'cog'
(几何中心),展开的化合物将被移位,以便它们的单独参考点位于主单元格内。如果None
,则不执行这样的移位。inplace (bool, optional) -- 如果
True
,坐标将被原地修改。
- 返回:
余弦 --展开的原子坐标形状数组
(n, 3)
。- 返回类型:
- 抛出:
NoDataError -- 如果 compound 是
'molecules'
但基本的拓扑结构不包含分子信息,或者如果 reference 是'com'
但该拓扑不包含体量。ValueError -- 如果 reference 不是
'com'
,'cog'
,或None
,或者如果 reference 是'com'
以及任何物体的总质量 compound 是零。
备注
请注意,只有原子才能 属于这个团体 将会被解开!如果要展开整个分子,请确保这些分子中的所有原子都是该群的一部分。包含群中所有碎片的所有原子的原子群
ag
可以使用以下命令创建:all_frag_atoms = sum(ag.fragments)
参见
make_whole()
,wrap()
,pack_into_box()
,apply_PBC()
在 0.20.0 版本加入.
- property ureybradley
这
AtomGroup
表示为MDAnalysis.core.topologyobjects.UreyBradley
对象- 抛出:
ValueError -- 如果
AtomGroup
不是长度为2
在 1.0.0 版本加入.
- property velocities
-
A
numpy.ndarray
使用shape
=(
n_atoms
, 3)
和dtype
=numpy.float32
。速度可以通过分配适当形状的数组来改变,即
(
n_atoms
, 3)
指定单独的速度或(3,)
要将 same 速度通向所有人Atoms
(例如ag.velocities = array([0,0,0])
我会付出一切Atoms
零velocity
)。- 抛出:
NoDataError -- 如果潜在的
Timestep
不包含velocities
。
- wrap(compound='atoms', center='com', box=None, inplace=True)
根据周期性边界条件,将该组的内容移回到主单元格中。
指定一个 compound 将保留
Atoms
在这个过程中,每一种化合物都会结合在一起。如果 compound 不同于'atoms'
,每个化合物作为一个整体将被移位,以便其 center 位于主单元格内。- 参数:
compound ({'atoms', 'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional Which type of compound to keep together during wrapping. Note that, in any case, only the positions of
Atoms
belonging to the group will be taken into account.center ({'com', 'cog'}) -- 如何定义一组给定原子的中心。如果 compound 是
'atoms'
,则此参数没有意义,因此被忽略。box (array_like, optional) -- 系统的单位单元尺寸,可以是正交的或三斜的,并且必须以与返回的相同格式提供
MDAnalysis.coordinates.timestep.Timestep.dimensions
:[lx, ly, lz, alpha, beta, gamma]
。如果None
,使用当前时间点的维度。inplace (bool, optional) -- 如果
True
,坐标将更改到位。
- 返回:
Dtype的包裹原子坐标数组 np.float32 和形状
(len(self.atoms.n_atoms), 3)
- 返回类型:
- 抛出:
ValueError -- 如果 compound 不是
'atoms'
,'group'
,'segments'
,'residues'
,'molecules'
,或'fragments'
。NoDataError -- 如果 compound 是
'molecule'
但拓扑结构不包含分子信息(分子数),或者如果 compound 是'fragments'
但该拓扑不包含键,或者如果 center 是'com'
但拓扑图中并不包含质量。
备注
该基团的所有原子都将移动,使其化合物的中心位于初级周期图像内。对于正交单胞,主周期像被定义为半开区间 \([0,L_i)\) 之间 \(0\) 和方框长度 \(L_i\) 在所有维度中 \(i\in\{{x,y,z\}}\) 即,模拟框的原点被视为在原点处 \((0,0,0)\) 欧几里得坐标系的。一个复合中心驻留在 \(x_i\) 在维度上 \(i\) 将转移到 \(x_i'\) 根据
\[X_i‘=x_i-\Left\lFloor\Frc{x_i}{L_i}\Right\rFloor\,.\]在指定 compound ,平移是基于每个化合物来计算的。同样的平移适用于该化合物中的所有原子,这意味着它不会被位移打破。然而,这可能意味着化合物的所有原子在包裹后并不都在单胞内,而是化合物的中心。请注意,只有原子才能 属于这个团体 都会被考虑进去的!
center 允许定义如何计算每组的中心。这可以是
'com'
对于质心,或'cog'
表示几何图形的中心。box 允许为转换提供单位单元格。如果未指定,则
dimensions
来自当前的信息Timestep
将会被使用。备注
AtomGroup.wrap()
当前的速度比ResidueGroup.wrap()
或SegmentGroup.wrap()
。在 0.9.2 版本加入.
在 0.20.0 版本发生变更: 这种方法只作用于原子。 属于这个团体 并将换行位置作为
numpy.ndarray
。添加了可选参数 inplace 。
- write(filename=None, file_format=None, filenamefmt='{trjname}_{frame}', frames=None, **kwargs)[源代码]
写 AtomGroup 保存到文件中。
输出可以是坐标文件,也可以是选区,具体取决于格式。
示例
>>> ag = u.atoms >>> ag.write('selection.ndx') # Write a gromacs index file >>> ag.write('coordinates.pdb') # Write the current frame as PDB >>> # Write the trajectory in XTC format >>> ag.write('trajectory.xtc', frames='all') >>> # Write every other frame of the trajectory in PBD format >>> ag.write('trajectory.pdb', frames=u.trajectory[::2])
- 参数:
filename (str, optional) --
None
:从文件名efmt创建TRJNAME_FRAME.FORMAT [None
]file_format (str, optional) -- 坐标、轨迹或选择文件格式的名称或扩展名,例如PDB、CRD、GRO、VMD(TCL)、PYMOL(PML)、Gromacs(NDX)CHARMM(STR)或JMOL(SPT);不区分大小写 [PDB]
filenamefmt (str, optional) -- 默认文件名的格式字符串;使用替代标记‘trjname’和‘Frame’ ["%(trjname)s_%(frame)d"]
bonds (str, optional) -- 如何处理债券信息,尤其是与PDB相关的信息。
"conect"
:仅写入原始文件中定义的CONECT记录。"all"
:写出所有键,包括原始定义的键和MDAnalysis猜测的键。None
:不要注销债券。默认值为"conect"
。frames (array-like or slice or FrameIteratorBase or str, optional) -- 要写的一组帧。该集合可以是帧索引的列表或数组、布尔值的掩码、
slice
,或者在为轨迹编制索引时返回的值。默认情况下, frames 设置为None
并且仅写入当前帧。如果 frames 设置为“All”,则写入轨迹中的所有帧。
在 0.9.0 版本发生变更: 与WRITE_SELECTION合并。此方法现在可以写出两个选择。
在 0.19.0 版本发生变更: 可以使用‘Frames’参数编写多帧轨迹。
- class MDAnalysis.core.groups.ResidueGroup(*args, **kwargs)[源代码]
ResidueGroup基类。
此类由一个
Universe
用于生成特定于其拓扑的ResidueGroup
班级。所有的TopologyAttr
组件从以下位置获得GroupBase
,因此此类仅包含特定于ResidueGroups
。可以使用组运算符比较和合并剩余组。上查看这些运算符的列表
GroupBase
。自 0.16.2 版本弃用: 即时选择器 的数据段将在1.0版本中删除。
在 1.0.0 版本发生变更: 已删除即时选择器,改用SELECT_ATOMERS
在 2.1.0 版本发生变更: 使用为剩余组编制索引
None
引发了一个TypeError
。- accumulate(attribute, function=<function sum>, compound='group')
累加与组相关联的属性(组的化合物)。
累积的属性
Atoms
在这群人中。每一个人的累积Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。默认情况下,该方法对每个复合体的所有属性求和,但可以使用任何接受数组并返回给定轴上的累积的函数。对于多维输入阵列,沿着第一轴执行累加。- 参数:
attribute (str or array_like) -- 要累加的属性或值数组。如果一个
numpy.ndarray
(或相容的),则其第一维度必须与该群中的原子总数具有相同的长度。function (callable, optional) -- 执行累加的函数。它必须将要累积的属性值数组作为其唯一位置参数,并接受(可选)关键字参数
axis
从而允许指定沿其执行累加的轴。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional If
'group'
, the accumulation of all attributes associated with atoms in the group will be returned as a single value. Otherwise, the accumulation of the attributes perSegment
,Residue
, molecule, or fragment will be returned as a 1d array. Note that, in any case, only theAtoms
belonging to the group will be taken into account.
- 返回:
针灸的针灸 attribute 。如果 compound 设置为
'group'
的第一个维度。 attribute 数组将收缩为单个值。如果 compound 设置为'segments'
,'residues'
,'molecules'
,或'fragments'
,第一维的长度将对应于化合物的数量。在所有情况下,返回的数组的其他维度都将是原始形状(不包括第一个维度)。- 返回类型:
- 抛出:
ValueError -- 如果提供的长度为 attribute 数组与组中的原子数不对应。
ValueError -- 如果 compound 不是
'group'
,'segments'
,'residues'
,'molecules'
,或'fragments'
。NoDataError -- 如果 compound 是
'molecule'
但拓扑不包含分子信息(分子数),或者如果 compound 是'fragments'
但这种拓扑结构并不包含键。
示例
求出给定的总电荷量
AtomGroup
::>>> sel = u.select_atoms('prop mass > 4.0') >>> sel.accumulate('charges')
求出所有CA的每残基总质量
Atoms
::>>> sel = u.select_atoms('name CA') >>> sel.accumulate('masses', compound='residues')
找出给定的每个碎片的最大原子电荷
AtomGroup
::>>> sel.accumulate('charges', compound="fragments", function=np.max)
在 0.20.0 版本加入.
- align_principal_axis(axis, vector)
将主轴与索引对齐 axis 使用 vector 。
- 参数:
axis ({0, 1, 2}) -- 主轴的索引(0、1或2),由
principal_axes()
。vector (array_like) -- 要与主轴对齐的矢量。
备注
要对齐通道的长轴(第一主轴,即 axis =0)与z轴::
u.atoms.align_principal_axis(0, [0,0,1]) u.atoms.write("aligned.pdb")
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- asphericity(wrap=False, unwrap=False, compound='group')
非球形性。
看见 [Dima2004b] 获取背景信息。
- 参数:
在 0.7.7 版本加入.
在 0.8 版本发生变更: 已添加 pbc 关键字
在 0.20.0 版本发生变更: 已添加 展开 和 化合物 参数
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
在 2.5.0 版本发生变更: 添加了对任何 compound 类型
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- asunique(sorted=False)[源代码]
返回一个
ResidueGroup
包含唯一Residues
仅限,具有可选排序。如果
ResidueGroup
是独一无二的,这就是群体本身。- 参数:
sorted (bool (optional)) -- 返回的ResidueGroup是否应按resindex排序。
- 返回:
独一
ResidueGroup
- 返回类型:
示例
>>> rg = u.residues[[2, 1, 2, 2, 1, 0]] >>> rg <ResidueGroup with 6 residues> >>> rg.ix array([2, 1, 2, 2, 1, 0]) >>> rg2 = rg.asunique() >>> rg2 <ResidueGroup with 3 residues> >>> rg2.ix array([0, 1, 2]) >>> rg2.asunique() is rg2 True
在 2.0.0 版本加入.
- property atoms
一个
AtomGroup
的Atoms
出现在这张图中ResidueGroup
。这个
Atoms
按以下方式本地订购Residue
在ResidueGroup
。副本是 not 已删除。
- bbox(wrap=False)
返回所选内容的边框。
该正交框的长度A、B、C为:
L = AtomGroup.bbox() A,B,C = L[1] - L[0]
- 参数:
wrap (bool, optional) -- 如果
True
,全部移动Atoms
到计算前的主单位单元格。 [False
]- 返回:
转角 --2x3数组,将边框的角点指定为
[[xmin, ymin, zmin], [xmax, ymax, zmax]]
。- 返回类型:
在 0.7.2 版本加入.
在 0.8 版本发生变更: 已添加 pbc 关键字
在 1.0.0 版本发生变更: 删除了影响默认行为的标志
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- property bfactors
带有警告的B因子别名
备注
这要求底层拓扑具有临时因素。否则,一个
NoDataError
都被养大了。
- bsphere(wrap=False)
返回所选内容的边界球体。
球体是相对于
center of geometry
。- 参数:
wrap (bool, optional) -- 如果
True
,在计算之前,将所有原子移到主单元格中。 [False
]- 返回:
R ( 浮动 )--边界球体的半径。
居中 ( numpy.ndarray )-球体中心的坐标为
[xcen, ycen, zcen]
。
在 0.7.3 版本加入.
在 0.8 版本发生变更: 已添加 pbc 关键字
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- center(weights, wrap=False, unwrap=False, compound='group')
群的(化合物)的加权中心
计算的加权中心
Atoms
在这群人中。每个加权中心数Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。如果一个复合体的权重和为零,则该复合体的权重中心的坐标将为nan
(不是一个数字)。- 参数:
weights (array_like or None) -- 要使用的权重。设置 weights=None 相当于为群中的所有原子传递相同的权重。
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是'group'
每个化合物的中心将在不移动任何Atoms
以保持化合物的完整性。相反,生成的位置向量将在计算后移动到主单位单元格。默认 [False
] 。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'}, optional) -- If
'group'
, the weighted center of all atoms in the group will be returned as a single position vector. Else, the weighted centers of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
居中 --组的加权中心的位置向量。如果 compound 设置为
'group'
,则输出将是单个位置向量。如果 compound 设置为'segments'
,'residues'
,'molecules'
,或'fragments'
,则输出将是二维形状数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
- 抛出:
ValueError -- 如果 compound 不是
'group'
,'segments'
,'residues'
,'molecules'
,或'fragments'
。ValueError -- 如果‘WRAP’和‘UNWRAP’都设置为TRUE。
NoDataError -- 如果 compound 是
'molecule'
但拓扑结构不包含分子信息(分子数),或者如果 compound 是'fragments'
但这种拓扑结构并不包含键。
示例
找出一个给定的电荷中心
AtomGroup
::>>> sel = u.select_atoms('prop mass > 4.0') >>> sel.center(sel.charges)
求出所有CA的每个残基的质心
Atoms
::>>> sel = u.select_atoms('name CA') >>> sel.center(sel.masses, compound='residues')
在 0.19.0 版本发生变更: 已添加 compound 参数
在 0.20.0 版本发生变更: 已添加
'molecules'
和'fragments'
化合物在 0.20.0 版本发生变更: 已添加 unwrap 参数
在 1.0.0 版本发生变更: 删除了影响默认行为的标志
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- center_of_charge(wrap=False, unwrap=False, compound='group')
基团(化合物)的(绝对)电荷中心
\[\boldsymbol R = \frac{\sum_i \vert q_i \vert \boldsymbol r_i} {\sum_i \vert q_i \vert}\]哪里 \(q_i\) 就是指控和 \(\boldsymbol r_i\) 原子的位置 \(i\) 在给定的情况下
MDAnalysis.core.groups.AtomGroup
。每个收费中心Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。如果化合物的电荷之和为零,则该化合物的质心坐标为nan
(不是一个数字)。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。相反,生成的质心位置向量将在计算后移动到主单元格。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, the center of mass of all atoms in the group will be returned as a single position vector. Otherwise, the centers of mass of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
center --集团负责中锋(S)位置向量(S)。如果 compound 被设置为
'group'
,则输出将是单个位置向量。如果 compound 被设置为'segments'
或'residues'
,则输出将是形状的二维坐标数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
备注
只有当底层拓扑具有有关原子电荷的信息时,才能访问此方法。
在 2.2.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- center_of_geometry(wrap=False, unwrap=False, compound='group')
群的(化合物)的几何中心
\[\boldsymbol R = \frac{\sum_i \boldsymbol r_i}{\sum_i 1}\]哪里 \(\boldsymbol r_i\) 的
Atoms
\(i\) 。每个几何图形的中心Residue
或PerSegment
可以通过设置 compound 相应的参数。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 是'segments'
或'residues'
,将计算每个化合物的中心,而不移动任何Atoms
以保持化合物的完整性。相反,生成的位置向量将在计算后移动到主单位单元格。默认为FALSE。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'}, optional) -- If
'group'
, the center of geometry of allAtoms
in the group will be returned as a single position vector. Else, the centers of geometry of eachSegment
orResidue
will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
居中 --组几何中心的位置向量。如果 compound 设置为
'group'
,则输出将是单个位置向量。如果 compound 设置为'segments'
或'residues'
,则输出将是二维形状数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
在 0.8 版本发生变更: 已添加 pbc 关键字
在 0.19.0 版本发生变更: 已添加 compound 参数
在 0.20.0 版本发生变更: 已添加
'molecules'
和'fragments'
化合物在 0.20.0 版本发生变更: 已添加 unwrap 参数
在 1.0.0 版本发生变更: 删除了影响默认行为的标志
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- center_of_mass(wrap=False, unwrap=False, compound='group')
基团(化合物)的质心
\[\boldsymbol R = \frac{\sum_i m_i \boldsymbol r_i}{\sum m_i}\]哪里 \(m_i\) 是质量和质量 \(\boldsymbol r_i\) 原子的位置 \(i\) 在给定的情况下
MDAnalysis.core.groups.AtomGroup
。每个质心Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。如果化合物的质量之和为零,则该化合物的质心坐标为nan
(不是一个数字)。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。相反,生成的质心位置向量将在计算后移动到主单元格。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional If
'group'
, the center of mass of all atoms in the group will be returned as a single position vector. Otherwise, the centers of mass of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
居中 --群质心的位置向量。如果 compound 设置为
'group'
,则输出将是单个位置向量。如果 compound 设置为'segments'
或'residues'
,则输出将是形状的二维坐标数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
备注
只有当底层拓扑具有有关原子质量的信息时,才能访问此方法。
在 0.8 版本发生变更: 已添加 pbc 参数
在 0.19.0 版本发生变更: 已添加 compound 参数
在 0.20.0 版本发生变更: 已添加
'molecules'
和'fragments'
化合物;添加 unwrap 参数在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- centroid(wrap=False, unwrap=False, compound='group')
群的(化合物)的几何中心
\[\boldsymbol R = \frac{\sum_i \boldsymbol r_i}{\sum_i 1}\]哪里 \(\boldsymbol r_i\) 的
Atoms
\(i\) 。每个几何图形的中心Residue
或PerSegment
可以通过设置 compound 相应的参数。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 是'segments'
或'residues'
,将计算每个化合物的中心,而不移动任何Atoms
以保持化合物的完整性。相反,生成的位置向量将在计算后移动到主单位单元格。默认为FALSE。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'}, optional) -- If
'group'
, the center of geometry of allAtoms
in the group will be returned as a single position vector. Else, the centers of geometry of eachSegment
orResidue
will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
居中 --组几何中心的位置向量。如果 compound 设置为
'group'
,则输出将是单个位置向量。如果 compound 设置为'segments'
或'residues'
,则输出将是二维形状数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
在 0.8 版本发生变更: 已添加 pbc 关键字
在 0.19.0 版本发生变更: 已添加 compound 参数
在 0.20.0 版本发生变更: 已添加
'molecules'
和'fragments'
化合物在 0.20.0 版本发生变更: 已添加 unwrap 参数
在 1.0.0 版本发生变更: 删除了影响默认行为的标志
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- chi1_selections(n_name='N', ca_name='CA', cb_name='CB', cg_name='CG CG1 OG OG1 SG')
选择与CHI1侧链二面体N-CA-CB-CG对应的原子组列表。
- 参数:
- 返回:
原子组列表 --按正确顺序选择4个原子。如果未找到CB和/或CG,则列表中的对应项为
None
。。。添加的版本::1.0.0
备注
这要求底层拓扑具有名称。否则,一个
NoDataError
都被养大了。
- concatenate(other)
与同一级别的另一个组或组件串联。
保留重复条目和原始顺序。它与 + 接线员。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下元素的群 self 和 other 串接在一起
- 返回类型:
Group
示例
执行串联时保留原始内容(包括副本)的顺序。
>>> ag1 = u.select_atoms('name O') >>> ag2 = u.select_atoms('name N') >>> ag3 = ag1 + ag2 # or ag1.concatenate(ag2) >>> ag3[:3].names array(['O', 'O', 'O'], dtype=object) >>> ag3[-3:].names array(['N', 'N', 'N'], dtype=object)
在 0.16.0 版本加入.
- copy()
找另一组和这组一模一样的。
在 0.19.0 版本加入.
- difference(other)
此组中未出现在其他组中的元素
此方法删除重复元素并对结果进行排序。因此,它不同于
subtract()
。difference()
是与 - 接线员。- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下元素的组 self 不在其中的 other ,没有重复的元素
- 返回类型:
Group
在 0.16 版本加入.
- property dimensions
获取当前加载的时间步长的维度副本
- dipole_moment(**kwargs)
基团或基团中化合物的偶极矩。
\[\mu = |\boldsymbol{\mu}| = \sqrt{ \sum_{i=1}^{D} \mu^2 }\]哪里 \(D\) 是维度的数量,在本例中为3。
计算分子的偶极矩
Atoms
在这群人中。偶极子PERResidue
,Segment
、分子或片段可以通过设置 compound 相应的参数。请注意,当有净电荷时,偶极矩的大小取决于 center 被选中了。看见
dipole_vector()
。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, a single dipole vector returns. Otherwise, an array of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.center ({'mass', 'charge'}, optional) -- 选择偶极向量是在“质量”的中心还是“电荷”的中心计算,默认为“质量”。
- 返回:
群的(化合物)的偶极矩(S) \(eÅ\) 。如果 compound 被设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,)
哪里n
是化合物的数量。- 返回类型:
在 2.4.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- dipole_vector(wrap=False, unwrap=False, compound='group', center='mass')
群的偶极向量。
\[\boldsymbol{\mu} = \sum_{i=1}^{N} q_{i} ( \mathbf{r}_{i} - \mathbf{r}_{COM} )\]计算的偶极向量
Atoms
在这群人中。偶极向量PERResidue
,Segment
、分子或片段可以通过设置 compound 相应的参数。请注意,偶极矩的大小与
center
除非该物种有净电荷,否则选择。在带电基团的情况下,偶极矩稍后可以通过以下方式进行调整:\[\boldsymbol{\mu}_{COC} = \boldsymbol{\mu}_{COM} + q_{ag}\mathbf{r}_{COM} - q_{ag}\boldsymbol{r}_{COC}\]哪里 \(\mathbf{r}_{COM}\) 是质心, \(\mathbf{r}_{COC}\) 是指控的中心。
- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, a single dipole vector returns. Otherwise, an array of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.center ({'mass', 'charge'}, optional) -- 选择偶极向量是在“质量”的中心还是“电荷”的中心计算,默认为“质量”。
- 返回:
群的(化合物)的偶极向量(S) \(eÅ\) 。如果 compound 被设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,3)
哪里n
是化合物的数量。- 返回类型:
在 2.4.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- get_connections(typename, outside=True)
将原子之间的键合连接作为
TopologyGroup
。
- groupby(topattrs)
根据的值将此组中的项目组合在一起 头像
- 参数:
topattrs (str or list) -- 用于对组件进行分组的一个或多个拓扑属性。单个参数作为字符串传递。多个参数作为列表传递。
- 返回:
拓扑属性的多个组合的唯一值作为键,组作为值。
- 返回类型:
示例
将相同质量的原子组合在一起:
>>> ag.groupby('masses') {12.010999999999999: <AtomGroup with 462 atoms>, 14.007: <AtomGroup with 116 atoms>, 15.999000000000001: <AtomGroup with 134 atoms>}
要将具有相同残基名称和质量的原子组合在一起,请执行以下操作:
>>> ag.groupby(['resnames', 'masses']) {('ALA', 1.008): <AtomGroup with 95 atoms>, ('ALA', 12.011): <AtomGroup with 57 atoms>, ('ALA', 14.007): <AtomGroup with 19 atoms>, ('ALA', 15.999): <AtomGroup with 19 atoms>}, ('ARG', 1.008): <AtomGroup with 169 atoms>, ...}
>>> ag.groupby(['resnames', 'masses'])('ALA', 15.999) <AtomGroup with 19 atoms>
在 0.16.0 版本加入.
在 0.18.0 版本发生变更: 该函数接受多个属性
- gyration_moments(wrap=False, unwrap=False, compound='group')
旋转张量的力矩。
力矩定义为回转张量的特征值。
\[\mathsf{T} = \frac{1}{N} \sum_{i=1}^{N} (\mathbf{r}_\mathrm{i} - \mathbf{r}_\mathrm{COM})(\mathbf{r}_\mathrm{i} - \mathbf{r}_\mathrm{COM})\]哪里 \(\mathbf{r}_\mathrm{COM}\) 是质心。
看见 [Dima2004a] 获取背景信息。
- 参数:
- 返回:
principle_moments_of_gyration --中(化合物)基团的回转向量(S) \(Å^2\) 。如果 compound 被设置为
'group'
,则输出将是长度为3的单个向量。否则,输出将是形状的2D数组(n,3)
哪里n
是化合物的数量。- 返回类型:
在 2.5.0 版本加入.
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- intersection(other)
既在这个组中又在另一个组中的一组元素
此方法删除重复元素并对结果进行排序。它与 & 接线员。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下共同元素的组 self 和 other ,没有重复的元素
- 返回类型:
Group
示例
当选择原子字符串变得太复杂时,可以使用交叉点。例如,要找到两个区段的4.0A以内的水原子:
>>> shell1 = u.select_atoms('resname SOL and around 4.0 segid 1') >>> shell2 = u.select_atoms('resname SOL and around 4.0 segid 2') >>> common = shell1 & shell2 # or shell1.intersection(shell2)
参见
在 0.16 版本加入.
- is_strict_subset(other)
如果此组是另一个组的子集,但不相同
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果此组是另一个组的严格子集- 返回类型:
在 0.16 版本加入.
- is_strict_superset(other)
如果此组是另一个组的超集,但不相同
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果这个组是另一个组的严格超集- 返回类型:
在 0.16 版本加入.
- isdisjoint(other)
如果组中没有与其他组相同的元素
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果这两个组没有共同的元素- 返回类型:
在 0.16 版本加入.
- issubset(other)
如果此组的所有元素都是其他组的一部分
请注意,空组是同一级别的任何组的子集。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果此组是另一个组的子集- 返回类型:
在 0.16 版本加入.
- issuperset(other)
如果其他组的所有元素都是此组的一部分
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果此组是另一个组的子集- 返回类型:
在 0.16 版本加入.
- property isunique
指示该组的所有组件是否唯一的布尔值,即该组不包含重复项。
示例
>>> ag = u.atoms[[2, 1, 2, 2, 1, 0]] >>> ag <AtomGroup with 6 atoms> >>> ag.isunique False >>> ag2 = ag.unique >>> ag2 <AtomGroup with 3 atoms> >>> ag2.isunique True
参见
在 0.19.0 版本加入.
- property ix
集团中各成分股的唯一指数。
如果它是一个
ResidueGroup
,这些是该指数Residue
实例。如果它是一个
SegmentGroup
,这些是该指数Segment
实例。
- moment_of_inertia(wrap=False, unwrap=False, compound='group')
相对于质心的转动惯量张量。
- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。相反,生成的质心位置向量将在计算后移动到主单元格。unwrap (bool, optional) -- 如果
True
,化合物将在计算它们的中心和惯性张量之前被展开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional compound determines the behavior of wrap. Note that, in any case, only the positions of
Atoms
belonging to the group will be taken into account.
- 返回:
moment_of_inertia --转动惯量张量为3x3数值数组。
- 返回类型:
备注
转动惯量张量 \(\mathsf{{I}}\) 是为一组 \(N\) 具有坐标的原子 \(\mathbf{{r}}_i,\ 1 \le i \le N\) 相对于其质心的相对坐标
\[\mathbf{r}‘_i=\mathbf{r}_i-\frac{1}{\sum_{i=1}^{N}m_i}\sum_{i=1}^{N}m_i\mathbf{r}_i\]作为
\[\mathsf{i}=\sum_{i=1}^{N}m_i\Big[(\mathbf{r}‘_i\cot\mathbf{r}’_i)\sum_{\pha=1}^{3} \HAT{\mathbf{e}}_\Alpha\oTimes\HAT{\mathbf{e}}_\Alpha-\mathbf{r}‘_i\oTimes\mathbf{r}’_i\Big]\]哪里 \(\hat{{\mathbf{{e}}}}_\alpha\) 是笛卡尔单位向量,还是笛卡尔坐标
\[I_{\α,\beta}=\sum_{k=1}^{N}m_k \BIG(\BIG(\sum_{\Gamma=1}^3(x‘^{(K)}_{\Gamma})^2\BIG)\Delta_{\Alpha,\beta} -x‘^{(K)}_{\Alpha}x’^{(K)}_{\beta}\Big)。\]哪里 \(x'^{{(k)}}_{{\alpha}}\) 是相对坐标的笛卡尔坐标 \(\mathbf{{r}}'_k\) 。
在 0.8 版本发生变更: 已添加 pbc 关键字
在 0.20.0 版本发生变更: 已添加 unwrap 参数
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- property n_atoms
数量
Atoms
出现在这张图中ResidueGroup
,包括重复残基(因此,重复原子)。相当于
len(self.atoms)
。
- property n_residues
土壤中残留物的数量
ResidueGroup
。相当于
len(self)
。
- property n_segments
ResidueGroup中存在的唯一段数。
相当于
len(self.segments)
。
- omega_selections(c_name='C', n_name='N', ca_name='CA')
选择与omega蛋白质骨架二面体CA-C-N‘-CA’相对应的原子基团列表。
Omega描述的是-C-N-肽键。通常,它是反式的(180度),尽管偶尔也会观察到顺式键(0度)(特别是在Pro附近)。
- 参数:
- 返回:
原子组列表 --按正确顺序选择4个原子。如果在先前的残留物(通过残留物)中没有找到C‘,则列表中的对应项为
None
。。。添加的版本::1.0.0
备注
这要求底层拓扑具有名称。否则,一个
NoDataError
都被养大了。
- pack_into_box(box=None, inplace=True)
全部移位
Atoms
在这一组中到主单位单元。- 参数:
box (array_like) -- 长方体尺寸,可以是正交信息,也可以是三斜信息。单元格维度的格式必须与返回的格式相同
MDAnalysis.coordinates.timestep.Timestep.dimensions
,[lx, ly, lz, alpha, beta, gamma]
。如果None
,使用这些时间步长维度。inplace (bool) --
True
改变坐标的位置。
- 返回:
余弦 --原子坐标移位。
- 返回类型:
备注
所有原子都将被移动,以使它们位于0到盒长度之间 \(L_i\) 在所有维度中,即模拟框的左下角被视为位于(0,0,0):
\[X_i‘=x_i-\Left\lFloor\Frc{x_i}{L_i}\Right\r Floor\]默认情况下,从基础的
Timestep
举个例子。可选参数 box 可用于提供替代像元信息(采用MDAnalysis标准格式[Lx, Ly, Lz, alpha, beta, gamma]
)。适用于正交或三斜长方体类型。
备注
pack_into_box()
等同于wrap()
使用所有默认关键字。在 0.8 版本加入.
- phi_selections(c_name='C', n_name='N', ca_name='CA')
选择与Phi蛋白骨架二面体C‘-N-CA-C相对应的原子基团列表。
- 参数:
- 返回:
原子组列表 --按正确顺序选择4个原子。如果在先前的残留物(通过READ)中没有找到C‘,则列表中的对应项为
None
。。。添加的版本::1.0.0
备注
这要求底层拓扑具有名称。否则,一个
NoDataError
都被养大了。
- principal_axes(wrap=False)
根据转动惯量计算主轴。
E1,e2,e3=原子组.主体_轴()
特征向量按特征值排序,即第一个对应于最高特征值,因此是第一主轴。
特征向量构成右手坐标系。
- 参数:
wrap (bool, optional) -- 如果
True
,在计算前移动主单元格内的所有原子。 [False
]- 返回:
axis_vectors --3 x 3阵列,带
v[0]
作为第一个,v[1]
作为第二名,以及v[2]
作为第三特征向量。- 返回类型:
array
在 0.8 版本发生变更: 已添加 pbc 关键字
在 1.0.0 版本发生变更: 始终在右手惯例中返回主轴。
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- psi_selections(c_name='C', n_name='N', ca_name='CA')
选择与psi蛋白质骨架二面体N-CA-C-N‘相对应的原子基团列表。
- 参数:
- 返回:
原子组列表 --按正确顺序选择4个原子。如果在下面的残留物中找不到N‘(通过残留物),则列表中的对应项目为
None
。。。添加的版本::1.0.0
备注
这要求底层拓扑具有名称。否则,一个
NoDataError
都被养大了。
- quadrupole_moment(**kwargs)
基团的四极矩 [Gray1984] 。
\[Q = \sqrt{\frac{2}{3}{\hat{\mathsf{Q}}}:{\hat{\mathsf{Q}}}}\]其中,四极矩是由无迹四极张量的张量双重收缩计算的 \(\hat{\mathsf{Q}}\)
计算四极矩
Atoms
在这群人中。四极PERResidue
,Segment
、分子或片段可以通过设置 compound 相应的参数。注意,当分子或基团中有一个不对称的平面时,四极矩的大小取决于
center
已选择且无法翻译。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, a single quadrupole value returns. Otherwise, an array of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 1d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.center ({'mass', 'charge'}, optional) -- 选择偶极向量是在“质量”的中心还是“电荷”的中心计算,默认为“质量”。
- 返回:
群的(化合物)的四极矩(S) \(eÅ^2\) 。如果 compound 被设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,)
哪里n
是化合物的数量。- 返回类型:
在 2.4.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- quadrupole_tensor(wrap=False, unwrap=False, compound='group', center='mass')
基团或化合物的无迹四极张量。
这个张量首先被计算为从参考点到某个原子的矢量的外积,然后乘以原子电荷。然后将每个原子的张量相加,以产生该群的四极张量:
\[\mathsf{Q} = \sum_{i=1}^{N} q_{i} ( \mathbf{r}_{i} - \mathbf{r}_{COM} ) \otimes ( \mathbf{r}_{i} - \mathbf{r}_{COM} )\]无迹四极张量, \(\hat{\mathsf{Q}}\) ,然后取自:
\[\hat{\mathsf{Q}} = \frac{3}{2} \mathsf{Q} - \frac{1}{2} tr(\mathsf{Q})\]计算四极张量
Atoms
在这群人中。张量PERResidue
,Segment
、分子或片段可以通过设置 compound 相应的参数。请注意,当分子或基团中存在不对称平面时,四极张量的大小取决于
center
(例如, \(\mathbf{r}_{COM}\) ),并且不能翻译。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, a single quadrupole value returns. Otherwise, an array of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 1d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.center ({'mass', 'charge'}, optional) -- 选择偶极向量是在“质量”的中心还是“电荷”的中心计算,默认为“质量”。
- 返回:
群的(化合物)的四极张量(S) \(eÅ^2\) 。如果 compound 被设置为
'group'
,则输出将是形状的单个张量(3,3)
。否则,输出将是一维形状数组(n,3,3)
哪里n
是化合物的数量。- 返回类型:
在 2.4.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- radius_of_gyration(wrap=False, **kwargs)
回转半径。
- 参数:
wrap (bool, optional) -- 如果
True
,在计算前移动主单元格内的所有原子。 [False
]
在 0.8 版本发生变更: 已添加 pbc 关键字
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- property residues
这个
ResidueGroup
它本身。参见
copy
返回一个真实的
ResidueGroup
在 0.19.0 版本发生变更: 在以前的版本中,这返回一个副本,但现在
ResidueGroup
本身被返回。这应该不会影响任何代码,但只会加快计算速度。
- rotate(R, point=(0, 0, 0))
应用旋转矩阵 R 设置为选定的坐标。 \(\mathsf{{R}}\) 是一个3x3正交矩阵,它将向量 \(\mathbf{{x}} \rightarrow \mathbf{{x}}'\) :
\[\mathbf{x}‘=\mathsf{R}\mathbf{x}\]Atom
坐标将进行在位旋转。- 参数:
R (array_like) -- 3x3旋转矩阵
point (array_like, optional) -- 旋转中心
- 返回类型:
self
备注
默认情况下,绕原点旋转
point=(0, 0, 0)
。旋转组的步骤g
围绕其几何体中心,使用g.rotate(R, point=g.center_of_geometry())
。参见
rotateby
绕给定轴和角度旋转
MDAnalysis.lib.transformations
所有坐标变换的模
- rotateby(angle, axis, point=None)
对选区的坐标应用旋转。
- 参数:
angle (float) -- 以度为单位的旋转角度。
axis (array_like) -- 旋转轴向量。
point (array_like, optional) -- 旋转中心。如果
None
然后使用该组的几何中心。
- 返回类型:
self
备注
从当前坐标的变换 \(\mathbf{{x}}\) 到新的坐标 \(\mathbf{{x}}'\) 是
\[\mathbf{x}‘=\mathsf{R}\,(\mathbf{x}-\mathbf{p})+\mathbf{p}\]哪里 \(\mathsf{{R}}\) 是按以下方式旋转 angle 围绕着 axis 正在通过 point \(\mathbf{{p}}\) 。
参见
MDAnalysis.lib.transformations.rotation_matrix
calculate
数学:mathsf{R}
- property segments
整理好
SegmentGroup
中存在的唯一段的ResidueGroup
。
- sequence(**kwargs)
返回氨基酸序列。
使用关键字选择序列的格式 格式化 :
格式化
描述
‘SeqRecord’
Bio.SeqRecord.SeqRecord
(默认)“序号”
Bio.Seq.Seq
‘字符串’
字符串
默认情况下返回序列(关键字
format = 'SeqRecord'
)作为Bio.SeqRecord.SeqRecord
实例,然后可以对其进行进一步处理。在本例中,所有关键字参数(如 id 字符串或 name 或者 描述 )被直接传递到Bio.SeqRecord.SeqRecord
。如果关键字 格式化 设置为
'Seq'
,全部 科瓦格人 被忽略,并且一个Bio.Seq.Seq
实例返回。与记录的不同之处在于,记录还包含元数据,并可直接用作中其他函数的输入Bio
。如果关键字 格式化 设置为
'string'
,全部 科瓦格人 将被忽略,并返回一个Python字符串。示例:写入FASTA文件
使用
Bio.SeqIO.write()
,它接受序列记录::import Bio.SeqIO # get the sequence record of a protein component of a Universe protein = u.select_atoms("protein") record = protein.sequence(id="myseq1", name="myprotein") Bio.SeqIO.write(record, "single.fasta", "fasta")
具有多个条目的FASTA文件可以写为::
Bio.SeqIO.write([record1, record2, ...], "multi.fasta", "fasta")
- 参数:
format (string, optional) --
"string"
:以1个字母的代码字符串形式返回序列"Seq"
:返回Bio.Seq.Seq
实例"SeqRecord"
:返回Bio.SeqRecord.SeqRecord
实例
默认值为
"SeqRecord"
id (optional) -- SeqRecord的序列ID(对于不同的序列应该不同)
name (optional) -- 蛋白质的名称。
description (optional) -- 序列的简短描述。
kwargs (optional) -- 类可以理解的任何其他关键字参数:Bio.SeqRecord.SeqRecord。
- 抛出:
ValueError --
1-letter IUPAC protein amino acid code; make sure to only --
select protein residues. --
TypeError --
在 0.9.0 版本加入.
备注
这需要对底层拓扑进行重命名。否则,一个
NoDataError
都被养大了。
- shape_parameter(wrap=False, unwrap=False, compound='group')
形状参数。
看见 [Dima2004a] 获取背景信息。
- 参数:
在 0.7.7 版本加入.
在 0.8 版本发生变更: 已添加 pbc 关键字
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。多余的粗鲁人被移除了。
在 2.5.0 版本发生变更: 添加了对任何 compound 类型
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- subtract(other)
使用此组中未出现在其他组中的元素进行分组
该组的原始顺序以及任何重复的元素都将保留。如果此组中的某个元素被复制并出现在其他组或组件中,则该元素的所有匹配项都将从返回的组中删除。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下元素的组 self 不在其中的 other ,保持秩序和重复。
- 返回类型:
Group
示例
不像
difference()
此方法不会对重复项进行排序或删除。>>> ag1 = u.atoms[[3, 3, 2, 2, 1, 1]] >>> ag2 = u.atoms[2] >>> ag3 = ag1 - ag2 # or ag1.subtract(ag2) >>> ag1.indices array([3, 3, 1, 1])
在 0.16 版本加入.
- symmetric_difference(other)
仅属于这一组或另一组中的一组元素
此方法删除重复的元素,并对结果进行排序。它是与 ^ 接线员。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
使用中的元素分组 self 或在 other 但不是在两者中,没有重复的元素
- 返回类型:
Group
示例
>>> ag1 = u.atoms[[0, 1, 5, 3, 3, 2]] >>> ag2 = u.atoms[[4, 4, 6, 2, 3, 5]] >>> ag3 = ag1 ^ ag2 # or ag1.symmetric_difference(ag2) >>> ag3.indices # 0 and 1 are only in ag1, 4 and 6 are only in ag2 [0, 1, 4, 6]
参见
在 0.16 版本加入.
- total_charge(compound='group')
该族(化合物)的总电荷。
计算的总费用
Atoms
在这群人中。每项收费合计Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。- 参数:
compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional If 'group', the total charge of all atoms in the group will be returned as a single value. Otherwise, the total charges per
Segment
,Residue
, molecule, or fragment will be returned as a 1d array. Note that, in any case, only the charges ofAtoms
belonging to the group will be taken into account.- 返回:
该族(化合物)的总电荷。如果 compound 设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,)
哪里n
是化合物的数量。- 返回类型:
在 0.20.0 版本发生变更: 已添加 compound 参数
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- total_mass(compound='group')
该族(化合物)的总质量。
计算行星的总质量
Atoms
在这群人中。每单位总质量Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。- 参数:
compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional If
'group'
, the total mass of all atoms in the group will be returned as a single value. Otherwise, the total masses perSegment
,Residue
, molecule, or fragment will be returned as a 1d array. Note that, in any case, only the masses ofAtoms
belonging to the group will be taken into account.- 返回:
该族(化合物)的总质量。如果 compound 设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,)
哪里n
是化合物的数量。- 返回类型:
在 0.20.0 版本发生变更: 已添加 compound 参数
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- transform(M)
应用齐次变换矩阵 M 到坐标。
Atom
坐标将进行旋转和在位平移。- 参数:
M (array_like) -- 4x4矩阵,带旋转
R = M[:3, :3]
和中的翻译t = M[:3, 3]
。- 返回类型:
self
参见
MDAnalysis.lib.transformations
所有坐标变换的模
备注
轮换 \(\mathsf{{R}}\) 是关于原点的,并在翻译之前应用 \(\mathbf{{t}}\) :
\[\mathbf{x}‘=\mathsf{R}\mathbf{x}+\mathbf{t}\]
- translate(t)
应用平移向量 t 设置为选定的坐标。
Atom
坐标将进行在位转换。- 参数:
t (array_like) -- 要用来转换坐标的矢量
- 返回类型:
self
参见
MDAnalysis.lib.transformations
所有坐标变换的模
备注
该方法将翻译应用于
AtomGroup
从当前坐标 \(\mathbf{{x}}\) 到新的坐标 \(\mathbf{{x}}'\) :\[\mathbf{x}‘=\mathbf{x}+\mathbf{t}\]
- union(other)
此组或另一组中的元素组
与串联相反,此方法对元素进行排序并删除重复的元素。它与 | 接线员。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下组合元素的组 self 和 other ,没有重复的元素
- 返回类型:
Group
示例
与之形成鲜明对比的是
concatenate()
,则丢弃所有重复项,并对结果进行排序。>>> ag1 = u.select_atoms('name O') >>> ag2 = u.select_atoms('name N') >>> ag3 = ag1 | ag2 # or ag1.union(ag2) >>> ag3[:3].names array(['N', 'O', 'N'], dtype=object)
在 0.16 版本加入.
- property unique
返回一个
ResidueGroup
包含已排序和唯一的Residues
只有这样。示例
>>> rg = u.residues[[2, 1, 2, 2, 1, 0]] >>> rg <ResidueGroup with 6 residues> >>> rg.ix array([2, 1, 2, 2, 1, 0]) >>> rg2 = rg.unique >>> rg2 <ResidueGroup with 3 residues> >>> rg2.ix array([0, 1, 2]) >>> rg2.unique is rg2 False
在 0.16.0 版本加入.
在 0.19.0 版本发生变更: 如果
ResidueGroup
已经是独一无二的ResidueGroup.unique
现在返回组本身,而不是副本。在 2.0.0 版本发生变更: 现在,此函数始终返回副本。
- unwrap(compound='fragments', reference='com', inplace=True)
移动这个基团的原子,这样该基团化合物中的键就不会跨越周期边界分裂。
当原子被填充到初级单胞中,导致分子中间断裂时,这种功能最有用,然后分子出现在单胞的两边。这对于计算分子的质心等操作是有问题的。**
+-----------+ +-----------+ | | | | | 6 3 | | 3 | 6 | ! ! | | ! | ! |-5-8 1-2-| ==> | 1-2-|-5-8 | ! ! | | ! | ! | 7 4 | | 4 | 7 | | | | +-----------+ +-----------+
- 参数:
compound ({'group', 'segments', 'residues', 'molecules', ) -- ‘Fragments’},可选要解开哪种类型的化合物。注意,在任何情况下,每个化合物中的所有原子都必须通过键相互连接,即化合物必须对应于分子(的一部分)。
reference ({'com', 'cog', None}, optional) -- 如果
'com'
(质心)或'cog'
(几何中心),展开的化合物将被移位,以便它们的单独参考点位于主单元格内。如果None
,则不执行这样的移位。inplace (bool, optional) -- 如果
True
,坐标将被原地修改。
- 返回:
余弦 --展开的原子坐标形状数组
(n, 3)
。- 返回类型:
- 抛出:
NoDataError -- 如果 compound 是
'molecules'
但基本的拓扑结构不包含分子信息,或者如果 reference 是'com'
但该拓扑不包含体量。ValueError -- 如果 reference 不是
'com'
,'cog'
,或None
,或者如果 reference 是'com'
以及任何物体的总质量 compound 是零。
备注
请注意,只有原子才能 属于这个团体 将会被解开!如果要展开整个分子,请确保这些分子中的所有原子都是该群的一部分。包含群中所有碎片的所有原子的原子群
ag
可以使用以下命令创建:all_frag_atoms = sum(ag.fragments)
参见
make_whole()
,wrap()
,pack_into_box()
,apply_PBC()
在 0.20.0 版本加入.
- wrap(compound='atoms', center='com', box=None, inplace=True)
根据周期性边界条件,将该组的内容移回到主单元格中。
指定一个 compound 将保留
Atoms
在这个过程中,每一种化合物都会结合在一起。如果 compound 不同于'atoms'
,每个化合物作为一个整体将被移位,以便其 center 位于主单元格内。- 参数:
compound ({'atoms', 'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional Which type of compound to keep together during wrapping. Note that, in any case, only the positions of
Atoms
belonging to the group will be taken into account.center ({'com', 'cog'}) -- 如何定义一组给定原子的中心。如果 compound 是
'atoms'
,则此参数没有意义,因此被忽略。box (array_like, optional) -- 系统的单位单元尺寸,可以是正交的或三斜的,并且必须以与返回的相同格式提供
MDAnalysis.coordinates.timestep.Timestep.dimensions
:[lx, ly, lz, alpha, beta, gamma]
。如果None
,使用当前时间点的维度。inplace (bool, optional) -- 如果
True
,坐标将更改到位。
- 返回:
Dtype的包裹原子坐标数组 np.float32 和形状
(len(self.atoms.n_atoms), 3)
- 返回类型:
- 抛出:
ValueError -- 如果 compound 不是
'atoms'
,'group'
,'segments'
,'residues'
,'molecules'
,或'fragments'
。NoDataError -- 如果 compound 是
'molecule'
但拓扑结构不包含分子信息(分子数),或者如果 compound 是'fragments'
但该拓扑不包含键,或者如果 center 是'com'
但拓扑图中并不包含质量。
备注
该基团的所有原子都将移动,使其化合物的中心位于初级周期图像内。对于正交单胞,主周期像被定义为半开区间 \([0,L_i)\) 之间 \(0\) 和方框长度 \(L_i\) 在所有维度中 \(i\in\{{x,y,z\}}\) 即,模拟框的原点被视为在原点处 \((0,0,0)\) 欧几里得坐标系的。一个复合中心驻留在 \(x_i\) 在维度上 \(i\) 将转移到 \(x_i'\) 根据
\[X_i‘=x_i-\Left\lFloor\Frc{x_i}{L_i}\Right\rFloor\,.\]在指定 compound ,平移是基于每个化合物来计算的。同样的平移适用于该化合物中的所有原子,这意味着它不会被位移打破。然而,这可能意味着化合物的所有原子在包裹后并不都在单胞内,而是化合物的中心。请注意,只有原子才能 属于这个团体 都会被考虑进去的!
center 允许定义如何计算每组的中心。这可以是
'com'
对于质心,或'cog'
表示几何图形的中心。box 允许为转换提供单位单元格。如果未指定,则
dimensions
来自当前的信息Timestep
将会被使用。备注
AtomGroup.wrap()
当前的速度比ResidueGroup.wrap()
或SegmentGroup.wrap()
。在 0.9.2 版本加入.
在 0.20.0 版本发生变更: 这种方法只作用于原子。 属于这个团体 并将换行位置作为
numpy.ndarray
。添加了可选参数 inplace 。
- class MDAnalysis.core.groups.SegmentGroup(*args, **kwargs)[源代码]
SegmentGroup
基类。此类由一个
Universe
用于生成特定于其拓扑的SegmentGroup
班级。所有的TopologyAttr
组件从以下位置获得GroupBase
,因此此类仅包含特定于SegmentGroups
。SegmentGroups
可以使用组运算符进行比较和组合。上查看这些运算符的列表GroupBase
。自 0.16.2 版本弃用: 即时选择器 的数据段将在1.0版本中删除。
在 1.0.0 版本发生变更: 已删除即时选择器,改用SELECT_ATOMERS
在 2.1.0 版本发生变更: 使用为SegmentGroup编制索引
None
引发了一个TypeError
。- accumulate(attribute, function=<function sum>, compound='group')
累加与组相关联的属性(组的化合物)。
累积的属性
Atoms
在这群人中。每一个人的累积Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。默认情况下,该方法对每个复合体的所有属性求和,但可以使用任何接受数组并返回给定轴上的累积的函数。对于多维输入阵列,沿着第一轴执行累加。- 参数:
attribute (str or array_like) -- 要累加的属性或值数组。如果一个
numpy.ndarray
(或相容的),则其第一维度必须与该群中的原子总数具有相同的长度。function (callable, optional) -- 执行累加的函数。它必须将要累积的属性值数组作为其唯一位置参数,并接受(可选)关键字参数
axis
从而允许指定沿其执行累加的轴。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional If
'group'
, the accumulation of all attributes associated with atoms in the group will be returned as a single value. Otherwise, the accumulation of the attributes perSegment
,Residue
, molecule, or fragment will be returned as a 1d array. Note that, in any case, only theAtoms
belonging to the group will be taken into account.
- 返回:
针灸的针灸 attribute 。如果 compound 设置为
'group'
的第一个维度。 attribute 数组将收缩为单个值。如果 compound 设置为'segments'
,'residues'
,'molecules'
,或'fragments'
,第一维的长度将对应于化合物的数量。在所有情况下,返回的数组的其他维度都将是原始形状(不包括第一个维度)。- 返回类型:
- 抛出:
ValueError -- 如果提供的长度为 attribute 数组与组中的原子数不对应。
ValueError -- 如果 compound 不是
'group'
,'segments'
,'residues'
,'molecules'
,或'fragments'
。NoDataError -- 如果 compound 是
'molecule'
但拓扑不包含分子信息(分子数),或者如果 compound 是'fragments'
但这种拓扑结构并不包含键。
示例
求出给定的总电荷量
AtomGroup
::>>> sel = u.select_atoms('prop mass > 4.0') >>> sel.accumulate('charges')
求出所有CA的每残基总质量
Atoms
::>>> sel = u.select_atoms('name CA') >>> sel.accumulate('masses', compound='residues')
找出给定的每个碎片的最大原子电荷
AtomGroup
::>>> sel.accumulate('charges', compound="fragments", function=np.max)
在 0.20.0 版本加入.
- align_principal_axis(axis, vector)
将主轴与索引对齐 axis 使用 vector 。
- 参数:
axis ({0, 1, 2}) -- 主轴的索引(0、1或2),由
principal_axes()
。vector (array_like) -- 要与主轴对齐的矢量。
备注
要对齐通道的长轴(第一主轴,即 axis =0)与z轴::
u.atoms.align_principal_axis(0, [0,0,1]) u.atoms.write("aligned.pdb")
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- asphericity(wrap=False, unwrap=False, compound='group')
非球形性。
看见 [Dima2004b] 获取背景信息。
- 参数:
在 0.7.7 版本加入.
在 0.8 版本发生变更: 已添加 pbc 关键字
在 0.20.0 版本发生变更: 已添加 展开 和 化合物 参数
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
在 2.5.0 版本发生变更: 添加了对任何 compound 类型
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- asunique(sorted=False)[源代码]
返回一个
SegmentGroup
包含唯一Segments
仅限,具有可选排序。如果
SegmentGroup
是独一无二的,这就是群体本身。- 参数:
sorted (bool (optional)) -- 返回的SegmentGroup是否应按SegIndex排序。
- 返回:
独一
SegmentGroup
- 返回类型:
示例
>>> sg = u.segments[[2, 1, 2, 2, 1, 0]] >>> sg <SegmentGroup with 6 segments> >>> sg.ix array([2, 1, 2, 2, 1, 0]) >>> sg2 = sg.asunique() >>> sg2 <SegmentGroup with 3 segments> >>> sg2.ix array([0, 1, 2]) >>> sg2.asunique() is sg2 True
在 2.0.0 版本加入.
- property atoms
一个
AtomGroup
的Atoms
出现在这张图中SegmentGroup
。这个
Atoms
按以下方式本地订购Residue
,由以下人员进一步订购Segment
在SegmentGroup
。副本是 not 已删除。
- bbox(wrap=False)
返回所选内容的边框。
该正交框的长度A、B、C为:
L = AtomGroup.bbox() A,B,C = L[1] - L[0]
- 参数:
wrap (bool, optional) -- 如果
True
,全部移动Atoms
到计算前的主单位单元格。 [False
]- 返回:
转角 --2x3数组,将边框的角点指定为
[[xmin, ymin, zmin], [xmax, ymax, zmax]]
。- 返回类型:
在 0.7.2 版本加入.
在 0.8 版本发生变更: 已添加 pbc 关键字
在 1.0.0 版本发生变更: 删除了影响默认行为的标志
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- property bfactors
带有警告的B因子别名
备注
这要求底层拓扑具有临时因素。否则,一个
NoDataError
都被养大了。
- bsphere(wrap=False)
返回所选内容的边界球体。
球体是相对于
center of geometry
。- 参数:
wrap (bool, optional) -- 如果
True
,在计算之前,将所有原子移到主单元格中。 [False
]- 返回:
R ( 浮动 )--边界球体的半径。
居中 ( numpy.ndarray )-球体中心的坐标为
[xcen, ycen, zcen]
。
在 0.7.3 版本加入.
在 0.8 版本发生变更: 已添加 pbc 关键字
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- center(weights, wrap=False, unwrap=False, compound='group')
群的(化合物)的加权中心
计算的加权中心
Atoms
在这群人中。每个加权中心数Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。如果一个复合体的权重和为零,则该复合体的权重中心的坐标将为nan
(不是一个数字)。- 参数:
weights (array_like or None) -- 要使用的权重。设置 weights=None 相当于为群中的所有原子传递相同的权重。
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是'group'
每个化合物的中心将在不移动任何Atoms
以保持化合物的完整性。相反,生成的位置向量将在计算后移动到主单位单元格。默认 [False
] 。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'}, optional) -- If
'group'
, the weighted center of all atoms in the group will be returned as a single position vector. Else, the weighted centers of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
居中 --组的加权中心的位置向量。如果 compound 设置为
'group'
,则输出将是单个位置向量。如果 compound 设置为'segments'
,'residues'
,'molecules'
,或'fragments'
,则输出将是二维形状数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
- 抛出:
ValueError -- 如果 compound 不是
'group'
,'segments'
,'residues'
,'molecules'
,或'fragments'
。ValueError -- 如果‘WRAP’和‘UNWRAP’都设置为TRUE。
NoDataError -- 如果 compound 是
'molecule'
但拓扑结构不包含分子信息(分子数),或者如果 compound 是'fragments'
但这种拓扑结构并不包含键。
示例
找出一个给定的电荷中心
AtomGroup
::>>> sel = u.select_atoms('prop mass > 4.0') >>> sel.center(sel.charges)
求出所有CA的每个残基的质心
Atoms
::>>> sel = u.select_atoms('name CA') >>> sel.center(sel.masses, compound='residues')
在 0.19.0 版本发生变更: 已添加 compound 参数
在 0.20.0 版本发生变更: 已添加
'molecules'
和'fragments'
化合物在 0.20.0 版本发生变更: 已添加 unwrap 参数
在 1.0.0 版本发生变更: 删除了影响默认行为的标志
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- center_of_charge(wrap=False, unwrap=False, compound='group')
基团(化合物)的(绝对)电荷中心
\[\boldsymbol R = \frac{\sum_i \vert q_i \vert \boldsymbol r_i} {\sum_i \vert q_i \vert}\]哪里 \(q_i\) 就是指控和 \(\boldsymbol r_i\) 原子的位置 \(i\) 在给定的情况下
MDAnalysis.core.groups.AtomGroup
。每个收费中心Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。如果化合物的电荷之和为零,则该化合物的质心坐标为nan
(不是一个数字)。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。相反,生成的质心位置向量将在计算后移动到主单元格。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, the center of mass of all atoms in the group will be returned as a single position vector. Otherwise, the centers of mass of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
center --集团负责中锋(S)位置向量(S)。如果 compound 被设置为
'group'
,则输出将是单个位置向量。如果 compound 被设置为'segments'
或'residues'
,则输出将是形状的二维坐标数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
备注
只有当底层拓扑具有有关原子电荷的信息时,才能访问此方法。
在 2.2.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- center_of_geometry(wrap=False, unwrap=False, compound='group')
群的(化合物)的几何中心
\[\boldsymbol R = \frac{\sum_i \boldsymbol r_i}{\sum_i 1}\]哪里 \(\boldsymbol r_i\) 的
Atoms
\(i\) 。每个几何图形的中心Residue
或PerSegment
可以通过设置 compound 相应的参数。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 是'segments'
或'residues'
,将计算每个化合物的中心,而不移动任何Atoms
以保持化合物的完整性。相反,生成的位置向量将在计算后移动到主单位单元格。默认为FALSE。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'}, optional) -- If
'group'
, the center of geometry of allAtoms
in the group will be returned as a single position vector. Else, the centers of geometry of eachSegment
orResidue
will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
居中 --组几何中心的位置向量。如果 compound 设置为
'group'
,则输出将是单个位置向量。如果 compound 设置为'segments'
或'residues'
,则输出将是二维形状数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
在 0.8 版本发生变更: 已添加 pbc 关键字
在 0.19.0 版本发生变更: 已添加 compound 参数
在 0.20.0 版本发生变更: 已添加
'molecules'
和'fragments'
化合物在 0.20.0 版本发生变更: 已添加 unwrap 参数
在 1.0.0 版本发生变更: 删除了影响默认行为的标志
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- center_of_mass(wrap=False, unwrap=False, compound='group')
基团(化合物)的质心
\[\boldsymbol R = \frac{\sum_i m_i \boldsymbol r_i}{\sum m_i}\]哪里 \(m_i\) 是质量和质量 \(\boldsymbol r_i\) 原子的位置 \(i\) 在给定的情况下
MDAnalysis.core.groups.AtomGroup
。每个质心Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。如果化合物的质量之和为零,则该化合物的质心坐标为nan
(不是一个数字)。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。相反,生成的质心位置向量将在计算后移动到主单元格。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional If
'group'
, the center of mass of all atoms in the group will be returned as a single position vector. Otherwise, the centers of mass of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
居中 --群质心的位置向量。如果 compound 设置为
'group'
,则输出将是单个位置向量。如果 compound 设置为'segments'
或'residues'
,则输出将是形状的二维坐标数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
备注
只有当底层拓扑具有有关原子质量的信息时,才能访问此方法。
在 0.8 版本发生变更: 已添加 pbc 参数
在 0.19.0 版本发生变更: 已添加 compound 参数
在 0.20.0 版本发生变更: 已添加
'molecules'
和'fragments'
化合物;添加 unwrap 参数在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- centroid(wrap=False, unwrap=False, compound='group')
群的(化合物)的几何中心
\[\boldsymbol R = \frac{\sum_i \boldsymbol r_i}{\sum_i 1}\]哪里 \(\boldsymbol r_i\) 的
Atoms
\(i\) 。每个几何图形的中心Residue
或PerSegment
可以通过设置 compound 相应的参数。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 是'segments'
或'residues'
,将计算每个化合物的中心,而不移动任何Atoms
以保持化合物的完整性。相反,生成的位置向量将在计算后移动到主单位单元格。默认为FALSE。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'}, optional) -- If
'group'
, the center of geometry of allAtoms
in the group will be returned as a single position vector. Else, the centers of geometry of eachSegment
orResidue
will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.
- 返回:
居中 --组几何中心的位置向量。如果 compound 设置为
'group'
,则输出将是单个位置向量。如果 compound 设置为'segments'
或'residues'
,则输出将是二维形状数组(n, 3)
哪里n
是化合物的数量。- 返回类型:
在 0.8 版本发生变更: 已添加 pbc 关键字
在 0.19.0 版本发生变更: 已添加 compound 参数
在 0.20.0 版本发生变更: 已添加
'molecules'
和'fragments'
化合物在 0.20.0 版本发生变更: 已添加 unwrap 参数
在 1.0.0 版本发生变更: 删除了影响默认行为的标志
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
- concatenate(other)
与同一级别的另一个组或组件串联。
保留重复条目和原始顺序。它与 + 接线员。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下元素的群 self 和 other 串接在一起
- 返回类型:
Group
示例
执行串联时保留原始内容(包括副本)的顺序。
>>> ag1 = u.select_atoms('name O') >>> ag2 = u.select_atoms('name N') >>> ag3 = ag1 + ag2 # or ag1.concatenate(ag2) >>> ag3[:3].names array(['O', 'O', 'O'], dtype=object) >>> ag3[-3:].names array(['N', 'N', 'N'], dtype=object)
在 0.16.0 版本加入.
- copy()
找另一组和这组一模一样的。
在 0.19.0 版本加入.
- difference(other)
此组中未出现在其他组中的元素
此方法删除重复元素并对结果进行排序。因此,它不同于
subtract()
。difference()
是与 - 接线员。- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下元素的组 self 不在其中的 other ,没有重复的元素
- 返回类型:
Group
在 0.16 版本加入.
- property dimensions
获取当前加载的时间步长的维度副本
- dipole_moment(**kwargs)
基团或基团中化合物的偶极矩。
\[\mu = |\boldsymbol{\mu}| = \sqrt{ \sum_{i=1}^{D} \mu^2 }\]哪里 \(D\) 是维度的数量,在本例中为3。
计算分子的偶极矩
Atoms
在这群人中。偶极子PERResidue
,Segment
、分子或片段可以通过设置 compound 相应的参数。请注意,当有净电荷时,偶极矩的大小取决于 center 被选中了。看见
dipole_vector()
。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, a single dipole vector returns. Otherwise, an array of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.center ({'mass', 'charge'}, optional) -- 选择偶极向量是在“质量”的中心还是“电荷”的中心计算,默认为“质量”。
- 返回:
群的(化合物)的偶极矩(S) \(eÅ\) 。如果 compound 被设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,)
哪里n
是化合物的数量。- 返回类型:
在 2.4.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- dipole_vector(wrap=False, unwrap=False, compound='group', center='mass')
群的偶极向量。
\[\boldsymbol{\mu} = \sum_{i=1}^{N} q_{i} ( \mathbf{r}_{i} - \mathbf{r}_{COM} )\]计算的偶极向量
Atoms
在这群人中。偶极向量PERResidue
,Segment
、分子或片段可以通过设置 compound 相应的参数。请注意,偶极矩的大小与
center
除非该物种有净电荷,否则选择。在带电基团的情况下,偶极矩稍后可以通过以下方式进行调整:\[\boldsymbol{\mu}_{COC} = \boldsymbol{\mu}_{COM} + q_{ag}\mathbf{r}_{COM} - q_{ag}\boldsymbol{r}_{COC}\]哪里 \(\mathbf{r}_{COM}\) 是质心, \(\mathbf{r}_{COC}\) 是指控的中心。
- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, a single dipole vector returns. Otherwise, an array of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 2d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.center ({'mass', 'charge'}, optional) -- 选择偶极向量是在“质量”的中心还是“电荷”的中心计算,默认为“质量”。
- 返回:
群的(化合物)的偶极向量(S) \(eÅ\) 。如果 compound 被设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,3)
哪里n
是化合物的数量。- 返回类型:
在 2.4.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- get_connections(typename, outside=True)
将原子之间的键合连接作为
TopologyGroup
。
- groupby(topattrs)
根据的值将此组中的项目组合在一起 头像
- 参数:
topattrs (str or list) -- 用于对组件进行分组的一个或多个拓扑属性。单个参数作为字符串传递。多个参数作为列表传递。
- 返回:
拓扑属性的多个组合的唯一值作为键,组作为值。
- 返回类型:
示例
将相同质量的原子组合在一起:
>>> ag.groupby('masses') {12.010999999999999: <AtomGroup with 462 atoms>, 14.007: <AtomGroup with 116 atoms>, 15.999000000000001: <AtomGroup with 134 atoms>}
要将具有相同残基名称和质量的原子组合在一起,请执行以下操作:
>>> ag.groupby(['resnames', 'masses']) {('ALA', 1.008): <AtomGroup with 95 atoms>, ('ALA', 12.011): <AtomGroup with 57 atoms>, ('ALA', 14.007): <AtomGroup with 19 atoms>, ('ALA', 15.999): <AtomGroup with 19 atoms>}, ('ARG', 1.008): <AtomGroup with 169 atoms>, ...}
>>> ag.groupby(['resnames', 'masses'])('ALA', 15.999) <AtomGroup with 19 atoms>
在 0.16.0 版本加入.
在 0.18.0 版本发生变更: 该函数接受多个属性
- gyration_moments(wrap=False, unwrap=False, compound='group')
旋转张量的力矩。
力矩定义为回转张量的特征值。
\[\mathsf{T} = \frac{1}{N} \sum_{i=1}^{N} (\mathbf{r}_\mathrm{i} - \mathbf{r}_\mathrm{COM})(\mathbf{r}_\mathrm{i} - \mathbf{r}_\mathrm{COM})\]哪里 \(\mathbf{r}_\mathrm{COM}\) 是质心。
看见 [Dima2004a] 获取背景信息。
- 参数:
- 返回:
principle_moments_of_gyration --中(化合物)基团的回转向量(S) \(Å^2\) 。如果 compound 被设置为
'group'
,则输出将是长度为3的单个向量。否则,输出将是形状的2D数组(n,3)
哪里n
是化合物的数量。- 返回类型:
在 2.5.0 版本加入.
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- intersection(other)
既在这个组中又在另一个组中的一组元素
此方法删除重复元素并对结果进行排序。它与 & 接线员。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下共同元素的组 self 和 other ,没有重复的元素
- 返回类型:
Group
示例
当选择原子字符串变得太复杂时,可以使用交叉点。例如,要找到两个区段的4.0A以内的水原子:
>>> shell1 = u.select_atoms('resname SOL and around 4.0 segid 1') >>> shell2 = u.select_atoms('resname SOL and around 4.0 segid 2') >>> common = shell1 & shell2 # or shell1.intersection(shell2)
参见
在 0.16 版本加入.
- is_strict_subset(other)
如果此组是另一个组的子集,但不相同
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果此组是另一个组的严格子集- 返回类型:
在 0.16 版本加入.
- is_strict_superset(other)
如果此组是另一个组的超集,但不相同
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果这个组是另一个组的严格超集- 返回类型:
在 0.16 版本加入.
- isdisjoint(other)
如果组中没有与其他组相同的元素
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果这两个组没有共同的元素- 返回类型:
在 0.16 版本加入.
- issubset(other)
如果此组的所有元素都是其他组的一部分
请注意,空组是同一级别的任何组的子集。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果此组是另一个组的子集- 返回类型:
在 0.16 版本加入.
- issuperset(other)
如果其他组的所有元素都是此组的一部分
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
True
如果此组是另一个组的子集- 返回类型:
在 0.16 版本加入.
- property isunique
指示该组的所有组件是否唯一的布尔值,即该组不包含重复项。
示例
>>> ag = u.atoms[[2, 1, 2, 2, 1, 0]] >>> ag <AtomGroup with 6 atoms> >>> ag.isunique False >>> ag2 = ag.unique >>> ag2 <AtomGroup with 3 atoms> >>> ag2.isunique True
参见
在 0.19.0 版本加入.
- property ix
集团中各成分股的唯一指数。
如果它是一个
ResidueGroup
,这些是该指数Residue
实例。如果它是一个
SegmentGroup
,这些是该指数Segment
实例。
- moment_of_inertia(wrap=False, unwrap=False, compound='group')
相对于质心的转动惯量张量。
- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。相反,生成的质心位置向量将在计算后移动到主单元格。unwrap (bool, optional) -- 如果
True
,化合物将在计算它们的中心和惯性张量之前被展开。compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional compound determines the behavior of wrap. Note that, in any case, only the positions of
Atoms
belonging to the group will be taken into account.
- 返回:
moment_of_inertia --转动惯量张量为3x3数值数组。
- 返回类型:
备注
转动惯量张量 \(\mathsf{{I}}\) 是为一组 \(N\) 具有坐标的原子 \(\mathbf{{r}}_i,\ 1 \le i \le N\) 相对于其质心的相对坐标
\[\mathbf{r}‘_i=\mathbf{r}_i-\frac{1}{\sum_{i=1}^{N}m_i}\sum_{i=1}^{N}m_i\mathbf{r}_i\]作为
\[\mathsf{i}=\sum_{i=1}^{N}m_i\Big[(\mathbf{r}‘_i\cot\mathbf{r}’_i)\sum_{\pha=1}^{3} \HAT{\mathbf{e}}_\Alpha\oTimes\HAT{\mathbf{e}}_\Alpha-\mathbf{r}‘_i\oTimes\mathbf{r}’_i\Big]\]哪里 \(\hat{{\mathbf{{e}}}}_\alpha\) 是笛卡尔单位向量,还是笛卡尔坐标
\[I_{\α,\beta}=\sum_{k=1}^{N}m_k \BIG(\BIG(\sum_{\Gamma=1}^3(x‘^{(K)}_{\Gamma})^2\BIG)\Delta_{\Alpha,\beta} -x‘^{(K)}_{\Alpha}x’^{(K)}_{\beta}\Big)。\]哪里 \(x'^{{(k)}}_{{\alpha}}\) 是相对坐标的笛卡尔坐标 \(\mathbf{{r}}'_k\) 。
在 0.8 版本发生变更: 已添加 pbc 关键字
在 0.20.0 版本发生变更: 已添加 unwrap 参数
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- property n_atoms
原子中存在的原子数
SegmentGroup
,包括重复的片段(因此,重复的原子)。相当于
len(self.atoms)
。
- property n_residues
其中存在的残留物的数量
SegmentGroup
,包括重复片段(因此,残基)。相当于
len(self.residues)
。
- property n_segments
中的分段数
SegmentGroup
。相当于
len(self)
。
- pack_into_box(box=None, inplace=True)
全部移位
Atoms
在这一组中到主单位单元。- 参数:
box (array_like) -- 长方体尺寸,可以是正交信息,也可以是三斜信息。单元格维度的格式必须与返回的格式相同
MDAnalysis.coordinates.timestep.Timestep.dimensions
,[lx, ly, lz, alpha, beta, gamma]
。如果None
,使用这些时间步长维度。inplace (bool) --
True
改变坐标的位置。
- 返回:
余弦 --原子坐标移位。
- 返回类型:
备注
所有原子都将被移动,以使它们位于0到盒长度之间 \(L_i\) 在所有维度中,即模拟框的左下角被视为位于(0,0,0):
\[X_i‘=x_i-\Left\lFloor\Frc{x_i}{L_i}\Right\r Floor\]默认情况下,从基础的
Timestep
举个例子。可选参数 box 可用于提供替代像元信息(采用MDAnalysis标准格式[Lx, Ly, Lz, alpha, beta, gamma]
)。适用于正交或三斜长方体类型。
备注
pack_into_box()
等同于wrap()
使用所有默认关键字。在 0.8 版本加入.
- principal_axes(wrap=False)
根据转动惯量计算主轴。
E1,e2,e3=原子组.主体_轴()
特征向量按特征值排序,即第一个对应于最高特征值,因此是第一主轴。
特征向量构成右手坐标系。
- 参数:
wrap (bool, optional) -- 如果
True
,在计算前移动主单元格内的所有原子。 [False
]- 返回:
axis_vectors --3 x 3阵列,带
v[0]
作为第一个,v[1]
作为第二名,以及v[2]
作为第三特征向量。- 返回类型:
array
在 0.8 版本发生变更: 已添加 pbc 关键字
在 1.0.0 版本发生变更: 始终在右手惯例中返回主轴。
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- quadrupole_moment(**kwargs)
基团的四极矩 [Gray1984] 。
\[Q = \sqrt{\frac{2}{3}{\hat{\mathsf{Q}}}:{\hat{\mathsf{Q}}}}\]其中,四极矩是由无迹四极张量的张量双重收缩计算的 \(\hat{\mathsf{Q}}\)
计算四极矩
Atoms
在这群人中。四极PERResidue
,Segment
、分子或片段可以通过设置 compound 相应的参数。注意,当分子或基团中有一个不对称的平面时,四极矩的大小取决于
center
已选择且无法翻译。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, a single quadrupole value returns. Otherwise, an array of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 1d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.center ({'mass', 'charge'}, optional) -- 选择偶极向量是在“质量”的中心还是“电荷”的中心计算,默认为“质量”。
- 返回:
群的(化合物)的四极矩(S) \(eÅ^2\) 。如果 compound 被设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,)
哪里n
是化合物的数量。- 返回类型:
在 2.4.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- quadrupole_tensor(wrap=False, unwrap=False, compound='group', center='mass')
基团或化合物的无迹四极张量。
这个张量首先被计算为从参考点到某个原子的矢量的外积,然后乘以原子电荷。然后将每个原子的张量相加,以产生该群的四极张量:
\[\mathsf{Q} = \sum_{i=1}^{N} q_{i} ( \mathbf{r}_{i} - \mathbf{r}_{COM} ) \otimes ( \mathbf{r}_{i} - \mathbf{r}_{COM} )\]无迹四极张量, \(\hat{\mathsf{Q}}\) ,然后取自:
\[\hat{\mathsf{Q}} = \frac{3}{2} \mathsf{Q} - \frac{1}{2} tr(\mathsf{Q})\]计算四极张量
Atoms
在这群人中。张量PERResidue
,Segment
、分子或片段可以通过设置 compound 相应的参数。请注意,当分子或基团中存在不对称平面时,四极张量的大小取决于
center
(例如, \(\mathbf{r}_{COM}\) ),并且不能翻译。- 参数:
wrap (bool, optional) -- 如果
True
和 compound 是'group'
,在计算之前,将所有原子移到主单元格中。如果True
和 compound 不是group
,每种化合物的质量中心都将在不移动任何原子的情况下计算,以保持化合物的完整性。unwrap (bool, optional) -- 如果
True
,化合物将在计算其中心之前被解开。compound ({'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional If
'group'
, a single quadrupole value returns. Otherwise, an array of eachSegment
,Residue
, molecule, or fragment will be returned as an array of position vectors, i.e. a 1d array. Note that, in any case, only the positions ofAtoms
belonging to the group will be taken into account.center ({'mass', 'charge'}, optional) -- 选择偶极向量是在“质量”的中心还是“电荷”的中心计算,默认为“质量”。
- 返回:
群的(化合物)的四极张量(S) \(eÅ^2\) 。如果 compound 被设置为
'group'
,则输出将是形状的单个张量(3,3)
。否则,输出将是一维形状数组(n,3,3)
哪里n
是化合物的数量。- 返回类型:
在 2.4.0 版本加入.
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- radius_of_gyration(wrap=False, **kwargs)
回转半径。
- 参数:
wrap (bool, optional) -- 如果
True
,在计算前移动主单元格内的所有原子。 [False
]
在 0.8 版本发生变更: 已添加 pbc 关键字
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- property residues
A
ResidueGroup
的Residues
出现在这张图中SegmentGroup
。这个
Residues
按以下方式本地订购Segment
在SegmentGroup
。副本是 not 已删除。
- rotate(R, point=(0, 0, 0))
应用旋转矩阵 R 设置为选定的坐标。 \(\mathsf{{R}}\) 是一个3x3正交矩阵,它将向量 \(\mathbf{{x}} \rightarrow \mathbf{{x}}'\) :
\[\mathbf{x}‘=\mathsf{R}\mathbf{x}\]Atom
坐标将进行在位旋转。- 参数:
R (array_like) -- 3x3旋转矩阵
point (array_like, optional) -- 旋转中心
- 返回类型:
self
备注
默认情况下,绕原点旋转
point=(0, 0, 0)
。旋转组的步骤g
围绕其几何体中心,使用g.rotate(R, point=g.center_of_geometry())
。参见
rotateby
绕给定轴和角度旋转
MDAnalysis.lib.transformations
所有坐标变换的模
- rotateby(angle, axis, point=None)
对选区的坐标应用旋转。
- 参数:
angle (float) -- 以度为单位的旋转角度。
axis (array_like) -- 旋转轴向量。
point (array_like, optional) -- 旋转中心。如果
None
然后使用该组的几何中心。
- 返回类型:
self
备注
从当前坐标的变换 \(\mathbf{{x}}\) 到新的坐标 \(\mathbf{{x}}'\) 是
\[\mathbf{x}‘=\mathsf{R}\,(\mathbf{x}-\mathbf{p})+\mathbf{p}\]哪里 \(\mathsf{{R}}\) 是按以下方式旋转 angle 围绕着 axis 正在通过 point \(\mathbf{{p}}\) 。
参见
MDAnalysis.lib.transformations.rotation_matrix
calculate
数学:mathsf{R}
- property segments
这个
SegmentGroup
它本身。参见
copy
返回一个真实的
SegmentGroup
在 0.19.0 版本发生变更: 在以前的版本中,这返回一个副本,但现在
SegmentGroup
本身被返回。这应该不会影响任何代码,但只会加快计算速度。
- shape_parameter(wrap=False, unwrap=False, compound='group')
形状参数。
看见 [Dima2004a] 获取背景信息。
- 参数:
在 0.7.7 版本加入.
在 0.8 版本发生变更: 已添加 pbc 关键字
在 2.1.0 版本发生变更: 已重命名 pbc Kwarg to wrap 。 pbc 仍可接受,但已弃用,并将在3.0版中删除。多余的粗鲁人被移除了。
在 2.5.0 版本发生变更: 添加了对任何 compound 类型
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- subtract(other)
使用此组中未出现在其他组中的元素进行分组
该组的原始顺序以及任何重复的元素都将保留。如果此组中的某个元素被复制并出现在其他组或组件中,则该元素的所有匹配项都将从返回的组中删除。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下元素的组 self 不在其中的 other ,保持秩序和重复。
- 返回类型:
Group
示例
不像
difference()
此方法不会对重复项进行排序或删除。>>> ag1 = u.atoms[[3, 3, 2, 2, 1, 1]] >>> ag2 = u.atoms[2] >>> ag3 = ag1 - ag2 # or ag1.subtract(ag2) >>> ag1.indices array([3, 3, 1, 1])
在 0.16 版本加入.
- symmetric_difference(other)
仅属于这一组或另一组中的一组元素
此方法删除重复的元素,并对结果进行排序。它是与 ^ 接线员。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
使用中的元素分组 self 或在 other 但不是在两者中,没有重复的元素
- 返回类型:
Group
示例
>>> ag1 = u.atoms[[0, 1, 5, 3, 3, 2]] >>> ag2 = u.atoms[[4, 4, 6, 2, 3, 5]] >>> ag3 = ag1 ^ ag2 # or ag1.symmetric_difference(ag2) >>> ag3.indices # 0 and 1 are only in ag1, 4 and 6 are only in ag2 [0, 1, 4, 6]
参见
在 0.16 版本加入.
- total_charge(compound='group')
该族(化合物)的总电荷。
计算的总费用
Atoms
在这群人中。每项收费合计Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。- 参数:
compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional If 'group', the total charge of all atoms in the group will be returned as a single value. Otherwise, the total charges per
Segment
,Residue
, molecule, or fragment will be returned as a 1d array. Note that, in any case, only the charges ofAtoms
belonging to the group will be taken into account.- 返回:
该族(化合物)的总电荷。如果 compound 设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,)
哪里n
是化合物的数量。- 返回类型:
在 0.20.0 版本发生变更: 已添加 compound 参数
备注
这要求底层拓扑要有电荷。否则,一个
NoDataError
都被养大了。
- total_mass(compound='group')
该族(化合物)的总质量。
计算行星的总质量
Atoms
在这群人中。每单位总质量Residue
,Segment
、分子或片段可以通过设置 compound 相应的参数。- 参数:
compound ({'group', 'segments', 'residues', 'molecules', 'fragments'},) -- optional If
'group'
, the total mass of all atoms in the group will be returned as a single value. Otherwise, the total masses perSegment
,Residue
, molecule, or fragment will be returned as a 1d array. Note that, in any case, only the masses ofAtoms
belonging to the group will be taken into account.- 返回:
该族(化合物)的总质量。如果 compound 设置为
'group'
,则输出将是单个值。否则,输出将是一维形状数组(n,)
哪里n
是化合物的数量。- 返回类型:
在 0.20.0 版本发生变更: 已添加 compound 参数
备注
这要求底层拓扑具有体量。否则,一个
NoDataError
都被养大了。
- transform(M)
应用齐次变换矩阵 M 到坐标。
Atom
坐标将进行旋转和在位平移。- 参数:
M (array_like) -- 4x4矩阵,带旋转
R = M[:3, :3]
和中的翻译t = M[:3, 3]
。- 返回类型:
self
参见
MDAnalysis.lib.transformations
所有坐标变换的模
备注
轮换 \(\mathsf{{R}}\) 是关于原点的,并在翻译之前应用 \(\mathbf{{t}}\) :
\[\mathbf{x}‘=\mathsf{R}\mathbf{x}+\mathbf{t}\]
- translate(t)
应用平移向量 t 设置为选定的坐标。
Atom
坐标将进行在位转换。- 参数:
t (array_like) -- 要用来转换坐标的矢量
- 返回类型:
self
参见
MDAnalysis.lib.transformations
所有坐标变换的模
备注
该方法将翻译应用于
AtomGroup
从当前坐标 \(\mathbf{{x}}\) 到新的坐标 \(\mathbf{{x}}'\) :\[\mathbf{x}‘=\mathbf{x}+\mathbf{t}\]
- union(other)
此组或另一组中的元素组
与串联相反,此方法对元素进行排序并删除重复的元素。它与 | 接线员。
- 参数:
other (Group or Component) -- 组或组件具有 other.level 同 self.level
- 返回:
具有以下组合元素的组 self 和 other ,没有重复的元素
- 返回类型:
Group
示例
与之形成鲜明对比的是
concatenate()
,则丢弃所有重复项,并对结果进行排序。>>> ag1 = u.select_atoms('name O') >>> ag2 = u.select_atoms('name N') >>> ag3 = ag1 | ag2 # or ag1.union(ag2) >>> ag3[:3].names array(['N', 'O', 'N'], dtype=object)
在 0.16 版本加入.
- property unique
返回一个
SegmentGroup
包含已排序和唯一的Segments
只有这样。示例
>>> sg = u.segments[[2, 1, 2, 2, 1, 0]] >>> sg <SegmentGroup with 6 segments> >>> sg.ix array([2, 1, 2, 2, 1, 0]) >>> sg2 = sg.unique >>> sg2 <SegmentGroup with 3 segments> >>> sg2.ix array([0, 1, 2]) >>> sg2.unique is sg2 False
在 0.16.0 版本加入.
在 0.19.0 版本发生变更: 如果
SegmentGroup
已经是独一无二的SegmentGroup.unique
现在返回组本身,而不是副本。在 2.0.0 版本发生变更: 现在,此函数始终返回副本。
- unwrap(compound='fragments', reference='com', inplace=True)
移动这个基团的原子,这样该基团化合物中的键就不会跨越周期边界分裂。
当原子被填充到初级单胞中,导致分子中间断裂时,这种功能最有用,然后分子出现在单胞的两边。这对于计算分子的质心等操作是有问题的。**
+-----------+ +-----------+ | | | | | 6 3 | | 3 | 6 | ! ! | | ! | ! |-5-8 1-2-| ==> | 1-2-|-5-8 | ! ! | | ! | ! | 7 4 | | 4 | 7 | | | | +-----------+ +-----------+
- 参数:
compound ({'group', 'segments', 'residues', 'molecules', ) -- ‘Fragments’},可选要解开哪种类型的化合物。注意,在任何情况下,每个化合物中的所有原子都必须通过键相互连接,即化合物必须对应于分子(的一部分)。
reference ({'com', 'cog', None}, optional) -- 如果
'com'
(质心)或'cog'
(几何中心),展开的化合物将被移位,以便它们的单独参考点位于主单元格内。如果None
,则不执行这样的移位。inplace (bool, optional) -- 如果
True
,坐标将被原地修改。
- 返回:
余弦 --展开的原子坐标形状数组
(n, 3)
。- 返回类型:
- 抛出:
NoDataError -- 如果 compound 是
'molecules'
但基本的拓扑结构不包含分子信息,或者如果 reference 是'com'
但该拓扑不包含体量。ValueError -- 如果 reference 不是
'com'
,'cog'
,或None
,或者如果 reference 是'com'
以及任何物体的总质量 compound 是零。
备注
请注意,只有原子才能 属于这个团体 将会被解开!如果要展开整个分子,请确保这些分子中的所有原子都是该群的一部分。包含群中所有碎片的所有原子的原子群
ag
可以使用以下命令创建:all_frag_atoms = sum(ag.fragments)
参见
make_whole()
,wrap()
,pack_into_box()
,apply_PBC()
在 0.20.0 版本加入.
- wrap(compound='atoms', center='com', box=None, inplace=True)
根据周期性边界条件,将该组的内容移回到主单元格中。
指定一个 compound 将保留
Atoms
在这个过程中,每一种化合物都会结合在一起。如果 compound 不同于'atoms'
,每个化合物作为一个整体将被移位,以便其 center 位于主单元格内。- 参数:
compound ({'atoms', 'group', 'segments', 'residues', 'molecules', ) -- 'fragments'}, optional Which type of compound to keep together during wrapping. Note that, in any case, only the positions of
Atoms
belonging to the group will be taken into account.center ({'com', 'cog'}) -- 如何定义一组给定原子的中心。如果 compound 是
'atoms'
,则此参数没有意义,因此被忽略。box (array_like, optional) -- 系统的单位单元尺寸,可以是正交的或三斜的,并且必须以与返回的相同格式提供
MDAnalysis.coordinates.timestep.Timestep.dimensions
:[lx, ly, lz, alpha, beta, gamma]
。如果None
,使用当前时间点的维度。inplace (bool, optional) -- 如果
True
,坐标将更改到位。
- 返回:
Dtype的包裹原子坐标数组 np.float32 和形状
(len(self.atoms.n_atoms), 3)
- 返回类型:
- 抛出:
ValueError -- 如果 compound 不是
'atoms'
,'group'
,'segments'
,'residues'
,'molecules'
,或'fragments'
。NoDataError -- 如果 compound 是
'molecule'
但拓扑结构不包含分子信息(分子数),或者如果 compound 是'fragments'
但该拓扑不包含键,或者如果 center 是'com'
但拓扑图中并不包含质量。
备注
该基团的所有原子都将移动,使其化合物的中心位于初级周期图像内。对于正交单胞,主周期像被定义为半开区间 \([0,L_i)\) 之间 \(0\) 和方框长度 \(L_i\) 在所有维度中 \(i\in\{{x,y,z\}}\) 即,模拟框的原点被视为在原点处 \((0,0,0)\) 欧几里得坐标系的。一个复合中心驻留在 \(x_i\) 在维度上 \(i\) 将转移到 \(x_i'\) 根据
\[X_i‘=x_i-\Left\lFloor\Frc{x_i}{L_i}\Right\rFloor\,.\]在指定 compound ,平移是基于每个化合物来计算的。同样的平移适用于该化合物中的所有原子,这意味着它不会被位移打破。然而,这可能意味着化合物的所有原子在包裹后并不都在单胞内,而是化合物的中心。请注意,只有原子才能 属于这个团体 都会被考虑进去的!
center 允许定义如何计算每组的中心。这可以是
'com'
对于质心,或'cog'
表示几何图形的中心。box 允许为转换提供单位单元格。如果未指定,则
dimensions
来自当前的信息Timestep
将会被使用。备注
AtomGroup.wrap()
当前的速度比ResidueGroup.wrap()
或SegmentGroup.wrap()
。在 0.9.2 版本加入.
在 0.20.0 版本发生变更: 这种方法只作用于原子。 属于这个团体 并将换行位置作为
numpy.ndarray
。添加了可选参数 inplace 。
- class MDAnalysis.core.groups.UpdatingAtomGroup(*args, **kwargs)[源代码]
AtomGroup
动态更新其选定原子的子类。访问的任何属性/方法
UpdatingAtomGroup
实例触发对组更新的最后一帧的检查。如果最后一帧与当前轨迹帧匹配,则正常返回该属性;否则更新该组(重新应用存储的选择),然后才返回该属性。在 0.16.0 版本加入.
- 参数:
base_group (
AtomGroup
) -- 所在的组 精选 将被应用于。selections (a tuple of
Selection
) -- 已准备好应用的实例选择 base_group 。
- property atoms
拿到一个 静电
AtomGroup
与当前选定的组相同Atoms
在UpdatingAtomGroup
。通过返回一个 静电
AtomGroup
可以比较组中的内容 之间 轨迹帧。请参见下面的示例。备注
这个
atoms
对象的属性UpdatingAtomGroup
的行为方式与AtomGroup.atoms
:后者返回AtomGroup
本身,而前者返回一个AtomGroup
而不是一个UpdatingAtomGroup
(为此,请使用UpdatingAtomGroup.copy()
)。示例
静电式
atoms
允许比较框架之间的原子组。例如,跟踪进出蛋白质溶剂化Shell的水分子:u = mda.Universe(TPR, XTC) water_shell = u.select_atoms("name OW and around 3.5 protein", updating=True) water_shell_prev = water_shell.atoms for ts in u.trajectory: exchanged = water_shell - water_shell_prev print(ts.time, "waters in shell =", water_shell.n_residues) print(ts.time, "waters that exchanged = ", exchanged.n_residues) print(ts.time, "waters that remained bound = ", water_shell.n_residues - exchanged.n_residues) water_shell_prev = water_shell.atoms
通过记住当前时间步长中的原子 water_shell_prev ,则可以使用
subtraction of AtomGroups
去寻找改变了的水分子。参见
copy
返回一个真实的
UpdatingAtomGroup
- copy()[源代码]
再买一台吧
UpdatingAtomGroup
和这个一模一样。在 0.19.0 版本加入.
- property is_uptodate
仅根据帧编号检查选择是否需要更新。
不会捕获对使选择过时的坐标数据的修改,并且在这些情况下
is_uptodate
可能会返回错误的值。- 返回:
True
如果该组的选择是最新的,False
不然的话。- 返回类型:
11.2.2.1.2. 化工单位
- class MDAnalysis.core.groups.Atom(*args, **kwargs)[源代码]
Atom
基类。此类由一个
Universe
用于生成特定于其拓扑的Atom
班级。所有的TopologyAttr
组件从以下位置获得ComponentBase
,因此此类仅包含特定于Atoms
。- property bfactor
带有警告的B因子别名
备注
这要求底层拓扑具有临时因素。否则,一个
NoDataError
都被养大了。
- property bonded_atoms
一个
AtomGroup
在所有的Atoms
捆绑在这上面Atom
。备注
这要求底层拓扑具有绑定。否则,一个
NoDataError
都被养大了。
- property force
对原子的作用力。
力可以通过指定形状数组来改变
(3,)
。备注
更改力不会反映在任何文件中;从轨迹读取任何帧都会将更改替换为文件中的更改
- 抛出:
NoDataError -- 如果潜在的
Timestep
不包含forces
。
- property fragindex
-
在 0.20.0 版本加入.
备注
这要求底层拓扑具有绑定。否则,一个
NoDataError
都被养大了。
- property fragment
-
片段是一个
group of atoms
它们通过以下方式互连Bonds
即,存在沿着一个或多个Bonds
在任何一对Atoms
在一个片段中。因此,一个片段通常对应于一个分子。在 0.9.0 版本加入.
备注
这要求底层拓扑具有绑定。否则,一个
NoDataError
都被养大了。
- get_connections(typename, outside=True)
将原子之间的键合连接作为
TopologyGroup
。
- property ix
此组件的唯一索引。
如果此组件是
Atom
,这是Atom
。如果它是一个Residue
,这是Residue
。如果它是一个Segment
,这是Segment
。
- property position
原子的坐标。
可以通过指定长度为(3,)的数组来更改位置。
备注
更改位置不会反映在任何文件中;从轨迹读取任何帧都会将更改替换为文件中的更改
- 抛出:
NoDataError -- 如果潜在的
Timestep
不包含positions
。
- property velocity
原子的速度。
可以通过指定形状数组来改变速度
(3,)
。备注
更改速度不会反映在任何文件中;从轨迹读取任何帧都会将更改替换为文件中的更改
- 抛出:
NoDataError -- 如果潜在的
Timestep
不包含velocities
。
- class MDAnalysis.core.groups.Residue(*args, **kwargs)[源代码]
Residue
基类。此类由一个
Universe
用于生成特定于其拓扑的Residue
班级。所有的TopologyAttr
组件从以下位置获得ComponentBase
,因此此类仅包含特定于Residues
。- property bfactors
带有警告的B因子别名
备注
这要求底层拓扑具有临时因素。否则,一个
NoDataError
都被养大了。
- chi1_selection(n_name='N', ca_name='CA', cb_name='CB', cg_name='CG CG1 OG OG1 SG')
选择与CH1侧链二面体对应的原子基团
N-CA-CB-*G.
伽马原子被认为是伽马位置上的重原子。如果存在一个以上的重原子(例如CG1和CG2),则使用数较小的那个(CG1)。警告
这里的CH1原子的编号遵循IUPAC 1970年的规则。然而,应该注意的是,使用二面角的分析可能有不同的定义。例如,
MDAnalysis.analysis.dihedrals.Janin
类不将伽马原子不是碳原子的氨基酸纳入其Ch1选择中。- 参数:
- 返回:
以正确的顺序选择4个原子。如果未找到CB和/或CG,则此方法返回
None
。- 返回类型:
在 0.7.5 版本加入.
在 1.0.0 版本发生变更: 为灵活的原子名称添加了参数,并重构了代码以加快原子与布尔数组的匹配。
备注
这要求底层拓扑具有名称。否则,一个
NoDataError
都被养大了。
- get_connections(typename, outside=True)
将原子之间的键合连接作为
TopologyGroup
。
- property ix
此组件的唯一索引。
如果此组件是
Atom
,这是Atom
。如果它是一个Residue
,这是Residue
。如果它是一个Segment
,这是Segment
。
- omega_selection(c_name='C', n_name='N', ca_name='CA')
选择与omega蛋白质骨架二面体CA-C-N‘-CA’相对应的原子基。
Omega描述的是-C-N-肽键。通常,它是反式的(180度),尽管偶尔也会观察到顺式键(0度)(特别是在Pro附近)。
- 参数:
- 返回:
AtomGroup --按正确顺序选择4个原子。如果在前一个残数(按READ)中没有找到C‘,则此方法返回
None
。。。版本已更改::1.0.0 --添加了灵活原子名称的参数和重构代码,以加快原子与布尔数组的匹配。
备注
这要求底层拓扑具有名称。否则,一个
NoDataError
都被养大了。
- phi_selection(c_name='C', n_name='N', ca_name='CA')
选择与Phi蛋白骨架二面体C‘-N-CA-C对应的原子基团。
- 参数:
- 返回:
AtomGroup --按正确顺序选择4个原子。如果在前一个残数(按READ)中没有找到C‘,则此方法返回
None
。。。版本已更改::1.0.0 --添加了灵活原子名称的参数和重构代码,以加快原子与布尔数组的匹配。
备注
这要求底层拓扑具有名称。否则,一个
NoDataError
都被养大了。
- psi_selection(c_name='C', n_name='N', ca_name='CA')
选择与psi蛋白骨架二面体N-CA-C-N‘相对应的原子基。
- 参数:
- 返回:
AtomGroup --按正确顺序选择4个原子。如果在下面的残数(按READ)中没有找到N‘,则此方法返回
None
。。。版本已更改::1.0.0 --添加了灵活原子名称的参数和重构代码,以加快原子与布尔数组的匹配。
备注
这要求底层拓扑具有名称。否则,一个
NoDataError
都被养大了。
- class MDAnalysis.core.groups.Segment(*args, **kwargs)[源代码]
Segment
基类。此类由一个
Universe
用于生成特定于其拓扑的Segment
班级。所有的TopologyAttr
组件从以下位置获得ComponentBase
,因此此类仅包含特定于Segments
。自 0.16.2 版本弃用: 即时选择器 的
Segments
将在1.0版本中删除。在 1.0.0 版本发生变更: 删除即时选择器,使用以下任一段.残留物 [...] 按数字或分段选择残留物 [segment.residue.resnames = ...] 按重新命名进行选择。
- property bfactors
带有警告的B因子别名
备注
这要求底层拓扑具有临时因素。否则,一个
NoDataError
都被养大了。
- get_connections(typename, outside=True)
将原子之间的键合连接作为
TopologyGroup
。
- property ix
此组件的唯一索引。
如果此组件是
Atom
,这是Atom
。如果它是一个Residue
,这是Residue
。如果它是一个Segment
,这是Segment
。
- property residues
A
ResidueGroup
的Residues
出现在这张图中Segment
。
11.2.2.1.3. 级别
上面的每个类都有一个 级别 属性。这可用于验证两个对象是否属于同一级别,或用于访问特定类:
u = mda.Universe()
ag = u.atoms[:10]
at = u.atoms[11]
ag.level == at.level # Returns True
ag.level.singular # Returns Atom class
at.level.plural # Returns AtomGroup class