You's guys!

Spurred into action by the flurry of movie questions, I thought I'd chime in. Well, I kept touching this up so it never quite seemed done, but here is a version that does some nice movie stuff.

Basically, I've modified the camera_view routine that Laurence Pearl submitted not too long ago into the framework of Kristian Rother's very nice movie tools. I also added a sin smoothed version of the camera view travel which starts and finishes the interpolation slowly so you ease into the final viewpoint in a slick kind of way.

Then I wrote another command extension that I've found quite useful for going through your molecule following along the peptide backbone. It basically calculates the carbon alpha to carbon alpha vectors, turns those into view matrices, and passes that to the modified view interpolation I mentioned above. Makes for very nice eye candy even if you aren't going to try to do anything useful with it, but I think it also saves a lot of clicking and has made pymol my map viewer of choice although I haven't yet figured out a good way to do the building in it and I'm sticking with O for now...but if I could fully understand the sculpting stuff that looks very nice in the demo!!

Ok, some explanation is probably in order:
Just to be clear, I didn't write all the stuff in the file I'm attaching.
This file, MasterMovie.py is my modified version of Kristain Rother's movie.py. It also includes a lot of the stuff derived from Laurence Pearl's routines as mentioned. Morri Feldman also inspired a lot of these changes when he was recently in the lab.

I usually run this script as a header when I start up PyMOL and then everything is predefined and then you can use the following commands.

mvViewTravel is essentially from Laurence Pearl's script, but incorporated into the movie.py tools.

usage:
mvViewTravel frames, old_view, new_view

The nice thing here is that now you can combine these motions over prescribed frame ranges with various rocks, rotations, or scene changes at the different stops which are made easy using Kristian Rother's other commands.

mvSinViewTravel frames, old_view, new_view
e.g.
mvSinViewTravel("61-140",old,new)
where old is the 18-element old view matrix, and new the new. Carries out the interpolation over frames 61 to 140. This command is analogous to mvViewTravel, but smoothed. With both of these commands it is impractical to type in a full 18 element view matrix, so I usually run them from scripts. For some reason, no doubt related to my primitive understanding of python, the scripts seem quite particular about how the views are defined, so I usually use something like cmd.get_view() to define a variable with the appropriate view and then hand that off to the mvSinViewTravel routine. Otherwise I seem to invariably run into improper usage of tuples or lists or something. Don't forget to type movie at the end to get your movie assembled. I generally save views in files (I also added a "storeview" command in the attached file which will write out the view and saves a cutting and pasting step, by the way) and then you can load up your active site view or whatever, followed by backing out to the overview of the molecule followed by your next tour point of interest all from your script and make a very nice journey with delays at each point as you like since you just set the frame range explicitly. (I can send sample scripts upon request of these commands in use.) Another way to do it is make a big "for" loop and have all your viewpoints named sequentially, like "view1", "view2", "view3", etc. and have the for loop go through each one at a specified speed. Very simple, very nice!


Then we have my recent favorite, Ribbon Rider! Coming out of the California West, this cowboy makes for an entertaining romp through your structure, if not stomach turning at times depending on how many frames per residue you choose and whether you have a souped up graphics card.
usage:
ribbon_ride("selection", frames_per_step, zoom_buffer, half_slab, frequency)

