Hi, Warren-
On Mon, 2002-01-14 at 01:53, Warren L. DeLano wrote:
> > First of all, Warren, thanks for an impressive program.  A couple of
> > questions as I begin to get into it:
> 
> Thanks for the kind words!
> 
> > I'm probably missing something obvious, but I don't see it in the
> > documentation.  Is it possible to send arguments to scripts (either the
> > .pml script or Python scripts)?  It would seem like that would make them
> > much more versatile.
> 
> Hmm...script arguments aren't exactly present, but there is a more
> powerful solution: use Python functions to extend the PyMOL command
> language.  Any functions defined in Python script can then be called from
> PyMOL (interatively or otherwise)
> 
> By the way, it is important to understand the disntinction between PyMOL's
> scripts and Python programs you run your PyMOL -- PyMOL scripts are
> basically just a linear series of PyMOL commands.  For anything more
> sophisticated, use straight Python.
Understood.  BTW, one way to get part of the benefit of arguments to
PyMOL scripts is to use named selections and to load molecules into
specific object names (like say, "ligand").  Then your scripts can work
on the standard names and be more widely reusable.  But I take your
point about Python being much more versatile.
> 
> To achieve what you're looking for, create "test.py" with the following
> function (foo here for example)
> 
> from pymol import cmd
> def foo(arg1,arg2):
>    print arg1,arg2
> cmd.extend("foo",foo)
> 
> Once you run the above script in PyMOL "run test.py", you will then be
> able to type "foo 1,2" to invoke the foo command with arguments.
Perfect.  That is what I needed to know.
> 
> > Second question:  How would one write a Python script which went through
> > each frame of a movie and modified some aspect of the structure (like
> > the molecule name for example)?
> 
> There are a couple of ways to do this.  One would be to pull the object
> into the Python layer (cmd.get_model), change it, and then load in back in
> to PyMOL (cmd.load_model).  The advantage of this approach is that you can
> directly manipulate the molecule, bond, and atom objects.  The
> disadvantage is poor performance for large molecules (probably fine for
> organics though).
> 
> Other approaches vary depending on what you want to change.  Titles can be
> changed with "set_title", (which revealed a couple of minor bugs when I
> tried it just now, arrgh).  Atomic properities can be modified using
> "alter".  Atoms and bonds can be moved, created, or deleted using the
> editor functions, but which may not yet me sufficiently documented.
> 
> No matter what you're changing, you'll need to apply changes to molecular
> "states".  Just use a 1-based loop over each state, and pass this integer
> into the state argument (where required).  Example:
> 
> dock_score = [ -24.0, -9.5, -2.0 ]
> obj = "foo1" # your object name
> for a in xrange(1,4):
>    cmd.set_title(obj,a,str(dock_score[a-1]))
Exactly what I wanted.  Thanks.
Scott




Reply via email to