IMP logo
IMP Reference Guide  2.16.0
The Integrative Modeling Platform
charmm_segment_topology.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/charmm_segment_topology.h
3  * \brief Classes for handling CHARMM-style topology of segments.
4  *
5  * Copyright 2007-2021 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_CHARMM_SEGMENT_TOPOLOGY_H
10 #define IMPATOM_CHARMM_SEGMENT_TOPOLOGY_H
11 
12 #include "IMP/Object.h"
13 #include "Hierarchy.h"
14 #include <IMP/atom/atom_config.h>
15 #include "charmm_topology.h"
16 #include "CHARMMParameters.h"
17 
18 IMPATOM_BEGIN_NAMESPACE
19 
20 //! The topology of a single CHARMM segment in a model.
21 /** CHARMM segments typically correspond to IMP::atom::Chain particles.
22  */
23 class IMPATOMEXPORT CHARMMSegmentTopology : public IMP::Object {
24  /** @name Residues
25 
26  The segment contains a chain of residues.
27  */
28  /**@{*/
29  IMP_LIST_ACTION(public, CHARMMResidueTopology, CHARMMResidueTopologies,
30  residue, residues, CHARMMResidueTopology *,
31  CHARMMResidueTopologies, obj->set_was_used(true), , );
32  /**@}*/
33 
35 
36  public:
37  CHARMMSegmentTopology(std::string name = "CHARMM segment topology %1%")
38  : Object(name) {}
39 
40  //! Apply patches to the first and last residue in the segment.
41  /** Default patches are defined for each residue type in the topology
42  file. For example, segments containing amino acids will by default
43  apply the CTER and NTER patches to the C and N termini, respectively.
44  */
45  void apply_default_patches(const CHARMMParameters *ff);
46 };
47 
49 
50 //! The topology of a complete CHARMM model.
51 /** This defines all of the segments (chains) in the model as
52  CHARMMSegmentTopology objects, which in turn define the list of residues,
53  the atoms in each residue, and their types and the connectivity
54  between them.
55 
56  A CHARMMTopology object can be created manually, in which case add_segment()
57  can be called to add individual CHARMMSegmentTopology objects. In this way
58  a new topology can be created, e.g. from protein primary sequence.
59 
60  Alternatively, given an existing Hierarchy, e.g. as returned from
61  read_pdb(), CHARMMParameters::create_topology() can be called to generate
62  a new topology that corresponds to the primary sequence of the Hierarchy.
63 
64  A new topology can be patched (apply_default_patches() or
65  CHARMMPatch::apply()) to modify the simple chain of residues to
66  account for modified residues, C- or N-termini special cases, disulfide
67  bridges, etc.
68 
69  Once a topology is created, it can be used to generate new particles
70  which conform to that topology (create_hierarchy()), or to add
71  topology information to an existing Hierarchy (e.g. add_atom_types(),
72  add_bonds(), add_charges()).
73  */
74 class IMPATOMEXPORT CHARMMTopology : public IMP::Object {
75 public:
76  typedef std::map<const CHARMMResidueTopology *, Hierarchy> ResMap;
77 private:
79  WarningContext warn_context_;
80 
81  void map_residue_topology_to_hierarchy(Hierarchy hierarchy,
82  ResMap &resmap) const;
83 
84  public:
85  CHARMMTopology(const CHARMMParameters *force_field,
86  std::string name = "CHARMM topology %1%")
87  : Object(name), force_field_(force_field) {
88  set_was_used(true);
89  }
90 
91  const CHARMMParameters *get_parameters() { return force_field_; }
92 
93  //! Add a sequence (as a string of one-letter codes) to the topology.
94  /** The sequence can contain amino-acid one-letter codes and '/' characters
95  to denote the start of a new segment. The empty string simply adds a new
96  segment that contains no residues.
97  \exception ValueException if an invalid one-letter code is passed.
98  */
99  void add_sequence(std::string sequence);
100 
101  //! Call CHARMMSegmentTopology::apply_default_patches() for all segments.
103  for (unsigned int i = 0; i < get_number_of_segments(); ++i) {
104  get_segment(i)->apply_default_patches(force_field_);
105  }
106  }
107 
108  //! Create a new Hierarchy in the given model using this topology.
109  /** The hierarchy contains chains, residues and atoms as defined in the
110  topology. Note, however, that none of the generated atoms is given
111  coordinates.
112  Chains are labeled 'A', 'B' etc. Residues are numbered from 1 within
113  each chain.
114  \see add_coordinates.
115  */
116  Hierarchy create_hierarchy(Model *model) const;
117 
118  //! Add CHARMM atom types to the given Hierarchy using this topology.
119  /** The primary sequence of the Hierarchy must match that of the topology.
120  A warning will be printed for any atoms that cannot be found in the
121  topology (and no CHARMM atom type will be assigned). Any atoms that
122  already have a CHARMM atom type and that are present in the topology
123  will have that type reassigned.
124  \see CHARMMAtom.
125  */
126  void add_atom_types(Hierarchy hierarchy) const;
127 
128  //! Add atom Cartesian coordinates to the given Hierarchy using this topology.
129  /** The primary sequence of the Hierarchy must match that of the topology.
130 
131  This method can be used to add missing coordinates (e.g. of hydrogens
132  or sidechains, such as those added by add_missing_atoms()), or to
133  generate a starting conformation for a new Hierarchy (e.g. generated
134  by create_hierarchy()). On exit, all atoms will have coordinates.
135 
136  - Cartesian coordinates for any atoms that are not currently core::XYZ
137  particles are generated using internal coordinates that relate them
138  to particles that do have XYZ coordinates.
139 
140  - For each segment (chain), if no atoms have coordinates but a triplet
141  of atoms can be found where their internal distances and angle can be
142  determined from internal coordinates, these three atoms will be
143  placed to seed the generation procedure. For the first segment, the
144  atoms will be placed on the xy plane with the first atom at the origin.
145  For subsequent segments, the first atom is placed offset by (2.,2.,2.)
146  from the last atom in the previous segment.
147 
148  - If any atoms cannot be placed using either method, their coordinates
149  are assigned randomly to lie near atoms that are near in sequence or,
150  if no such atoms exist, near the segment origin.
151 
152  \note It is valid to specify internal coordinates in a CHARMM topology
153  file that leave the angles or distances unspecified. This function
154  will attempt to fill in this missing information using CHARMM atom
155  types and the parameter file. Thus, better results will be obtained
156  if add_atom_types() is called before this function, and the
157  CHARMMParameters object used contains parameter information.
158  */
159  void add_coordinates(Hierarchy hierarchy) const;
160 
161  //! Add any missing atoms to the given Hierarchy using this topology.
162  /** Missing atoms are defined as those present in the topology but not
163  in the hierarchy.
164  Newly-added atoms are assigned CHARMM types, but no coordinates
165  (use add_coordinates() to add them).
166  The primary sequence of the Hierarchy must match that of the topology.
167  \see CHARMMAtom, remove_charmm_untyped_atoms, add_coordinates.
168  */
169  void add_missing_atoms(Hierarchy hierarchy) const;
170 
171  //! Make the Hierarchy conform with this topology.
172  /** The hierarchy is modified if necessary so that each residue contains
173  the same set of atoms as defined in the CHARMM topology, and any
174  atoms missing coordinates are assigned them.
175 
176  This is equivalent to calling add_atom_types(), add_missing_atoms(),
177  remove_charmm_untyped_atoms(), and add_coordinates() in that order.
178  */
179  void setup_hierarchy(Hierarchy hierarchy) const;
180 
181  //! Add CHARMM charges to the given Hierarchy using this topology.
182  /** The primary sequence of the Hierarchy must match that of the topology.
183  \see Charged.
184  */
185  void add_charges(Hierarchy hierarchy) const;
186 
187  //! Add bonds to the given Hierarchy using this topology, and return them.
188  /** The primary sequence of the Hierarchy must match that of the topology.
189  Parameters for the bonds (ideal bond length, force constant) are
190  extracted from the CHARMM parameter file, using the types of each atom
191  (add_atom_types() must be called first, or the particles otherwise
192  manually typed using CHARMMAtom::set_charmm_type()).
193 
194  If no parameters are defined for a given bond, the bond is created
195  with zero stiffness, such that the bond can still be excluded from
196  nonbonded interactions but BondSingletonScore will not score it.
197 
198  Note that typically CHARMM defines bonds and impropers
199  (see add_impropers()) but angles and dihedrals are auto-generated from
200  the existing bond graph (see CHARMMParameters::create_angles() and
201  CHARMMParameters::create_dihedrals()).
202 
203  The list of newly-created Bond particles can be passed to a
204  StereochemistryPairFilter to exclude bonded particles from nonbonded
205  interactions, or to a BondSingletonScore to score each bond.
206 
207  \return a list of the generated Bond decorators.
208  */
209  Particles add_bonds(Hierarchy hierarchy) const;
210 
211  //! Add dihedrals to the given Hierarchy using this topology, and return them.
212  /** The primary sequence of the Hierarchy must match that of the topology.
213 
214  Typically, dihedrals are auto-generated from the existing bond
215  graph (see CHARMMParameters::create_dihedrals()) rather than using
216  this function.
217 
218  \return a list of the generated Dihedral decorators.
219 
220  \see add_bonds().
221  */
222  Particles add_dihedrals(Hierarchy hierarchy) const;
223 
224  //! Add impropers to the given Hierarchy using this topology, and return them.
225  /** The primary sequence of the Hierarchy must match that of the topology.
226 
227  The list of newly-created Dihedral particles can be passed to a
228  ImproperSingletonScore to score each improper dihedral.
229 
230  \return a list of the generated Dihedral decorators.
231 
232  \see add_bonds().
233  */
234  Particles add_impropers(Hierarchy hierarchy) const;
235 
236  /** @name Segments
237 
238  The topology contains a list of segments, one for each chain.
239  */
240  /**@{*/
241  IMP_LIST_ACTION(public, CHARMMSegmentTopology, CHARMMSegmentTopologies,
242  segment, segments, CHARMMSegmentTopology *,
243  CHARMMSegmentTopologies, obj->set_was_used(true), , );
244  /**@}*/
245 
247 };
249 
250 IMPATOM_END_NAMESPACE
251 
252 #endif /* IMPATOM_CHARMM_SEGMENT_TOPOLOGY_H */
access to CHARMM force field parameters
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
A more IMP-like version of the std::vector.
Definition: Vector.h:40
Warnings with the same key within the context are only output once.
The topology of a single residue in a model.
A smart pointer to a reference counted object.
Definition: Pointer.h:87
CHARMM force field parameters.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:73
Classes for handling CHARMM-style topology.
Decorator for helping deal with a hierarchy of molecules.
void apply_default_patches()
Call CHARMMSegmentTopology::apply_default_patches() for all segments.
The standard decorator for manipulating molecular structures.
Common base class for heavy weight IMP objects.
Definition: Object.h:106
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
A shared base class to help in debugging and things.
Object(std::string name)
Construct an object with the given name.
The topology of a single CHARMM segment in a model.
The topology of a complete CHARMM model.
DensityMap * get_segment(DensityMap *map_to_segment, int nx_start, int nx_end, int ny_start, int ny_end, int nz_start, int nz_end)
Get a segment of the map according to xyz indexes.
void add_bonds(Hierarchy d, const ForceFieldParameters *ffp=get_all_atom_CHARMM_parameters())
void set_was_used(bool tf) const