How to use the mdtraj.core.selection.parse_selection function in mdtraj

To help you get started, we’ve selected a few mdtraj examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mdtraj / mdtraj / tests / test_selection.py View on Github external
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)
github mdtraj / mdtraj / tests / test_selection.py View on Github external
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'))
github mdtraj / mdtraj / tests / test_selection.py View on Github external
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)
github mdtraj / mdtraj / tests / test_selection.py View on Github external
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)
github mdtraj / mdtraj / tests / test_selection.py View on Github external
    pytest.raises(ValueError, lambda: parse_selection('dog 1 to 5'))
    pytest.raises(ValueError, lambda: parse_selection('dog'))
github mdtraj / mdtraj / tests / test_selection.py View on Github external
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])")
github mdtraj / mdtraj / tests / test_selection.py View on Github external
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'))
github mdtraj / mdtraj / tests / test_selection.py View on Github external
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)
github mdtraj / mdtraj / tests / test_selection.py View on Github external
def test_binary_1():
    sp = parse_selection('resname "ALA"')
    assert sp.expr(tt.atom(0))
    assert sp.expr(tt.atom(1))

    sp = parse_selection('rescode A')
    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))
github mdtraj / mdtraj / tests / test_selection.py View on Github external
def test_element():
    sp = parse_selection("element 'O'")
    eq(sp.source, "(atom.element.symbol == 'O')")

    sp = parse_selection("mass 5.5 to 12.3")
    eq(sp.astnode, pnode("(5.5 <= atom.element.mass <= 12.3)"))