Skip to content

Commit

Permalink
Add tests: minimizing
Browse files Browse the repository at this point in the history
  • Loading branch information
speleo3 committed Jul 31, 2023
1 parent 4bdad7d commit 1e5e07d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ testpaths = ["tests"]
markers = [
"exe: test requires third-party executable",
"web: test requires internet access",
"rdkit: test requires RDKit",
]
filterwarnings = [
'ignore:.*xdrlib.*:DeprecationWarning:mdtraj.formats',
Expand Down
2 changes: 2 additions & 0 deletions tests/test_mcsalign.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import psico.mcsalign
from pymol import cmd
import pytest


@pytest.mark.rdkit
def test_mcsalign():
cmd.reinitialize()
cmd.fragment("his")
Expand Down
43 changes: 43 additions & 0 deletions tests/test_minimizing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import psico.minimizing
from pymol import cmd
import pytest
from pytest import approx


def test_get_fixed_indices():
cmd.reinitialize()
cmd.fragment("gly", "m1")
cmd.flag("fix", "elem N+O")
r = psico.minimizing.get_fixed_indices("m1", 1, _self=cmd)
assert r == [0, 3]
r = psico.minimizing.get_fixed_indices("m1 & elem C+O", 1, _self=cmd)
assert r == [2]


def test_load_or_update():
cmd.reinitialize()
cmd.fragment("gly", "m1")
molstr = cmd.get_str("mol", "m1")
psico.minimizing.load_or_update(molstr, "m2", "m1", 1, _self=cmd)
assert cmd.rms_cur("m2", "m1", matchmaker=-1) == approx(0.0)
cmd.alter_state(1, "m1", "(x,y,z) = (x*2, y*2, z*2)")
assert cmd.rms("m2", "m1", matchmaker=-1) > 1
psico.minimizing.load_or_update(molstr, "", "m1", 1, _self=cmd)
assert cmd.get_names() == ["m1", "m2"]
assert cmd.rms("m2", "m1", matchmaker=-1) == approx(0.0)


# def minimize_ob(selection='enabled', state=-1, ff='UFF', nsteps=500,


@pytest.mark.rdkit
def test_minimize_rdkit():
cmd.reinitialize()
cmd.fab("ACD", "m1")
cmd.copy("m2", "m1")
psico.minimizing.minimize_rdkit("m2", nsteps=100)
r = cmd.rms("m2", "m1")
assert r == approx(0.7118, abs=1e-2)


# def clean_ob(selection, present='', state=-1, fix='', restrain='',

0 comments on commit 1e5e07d

Please sign in to comment.