IMP logo
IMP Reference Guide  develop.d97d4ead1f,2024/11/21
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 import IMP.atom
8 import sys
9 
10 IMP.setup_from_argv(sys.argv, "CHARMM topology")
11 
12 # Read CHARMM non-hydrogen parameters
14 
15 # Start building a single segment (chain) topology
17 
18 # Get the topology of an ideal alanine from the CHARMM topology
19 ideal_ala = ff.get_residue_topology(IMP.atom.ALA)
20 
21 # Use ideal topology as a template to make the real alanine topology
22 # ("real" topology can be modified, e.g. by patching)
23 ala = IMP.atom.CHARMMResidueTopology(ideal_ala)
24 
25 # Apply ACE and CT3 patches to our topology. Normally a residue can only
26 # be patched once, so reset the patched flag after the first patch.
27 ace = ff.get_patch("ACE")
28 ct3 = ff.get_patch("CT3")
29 ace.apply(ala)
30 ala.set_patched(False)
31 ct3.apply(ala)
32 
33 # Add the residue and chain to the top-level topology
34 st.add_residue(ala)
36 t.add_segment(st)
37 
38 # Make a Hierarchy using this topology
39 m = IMP.Model()
40 h = t.create_hierarchy(m)
41 IMP.atom.show(h)