IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
profile_fit.py
1 ## \example saxs/profile_fit.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. Unlike in profile.py example, here we fit the
5 # profile with adjustment of the excluded volume and hydration layer density
6 # of the molecule.
7 #
8 # This application is available as a web service at salilab.org/foxs. It is
9 # also available as C++ code in IMP at modules/foxs/bin/foxs.cpp.
10 #
11 # The experimental data for lysozyme is taken from crysol program
12 # (www.embl-hamburg.de/ExternalInfo/Research/Sax/crysol.html)
13 #
14 
15 from __future__ import print_function
16 import IMP
17 import IMP.atom
18 import IMP.core
19 import IMP.saxs
20 import sys
21 
22 IMP.setup_from_argv(sys.argv, "profile fit")
23 
24 m = IMP.Model()
25 
26 # read PDB
29 
30 # read experimental profile
31 exp_profile = IMP.saxs.Profile(IMP.saxs.get_example_path('lyzexp.dat'))
32 
33 print('min_q = ' + str(exp_profile.get_min_q()))
34 print('max_q = ' + str(exp_profile.get_max_q()))
35 print('delta_q = ' + str(exp_profile.get_delta_q()))
36 
37 # select particles from the model
38 particles = IMP.atom.get_by_type(mp, IMP.atom.ATOM_TYPE)
39 
40 # add radius for water layer computation
42 for i in range(0, len(particles)):
43  radius = ft.get_radius(particles[i])
44  IMP.core.XYZR.setup_particle(particles[i], radius)
45 # compute surface accessibility
47 surface_area = s.get_solvent_accessibility(IMP.core.XYZRs(particles))
48 
49 # calculate SAXS profile
50 delta_q = 0.5 / 500
51 model_profile = IMP.saxs.Profile(0.0, 0.5, delta_q)
52 model_profile.calculate_profile_partial(particles, surface_area)
53 # model_profile.write_SAXS_file('6lyz.dat')
54 
55 # calculate chi-square score (should be ~0.25 for this example)
56 saxs_score = IMP.saxs.ProfileFitterChi(exp_profile)
57 chi = saxs_score.compute_score(model_profile)
58 print('Chi without parameter fitting = ' + str(chi))
59 
60 chi = (saxs_score.fit_profile(model_profile)).get_chi_square()
61 print('Chi after adjustment of excluded volume and water layer parameters = '
62  + str(chi))
63 saxs_score.fit_profile(model_profile, 0.95, 1.05, -2.0, 4.0, False,
64  '6lyz_fitted.dat')
Select non water and non hydrogen atoms.
Definition: pdb.h:331
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
static XYZR setup_particle(Model *m, ParticleIndex pi)
Definition: XYZR.h:48
FormFactorTable * get_default_form_factor_table()
void read_pdb(TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
Basic functionality that is expected to be used by a wide variety of IMP users.
Functionality for loading, creating, manipulating and scoring atomic structures.
Support for small angle X-ray scattering (SAXS) data.