IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
profile.py
1## \example saxs/profile.py
2# In this example, we read a protein from a PDB file and experimental profile
3# file. Next we compute the theoretical profile from the PDB file and fit it
4# to the experimental one.
5#
6# This application is available as a web service at salilab.org/foxs. It is
7# also available as C++ code in IMP at modules/foxs/bin/foxs.cpp.
8#
9# The experimental data for lysozyme is taken from crysol program
10# (www.embl-hamburg.de/ExternalInfo/Research/Sax/crysol.html)
11#
12
13import IMP
14import IMP.atom
15import IMP.core
16import IMP.saxs
17import sys
18
19IMP.setup_from_argv(sys.argv, "profile")
20
21m = IMP.Model()
22
23# read PDB
26
27# read experimental profile
28exp_profile = IMP.saxs.Profile(IMP.saxs.get_example_path('lyzexp.dat'))
29
30print('min_q = ' + str(exp_profile.get_min_q()))
31print('max_q = ' + str(exp_profile.get_max_q()))
32print('delta_q = ' + str(exp_profile.get_delta_q()))
33
34# select particles from the model
35particles = IMP.atom.get_by_type(mp, IMP.atom.ATOM_TYPE)
36
37# calculate SAXS profile
38model_profile = IMP.saxs.Profile()
39model_profile.calculate_profile(particles)
40model_profile.write_SAXS_file('6lyz.dat')
41
42# calculate chi score (should be ~0.5 for this example)
43saxs_score = IMP.saxs.ProfileFitterChi(exp_profile)
44chi = saxs_score.compute_score(model_profile)
45print('Chi = ' + str(chi))
46
47
48# convert to p(r)
50model_profile.profile_2_distribution(pr, 48.0)
51pr.normalize()
52pr.show()
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.
Select non water and non hydrogen atoms.
Definition pdb.h:320
Functionality for loading, creating, manipulating and scoring atomic structures.
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.
Basic functionality that is expected to be used by a wide variety of IMP users.
Support for small angle X-ray scattering (SAXS) data.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.