schrodinger / pymol-open-source

Open-source foundation of the user-sponsored PyMOL molecular visualization system.
https://pymol.org/
Other
1.2k stars 281 forks source link

cmd.load_model discrete argument unexpected behavior #212

Closed speleo3 closed 2 years ago

speleo3 commented 2 years ago

I would expect the following test to pass:

from pymol import cmd
cmd.fragment("gly")
model = cmd.get_model()

cmd.load_model(model, "m1", discrete=0, state=1)
cmd.load_model(model, "m2", discrete=1, state=1)
cmd.load_model(model, "m3", discrete=-1, state=1)

assert cmd.count_discrete("m1") == 0
assert cmd.count_discrete("m2") == 1
assert cmd.count_discrete("m3") == 1

cmd.load_model(model, "m1", discrete=-1, state=2)
cmd.load_model(model, "m2", discrete=-1, state=2)
cmd.load_model(model, "m3", discrete=-1, state=2)

assert cmd.count_discrete("m1") == 0
assert cmd.count_discrete("m2") == 1
assert cmd.count_discrete("m3") == 1

cmd.load_model(model, "m1", discrete=0, state=3)
cmd.load_model(model, "m2", discrete=1, state=3)
cmd.load_model(model, "m3", discrete=1, state=3)

assert cmd.count_discrete("m1") == 0
assert cmd.count_discrete("m2") == 1
assert cmd.count_discrete("m3") == 1

cmd.load_model(model, "m1", discrete=1, state=4)
cmd.load_model(model, "m2", discrete=0, state=4)
cmd.load_model(model, "m3", discrete=0, state=4)

assert cmd.count_discrete("m1") == 1
assert cmd.count_discrete("m2") == 0
assert cmd.count_discrete("m3") == 0
speleo3 commented 2 years ago

I think this pymol-users message is related: Loading chempy objects into PyMOL 2.4.0