1
$\begingroup$

I have a sequence of pdb files which I want to load in pymol window so that it gives an impression of a video. I am using cmd.load function in a loop and deleting the loaded file in the next step. But for some reason the window pauses until all iteration steps have been completed and giving nothing else in the end. I know that the files are loaded because without the “delete” line I can find all pdbs overlapped on one another. Any suggestions? Thanks and regards

def trial(pathname, num_files):
    for i in range(num_files):
        filename = (pathname + str(i + 1)  +'.pdb')
        print(filename)
        # print(i)
        cmd.load(filename, (i+1))
        cmd.hide()
$\endgroup$
1
  • $\begingroup$ pymolwiki.org/index.php/Frame is the way —you are after moviemaking which is rich in tutorials, so I am just leaving the link here. Hopefully a tutorial about working with Frames with answer your Q. $\endgroup$ Commented Dec 7, 2022 at 15:05

1 Answer 1

0
$\begingroup$

try:


import time

def trial(pathname, num_files):
    for i in range(num_files):
        filename = (pathname + str(i + 1)  +'.pdb')
        print(filename)
        # print(i)
        cmd.load(filename, (i+1))
        
        cmd.sync(timeout=2000 , poll=2.0) ### ***

        time.sleep(4)

        cmd.hide()

***See cmd.sync(timeout: float = 1.0, poll: float = 0.05)

sync is an API-only function which waits until all current commands have been executed before returning. A timeout can be used to insure that this command eventually returns.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.