You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I start Vmd and type gopython and then load a file by:
molid = molecule.load('parm7', '1BIQ_solvate.top', 'crdbox', 'prod_imaged.mdcrd')
tf = molecule.numframes(molid)
print(tf)
This will give the number of total frames of 300, it works.
However, when I put the same code in a python file like:
from vmd import *
mid = molecule.load('parm7', '1BIQ_solvate.top', 'crdbox', 'prod_imaged.mdcrd')
tf = molecule.numframes(mid)
print('Loaded mid is: ', mid)
print('Total number frames is', tf)
The total number of frames is 0.
Do you have any idea of what is wrong here?
Thanks.
Have you looked at the docs? What you are doing in VMD depends on behavior described in the user guide, where molecule.load in VMD 1.9.3 (or I think 1.9.4) will basically wait until all frames are loaded before returning. I think in the rejiggering to get this to work for python3, this side effect disappeared.
I just want to load the topo and mdcrd file, then get the total number of frames, and do a for loop base on the frames.
I add a sleep(20) after the load function, but it does not work at all.
Activity
jvermaas commentedon Sep 30, 2022
Have you looked at the docs? What you are doing in VMD depends on behavior described in the user guide, where
molecule.loadin VMD 1.9.3 (or I think 1.9.4) will basically wait until all frames are loaded before returning. I think in the rejiggering to get this to work for python3, this side effect disappeared.sjzhao commentedon Oct 2, 2022
I just want to load the topo and mdcrd file, then get the total number of frames, and do a for loop base on the frames.
I add a sleep(20) after the load function, but it does not work at all.
sjzhao commentedon Oct 3, 2022
This is the example from the docs:
from vmd import molecule
molid = molecule.load("parm7", "system.prmtop")
molecule.read(molid, "netcdf", "simulation.nc", skip=5, waitfor=-1)
last_frame = molecule.numframes - 1
molecule.write(molid, "pdb", "last_frame.pdb", first=last_frame)
However, molecule.numframes is a function which require molecule id.
I did molecule.numframes(molid), which return 0