3
$\begingroup$

I am very new to Pymol and was trying to figure out how I can find the largest distance between 2 residues. Using just the basic distance function I get multiple distances which is not very useful in my case as it finds the distance between every single atom in the residue. I would like this distance to be stored in a list because I will repeat this multiple times for other residues.

enter image description here

$\endgroup$
1
  • $\begingroup$ Possible duplicate of this old question on StackOverflow. It should be adaptable whether you want the closest or furthest distance. $\endgroup$
    – Tyberius
    Jul 15, 2023 at 13:40

1 Answer 1

1
$\begingroup$

Roughly these are the steps to follow:

  1. Install PyMOL software
  2. Run a python script which captures the distance between residues in PyMOL command line

The script would do the following

  1. Load your structure into pymol python library using the cmd.load() function.

  2. Calculate the distances between specific atoms of the two residues using cmd.distance() function. You will need to specify the atom selection strings for the two:

    distance_value = cmd.distance("resi 1 and name CA", "resi 10 and name CA")
    
  3. This calculates the distance between the alpha carbon atoms of residue 1 and residue 10.

  4. Store the distances in a list and find the maximum distance using the max() function.


Below is a boilerplate code. Add a loop to calculate distances over all the residues according to your requirements.

# Import the PyMOL module
import pymol

# Initialize PyMOL
pymol.finish_launching()

# Load your structure
cmd.load("your_structure.pdb")

# List to store distances
distances = []

# Residue indices
residue_1_index = 1
residue_10_index = 10

# Calculate distance and store in the list
distance_value = cmd.distance(f"resi {residue_1_index} and name CA", f"resi {residue_10_index} and name CA")
distances.append(distance_value)

# You can repeat the above block of code for other residue pairs

# Find the largest distance
largest_distance = max(distances)

# Print the largest distance
print("Largest distance:", largest_distance)

# Close PyMOL
pymol.cmd.quit()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .