I think he means for you to have a "Load" button as part of your
plugin. That button would first record the path to the file and then
call through to cmd.load().
Perhaps what Ron needs to do is not use the cmd.load() function but
use his own file reading procedure. The lines containing coordinates
could be extracted from the file (by recognizing them with a
regexp) and
passed to the cmd.read_pdbstr() function. The CGO commands could be
read separately. Then there is no need to worry about where
cmd.load()
thinks file is.
Rob, thanks for the response. I'm currently using a variation of
what you wrote above. It's just that the primary "use case" in my
lab is to load multiple structures at once when starting pymol on the
command line.
$ pymol 1AAA.pdb 1AAB.pdb 1AAC.pdb or, more frequently
$ pymol *.pdb
I then want the user to be able to click on my plugin in the Plugin
menu and have it run without the need for a GUI asking where to find
the files (so I can reread them for the extra info I need). In the
example above, there's no problem: The files are all located in the
current working directory so I know where to find them. I start
having problems when users do things as below:
$ pymol ../1AAD.pdb ~/jsmith/1AAE.pdb ./structures/1AAF.pdb
When PyMOL loads these structures, it drops the path information to
create the object name and none of these structures are in the
current working directory. Hence, my plugin can't find the files.
For the time being, I'm going to instruct users in my lab that the
structures they load must be in the same directory as the one from
which they execute pymol. At some point I will (hopefully) release
the plugin to the public. If I see that it's being used, I'll
consider adding some preprocessing step that checks to see if the
files can be found and if not, maybe execute a restricted "find"
command up and down one or two directories or pop up a GUI that asks
users to specify where to find the files (that couldn't be found).
I don't want to beat/flog a dead horse here, but other suggestions
are always welcome.
Best,
-Ron