Closed wrmartin closed 1 year ago
Hi, exporting the cif file is done using PyMOL, so if it crashes doing that I cannot really help you out. To confirm this can you please try to export your model yourself and see if it still doesn't work? "File > Export Molecule" and select all models.
You're correct, it does still crash. Is there a way to pull the trajectory length into main_window.py? A simple fix is the following:
file_pth = os.path.join(self.temp_dir.name, obj_name + ".cif")
self.log("Exporting pymol object {} in cif format ({})".format(obj_name, file_pth))
cifdata=[]
for i in range(1, len_traj + 1):
file_pth = os.path.join(self.temp_dir.name, obj_name + "_" + str(i) + ".cif")
cmd.save(filename=file_pth, selection=obj_name, state=i)
tmpcif=open(file_pth, "r")
if i == 1:
for line in tmpcif:
cifdata.append(line)
else:
for line in tmpcif:
tmpline=line.split()
if tmpline[0] == 'ATOM':
cifdata.append(line)
os.remove(file_pth)
file_pth = os.path.join(self.temp_dir.name, obj_name + ".cif")
with open('{}'.format(file_pth), 'w') as f:
for line in cifdata:
f.write(f"{line}\n")
self.log("Exporting done")
len_traj can be changed manually, but it would be better if that could be pulled in some way from pymol.
Yes thats totally doable, with cmd.count_states(obj_name)
, in PyMOL each model of the trajectory is called state. Taking this number and assigning it to len_traj
should do the trick, even though I don't really like the fact that it has to write a lot of files to do that, but it seems that it is the only option here.
Can you be so kind to open pull request with this fix so I can merge it into the codebase? Otherwise I will do it myself, no problem.
Thanks again!
I've not done that before, so hopefully I did it correctly. I also didn't like writing all of those files, but it does clean up after itself at least.
When attempting to run the plugin on a 10,000 frame trajectory (300 residue protein), the everything bombs out and throws a segmentation fault after roughly 30 seconds. It appears to be failing when attempting to generate the .cif file. The occurs both when using the webserver and when running locally. A 1000 frame trajectory does load just fine, but it would be nice to be able to use it for much larger trajectories.