PyRosetta (2) PyMOL Mover

PyRosetta (2): PyMOL Mover

1
2
3
4
from pyrosetta.rosetta.protocols.moves import PyMOLMover
init()
#import pyrosetta
#pyrosetta.init()
1
my_pose = pose_from_pdb("inputs/5tj3.pdb")

Resource

https://www.pyrosetta.org/documentation/pymol_mover-tutorial

PyMOLMover class

The pyrosetta.rosetta.protocols.moves.PyMOLMover class will let us send information from PyRosetta to PyMOL for quick visualization.

Setup PyMOL

Get Configuration file: PyMOLPyRosettaServer.py(in Linux)

PyMOLPyRosettaServer.py is found in the main directory of PyRosetta.

The path to PyRosetta can be discovered in the init information.

For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Requirement already satisfied: pyrosettacolabsetup in /home/michael2003/anaconda3/envs/DESIGN_PROTEIN/lib/python3.9/site-packages (1.0.9)
┌──────────────────────────────────────────────────────────────────────────────┐
│ PyRosetta-4 │
│ Created in JHU by Sergey Lyskov and PyRosetta Team │
│ (C) Copyright Rosetta Commons Member Institutions │
│ │
│ NOTE: USE OF PyRosetta FOR COMMERCIAL PURPOSES REQUIRE PURCHASE OF A LICENSE │
│ See LICENSE.PyRosetta.md or email license@uw.edu for details │
└──────────────────────────────────────────────────────────────────────────────┘
PyRosetta-4 2025 [Rosetta PyRosetta4.conda.ubuntu.cxx11thread.serialization.Ubuntu.python39.Release 2025.24+release.8e1e5e54f047b0833dcf760a5cd5d3ce94d63938 2025-06-06T09:20:57] retrieved from: http://www.pyrosetta.org
core.init: Checking for fconfig files in pwd and ./rosetta/flags
core.init: Rosetta version: PyRosetta4.conda.ubuntu.cxx11thread.serialization.Ubuntu.python39.Release r403 2025.24+release.8e1e5e54f0 8e1e5e54f047b0833dcf760a5cd5d3ce94d63938 http://www.pyrosetta.org 2025-06-06T09:20:57
core.init: Rosetta extras: [cxx11thread, serialization]
core.init: command: PyRosetta -ex1 -ex2aro -database /home/michael2003/anaconda3/envs/DESIGN_PROTEIN/lib/python3.9/site-packages/pyrosetta/database
basic.random.init_random_generator: 'RNG device' seed mode, using '/dev/urandom', seed=-481462242 seed_offset=0 real_seed=-481462242 thread_index=0
basic.random.init_random_generator: RandomGenerator:init: Normal mode, seed=-481462242 RG_type=mt19937

In this example, path to PyRosetta is:

/home/michael2003/anaconda3/envs/DESIGN_PROTEIN/lib/python3.9/site-packages/pyrosetta/

Copy & edit the configuration file (in Windows)

I’m using PyMOL on Windows, and PyRosetta on WSL Ubuntu.

Therefore, I have to edit the PyMOLPyRosettaServer.py file to appoint a correct IP address.

https://learn.microsoft.com/en-us/windows/wsl/networking

A program running inside a Linux distribution via WSL2 (instance) wants to know the Windows host’s IP address, so that a Linux program can connect to a Windows host server program.

1
ip route show | grep -i default | awk '{ print $3}'

And a typical output might look like:

1
>>> 172.24.112.1

Copy the PyMOLPyRosettaServer.py from Linux to Windows (to D:).

1
cp <Path-to-PyRosetta>/PyMOLPyRosettaServer.py /mnt/d/

And edit the file according to the comments within it. (The IP configuration is in the last few lines.) Appoint the right remote IP, and appoint an available port (e.g. 65000).

Apply the PyMOLPyRosettaServer.py to PyMOL (in Windows)

a. Drag the file to PyMOL window.

b. Or, run the following commands in the PyMOL command line.

1
2
cd D: #Because I save PyMOLRosettaServer.py there.
run PyMOLRosettaServer.py

c. Or, save the commands above to pymolrc.pml; thus it runs automatically each time pyMOL launches
(The pymolrc.pmlfile can be found from GUI menu: File >> Edit pymolrc)

Instantiation of PyMOLMover

1
pmm = PyMOLMover("172.24.112.1", 65000)

PyMOLMovermethods

Keep history

The method keep_history, if set to True, allows you to load in structures with the same name into states of the same object in PyMOL.

This is the starting point for creating a PyMOL movie of your structure.

1
pmm.keep_history(True) # This keeps history of all poses sent to PyMOL

Send a pose object to PyMOL

1
2
pmm.apply(my_pose)
# After running this, my_pose is expected to show up in the PyMOL window

See AddPyMOLObserverclass for information about automatic updating the pose during move.

Send energy (energy across every residue) of a poseobject to PyMOL

1
2
3
4
# assume that `pmm` is an instance of `PyMOLMover`
# assume that `my_pose` is an instance of `Pose`
pmm.send_energy(my_pose) # visualize the distribution of energy across the structure
pmm.send_energy(my_pose, fa_sol) # visualize the distribution of solvation energy (of full atom energy landscape) across the structure

Send properties of the poseobject to PyMOL

1
2
# if you have scored the pose first, you can:
pmm.send_hbonds(my_pose) #show all hydrogen bonds in PyMOL

AddPyMOLObserver class

The observer is configured to execute a PyMOLMover.apply() every time a change is observed in the pose coordinates. The True is a flag to ensure that PyMOL keeps a history of the moves.

The observer should be added before executing the move(s).

1
2
observer = pyrosetta.rosetta.protocols.moves.AddPyMOLObserver(my_pose, True)
my_mover.apply(my_pose)
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2024-2025 Michael Lau
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信