vmd-python icon indicating copy to clipboard operation
vmd-python copied to clipboard

number of frames is 0

Open sjzhao opened this issue 3 years ago • 3 comments

Hi Robin,

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.

sjzhao avatar Sep 30 '22 20:09 sjzhao

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.

jvermaas avatar Sep 30 '22 20:09 jvermaas

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 avatar Oct 02 '22 19:10 sjzhao

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

sjzhao avatar Oct 03 '22 15:10 sjzhao