I'm writing a python script to run pymol. I want to check if a file is already loaded so I can avoid loading the same molecule again and again.
here's a pseudocode of my idea:
if (file is already loaded on pymol):
skip to next step
else:
fetch [filename]
[next step]
how can i implement the first line in python?
I think something along the line of
should work, see https://pymolwiki.org/index.php/Get_Names
Regarding loading file from onsite [ think you could apply same logic to
pymol.cmd.fetch] I devised the strategy below:First I start launching pymol with modified
cmd.loadandcmd.deletefrom this file :then from pymol GUI I can launch my script [ menu : File --> Run Script ], that tries to load same pdb three time from different locations (copies of the file are there):
output printed on pymole console while first molecule is shown on maainwindow:
Clearly my first script does not allow pymol to load different states of the same molecule, each molecule is identified by its filename (i.e. 2x3y.pdb)