Re: [PyMOL] How to tell from within a script if a plugin is loaded?

2016-02-19 Thread Sampson, Jared M.
Hi Thomas -

Thanks for the clarification on cmd.extend() and the difference between how 
commands and functions are made available. I hadn't thought to just add the 
function to cmd directly.  This will come in handy!

Cheers,
Jared

--
Jared Sampson
Columbia University

On Feb 18, 2016, at 1:14 PM, Thomas Holder 
> wrote:

Hi Jared,

The plugin system isn't really tuned for API extension. As Tsjerk pointed out, 
cmd.extend only registers a command, not a cmd. function. Also, scripts 
which are installed as plugins get loaded asynchronously from the external GUI. 
I suggest you do the following:

1) Inside your plugin (Python module), do:

from pymol import cmd
def my_func(): ...
cmd.my_func = my_func
cmd.extend('my_func', my_func)

2) The plugin's __init_plugin__ (or __init__) function should only be 
responsible for adding Plugin menu entries, not for anything else.

3) Inside your test file, do:

from pymol import cmd
import pmg_tk.startup.my_plugin
# (now cmd.my_func should be available immediately)

Hope that helps.

Cheers,
 Thomas

On 17 Feb 2016, at 11:32, Sampson, Jared M. 
> wrote:

Hi Tsjerk -

Thanks for the suggestion.  I tried this with:

import time
from pymol import cmd
while not hasattr(cmd, 'my_func'):
time.sleep(0.5)

Unfortunately that also causes everything to hang.  I think I might need to do 
this in a separate thread.  I'll have to look into how to do that.

Cheers,
Jared

--
Jared Sampson
Columbia University

On Feb 16, 2016, at 2:47 PM, Tsjerk Wassenaar 
> wrote:

Hi Jared,

The extend function must set an attribute "my_func" on cmd. You can test for 
that with hasattr:

while not hasattr(cmd, "my_func"):
   # wait some more

Hope it helps,

Tsjerk

On Feb 16, 2016 20:07, "Sampson, Jared M." 
> wrote:
To my previous message I should add that it works fine if I do:

```
import pmg_tk.startup.my_plugin as mp
mp.my_func()
```

but I'd like to use the `cmd.my_func()` version, so that `my_func` will work in 
a .pml script.

>From `help(cmd)` I found `cmd.kw_list`, but this apparently doesn't include 
>"extended" functions, even after the function is loaded.

```
PyMOL>print 'ray' in cmd.kw_list
True
PyMOL>print 'my_func' in cmd.kw_list
False
```

Looking forward to any suggestions.  Thanks!

Cheers,
Jared

--
Jared Sampson
Columbia University

On Feb 16, 2016, at 1:50 PM, Sampson, Jared M. 
> wrote:

Hi PyMOLers -

Maybe some more experienced users/developers can help me out here.  I'm trying 
to write some automated test scripts for the plugin I'm writing, but the test 
functions end up running before the plugin is loaded.  Is there a way to tell 
if a plugin has been loaded from within a .pml or .py script?  For example, if 
the plugin makes commands available via `cmd.extend('my_func', my_func)`, how 
can I run `cmd.myfunc()` from a script and not have it execute before the 
plugin finishes loading?

I've tried something like this:

```
import time
from pymol import cmd
loaded = 0
while not loaded:
   try:
   cmd.my_func()  # if it's loaded no exception will be raised
   loaded = 1
   except:
   time.sleep(0.5)
```

But this just hangs, as apparently `time.sleep()` halts the execution of all 
threads, so the plugin won't ever be loaded.

Thanks,
Jared

--
Jared Sampson
Columbia University

--
Thomas Holder
PyMOL Principal Developer
Schrödinger, Inc.

--
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151=/4140___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

[PyMOL] maps and volumes -- transforming to match molecule

2016-02-19 Thread McGrath, Connor (NIH/NCI) [C]
Hello folks:

I have loaded a series of small molecules and have loaded maps of quantum 
properties from another source.
I want to align the molecules to a "base" scaffold, which I can do. What I am 
having difficulty with is the subsequent
Rotation/translation of the map object for given molecule. The matrix_copy 
approach does not appear to have any effect,
although it does not generate an error.
Someone must have come across this problem. I have seen requests similar to 
mine as far back as 2004, but no resolution that I can find.

Of course, any help would be greatly appreciated

Connor F. McGrath, Ph.D.

Manager, Computational Drug Development Group
Frederick National Laboratory for Cancer Research
CDDG, DTP, DCTD (Leidos Biomedical contract)

mcgrathcon...@mail.nih.gov


--
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151=/4140___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net