Again, I generally use it from a script and in that context it seems strangely important that the selection is in quotes and that there is NOT a space between ribbon_ride and the following parentheses.(but maybe that's just me?) Your selection should be something that has alpha carbons (atoms named "CA") since that's what it looks for. The last argument, frequency, tells it to look at each CA atom (frequency=1) or every 2nd, 3rd, 4th, or whatever, so you can get a faster, more direct trip through if you like. The zoom_buffer sets how close up your view is as you go through, and the half_slab is a parameter for controlling the depth of field, if you will. frames_per_step tells how many movie frames to spend between the two views.
Example:
For going residue by residue and looking closely at your maps you might do something like:
ribbon_ride("mymolecule", 20, 35, 7, 1)

Or for a grander overview of, say, a cartoon representation, you might try:
ribbon_ride("mymolecule", 30, 100, 30, 4)

Some nice features: you can pause and restart anywhere in the movie, you can change many display options live and have them persist. Since the view is completely defined when you restart ("mplay") it will pick up right where it was. Type "frame xxx" to jump to frame xxx so you can move easily through the movie. Note that if you load up a map for your entire molecule performance may get a bit bogged down, though still quite smooth and fast on a good machine and graphics card. A little herky, jerky but usable on my iMac. Better yet, you can set roving_detail, 1 and use the roving maps so that it only needs to display the maps locally (nice job Warren!) and you'll get pretty good performance under most any circumstance that way: "set roving_map1_name, my_fofc_map" and "set roving_map1_level, 2.5" , for example. WIth the roving detail on you can also get H bonds and nice sticks and spheres in that region. Note that the roving detail works great for live viewing of the movie, but when I try mpng out segments of the movie the roving detail is static. Unless Warren corrects me otherwise, if you want to do a whole molecule with maps and everything, you're probably going to have to turn on the full map etc and let it go overnight. As another warning, the movies assembled can be very long...with whatever "frames_per_step" you choose multiplied by every CA in the object you select, you can easily have 10's of thousand of frames. Happily, pymol seems to happily handle this happiness, but it's just a warning before you issue those mpng commands!

Finally, I just added a little code to allow you to visit peaks in a map using a CNS output peaks file (pdb format, but atoms are named "PEAK").
Usage: peak_tour selection, zoom_buffer

e.g.
load pdb/fofc_positive_peaks.pdb, pos
peak_tour pos, 10
movie
mplay

and you should now be watching the first peak as it does a 360 degree around y and then 360 around x, then moves on to the next peak. Caveats & comments: your pdb file should have atoms named "PEAK" in it (this is the standard CNS output). or edit the attached file to look for whatever it is your atoms are named. You can also change the rotation and stuff that happens at each site by editing the attached file...you should be able to see where it's happening around the "lit1", "lit2" definitions and things.


Closing remarks (finally, you say!)

I'd like to reiterate how much this was based on the excellent tools provided by Kristian Rother and the view interpolation put together by Laurence Pearl. I mentioned something like this viewpoint to viewpoint idea to Warren about a year ago, but as my Python was non-existent and my math very rusty, I'm glad Dr. Pearl got around to this. I hope my modifications and extensions prove useful to some and you aren't put off by these seemingly complicated and certainly verbose set of instructions.

Finally there are some funny behaviors I've noticed.  For instance,
1. in a script if I turn the roving_detail on and run the ribbon_ride, I can't seem to color the roving map from the script (using "color blue, rov_m1" for example, even though the very same command typed into the command window works fine. Any comments?

2. Somebody's math is a little off. The alpha carbons don't always end up EXACTLY in line as each transition down the ribbon progresses. Don't know why for sure, but frankly, it's kind of a feature instead of a bug since the view is a bit better when you aren't looking right down the axis anyway. Possible variation would be to always have the view offset by a certain amount which shouldn't be too hard to implement.

3. What would be really nice is if I could access the smoothed path that a smoothed cartoon or ribbon takes and use that to define the ribbon_ride vectors instead of these angled ones. Probably easy for some but I haven't gotten around to looking for it.

It is kind of obvious and therefore in some ways goes without saying that this is also heavily reliant on the work of Warren DeLano...but there I've gone and said it anyway. Thanks again Warren!

Cheers,
Seth

p.s. I assume it is OK to attach this code license-wise and all that from many people since it seemed impractical to send the bits and pieces without the framework. Let me know if this is incorrect and I won't do that again. I have tried to make sure that the history of it is properly annotated, and assume this respect will be continued down the line.

p.p.s I don't believe I have broken anything in the final last-minute editing clean up pass (still rough, though!), but let me know if it doesn't work, or if Eudora has inconveniently bin-hexed the file or something.

p.p.p.s Gee, I just love to hear myself type, but again, I have sample scripts for those who are just getting started and can share them if needed but this tome seemed enough for now!




--
Seth Harris, Ph.D.
Agard Laboratory Suite S416
Box 2240
UCSF/HHMI
600 16th Street
San Francisco, CA 94143-2240
(Shipping Zip 94158)
415.502.2930

Attachment: MasterMovie.py
Description: Mac BinHex archive

Reply via email to