PyRosetta (1) Pose

PyRosetta (1): Pose

1
2
3
4
from pyrosetta import *
init()
#import pyrosetta
#pyrosetta.init()

Poseclass

Introduction

  1. Simplified explanation:
    1. Pose(pyrosetta.Pose) is defined as a Python class
    2. Poseis the core concept of PyRosetta
    3. An instance of thePoseclass is refered to as a “pose object”.
    4. A pose object is a protein structure.
  2. Further explanation:
    1. A pose object may also include informations about related ions, ligand and other molecules.
    2. A pose object may have more than one protein chains (quaternary protein, or protein complex)
    3. Like any other Python classes, thePoseclass has methods and attributes.
    4. Class methods can be visited from the instances of the class.

Pose instantiation

Initiate an instance of Pose from a PDB file

1
2
3
pose_1 = pose_from_pdb("./path_to_pdb/5tj3.pdb") 
# pyrosetta.pose_from_pdb
# load '5tj3.pdb' from file

Or,

1
2
pose_1 = pyrosetta.io.pose_from_file(filename="./path_to_pdb/5tj3.pdb")
# load '5tj3.pdb' from file

Initiate an instance of Pose from https://www.rcsb.org/

1
2
3
pose_2 = pose_from_rcsb("5TJ3")
# pyrosetta.toolbox.rcsb.pose_from_rcsb
# load 5TJ3 from online database

Initiate an instance of Posefrom a string (a sequence)

1
2
3
pose_3 = pose_from_sequence("AAAAAAAAAA")
# pyrosetta.pose_from_sequence
# load a "poly alanine sequence" from string

Initiate an empty instance of Pose (And create a clone of a pose object)

1
2
3
4
pose_4 = Pose() # Now pose_4 is empty

# we can now use pose_4 to create a deep clone (copy) of pose_1
pose_4.assign(pose_1)

Pose methods

Copy a pose object via Pose.assign

1
2
3
4
5
# Assume that we have a Pose instance called `my_pose`
my_pose_clone = Pose() # Now my_pose_clone is empty

#create a deep clone (copy) of my_pose
my_pose_clone.assign(my_pose)

WARNING: Avoid writing something like:

1
2
my_pose_clone = my_pose 
# This is incorrect

Because in this way, my_pose_clone is pointed to value of my_pose, and modification to my_pose_clone will change my_pose.

Copy a pose object via Pose.clone

1
2
# assume that we have a `pose` object called `my_pose`
my_pose_clone = my_pose.clone()

Get sequence

1
2
3
# `my_pose` is an instance of Pose
my_seq = my_pose.sequence()
# `my_seq` is a string, storing the sequence of my_pose

Get annotated sequence

1
2
3
my_seq_annotated = my_pose.annotated_sequence()
# `my_seq` is a string, storing the annotated sequence of my_pose
# annotations are like: '...T[THR:phosphorylated]...'

Get total residue count

1
2
my_total_residue_count = my_pose.total_residue()
# `my_total_residue_count` is an integer

Get dihedral angles

1
2
3
4
5
6
7
# `residue_id` is the ID (in pose) of a residue, type is integer
my_pose.phi(residue_id) # C-CaN-C dihedral
# >>> −64.8
my_pose.psi(residue_id) # N-CaC-N dihedral
# >>> -41.0
my_pose.chi(1, residue_id) # 1st C-C dihedral in side chain
# >>> -82.8

Get an Energies object

1
2
3
my_energies = my_pose.energies()

print(my_energies.show(24)) # Print all energies terms (unweighted) of residue 24

Get a Residue object by its position

1
2
residue_20th = my_pose.residue(20)
# `residue_20th` is an object that stores the 20th residue of `my_pose`

Or,

1
residue_20th = my_pose.aa(20)

Or,

1
residue_20th = relaxPose.sequence()[19]

See “Residue objects” in this note

WARNING: “the 20th residue in pose” is not equal to “the 20th residue in PDB”, because a pdb file may contain more than one chain.

Get a PdbInfo object

This object is a bridge between a Pose object and a PDB file:

  1. This object stores information from the original PDB file (if the pose is from a pdb file or from the pdb database).
  2. Or, this object stores information that can be written into a PDB file.
1
my_pdb_info = my_pose.pdb_info()

See “PdbInfo objects” in this note

Get a Conformation object

1
my_conformation = my_pose.conformation() # Get conformation object

Get a FoldTree object

1
2
3
my_tree = my_pose.fold_tree()
print(my_tree)
# >>> FOLD_TREE EDGE 1 107 -1 EDGE 1 108 1 EDGE 108 194 -1

The fundamental docking move is a rigid-body transformation consisting of a translation and rotation. Any rigid body move also needs to know which part moves and which part is fixed. In Rosetta, this division is known as a Jump and the set of protein segments and jumps are stored in an object attached to a pose called a FoldTree.

In the FoldTree printout, each three number sequence following the word EDGE is the beginning and ending residue number, then a code. The codes are -1 for stretches of protein and any positive integer for a Jump, which represents the Jump number.

Get a Jump class by its ID

1
2
3
jump_num = 1 # the first jump
print(pose.jump(jump_num).get_rotation()) # show the rotation matrix
print(pose.jump(jump_num).get_translation()) # show the translation vector

Set dihedral angles (a basic mover)

