Skip to content

Instantly share code, notes, and snippets.

@bjornblissing
Created January 15, 2018 17:28
Show Gist options
  • Save bjornblissing/8001771eb71aa64565aa07876f76bf85 to your computer and use it in GitHub Desktop.
Save bjornblissing/8001771eb71aa64565aa07876f76bf85 to your computer and use it in GitHub Desktop.
PyMol script: 360 degree rotation animation in GIF format
# Load PyMol model, file extension will be autodetected
load testmodel
# Start of python script
python
import imageio
# Number of degrees to rotate each frame
step = 10
# Vector to hold images
images = []
for a in range(0,360,step):
cmd.rotate("y", float(step)) # Rotate around Y-axis
cmd.ray(256,256) # Raytrace 256x256 image
filename = "file"+str(a)+".png"
cmd.png(filename)
images.append(imageio.imread(filename))
# Create gif animation from images
imageio.mimsave('animation.gif', images)
# End of python script
python end
@bjornblissing
Copy link
Author

Note: The imageio package needs to be installed to run this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment