IMP  2.4.0
The Integrative Modeling Platform
atom/charmm_forcefield.py

In this example, a PDB file is read in and scored using the CHARMM forcefield. For more control over the setup of the forcefield, see the 'charmm_forcefield_verbose.py' example.

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 from __future__ import print_function
7 import IMP.atom
8 import IMP.container
9 
10 # Create an IMP model and add a heavy atom-only protein from a PDB file
11 m = IMP.kernel.Model()
12 prot = IMP.atom.read_pdb(IMP.atom.get_example_path("example_protein.pdb"), m,
14 
15 # Read in the CHARMM heavy atom topology and parameter files
17 
18 # Using the CHARMM libraries, determine the ideal topology (atoms and their
19 # connectivity) for the PDB file's primary sequence
20 topology = ff.create_topology(prot)
21 
22 # Typically this modifies the C and N termini of each chain in the protein by
23 # applying the CHARMM CTER and NTER patches. Patches can also be manually
24 # applied at this point, e.g. to add disulfide bridges.
25 topology.apply_default_patches()
26 
27 # Make the PDB file conform with the topology; i.e. if it contains extra
28 # atoms that are not in the CHARMM topology file, remove them; if it is
29 # missing atoms (e.g. sidechains, hydrogens) that are in the CHARMM topology,
30 # add them and construct their Cartesian coordinates from internal coordinate
31 # information.
32 topology.setup_hierarchy(prot)
33 
34 # Set up and evaluate the stereochemical part (bonds, angles, dihedrals,
35 # impropers) of the CHARMM forcefield
37 m.add_restraint(r)
38 
39 # Add non-bonded interaction (in this case, Lennard-Jones). This needs to
40 # know the radii and well depths for each atom, so add them from the forcefield
41 # (they can also be assigned manually using the XYZR or LennardJones
42 # decorators):
43 ff.add_radii(prot)
44 ff.add_well_depths(prot)
45 
46 # Get a list of all atoms in the protein, and put it in a container
47 atoms = IMP.atom.get_by_type(prot, IMP.atom.ATOM_TYPE)
49 
50 # Add a restraint for the Lennard-Jones interaction. This is built from
51 # a collection of building blocks. First, a ClosePairContainer maintains a list
52 # of all pairs of Particles that are close. Next, all 1-2, 1-3 and 1-4 pairs
53 # from the stereochemistry created above are filtered out.
54 # Then, a LennardJonesPairScore scores a pair of atoms with the Lennard-Jones
55 # potential. Finally, a PairsRestraint is used which simply applies the
56 # LennardJonesPairScore to each pair in the ClosePairContainer.
57 nbl = IMP.container.ClosePairContainer(cont, 4.0)
58 nbl.add_pair_filter(r.get_pair_filter())
59 
60 sf = IMP.atom.ForceSwitch(6.0, 7.0)
62 restraints = [r, IMP.container.PairsRestraint(ps, nbl)]
63 scoring_function = IMP.core.RestraintsScoringFunction(restraints)
64 
65 # it gets awfully slow with internal checks
66 IMP.base.set_check_level(IMP.base.USAGE)
67 # Finally, evaluate the score of the whole system (without derivatives)
68 print(scoring_function.evaluate(False))