http://www.rubor.de/bioinf/
This script has greatly simplified rotation commands. You just call the script in your movie script.
I have included the script, an example movie, and the pdb to run the example movie.
Just remember the commands don't work unless you call movie.py (correctly). Mike Ford pymol-users-requ...@lists.sourceforge.net wrote:
Send PyMOL-users mailing list submissions to pymol-users@lists.sourceforge.net To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/pymol-users or, via email, send a message with subject or body 'help' to pymol-users-requ...@lists.sourceforge.net You can reach the person managing the list at pymol-users-ad...@lists.sourceforge.net When replying, please edit your Subject line so it is more specific than "Re: Contents of PyMOL-users digest..." Today's Topics: 1. Movement in animations (Kelley Moremen) 2. Re: Movement in animations: version 2 (Kelley Moremen) --__--__-- Message: 1 Date: Mon, 31 Mar 2003 16:18:17 -0500 From: Kelley Moremen <more...@arches.uga.edu> To: <pymol-users@lists.sourceforge.net> Subject: [PyMOL] Movement in animations Dear Pymolers: I am sure that this has been beaten to death on this email list but I am having a heck of a time trying to figure out the following: I am trying to make simple animations with movement, rotation, zoom and other simple transitions in Pymol. I have a basic understanding of the simple movement commands as follows: mset 1 x100 movie.roll(20, 50,axis="x") mdo 51: move x,10 mdo 54: turn x, 5; turn y,5 The problem comes when I want to make defined rolls, zooms, or moves that start and stop at specific places. There must be a better way than concatenating a collection of "move x,10" commands. I have seen in several scripts containing the following syntax: for a in range(702,802): cmd.mdo(a,"translate [0.40,-0.5,0],object=lambda2") Could somebody please explain what this syntax means and how to employ it (in detail and in simple terms, if possible, for the many of us out there who don't quite grasp all of the nuances of Pymol and Pythol commandsyntax).When I try to incorporate a similar usage as follows: for a in range(55,70): cmd.mdo(a,"move x,10,object=proteinA") I get an error message that says: for a in range(55,70): cmd.mdo(a,"move x,10,object=proteinA") ^ SyntaxError: invalid syntax I have tried MANY variations on this theme and seem to be stumbling around in the dark. Any help would be greatly appreciated. Thanks, KelleyDr. Kelley Moremen Associate ProfessorComplex Carbohydrate Research Center Department of Biochemistry and Molecular Biology University of Georgia, Athens, GA 30602-7229 --__--__-- Message: 2 Date: Tue, 01 Apr 2003 09:11:45 -0500 Subject: Re: [PyMOL] Movement in animations: version 2 From: Kelley Moremen <more...@arches.uga.edu> To: Kristian Rother <kristian.rot...@charite.de>, <pymol-users@lists.sourceforge.net>, <war...@delanoscientific.com> Dear Kristian, Warren, and other Pymolers: In regard to my previously stated problems in making movement animations in Pymol, I have tried the rTools plug-in before, and I tried it again after your suggestion. In my system they do not work correctly, or at least I have not installed them correctly. I am running both a Mac powerbook and a G4 desktop machine, with either the stand-alone Pymol 10.2 for Mac OSX or Pymol version 0.86 running in unix in the Mac X11 version of the X windows system. As indicated in the install instructions for rTools (version0.5.2) = I have copied the rubor.py and rubor/ directory into the .../modules/pmg_tk/startup directory, modified the path in rConfig.py, created /tmp and /pdb directories (in the startup directory because the install instructions were not clear on this topic), added the relevant line= s to PMGApp.py. I should state that several aspects of the install instructions in regard to the directory structures in my system were unclear.=20 In both versions of Pymol described above, when a simple move command is inserted into a script as follows: mset 1 x100 mvMove 20-40,x,80 movie I get the following error messages: PyMOL>mset 1 x100 PyMOL>mvMove 20-40,x,80 Traceback (most recent call last): File "/Applications/PyMOL/Darwin/modules/pymol/parser.py", line 234, in pars e exec(com2[nest],pymol_names,pymol_names) File "<string>", line 1 mvMove 20-40,x,80 ^ SyntaxError: invalid syntax PyMOL>movie Error: ambiguous command: movie.load movie.rock movie.screw movie.zoom movie.nutate movie.roll movie.tdroll Obviously I have made a mistake in the install process somewhere, and I would appreciate a more detailed description of where and why the plug-in components are supposed to be inserted since I will have to interpret them for my own directory structure rather than a standard Linux install. Regardless of all of the above, there also MUST be an easier way to do the animations that I need. Is there no direct scripting in Pymol that can do the equivalent smooth moves or transitions? The rTools package may be the way to go in the future, especially if it in incorporated in a seemless manner into the next version of Pymol that works in ALL platforms without undue tinkering with scripts and directory structures. In the meantime is there an effective Pymol scripting approach that will work in the platforms that I have described above? Any assistance would be greatly appreciated. Regards, Kelley On 4/1/03 4:43 AM, "Kristian Rother" <kristian.rot...@charite.de> wrote:Am Montag, 31. M=E4rz 2003 23:18 schrieb Kelley Moremen:Dear Pymolers: =20 The problem comes when I want to make defined rolls, zooms, or moves tha=tstart and stop at specific places. There must be a better way than concatenating a collection of "move x,10" commands. I have seen in seve=ral=20 There is a plug-in for PyMOL on http://www.rubor.de/bioinf/ that has been designed to handle that kind of thing. With it installed, you can do the following: =20 mvMove 1-100,z,50 # Zoom over frames 1-100 mvRot 50-110,x,260 # Rotate around x-axis mvSet 1-10,transparency,1.0,0.0 # fade surface in movie # start the whole thing =20 Maybe that helps, =20 Kristian Rother =20Dr. Kelley Moremen=20 Associate Professor Complex Carbohydrate Research Center Department of Biochemistry and Molecular Biology University of Georgia, Athens, GA 30602-7229 Office (706) 542-1705 Fax: (706) 542-1759 Email: more...@arches.uga.edu (send email with large attachments to: more...@bmb.uga.edu) Website: http://bmbiris.bmb.uga.edu/moremen/lab/ --__--__-- _______________________________________________ PyMOL-users mailing list PyMOL-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pymol-users End of PyMOL-users Digest
# # Example script for movie.py for PyMOL # run movie.py # initialize everything to look nice load C:\Program Files\DeLano Scientific\PyMOL\Movies\orient.pdb orient frame 1 mset 1 x3000 # clear the movie.py memory mvClear #create chains of the monomers create chaina, chain a create chainb, chain b color marine, chaina color purple, chainb #define ligand - sticks create ligand, (resi 401,402,411,412) #show sticks, ligand hide lines, ligand #h_add ligand delete orient #show gly where Cys2 is create orange_gly, (chainb and resi 3) color white, orange_gly show sticks, orange_gly hide sticks, orange_gly hide surface, orange_gly orient #show surfaces show surface, chaina show surface, chainb create cys1, (chainb and resn cys) create cys2, (chaina and resn cys) show sticks, cys1 show sticks, cys2 color yellow, cys1 color yellow, cys2 hide sticks, cys1 hide surface, cys1 hide sticks, cys2 hide surface, cys2 create h44, (chainb and (resi 44,46,48)) color teal, h44 hide lines, h44 hide surface, h44 distance d1 = (/h44/1SLT/B/44/NE2), (/ligand/1SLT//412/O4) distance d2 = (/h44/1SLT/B/46/OD1), (/ligand/1SLT//412/O4) distance d3 = (/h44/1SLT/B/48/NH2), (/ligand/1SLT//412/O4) hide labels, d1 hide labels, d2 hide labels, d3 hide dashes, d1 hide dashes, d2 hide dashes, d3 create O6, (chainb and (resi 61,71)) color salmon, O6 hide lines, O6 hide surface, O6 distance d4 = (/ligand/1SLT//412/O6), (/chainb/1SLT/B/71/OE2) distance d5 = (/ligand/1SLT//412/O6), (/chainb/1SLT/B/61/ND2) hide labels, d4 hide dashes, d4 hide labels, d5 hide dashes, d5 distance d6 = (/h44/1SLT/B/48/NH1), (/ligand/1SLT//411/O3) distance d7 = (/chainb/1SLT/B/73/NH2), (/ligand/1SLT//411/O3) distance d8 = (/O6/1SLT/B/71/OE2), (/ligand/1SLT//411/O3) hide labels, d6 hide dashes, d6 hide labels, d7 hide dashes, d7 hide labels, d8 hide dashes, d8 distance d9 = (/chainb/1SLT/B/73/NH2), (/ligand/1SLT//411/O7) hide labels, d9 hide dashes, d9 #orient yourself after making objects orient # clear the movie.py memory mvClear #store orientation matrix to recall at end of movie mmatrix store # fade in and fade out mvSet 1-100,transparency,1.0,0.15 mvSet 751-800,transparency,0.15,1.0 mvSinrot 1-250,x,-340 mvSinrot 251-750,x,355 mvSinmove 251-550,z,25 mvSinrot 751-1050,x,360 mvSinmove 1051-1250,z,15 mvSinrot 1051-1250,x,35 mvSinrot 1051-1250,y,35 mvSinrot 1251-1500,x,-55 mvSinrot 1251-1500,y,-75 mvSinmove 1501-1800,z,2 mvCmd 180-250,cmd.do('show sticks, ligand') mstop # start the movie movie mappend 250:color yellow, (chainb and resn cys) mappend 250:color yellow, (chaina and resn cys) mappend 250:color white, orange_gly mappend 751:show sticks, orange_gly mappend 1049:zoom chainb mappend 751:show sticks, cys1 mappend 751:show sticks, cys2 mappend 1051: hide sticks, cys1 mappend 1051: hide sticks, cys2 mappend 1051: hide sticks, orange_gly mappend 1200: show sticks, h44 mappend 1240: show dashes, d1 mappend 1240: show dashes, d2 mappend 1240: show dashes, d3 mappend 1350: show stick, O6 mappend 1400: show dashes, d4 mappend 1400: show dashes, d5 mappend 1500: show sticks, d6 mappend 1500: show dashes, d6 mappend 1500: show sticks, d7 mappend 1500: show dashes, d7 mappend 1500: show sticks, d8 mappend 1500: show dashes, d8 mappend 1550: show sticks, d9 mappend 1550: show dashes, d9
orient.pdb
Description: Protein Databank data
""" --- Movie: easy movie scripting in PyMOL --- Script : Movie Author : Kristian Rother Date : 9.8.2002 Version : 0.2 Contact : kristian.rot...@berlin.de Copyright (C) 2002 K. Rother Movie is an extension for the PyMOL Molecular Graphics System. It provides lots of new commands for PyMOL: movie - plays a movie mvClear - see descriptions below mvMove mvRot mvSet mvCmd mvSinrot mvSinmove mvSinset Translation and rotation commands are assigned to frame ranges, resulting in a much shorter scripting of animations. Additionaly, smooth movements are enabled by the mvSinxxx commands. See example scripts. Usage: run from PyMOL or .pymolrc Literature: DeLano, W.L. The PyMOL Molecular Graphics System (2002) DeLano Scientific, San Carlos, CA, USA. http://www.pymol.org ---------------------------------------------------------------------- Movie for PyMOL is an OPEN SOURCE program distributed under the "Python" license. Please see the LICENSE file for additional information. ---------------------------------------------------------------------- """ class mvMovie: def __init__(self): """Permanently stores what should appear in the movie.""" self.movie=[] self.backmovie=[] mv = mvMovie() # import some python modules from pymol import cmd import string from math import * # --------------------------------------------------------- # internal stuff def parseFrames(frames): """Returns a tuple of first and last frame from a string like 1-10; 10; 99-200; 5; """ firstFrame=1 lastFrame=1 if string.find(frames,"-")>=0: # range info given t=string.split(frames,"-") firstFrame=int(t[0]) lastFrame=int(t[1]) else: # no range specified firstFrame=int(frames) lastFrame=firstFrame return (firstFrame,lastFrame) # ------------------------------------- # here come the commands def mvClear(): """Deletes the movie.""" mv.movie=[] mv.backmovie=[] cmd.mclear() cmd.frame(1) def mvRot(frames="1",axis="z",totalAngle=360): """ mvRot(frames,axis,totalAngle) - rotates the environment over the given frame range, the rotation angle summing up to the totalAngle given. """ frameRange = parseFrames(frames) nFrames = frameRange[1]-frameRange[0]+1 angleIncrement = float(totalAngle)/(1.0*nFrames) i=frameRange[0] while i<=frameRange[1]: mv.movie.append((i,"turn %s,%f"%(axis,angleIncrement))) i+=1 def mvMove(frames="1",axis="x",totalDistance="0"): """ mvMove(frames,axis,totalDistance) - moves the environment over the given frame range, the moved distance summing up to the totalDistance given. """ frameRange = parseFrames(frames) nFrames = frameRange[1]-frameRange[0]+1 distanceIncrement = float(totalDistance)/(1.0*nFrames) i=frameRange[0] while i<=frameRange[1]: mv.movie.append((i,"move %s,%f"%(axis,distanceIncrement))) i+=1 def mvCmd(frames="1",command=""): """ mvCmd(frames,command) - executes a command in all frames specified. """ frameRange = parseFrames(frames) nFrames = frameRange[1]-frameRange[0]+1 i=frameRange[0] while i<=frameRange[1]: mv.movie.append((i,command)) i+=1 def mvSet(frames="1",variable="",startValue="0.0",endValue="1.0"): """ mvSet(frames,variable,startValue,endValue) - lets a variable go through a gradient in the specified frame range. Great for fading effects! """ frameRange = parseFrames(frames) nFrames = frameRange[1]-frameRange[0]+1 stV=float(startValue) endV=float(endValue) increment = (endV-stV)/(1.0*nFrames) i=frameRange[0] j=0 while i<=frameRange[1]: mv.movie.append((i,"set %s,%f"%(variable,stV+j*increment))) j+=1 i+=1 def mvSinrot(frames="1",axis="z",totalAngle=360): """ mvSinrot(frames,axis,totalAngle) - rotates the environment over the given frame range, the angles summing up to the totalAngle given. The incremental steps will be calculated with the sinus function to make the rotation smoother. """ frameRange = parseFrames(frames) nFrames = frameRange[1]-frameRange[0]+1 angle = float(totalAngle) arcIncrement=pi/(1.0*nFrames) i=frameRange[0] j=1 prev=1.0 while i<=frameRange[1]: arc=cos(j*arcIncrement) # print arc," * ",abs(arc-prev)*0.5 angleIncrement=angle*abs(arc-prev)*0.5 mv.movie.append((i,"turn %s,%f"%(axis,angleIncrement))) prev=arc j+=1 i+=1 def mvSinmove(frames="1",axis="x",totalDistance="0"): """ mvSinmove(frames,axis,totalDistance) - moves the environment over the given frame range, the moved distance summing up to the totalDistance given. The incremental steps will be calculated with the sinus function to make the movement smoother. """ frameRange = parseFrames(frames) nFrames = frameRange[1]-frameRange[0]+1 dist = float(totalDistance) arcIncrement=pi/(1.0*nFrames) i=frameRange[0] j=1 prev=1.0 while i<=frameRange[1]: arc=cos(j*arcIncrement) # print arc," * ",abs(arc-prev)*0.5 distanceIncrement=dist*abs(arc-prev)*0.5 mv.movie.append((i,"move %s,%f"%(axis,distanceIncrement))) prev=arc j+=1 i+=1 def mvSinset(frames="1",variable="",startValue="0.0",endValue="1.0"): """ mvSet(frames,variable,startValue,endValue) - lets a variable go through a gradient in the specified frame range. Great for fading effects! The incremental steps will be calculated with the sinus function to make the movement smoother. """ frameRange = parseFrames(frames) nFrames = frameRange[1]-frameRange[0]+1 arcIncrement=pi/(1.0*nFrames) stV=float(startValue) endV=float(endValue) i=frameRange[0] j=1 prev=1.0 sum=0.0 while i<=frameRange[1]: arc=cos(j*arcIncrement) increment=(endV-stV)*abs(arc-prev)*0.5 sum+=increment mv.movie.append((i,"set %s,%f"%(variable,stV+sum))) prev=arc j+=1 i+=1 def mvForward(): """Creates the movie and plays it.""" # find out the frame range nFrames=1 for m in mv.movie: if m[0]>nFrames: nFrames=m[0] # Specify movie length print "creating movie with %i frames."%(nFrames) cmd.mset("1 x%i"%(nFrames)) # create empty frame-2do-lists do=["zero frame is unused"] for i in range(nFrames): do.append("") # push all movie commands to the 2do-list for m in mv.movie: do[m[0]]+=m[1]+";" # now let action happen in the frames i=1 while i<=nFrames: cmd.mdo(i,do[i]) i+=1 # start the movie cmd.mplay() def mvBackward(): # not implemented yet return # ---------------------------------------------- def fwd(amount): for i in range(int(amount)): mvMovie.append("move z,5") backmovie.append("move z,-5") # ----------------------------------------------------------------- # define a set of new PyMOL commands for creation of movies # this part will be executed first upon the 'run movie.py' command from within PyMOL. cmd.extend('movie',mvForward) # cmd.extend('movie_back',mvBackward) cmd.extend('mvClear',mvClear) cmd.extend('mvRot',mvRot) cmd.extend('mvMove',mvMove) cmd.extend('mvCmd',mvCmd) cmd.extend('mvSet',mvSet) cmd.extend('mvSinrot',mvSinrot) cmd.extend('mvSinmove',mvSinmove) cmd.extend('mvSinset',mvSinset)