IMP  2.2.1
The Integrative Modeling Platform
charmm_forcefield.py
1 ## \example atom/charmm_forcefield.py
2 # In this example, a PDB file is read in and scored using the CHARMM
3 # forcefield. For more control over the setup of the forcefield, see
4 # the 'charmm_forcefield_verbose.py' example.
5 
6 import IMP.atom
7 import IMP.container
8 
9 # Create an IMP model and add a heavy atom-only protein from a PDB file
10 m = IMP.kernel.Model()
11 prot = IMP.atom.read_pdb(IMP.atom.get_example_path("example_protein.pdb"), m,
13 
14 # Read in the CHARMM heavy atom topology and parameter files
16 
17 # Using the CHARMM libraries, determine the ideal topology (atoms and their
18 # connectivity) for the PDB file's primary sequence
19 topology = ff.create_topology(prot)
20 
21 # Typically this modifies the C and N termini of each chain in the protein by
22 # applying the CHARMM CTER and NTER patches. Patches can also be manually
23 # applied at this point, e.g. to add disulfide bridges.
24 topology.apply_default_patches()
25 
26 # Make the PDB file conform with the topology; i.e. if it contains extra
27 # atoms that are not in the CHARMM topology file, remove them; if it is
28 # missing atoms (e.g. sidechains, hydrogens) that are in the CHARMM topology,
29 # add them and construct their Cartesian coordinates from internal coordinate
30 # information.
31 topology.setup_hierarchy(prot)
32 
33 # Set up and evaluate the stereochemical part (bonds, angles, dihedrals,
34 # impropers) of the CHARMM forcefield
36 m.add_restraint(r)
37 
38 # Add non-bonded interaction (in this case, Lennard-Jones). This needs to
39 # know the radii and well depths for each atom, so add them from the forcefield
40 # (they can also be assigned manually using the XYZR or LennardJones
41 # decorators):
42 ff.add_radii(prot)
43 ff.add_well_depths(prot)
44 
45 # Get a list of all atoms in the protein, and put it in a container
46 atoms = IMP.atom.get_by_type(prot, IMP.atom.ATOM_TYPE)
48 
49 # Add a restraint for the Lennard-Jones interaction. This is built from
50 # a collection of building blocks. First, a ClosePairContainer maintains a list
51 # of all pairs of Particles that are close. Next, all 1-2, 1-3 and 1-4 pairs
52 # from the stereochemistry created above are filtered out.
53 # Then, a LennardJonesPairScore scores a pair of atoms with the Lennard-Jones
54 # potential. Finally, a PairsRestraint is used which simply applies the
55 # LennardJonesPairScore to each pair in the ClosePairContainer.
56 nbl = IMP.container.ClosePairContainer(cont, 4.0)
57 nbl.add_pair_filter(r.get_pair_filter())
58 
59 sf = IMP.atom.ForceSwitch(6.0, 7.0)
61 restraints = [r, IMP.container.PairsRestraint(ps, nbl)]
62 scoring_function = IMP.core.RestraintsScoringFunction(restraints)
63 
64 # it gets awfully slow with internal checks
65 IMP.base.set_check_level(IMP.base.USAGE)
66 # Finally, evaluate the score of the whole system (without derivatives)
67 print scoring_function.evaluate(False)
Select non water and non hydrogen atoms.
Definition: pdb.h:197
CHARMMParameters * get_heavy_atom_CHARMM_parameters()
Enforce CHARMM stereochemistry on the given Hierarchy.
See IMP.container for more information.
void set_check_level(CheckLevel tf)
Control runtime checks in the code.
std::string get_example_path(std::string file_name)
Return the path to installed example data for this module.
Return all close unordered pairs of particles taken from the SingletonContainer.
Lennard-Jones score between a pair of particles.
Store a kernel::ParticleIndexes.
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
Smooth interaction scores by switching the derivatives (force switch).
See IMP.atom for more information.
void read_pdb(base::TextInput input, int model, Hierarchy h)
Applies a PairScore to each Pair in a list.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72