IMP logo
IMP Reference Guide  2.18.0
The Integrative Modeling Platform
atom/charmm_topology.py

This example shows how to use IMP's CHARMM topology reader to build an atomic structure (in this case, alanine dipeptide) from primary sequence, and to apply topology patches.

1 ## \example atom/charmm_topology.py
2 # This example shows how to use IMP's CHARMM topology reader to
3 # build an atomic structure (in this case, alanine dipeptide) from
4 # primary sequence, and to apply topology patches.
5 #
6 
7 from __future__ import print_function
8 import IMP.atom
9 import sys
10 
11 IMP.setup_from_argv(sys.argv, "CHARMM topology")
12 
13 # Read CHARMM non-hydrogen parameters
15 
16 # Start building a single segment (chain) topology
18 
19 # Get the topology of an ideal alanine from the CHARMM topology
20 ideal_ala = ff.get_residue_topology(IMP.atom.ALA)
21 
22 # Use ideal topology as a template to make the real alanine topology
23 # ("real" topology can be modified, e.g. by patching)
24 ala = IMP.atom.CHARMMResidueTopology(ideal_ala)
25 
26 # Apply ACE and CT3 patches to our topology. Normally a residue can only
27 # be patched once, so reset the patched flag after the first patch.
28 ace = ff.get_patch("ACE")
29 ct3 = ff.get_patch("CT3")
30 ace.apply(ala)
31 ala.set_patched(False)
32 ct3.apply(ala)
33 
34 # Add the residue and chain to the top-level topology
35 st.add_residue(ala)
37 t.add_segment(st)
38 
39 # Make a Hierarchy using this topology
40 m = IMP.Model()
41 h = t.create_hierarchy(m)
42 IMP.atom.show(h)