1
2
my_pose.set_phi(24, -64.8) # set phi of residue #24 to -64.8
my_pose.set_psi(24, -41.0) # set psi of residue #24 to -41.0

Set foldtree (requires a pre-defined FoldTree object)

1
2
# Assume that we have a `FoldTree` object called `my_ft`
my_pose.fold_tree(my_ft)

Output (Save) a pose as a PDB file

1
my_pose.dump_pdb('/outputs/my_pose_arxiv.pdb')

Residue class

Residueis a secondary class of Pose.

A residueobject stores information about a residue.

NOTICE: An ion, or a small molecule ligand, etc. is also seen as a residue.

Get residue name

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
residue_20th = my_pose.residue(20)
# my_pose is a `Pose` object
# residue_20th is a `Residue` object
residue_20th_name = residue_20th.name()
# a string, the uppercased 3-letter name
# e.g. 'ASP'

residue_20th_base_name = residue_20th.base_name()
# a string, the uppercased 3-letter name
# e.g. 'ASP'

residue_20th_name3 = residue_20th.name3()
# a string, the uppercased 3-letter name
#e.g. 'ASP'

residue_20th_name1 = residue_20th.name1()
# a string, the uppercased 1-letter name
#e.g. 'D'

Get residue property: is_xxx booleans

1
2
3
residue_24th = my_pose.residue(24) # Get #24 residue from my_pose
residue_24th_is_charged = residue_24th.is_charged() # Boolean, `True` if it is charged
residue_24th_is_aa = residue_24th.is_protein() # Boolean, `True` if it is an amino acid

Get atom index

1
2
residue_24th = my_pose.residue(24) # get #24 residue
carbon_alpha_of_residue_24th = residue_24th.atom_index("CA")

"N"is the nitrogen of main-chain amino group.

"CA"is the central carbon.

"C"is the carbon of main-chain carboxyl group.

For atom nomenclatures, search for “amino acid structure”.

1
2
3
# `residue_24th` is a residue in `my_pose`
N_xyz = residue_24th.xyz("N")
# N_xyz is a vector (length = 3)

PdbInfoclass

PdbInfois a secondary class of Pose.

This class is a bridge between a Pose object and a PDB file:

  1. A pdb_infoobject stores information from the original PDB file (if the pose is from a pdb file or from the pdb database).
  2. Or, this object stores information that can be written into a PDB file.

Convert residue ID (number): pdb2pose and pose2pdb

The ID (number) of a residue starts at #1 in pose.

The ID of a residue in a poseobject is different from its ID in a .pdbfile.

1
2
3
4
5
6
7
8
# In PDB file, a residue of interect is in "chain A", and its ID (number) in the PDB file is 24
# But its ID in the `Pose` object (my_pose) is unknown.
my_pdb_info = my_pose.pdb_info()
my_residue_id_in_pose = my_pdb_info.pdb2pose('A', 24) # get the residue ID in pose, stored as an integer
my_residue = my_pose.residue(my_residue_id_in_pose) # get the `Residue` object by its ID in pose

# alternatively, we can call the methods in a chain:
# my_residue_id_in_pose = my_pose.pdb_info().pdb2pose('A', 24)
1
2
3
4
# On the other hand, we can get the corresponding PDB chain infomation and ID information for a specific residue
# In a `Pose` object, a residue is at #1 position (its ID is 1), but its location in corresponding PDB file is unknown
my_residue_info_in_pdb = my_pdb_info.pose2pdb(1)
# my_residue_info_in_pdb is a string that looks like '24 A'

Get chain information & Get number (ID) information

1
2
3
4
5
6
7
# a `Pose` instance called `my_pose`, and a residue of interest whose ID (in pose) is 1
my_pose.pdb_info().chain(1)
# >>> A
# The #1 residue is in 'chain A'
my_pose.pdb_info().number(1)
# >>> 24
# The ID of #1 (in pose) residue in corresponding PDB file is 24

Set PdbInfo name

1
2
3
4
# assume that my_pose is a `pose` object
my_pose.pdb_info().name("test")
# set the name of this pose in its pdb_info as "test"
# if it is sent to PyMOL, it will be displayed as "test" in the object list

Set chain (split chain)

1
2
3
4
5
6
7
8
9
# Assume that my_pose is a `pose` object with a single chain, chain "A".
# Assume that we are going to split the residues
# from #101 to the end of the chain into chain "B".
pose = pose_from_pdb("myprotein.pdb")
pdbinfo = pose.pdb_info()
# Cut between residue 100 and 101 in the pose
strand_start = 101
for res in range(strand_start, pose.size() + 1):
pdb_info.chain(res, 'B')

Conformation class

Get bond length & Get bond angle

1
2
3
4
5
6
7
8
9
10
# given a `residue_id` (ID of a residue):
residue_28th = my_pose.residue(residue_id) # Get residue
N28 = AtomID(residue_28th.atom_index("N"), residue_id) # Construct an `AtomID` object for backbone nitrogen
CA28 = AtomID(residue_28th.atom_index("CA"), residue_id)
C28 = AtomID(res_28.atom_index("C"), resid)

my_conformation = my_pose.conformation() # Get conformation object

N_CA_28_bond_length = my_conformation.bond_length(N28, CA28) # get bond length; type is float
bb_angle = my_conformation.bond_angle(N28, CA28, C28) # get bond angle; type is float; in degree
  • 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:

请我喝杯咖啡吧~

支付宝
微信