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