rsd.py(Toggle Plain Text)
from pymol import * from time import * # Variables width = 500 height = 375 step = 5 angle = 360 molecule = 'morphine.mol' # Main settings logfile = open("rsd.log","w") logfile.write('Script started '+strftime("%Y-%m-%d %H:%M:%S"+"\n")) logfile.write('====================================================================\n') logfile.close() cmd.load(molecule,"molecule") # Load molecule cmd.hide("everything","molecule") # Hide everything cmd.show("surface" ,"molecule") # Show surface cmd.set("surface_quality",3) # Set a high surface resolution util.ray_shadows('heavy') # Set heavy shadows drop cmd.zoom("all",1) # Zoom out util.cba(29,"molecule") # Apply color scheme # Rendering A (rotating the camera) logfile = open("rsd.log","a") t=time() logfile.write('Starting rendering A => '+strftime("%Y-%m-%d %H:%M:%S",gmtime(t))+"\n") logfile.close() i=0 while i<angle: name = "%s%.4d" % ("molecule_A_",i) cmd.ray(width,height,0,i) cmd.png(name) i+=step logfile = open("rsd.log","a") t2=time() logfile.write('Stoping rendering A => '+strftime("%Y-%m-%d %H:%M:%S",gmtime(t2))+"\n") logfile.write('--------------------------------------------------------------------\n') diff=t2-t logfile.write('Summary: '+strftime("%H hours, %M minutes, ",gmtime(diff))+str(diff % 60)+' seconds taken to render '+str(angle/step)+' frames'+"\n") logfile.write('====================================================================\n') logfile.close() i=0 # Rendering B (rotating the model) logfile = open("rsd.log","a") t=time() logfile.write('Starting rendering B => '+strftime("%Y-%m-%d %H:%M:%S",gmtime(t))+"\n") logfile.close() while i<angle: name = "%s%.4d" % ("molecule_B_",i) cmd.rotate("y",step) cmd.ray(width,height) cmd.png(name) i+=step logfile = open("rsd.log","a") t2=time() logfile.write('Stoping rendering B => '+strftime("%Y-%m-%d %H:%M:%S",gmtime(t2))+"\n") logfile.write('--------------------------------------------------------------------\n') diff=t2-t logfile.write('Summary: '+strftime("%H hours, %M minutes, ",gmtime(diff))+str(diff % 60)+' seconds taken to render '+str(angle/step)+' frames'+"\n") logfile.write('====================================================================\n') logfile.close() # End log logfile = open("rsd.log","a") logfile.write('Script stoped '+strftime("%Y-%m-%d %H:%M:%S")+"\n") logfile.close()
pymol -qcr rsd.py
Note that the morphine.mol file used in this script have to be in the same directory as the script. What exactly does the script? First it renders a full-angle rotation of the "camera" along the Y axis using a five degree step. Second it renders a full-angle rotation of the molecule (morphine in my case) along the Y axis also using a five degree step. The output is dumped into a log file and the rendered images are saved in the current directory. The final result looks like this:
(Download video)
Here's the output of my log file(rsd.log):
Script started 2008-05-18 15:27:04
====================================================================
Starting rendering A => 2008-05-18 13:27:04
Stoping rendering A => 2008-05-18 13:34:18
--------------------------------------------------------------------
Summary: 00 hours, 07 minutes, 14.7353949547 seconds taken to render 72 frames
====================================================================
Starting rendering B => 2008-05-18 13:34:18
Stoping rendering B => 2008-05-18 14:04:11
--------------------------------------------------------------------
Summary: 00 hours, 29 minutes, 52.1074898243 seconds taken to render 72 frames
====================================================================
Script stoped 2008-05-18 16:04:11
I was amazed by myself when i looked at this. Not only I created an interesting animation effect, but also cut down the rendering time by four. For small molecules the difference in time taken to render is not so visible, but if you use a bigger model like a protein or increase the quality of displayed model (in my case more detailed surface) you'll better take a longer coffee break or go for a longer walk. Sure, the two renders looks different, but only because I'd set Pymol to render heavy dropped shadows. By default you don't see a difference or a slightly one. I think I'll add this method of rendering to my batch rendering scripts. ]:)
1 komentarz:
whats up!, im new . This website's fantastic, ive learned tons from it today!
Prześlij komentarz