Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResidueTypeSet.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file
11 /// @author Phil Bradley
12 
13 
14 #ifndef INCLUDED_core_chemical_ResidueTypeSet_hh
15 #define INCLUDED_core_chemical_ResidueTypeSet_hh
16 
17 
18 // Unit headers
20 
21 
22 // Package headers
23 #include <core/chemical/AA.hh>
24 // AUTO-REMOVED #include <core/chemical/ResidueType.hh>
26 // Commented by inclean daemon #include <core/chemical/AtomTypeSet.hh>
27 // Commented by inclean daemon #include <core/chemical/MMAtomTypeSet.hh>
28 
29 // Project headers
30 //XRW_B_T1
31 // Commented by inclean daemon #include <core/coarse/TranslatorSet.fwd.hh>
32 //XRW_E_T1
33 //#include <core/pose/Pose.fwd.hh>
34 
35 // Utility Headers
36 // Commented by inclean daemon #include <utility/pointer/ReferenceCount.hh>
37 // Commented by inclean daemon #include <utility/vector1_bool.hh>
38 
39 
40 // STL headers
41 #include <list>
42 
43 // AUTO-REMOVED #include <core/chemical/Adduct.hh>
50 #include <utility/exit.hh>
51 #include <utility/vector1.hh>
52 #include <utility/pointer/ReferenceCount.hh>
53 #include <map>
54 
55 //Auto Headers
57 #ifdef PYROSETTA
59 #endif
60 
61 
62 
63 namespace core {
64 namespace chemical {
65 
66 /// A collection of ResidueType defined
67 /**
68  One thing that is not nailed down is whether a single ResidueSet can have ResidueType's with
69  different AtomTypeSets. I've left open this possibility currently although there isnt any code
70  for this yet (PB-07/07)
71 **/
72 
73 
75 {
76 public:
77  typedef std::list< AA >::const_iterator AAsIter;
78  typedef std::map< std::string, ResidueTypeCOP >::const_iterator const_residue_iterator;
79 
80 public:
81 
82 
83  /// @brief default c-tor
85 
86  /// @brief constructor from directory
88  std::string const & name,
89  std::string const & directory,
90  std::vector< std::string > const & extra_res_param_files = std::vector< std::string >(),
91  std::vector< std::string > const & extra_patch_files = std::vector< std::string >()
92  );
93 
94  virtual ~ResidueTypeSet();
95 
96  /// @brief name of the residue type set
97  std::string const &
98  name() const {
99  return name_;
100  }
101 
102  /// @brief read a list of residue types
103  void
105  std::string const & list_filename,
106  AtomTypeSetCAP atom_types,
107  ElementSetCAP elements,
108  MMAtomTypeSetCAP mm_atom_types,
109  orbitals::OrbitalTypeSetCAP orbital_types//,
110 // CSDAtomTypeSetCAP csd_atom_types kwk commenting out csd atomtypes until I have had a chance to fully implement them
111  );
112 
113  void
114  read_files(
115  utility::vector1< std::string > const & filenames,
116  AtomTypeSetCAP atom_types,
117  ElementSetCAP elements,
118  MMAtomTypeSetCAP mm_atom_types,
119  orbitals::OrbitalTypeSetCAP orbital_types//,
120 // CSDAtomTypeSetCAP csd_atom_types kwk commenting out the csd atomtypes until I have had a chance to implement them
121  );
122 
123 // Old code - doesn't respect various command line options. See constructor for current patch-loading functionality
124 // /// @brief apply patches to base ResidueType to generate variant ResidueTyes
125 // void
126 // apply_patches( std::string const & filename );
127 
128  void
130  utility::vector1< std::string > const & filenames
131  );
132 
133  /// @brief apply patches to base ResidueType to generate variant ResidueTyes
134  void
135  place_adducts();
136 
137  /// @brief adds a new residue type to the set
138  void
139  add_residue_type( ResidueTypeOP new_type );
140 
141  /// @brief delete a residue type from the set (Use with care)
142  void
143  remove_residue_type(std::string const & name);
144 
145  /// @brief Create correct combinations of adducts for a residue type
147  ResidueType const & rsd,
148  std::map< std::string, int > ref_map,
149  std::map< std::string, int > count_map,
150  utility::vector1< bool > add_mask,
152  );
153 
154  /// @brief query ResidueTypes by their 3-letter name
155  ///
156  /// @details 3-letter name is not unique to each ResidueType
157  /// for example, 3-letter name "HIS" matches both his tautomers,
158  /// HIS and HIS_D. Return an empty list if no match is found.
159  ResidueTypeCOPs const &
160  name3_map( std::string const & name ) const
161  {
162  assert( name.size() == 3 );
163  if ( name3_map_.find( name ) == name3_map_.end() ) {
164  return empty_residue_list_;
165  }
166  return name3_map_.find( name )->second;
167  }
168 
169  /// @brief query ResidueType by its unique residue id.
170  ///
171  /// @details since residue id is unique, it only returns
172  /// one residue type or exit without match.
173  ResidueType const &
174  name_map( std::string const & name ) const
175  {
176  if ( name_map_.find( name ) == name_map_.end() ) {
177  utility_exit_with_message( "unrecognized residue name '"+name+"'" );
178  }
179  return *( name_map_.find( name )->second );
180  }
181 
182  /// @brief query ResidueType by its unique residue id.
183  ///
184  /// @details since residue id is unique, it only returns
185  /// one residue type or exit without match.
186  ResidueType &
188  {
189  if ( nonconst_name_map_.find( name ) == nonconst_name_map_.end() ) {
190  utility_exit_with_message( "unrecognized residue name" );
191  }
192  return *( nonconst_name_map_.find( name )->second );
193  }
194 
195  /// @brief query if a ResidueType of the unique residue id is present.
196  ///
197  ///
198  bool
199  has_name( std::string const & name ) const
200  {
201  return ( name_map_.find( name ) != name_map_.end() );
202  }
203 
204  /// @brief query if a ResidueType of a certain 3letter name is present.
205  bool
206  has_name3( std::string const & name3 ) const
207  {
208  return ( name3_map_.find( name3 ) != name3_map_.end() );
209  }
210 
211  /// @brief query a variant ResidueType by its base ResidueType and VariantType
212  ///
213  /// @note currently, this will not work for variant types defined as alternate
214  /// base residues (ie different params files)
215  ResidueType const &
216  get_residue_type_with_variant_added( ResidueType const & init_rsd, VariantType const & new_type ) const;
217 
218 
219  /// @brief return the residuetype we get from variant rsd type after removing the desired variant type
220  ///
221  /// @note currently, this will not work for variant types defined as alternate
222  /// base residues (ie different params files)
223  ResidueType const &
224  get_residue_type_with_variant_removed( ResidueType const & init_rsd, VariantType const & old_type ) const;
225 
226 
227  /// @brief query ResidueTypes by their AA enum type
228  ///
229  /// @details similar to name3_map, return all matched residue types
230  /// or an empty list.
231  ResidueTypeCOPs const &
232  aa_map( AA const & aa ) const
233  {
234  if ( aa_map_.find( aa ) == aa_map_.end() ) {
235  return empty_residue_list_;
236  }
237  return aa_map_.find( aa )->second;
238  }
239 
240  /// @brief select a set of ResidueTypes give certain criteria
241  void
243  ResidueSelector const & selector,
244  ResidueTypeCOPs & matches
245  ) const;
246 
247  /// @brief beginning of aas_defined_ list
248  std::list< AA >::const_iterator
249  aas_defined_begin() const;
250 
251  /// @brief end of aas_defined_ list
252  std::list< AA >::const_iterator
253  aas_defined_end() const;
254 
257  {
258  return name_map_.begin();
259  }
260 
263  {
264  return name_map_.end();
265  }
266 
267  /// alternate access to all residuetypes as vector
268  ResidueTypeCOPs const &
270  {
271  return residue_types_const_;
272  }
273 
274  /// @brief accessor for database_directory
275  std::string const&
277  {
278  return database_directory_;
279  }
280 
281  //////////////////
282  // private methods
283 private:
284 
285  /// @brief clear residue maps
286  void
288 
289  /// @brief update residue maps
290  void
292 
293  void
295 
296  void
298 
299  //////////////////
300  // data
301 private:
302 
303  //chemical::AtomTypeSet const & atom_types_;
304 
305 // /// @brief the atom-types
306 // chemical::AtomTypeSetCAP atom_types_;
307 
308 // /// @brief the MMatom-types
309 // chemical::MMAtomTypeSetCAP mm_atom_types_;
310 
311  /// What does the ChemicalManager call this ResidueTypeSet?
313 
314  /// @brief the residues
316 
317  /// for handing out
319 
320  /// @brief null list of residues when query fails
321  //should make this static or something
323 
324 
325  /// @brief map to ResidueType pointers by AA enum
326  std::map< AA, ResidueTypeCOPs > aa_map_;
327 
328  /// @brief map to ResidueType pointers by 3-letter string name
329  std::map< std::string, ResidueTypeCOPs > name3_map_;
330 
331  /// @brief map to ResidueType pointers by unique residue id
332  std::map< std::string, ResidueTypeCOP > name_map_;
333 
334  /// @brief map to ResidueType pointers by unique residue id, for nonconst access
335  std::map< std::string, ResidueTypeOP > nonconst_name_map_;
336 
337  /// @brief list of AA types defined
338  std::list< AA > aas_defined_;
339 
340  //XRW_B_T1
341  /*
342  /// @brief the coarsify translator in case this a coarse residue set
343  coarse::TranslatorSetCOP coarsifier_;
344  */
345  //XRW_E_T1
346 
347  /// @brief the database directory of the generating files ---> allows to use cached dunbrack libs
349 
350 private:
351  // uncopyable
352  ResidueTypeSet( ResidueTypeSet const & );
353  ResidueTypeSet const & operator = ( ResidueTypeSet const & );
354 };
355 
356 } // chemical
357 } // core
358 
359 
360 
361 #endif