IMP logo
IMP Reference Guide  2.10.1
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-2018 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  \see CHARMMAtom.
121  */
122  void add_atom_types(Hierarchy hierarchy) const;
123 
124  //! Add atom Cartesian coordinates to the given Hierarchy using this topology.
125  /** The primary sequence of the Hierarchy must match that of the topology.
126 
127  This method can be used to add missing coordinates (e.g. of hydrogens
128  or sidechains, such as those added by add_missing_atoms()), or to
129  generate a starting conformation for a new Hierarchy (e.g. generated
130  by create_hierarchy()). On exit, all atoms will have coordinates.
131 
132  - Cartesian coordinates for any atoms that are not currently core::XYZ
133  particles are generated using internal coordinates that relate them
134  to particles that do have XYZ coordinates.
135 
136  - For each segment (chain), if no atoms have coordinates but a triplet
137  of atoms can be found where their internal distances and angle can be
138  determined from internal coordinates, these three atoms will be
139  placed to seed the generation procedure. For the first segment, the
140  atoms will be placed on the xy plane with the first atom at the origin.
141  For subsequent segments, the first atom is placed offset by (2.,2.,2.)
142  from the last atom in the previous segment.
143 
144  - If any atoms cannot be placed using either method, their coordinates
145  are assigned randomly to lie near atoms that are near in sequence or,
146  if no such atoms exist, near the segment origin.
147 
148  \note It is valid to specify internal coordinates in a CHARMM topology
149  file that leave the angles or distances unspecified. This function
150  will attempt to fill in this missing information using CHARMM atom
151  types and the parameter file. Thus, better results will be obtained
152  if add_atom_types() is called before this function, and the
153  CHARMMParameters object used contains parameter information.
154  */
155  void add_coordinates(Hierarchy hierarchy) const;
156 
157  //! Add any missing atoms to the given Hierarchy using this topology.
158  /** Missing atoms are defined as those present in the topology but not
159  in the hierarchy.
160  Newly-added atoms are assigned CHARMM types, but no coordinates
161  (use add_coordinates() to add them).
162  The primary sequence of the Hierarchy must match that of the topology.
163  \see CHARMMAtom, remove_charmm_untyped_atoms, add_coordinates.
164  */
165  void add_missing_atoms(Hierarchy hierarchy) const;
166 
167  //! Make the Hierarchy conform with this topology.
168  /** The hierarchy is modified if necessary so that each residue contains
169  the same set of atoms as defined in the CHARMM topology, and any
170  atoms missing coordinates are assigned them.
171 
172  This is equivalent to calling add_atom_types(), add_missing_atoms(),
173  remove_charmm_untyped_atoms(), and add_coordinates() in that order.
174  */
175  void setup_hierarchy(Hierarchy hierarchy) const;
176 
177  //! Add CHARMM charges to the given Hierarchy using this topology.
178  /** The primary sequence of the Hierarchy must match that of the topology.
179  \see Charged.
180  */
181  void add_charges(Hierarchy hierarchy) const;
182 
183  //! Add bonds to the given Hierarchy using this topology, and return them.
184  /** The primary sequence of the Hierarchy must match that of the topology.
185  Parameters for the bonds (ideal bond length, force constant) are
186  extracted from the CHARMM parameter file, using the types of each atom
187  (add_atom_types() must be called first, or the particles otherwise
188  manually typed using CHARMMAtom::set_charmm_type()).
189 
190  If no parameters are defined for a given bond, the bond is created
191  with zero stiffness, such that the bond can still be excluded from
192  nonbonded interactions but BondSingletonScore will not score it.
193 
194  Note that typically CHARMM defines bonds and impropers
195  (see add_impropers()) but angles and dihedrals are auto-generated from
196  the existing bond graph (see CHARMMParameters::create_angles() and
197  CHARMMParameters::create_dihedrals()).
198 
199  The list of newly-created Bond particles can be passed to a
200  StereochemistryPairFilter to exclude bonded particles from nonbonded
201  interactions, or to a BondSingletonScore to score each bond.
202 
203  \return a list of the generated Bond decorators.
204  */
205  Particles add_bonds(Hierarchy hierarchy) const;
206 
207  //! Add dihedrals to the given Hierarchy using this topology, and return them.
208  /** The primary sequence of the Hierarchy must match that of the topology.
209 
210  Typically, dihedrals are auto-generated from the existing bond
211  graph (see CHARMMParameters::create_dihedrals()) rather than using
212  this function.
213 
214  \return a list of the generated Dihedral decorators.
215 
216  \see add_bonds().
217  */
218  Particles add_dihedrals(Hierarchy hierarchy) const;
219 
220  //! Add impropers to the given Hierarchy using this topology, and return them.
221  /** The primary sequence of the Hierarchy must match that of the topology.
222 
223  The list of newly-created Dihedral particles can be passed to a
224  ImproperSingletonScore to score each improper dihedral.
225 
226  \return a list of the generated Dihedral decorators.
227 
228  \see add_bonds().
229  */
230  Particles add_impropers(Hierarchy hierarchy) const;
231 
232  /** @name Segments
233 
234  The topology contains a list of segments, one for each chain.
235  */
236  /**@{*/
237  IMP_LIST_ACTION(public, CHARMMSegmentTopology, CHARMMSegmentTopologies,
238  segment, segments, CHARMMSegmentTopology *,
239  CHARMMSegmentTopologies, obj->set_was_used(true), , );
240  /**@}*/
241 
243 };
245 
246 IMPATOM_END_NAMESPACE
247 
248 #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:39
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:72
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