本文整理汇总了Python中mdtraj.core.selection.parse_selection函数的典型用法代码示例。如果您正苦于以下问题:Python parse_selection函数的具体用法?Python parse_selection怎么用?Python parse_selection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_selection函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_bool
def test_bool():
sp = parse_selection("protein or water")
eq(sp.source, "(atom.residue.is_protein or atom.residue.is_water)")
sp = parse_selection("protein or water or all")
eq(sp.source,
"(atom.residue.is_protein or atom.residue.is_water or True)")
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:7,代码来源:test_selection.py
示例2: test_nested_bool
def test_nested_bool():
sp = parse_selection("nothing and water or all")
eq(sp.source,
"((False and atom.residue.is_water) or True)")
sp = parse_selection("nothing and (water or all)")
eq(sp.source,
"(False and (atom.residue.is_water or True))")
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:8,代码来源:test_selection.py
示例3: test_unary_2
def test_unary_2():
sp = parse_selection('all')
for a in tt.atoms:
assert sp.expr(a)
sp = parse_selection('none')
for a in tt.atoms:
assert not sp.expr(a)
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:8,代码来源:test_selection.py
示例4: test_not
def test_not():
sp = parse_selection("not protein")
eq(sp.source, "(not atom.residue.is_protein)")
sp = parse_selection("not not protein")
eq(sp.source, "(not (not atom.residue.is_protein))")
sp = parse_selection('!protein')
eq(sp.source, "(not atom.residue.is_protein)")
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:9,代码来源:test_selection.py
示例5: test_range
def test_range():
eq(parse_selection('resSeq 1 to 10').astnode, pnode('1 <= atom.residue.resSeq <= 10'))
sp = parse_selection('resSeq 5 to 6')
for a in tt.atoms:
assert sp.expr(a)
sp = parse_selection('resSeq 7 to 8')
for a in tt.atoms:
assert not sp.expr(a)
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:9,代码来源:test_selection.py
示例6: test_values
def test_values():
sp = parse_selection("resid 4")
eq(sp.source, "(atom.residue.index == 4)")
sp = parse_selection("resid > 4")
eq(sp.source, "(atom.residue.index > 4)")
sp = parse_selection("resid gt 4")
eq(sp.source, "(atom.residue.index > 4)")
sp = parse_selection("resid 5 to 8")
eq(sp.source, "(5 <= atom.residue.index <= 8)")
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:12,代码来源:test_selection.py
示例7: test_binary_1
def test_binary_1():
sp = parse_selection('resname "ALA"')
assert sp.expr(tt.atom(0))
assert sp.expr(tt.atom(1))
sp = parse_selection('mass > 2')
assert sp.expr(tt.atom(0))
assert not sp.expr(tt.atom(1))
assert sp.expr(tt.atom(2))
sp = parse_selection('name ne O')
assert sp.expr(tt.atom(0))
assert not sp.expr(tt.atom(2))
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:13,代码来源:test_selection.py
示例8: test_quotes
def test_quotes():
should_be = "((atom.name == 'CA') and (atom.residue.name == 'ALA'))"
sp = parse_selection("name CA and resname ALA")
eq(sp.source, should_be)
assert sp.expr(tt.atom(0))
sp = parse_selection('name "CA" and resname ALA')
eq(sp.source, should_be)
assert sp.expr(tt.atom(0))
sp = parse_selection("name 'CA' and resname ALA")
eq(sp.source, should_be)
assert sp.expr(tt.atom(0))
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:14,代码来源:test_selection.py
示例9: test_unary_1
def test_unary_1():
eq(parse_selection('all').astnode, pnode('True'))
eq(parse_selection('everything').astnode, pnode('True'))
eq(parse_selection('none').astnode, pnode('False'))
eq(parse_selection('nothing').astnode, pnode('False'))
# eq(parse_selection('nucleic').astnode, pnode('atom.residue.is_nucleic'))
# eq(parse_selection('is_nucleic').astnode, pnode('atom.residue.is_nucleic'))
eq(parse_selection('protein').astnode, pnode('atom.residue.is_protein'))
eq(parse_selection('is_protein').astnode, pnode('atom.residue.is_protein'))
eq(parse_selection('water').astnode, pnode('atom.residue.is_water'))
eq(parse_selection('is_water').astnode, pnode('atom.residue.is_water'))
eq(parse_selection('waters').astnode, pnode('atom.residue.is_water'))
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:12,代码来源:test_selection.py
示例10: select
def select(self, selection_string):
"""Execute a selection against the topology
Parameters
----------
selection_string : str
An expression in the MDTraj atom selection DSL
Examples
--------
>>> topology.select('name O and water')
array([1, 3, 5, 10, ...])
Returns
-------
indices : np.ndarray, dtype=int, ndim=1
Array of the indices of the atoms matching the selection expression.
See Also
--------
select_expression, mdtraj.core.selection.parse_selection
"""
filter_func = parse_selection(selection_string).expr
indices = np.array([a.index for a in self.atoms if filter_func(a)])
return indices
开发者ID:cing,项目名称:mdtraj,代码行数:26,代码来源:topology.py
示例11: test_unary_3
def test_unary_3():
sp = parse_selection('protein or water')
for a in tt.atoms:
assert sp.expr(a)
sp = parse_selection('protein and water')
for a in tt.atoms:
assert not sp.expr(a)
sp = parse_selection('not (protein and water)')
for a in tt.atoms:
assert sp.expr(a)
sp = parse_selection('not not (protein and water)')
for a in tt.atoms:
assert not sp.expr(a)
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:17,代码来源:test_selection.py
示例12: test_raises2
def test_raises2():
pytest.raises(ValueError, lambda: parse_selection('dog 5'))
pytest.raises(ValueError, lambda: parse_selection('dog == 5'))
pytest.raises(ValueError, lambda: parse_selection('dog frog'))
pytest.raises(ValueError, lambda: parse_selection('not dog'))
pytest.raises(ValueError, lambda: parse_selection('protein or dog'))
pytest.raises(ValueError, lambda: parse_selection('dog 1 to 5'))
pytest.raises(ValueError, lambda: parse_selection('dog'))
开发者ID:dr-nate,项目名称:mdtraj,代码行数:8,代码来源:test_selection.py
示例13: select_expression
def select_expression(self, selection_string):
"""Translate a atom selection expression into a pure python expression.
Parameters
----------
selection_string : str
An expression in the MDTraj atom selection DSL
Examples
--------
>>> topology.select_expression('name O and water')
"[atom.index for atom in topology.atoms if ((atom.name == 'O') and atom.residue.is_water)]")
Returns
-------
python_string : str
A string containing a pure python expression, equivalent to the
selection expression.
"""
condition = parse_selection(selection_string).source
fmt_string = "[atom.index for atom in topology.atoms if {condition}]"
return fmt_string.format(condition=condition)
开发者ID:cing,项目名称:mdtraj,代码行数:22,代码来源:topology.py
示例14: test_raises
def test_raises():
pytest.raises(ValueError, lambda: parse_selection('or'))
pytest.raises(ValueError, lambda: parse_selection('a <'))
开发者ID:dr-nate,项目名称:mdtraj,代码行数:3,代码来源:test_selection.py
示例15: test_in
def test_in():
sp = parse_selection("resname ALA ASP GLU")
eq(sp.source, "(atom.residue.name in ['ALA', 'ASP', 'GLU'])")
sp = parse_selection("resid 100 101 102")
eq(sp.source, "(atom.residue.index in [100, 101, 102])")
开发者ID:dr-nate,项目名称:mdtraj,代码行数:6,代码来源:test_selection.py
示例16: test_binary_2
def test_binary_2():
sp = parse_selection('name O and mass > 2')
assert sp.expr(tt.atom(2))
assert not sp.expr(tt.atom(3))
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:4,代码来源:test_selection.py
示例17: test_simple
def test_simple():
sp = parse_selection("protein")
eq(sp.source, "atom.residue.is_protein")
assert sp.expr(tt.atom(0))
assert sp.expr(tt.atom(1))
assert not sp.expr(tt.atom(2))
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:6,代码来源:test_selection.py
示例18: test_alias
def test_alias():
sp = parse_selection("waters")
eq(sp.source, "atom.residue.is_water")
assert sp.expr(tt.atom(3))
assert sp.expr(tt.atom(4))
assert not sp.expr(tt.atom(0))
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:6,代码来源:test_selection.py
示例19: test_re
def test_re():
sp = parse_selection("name =~ 'C.*'")
eq(sp.source, "(re.match('C.*', atom.name) is not None)")
sp = parse_selection("(name =~ 'C.*') and all")
eq(sp.source, "((re.match('C.*', atom.name) is not None) and True)")
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:6,代码来源:test_selection.py
示例20: test_binary_selection_operator
def test_binary_selection_operator():
eq(parse_selection('name < 1').astnode, pnode('atom.name < 1'))
eq(parse_selection('name lt 1').astnode, pnode('atom.name < 1'))
eq(parse_selection('name > 1').astnode, pnode('atom.name > 1'))
eq(parse_selection('name gt 1').astnode, pnode('atom.name > 1'))
eq(parse_selection('name == 1').astnode, pnode('atom.name == 1'))
eq(parse_selection('name eq 1').astnode, pnode('atom.name == 1'))
eq(parse_selection('name != 1').astnode, pnode('atom.name != 1'))
eq(parse_selection('name ne 1').astnode, pnode('atom.name != 1'))
eq(parse_selection('name >= 1').astnode, pnode('atom.name >= 1'))
eq(parse_selection('name ge 1').astnode, pnode('atom.name >= 1'))
eq(parse_selection('name <= 1').astnode, pnode('atom.name <= 1'))
eq(parse_selection('name le 1').astnode, pnode('atom.name <= 1'))
eq(parse_selection('1 == name').astnode, pnode('1 == atom.name'))
eq(parse_selection('1 eq name').astnode, pnode('1 == atom.name'))
开发者ID:ChayaSt,项目名称:mdtraj,代码行数:16,代码来源:test_selection.py
注:本文中的mdtraj.core.selection.parse_selection函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论