How to do it...

Take a look at the following steps:

  1. Let's initialize and retrieve our PDB model and prepare the rendering, as follows:
import pymolfrom pymol import cmd#pymol.pymol_argv = ['pymol', '-qc'] # Quiet / no GUIpymol.finish_launching()cmd.fetch('1TUP', async=False)cmd.disable('all')cmd.enable('1TUP')cmd.hide('all')cmd.show('sphere', 'name zn')

Note that the pymol_argv line makes the code silent. In your first execution, you may want to comment this out and see the user interface.

For movie rendering, this will come in handy (as we will see soon). As a library, PyMOL is quite tricky to use. For instance, after the import, you have to call finish_launching. We then fetch our PDB file.

What then follows is a set of PyMOL commands. ...

Get Bioinformatics with Python Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.