IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
score_protein_with_ligand.py
1## \example atom/score_protein_with_ligand.py
2# Show how to score a number of ligand conformations loaded from a file
3# against a protein loaded from a pdb.
4
5import IMP.atom
6import sys
7
8IMP.setup_from_argv(sys.argv, "score protein with ligand")
9
10m = IMP.Model()
11IMP.set_check_level(IMP.NONE)
12protein = IMP.atom.read_pdb(IMP.atom.get_example_path('1d3d-protein.pdb'), m)
13protein_atoms = IMP.atom.get_by_type(protein, IMP.atom.ATOM_TYPE)
14ligands = IMP.atom.read_mol2(IMP.atom.get_example_path('1d3d-ligands.mol2'), m)
15# create the score which applies to a pair of atoms
17ps.set_was_used(True)
18# label each atom of the protein with the type needed for scoring
20for cl in ligands.get_children():
21 # compute the atom type for each ligand atom
23 score = 0
24 ligand_atoms = IMP.atom.get_by_type(cl, IMP.atom.ATOM_TYPE)
25 for pa in protein_atoms:
26 for la in ligand_atoms:
27 # check if the atoms are close enough together
29 # score one pair of atoms
30 score += ps.evaluate_index(m,
31 (pa.get_particle_index(),
32 la.get_particle_index()), None)
33 print("score for ", cl.get_name(), "is", score)
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
Gather all the molecular particles of a certain level in the hierarchy.
A decorator for a particle with x,y,z coordinates.
Definition XYZ.h:30
Functionality for loading, creating, manipulating and scoring atomic structures.
Hierarchy read_mol2(TextInput mol2_file, Model *model, Mol2Selector *mol2sel=nullptr)
Create a hierarchy from a Mol2 file.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
void add_protein_ligand_score_data(Hierarchy h)
Hierarchy read_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the PDB file.
double get_distance(const Surface &s, const XYZR &d)
Get distance from sphere to surface.
Definition Surface.h:153
void set_check_level(CheckLevel tf)
Control runtime checks in the code.
Definition exception.h:72
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.