Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AtomTypeSet.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 /// @begin AtomTypeSet
11 ///
12 /// @brief
13 /// A class for reading in the atom type properties
14 ///
15 /// @detailed
16 /// This class reads in the atom_properties.txt file which contains the "chemical" information for atoms.
17 /// This does not contain the actual properties, but sets the properties through the AtomType class.
18 /// This class is called by the ChemicalManager
19 ///
20 ///
21 ///
22 /// @authors
23 /// Phil Bradley
24 /// Steven Combs - comments
25 ///
26 ///
27 /// @last_modified December 6 2010
28 /////////////////////////////////////////////////////////////////////////
29 
30 #ifndef INCLUDED_core_chemical_AtomTypeSet_hh
31 #define INCLUDED_core_chemical_AtomTypeSet_hh
32 
33 
34 // Unit headers
36 
37 // Utility headers
38 #include <utility/exit.hh>
39 #include <utility/pointer/ReferenceCount.hh>
40 
41 
42 // C++ headers
43 #include <map>
44 
45 #include <core/types.hh>
47 #include <utility/vector1_bool.hh>
48 #include <utility/sql_database/DatabaseSessionManager.fwd.hh>
49 
50 namespace core {
51 namespace chemical {
52 
53 
54 /// @brief a set of AtomTypes
55 ///
56 /// @details a vector of pointers each of which points to an AtomType
57 /// and the vector index is looked up by an atom_name string in a map
58 ///
60 
61 public:
62  /// @brief c-tor from directory in the rosetta_database This will go
63  /// through the directory, usually
64  /// "$ROSETTA3_DB/chemical/atom_type_sets/<atom_type_set_name>" and
65  /// initialize all the atom types defined in atom_properties.txt and
66  /// the extra parameters specified in extras.txt
68 
69  // Construct the atom type set from an sql database
71  std::string const & name,
72  utility::sql_database::sessionOP db_session);
73 
74  virtual ~AtomTypeSet();
75 
76 public:
77 
78  /// @brief the name of the AtomTypeSet
80  name() const;
81 
82  /// @brief number of atom types in the set
83  Size
84  n_atomtypes() const
85  {
86  return atoms_.size();
87  }
88 
89  /// @brief Get the source directory, eg to open an additional file in that directory
90  std::string const &
91  directory() const
92  {
93  return directory_;
94  }
95 
96  /// @brief Check if atom is present
97  bool
98  has_atom( std::string const & atom_type_name ) const
99  {
100  return ( atom_type_index_.find( atom_type_name ) != atom_type_index_.end() );
101  }
102 
103  /// @brief lookup the atom_type by the atom_type_name string
104  int
105  atom_type_index( std::string const & atom_type_name ) const
106  {
107  std::map< std::string, int >::const_iterator
108  iter( atom_type_index_.find( atom_type_name ) );
109  if ( iter == atom_type_index_.end() ) {
110  utility_exit_with_message("unrecognized atom_type_name "+atom_type_name);
111  }
112  return iter->second;
113  }
114 
115 
116  /// @brief [ ] operator, simulating vector index behavior
117  ///
118  /// @details look up an AtomTypeSet by 1-based indexing
119  ///
120  AtomType const &
121  operator[] ( Size const index ) const
122  {
123  return *( atoms_[ index ] );
124  }
125 
126  /// @brief [ ] operator, simulating vector index behavior, non-const version
127  ///
128  /// @details look up an AtomTypeSet by 1-based indexing
129  ///
130  AtomType &
131  operator[] ( Size const index )
132  {
133  return *( atoms_[ index ] );
134  }
135 
136  /// SLOW
137  int
138  extra_parameter_index( std::string const & name ) const
139  {
140  std::map< std::string, int >::const_iterator iter( extra_parameter_indices_.find( name ) );
141  if ( iter == extra_parameter_indices_.end() ) {
142  utility_exit_with_message( "AtomTypeSet: unrecognized atom parameter: "+name );
143  }
144  return iter->second;
145  }
146 
147  std::map< std::string, int> const &
150  }
151 
152  bool
153  has_extra_parameter( std::string const & name ) const
154  {
155  return ( extra_parameter_indices_.find( name ) != extra_parameter_indices_.end() );
156  }
157 
158  /// @brief file I/O
159  void
160  read_file( std::string const & filename );
161 
162  /// @brief additional file I/O
163  void
165 
166  // data
167 private:
168  /// @brief Private helper fxn for performing default parameter substitutions while reading a params file
169  Real
170  get_default_parameter( std::string const & param_name, std::string const & atm_name ) const;
171 
172 
173 private: // helper methods for creating an atom type set from a database
174 
175  ///@brief create an atom type instance on the stack
176  AtomType &
178  std::string const & atom_type_set_name,
179  std::string const & atom_type_name,
180  utility::sql_database::sessionOP db_session);
181 
182 
183  void
185  std::string const & atom_type_set_name,
186  chemical::AtomType & atom_type,
187  utility::sql_database::sessionOP db_session);
188 
189  void
191  std::string const & atom_type_set_name,
192  chemical::AtomType & atom_type,
193  utility::sql_database::sessionOP db_session);
194 
195 private:
196  /// lookup map: get atom_type_index by atom_type_name
197  std::map< std::string, int > atom_type_index_;
198 
199  /// @brief a collection of AtomTypes,
200  ///
201  /// @details AtomType has data of atom properties, and it can be
202  /// looked up by atom_type_index.
204 
205  /// @brief lookup map: get atom extra parameter index by atom_type_name
206  std::map< std::string, int > extra_parameter_indices_;
207 
208  /// @brief Save the directory name for future use, eg to load associated AtomVDW data
210 
211  //Fang-Chieh Chou 8/10/2012
212  //Use larger LJ_WDEPTH for protons to avoid clashes in RNA
213  void enlarge_h_lj_wdepth();
214 
215 };
216 
217 } // chemical
218 } // core
219 
220 #endif