Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HBondTypeManager.cc
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 sw=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 core/scoring/hbonds/HBondTypeManager.hh
11 /// @brief HBond enumeration type manager
12 /// @author Matthew O'Meara
13 
14 // Unit headers
16 
17 // Project headers
19 #include <core/chemical/types.hh>
20 
21 // Utility headers
22 #include <utility/exit.hh>
23 #include <utility/vector1_bool.hh>
24 
25 // C++ headers
26 #include <map>
27 #include <string>
28 #include <iostream>
29 
30 #include <utility/vector1.hh>
31 
32 
33 
34 
35 namespace core {
36 namespace scoring {
37 namespace hbonds{
38 
39 using namespace std;
40 using utility::vector1;
41 using namespace chemical;
42 
43 bool HBondTypeManager::initialized_( false );
44 
45 map< string, HBondWeightType > HBondTypeManager::name2weight_type_;
46 vector1< string > HBondTypeManager::weight_type2name_;
47 
48 map< string, HBDerivType > HBondTypeManager::name2deriv_type_;
49 vector1< string > HBondTypeManager::deriv_type2name_;
50 
51 map< string, HBDonChemType > HBondTypeManager::name2don_chem_type_;
53 
54 map< string, HBAccChemType > HBondTypeManager::name2acc_chem_type_;
56 
57 map< string, HBSeqSep > HBondTypeManager::name2seq_sep_type_;
58 vector1< string > HBondTypeManager::seq_sep_type2name_;
59 
60 map< string, Hybridization > HBondTypeManager::name2hybridization_type_;
62 
63 map< string, HBGeoDimType > HBondTypeManager::name2geo_dim_type_;
64 vector1< string > HBondTypeManager::geo_dim_type2name_;
65 
66 
67 /// @brief initialize the ScoreType name vector and map
68 ///
69 /// @details initialize all the SCORETYPE string name into the vector then set up
70 /// the look-up map from string name to enum type
71 void
73 {
74  if ( initialized_ ) return;
75  initialized_ = true;
76 
77 
78  name2weight_type_["hbw_NONE"] = hbw_NONE;
79  name2weight_type_["hbw_SR_BB"] = hbw_SR_BB;
80  name2weight_type_["hbw_LR_BB"] = hbw_LR_BB;
81  name2weight_type_["hbw_SR_BB_SC"] = hbw_SR_BB_SC;
82  name2weight_type_["hbw_LR_BB_SC"] = hbw_LR_BB_SC;
83  name2weight_type_["hbw_SC"] = hbw_SC;
84 
85  name2deriv_type_["hbderiv_NONE"] = hbderiv_NONE;
86  name2deriv_type_["hbderiv_ABE_GO"] = hbderiv_ABE_GO;
87  name2deriv_type_["hbderiv_ABE_GO_NO_xD"] = hbderiv_ABE_GO_NO_xD;
88  name2deriv_type_["hbderiv_ABE_GO_NO_xH"] = hbderiv_ABE_GO_NO_xH;
89 
90  name2don_chem_type_["hbdon_NONE"] = hbdon_NONE;
91  name2don_chem_type_["hbdon_PBA"] = hbdon_PBA;
92  name2don_chem_type_["hbdon_CXA"] = hbdon_CXA;
93  name2don_chem_type_["hbdon_IMD"] = hbdon_IMD;
94  name2don_chem_type_["hbdon_IME"] = hbdon_IME;
95  name2don_chem_type_["hbdon_IND"] = hbdon_IND;
96  name2don_chem_type_["hbdon_AMO"] = hbdon_AMO;
97  name2don_chem_type_["hbdon_GDE"] = hbdon_GDE;
98  name2don_chem_type_["hbdon_GDH"] = hbdon_GDH;
99  name2don_chem_type_["hbdon_AHX"] = hbdon_AHX;
100  name2don_chem_type_["hbdon_HXL"] = hbdon_HXL;
101  name2don_chem_type_["hbdon_H2O"] = hbdon_H2O;
102  name2don_chem_type_["hbdon_GENERIC_BB"] = hbdon_GENERIC_BB;
103  name2don_chem_type_["hbdon_GENERIC_SC"] = hbdon_GENERIC_SC;
104 
105  name2acc_chem_type_["hbacc_NONE"] = hbacc_NONE;
106  name2acc_chem_type_["hbacc_PBA"] = hbacc_PBA;
107  name2acc_chem_type_["hbacc_CXA"] = hbacc_CXA;
108  name2acc_chem_type_["hbacc_CXL"] = hbacc_CXL;
109  name2acc_chem_type_["hbacc_IMD"] = hbacc_IMD;
110  name2acc_chem_type_["hbacc_IME"] = hbacc_IME;
111  name2acc_chem_type_["hbacc_AHX"] = hbacc_AHX;
112  name2acc_chem_type_["hbacc_HXL"] = hbacc_HXL;
113  name2acc_chem_type_["hbacc_PCA_DNA"] = hbacc_PCA_DNA;
114  name2acc_chem_type_["hbacc_PES_DNA"] = hbacc_PES_DNA;
115  name2acc_chem_type_["hbacc_RRI_DNA"] = hbacc_RRI_DNA;
116  name2acc_chem_type_["hbacc_PCA_RNA"] = hbacc_PCA_RNA;
117  name2acc_chem_type_["hbacc_PES_RNA"] = hbacc_PES_RNA;
118  name2acc_chem_type_["hbacc_RRI_RNA"] = hbacc_RRI_RNA;
119  name2acc_chem_type_["hbacc_H2O"] = hbacc_H2O;
120  name2acc_chem_type_["hbacc_GENERIC_SP2BB"] = hbacc_GENERIC_SP2BB;
121  name2acc_chem_type_["hbacc_GENERIC_SP2SC"] = hbacc_GENERIC_SP2SC;
122  name2acc_chem_type_["hbacc_GENERIC_SP3BB"] = hbacc_GENERIC_SP3BB;
123  name2acc_chem_type_["hbacc_GENERIC_SP3SC"] = hbacc_GENERIC_SP3SC;
124  name2acc_chem_type_["hbacc_GENERIC_RINGBB"] = hbacc_GENERIC_RINGBB;
125  name2acc_chem_type_["hbacc_GENERIC_RINGSC"] = hbacc_GENERIC_RINGSC;
126 
127  name2seq_sep_type_["seq_sep_other"] = seq_sep_other;
128  name2seq_sep_type_["seq_sep_M4"] = seq_sep_M4;
129  name2seq_sep_type_["seq_sep_M3"] = seq_sep_M3;
130  name2seq_sep_type_["seq_sep_M2"] = seq_sep_M2;
131  name2seq_sep_type_["seq_sep_PM1"] = seq_sep_PM1;
132  name2seq_sep_type_["seq_sep_P2"] = seq_sep_P2;
133  name2seq_sep_type_["seq_sep_P3"] = seq_sep_P3;
134  name2seq_sep_type_["seq_sep_P4"] = seq_sep_P4;
135 
136  name2hybridization_type_["SP2_HYBRID"] = chemical::SP2_HYBRID;
137  name2hybridization_type_["SP3_HYBRID"] = chemical::SP3_HYBRID;
138  name2hybridization_type_["RING_HYBRID"] = chemical::RING_HYBRID;
139  name2hybridization_type_["UNKNOWN_HYBRID"] = chemical::UNKNOWN_HYBRID;
140 
141  name2geo_dim_type_["hbgd_NONE"] = hbgd_NONE;
142  name2geo_dim_type_["hbgd_AHdist"] = hbgd_AHdist;
143  name2geo_dim_type_["hbgd_cosBAH"] = hbgd_cosBAH;
144  name2geo_dim_type_["hbgd_cosAHD"] = hbgd_cosAHD;
145  name2geo_dim_type_["hbgd_AHD"] = hbgd_AHD;
146  name2geo_dim_type_["hbgd_chi"] = hbgd_chi;
147 
148  assert( name2weight_type_.size() == hbw_MAX );
149  assert( name2deriv_type_.size() == hbderiv_MAX );
150  assert( name2don_chem_type_.size() == hbdon_MAX );
151  assert( name2acc_chem_type_.size() == hbacc_MAX );
152  assert( name2seq_sep_type_.size() == seq_sep_MAX );
153  assert( name2geo_dim_type_.size() == hbgd_MAX );
154  assert( name2hybridization_type_.size() == chemical::HYBRID_MAX );
155 
156  weight_type2name_.resize( hbw_MAX );
157  for ( map< string, HBondWeightType >::const_iterator iter = name2weight_type_.begin(),
158  iter_end = name2weight_type_.end(); iter != iter_end; ++iter ) {
159  weight_type2name_[ iter->second ] = iter->first;
160  }
161 
162  deriv_type2name_.resize( hbderiv_MAX );
163  for ( map< string, HBDerivType >::const_iterator iter = name2deriv_type_.begin(),
164  iter_end = name2deriv_type_.end(); iter != iter_end; ++iter ) {
165  deriv_type2name_[ iter->second ] = iter->first;
166  }
167 
168  don_chem_type2name_.resize(hbdon_MAX );
169  for ( map< string, HBDonChemType >::const_iterator iter = name2don_chem_type_.begin(),
170  iter_end = name2don_chem_type_.end(); iter != iter_end; ++iter ) {
171  don_chem_type2name_[ iter->second ] = iter->first;
172  }
173 
174  acc_chem_type2name_.resize(hbacc_MAX );
175  for ( map< string, HBAccChemType >::const_iterator iter = name2acc_chem_type_.begin(),
176  iter_end = name2acc_chem_type_.end(); iter != iter_end; ++iter ) {
177  acc_chem_type2name_[ iter->second ] = iter->first;
178  }
179 
180  seq_sep_type2name_.resize(seq_sep_MAX );
181  for ( map< string, HBSeqSep >::const_iterator iter = name2seq_sep_type_.begin(),
182  iter_end = name2seq_sep_type_.end(); iter != iter_end; ++iter ) {
183  seq_sep_type2name_[ iter->second ] = iter->first;
184  }
185 
186  hybridization_type2name_.resize(chemical::HYBRID_MAX);
187  for ( map< string, Hybridization >::const_iterator
188  iter = name2hybridization_type_.begin(),
189  iter_end = name2hybridization_type_.end();
190  iter != iter_end; ++iter ) {
191  hybridization_type2name_[iter->second ] = iter->first;
192  }
193 
194  geo_dim_type2name_.resize(hbgd_MAX );
195  for ( map< string, HBGeoDimType >::const_iterator iter = name2geo_dim_type_.begin(),
196  iter_end = name2geo_dim_type_.end(); iter != iter_end; ++iter ) {
197  geo_dim_type2name_[ iter->second ] = iter->first;
198  }
199 }
200 
201 //////////////////////////////////////////////////////////////////////////////
202 /// @brief give a HBondWeightType string name and return its enum type
205 {
206  setup_type_names();
207  map< string, HBondWeightType >::const_iterator iter( name2weight_type_.find( name ) );
208  if ( iter == name2weight_type_.end() ) {
209  utility_exit_with_message("unrecognized hydrogen bond weight type '"+name+"'");
210  }
211  return iter->second;
212 }
213 
214 string
216 {
217  setup_type_names();
218  return weight_type2name_[ type ];
219 }
220 
221 ///@brief
222 bool
223 HBondTypeManager::is_weight_type( string const & name )
224 {
225  setup_type_names();
226  map< string, HBondWeightType >::const_iterator iter( name2weight_type_.find( name ) );
227  return iter != name2weight_type_.end();
228 }
229 
230 
231 
232 //////////////////////////////////////////////////////////////////////////////
233 /// @brief give a HBDerivType string name and return its enum type
236 {
237  setup_type_names();
238  map< string, HBDerivType >::const_iterator iter( name2deriv_type_.find( name ) );
239  if ( iter == name2deriv_type_.end() ) {
240  utility_exit_with_message("unrecognized hydrogen bond deriv type "+name);
241  }
242  return iter->second;
243 }
244 
245 string
247 {
248  setup_type_names();
249  return deriv_type2name_[ type ];
250 }
251 
252 ///@brief
253 bool
254 HBondTypeManager::is_deriv_type( string const & name )
255 {
256  setup_type_names();
257  map< string, HBDerivType >::const_iterator iter( name2deriv_type_.find( name ) );
258  return iter != name2deriv_type_.end();
259 }
260 
261 
262 
263 
264 //////////////////////////////////////////////////////////////////////////////
265 /// @brief give a HBDonChemType string name and return its enum type
268 {
269  setup_type_names();
270  map< string, HBDonChemType >::const_iterator iter( name2don_chem_type_.find( name ) );
271  if ( iter == name2don_chem_type_.end() ) {
272  utility_exit_with_message("unrecognized hydrogen bond donor chemical type '"+name+"'");
273  }
274  return iter->second;
275 }
276 
277 string
279 {
280  setup_type_names();
281  return don_chem_type2name_[ type ];
282 }
283 
284 ///@brief
285 bool
287 {
288  setup_type_names();
289  map< string, HBDonChemType >::const_iterator iter( name2don_chem_type_.find( name ) );
290  return iter != name2don_chem_type_.end();
291 }
292 
293 
294 //////////////////////////////////////////////////////////////////////////////
295 /// @brief give a HBAccChemType string name and return its enum type
298 {
299  setup_type_names();
300  map< string, HBAccChemType >::const_iterator iter( name2acc_chem_type_.find( name ) );
301  if ( iter == name2acc_chem_type_.end() ) {
302  utility_exit_with_message("unrecognized hydrogen bond acceptor chemical type '"+name+"'");
303  }
304  return iter->second;
305 }
306 
307 string
309 {
310  setup_type_names();
311  return acc_chem_type2name_[ type ];
312 }
313 
314 ///@brief
315 bool
317 {
318  setup_type_names();
319  map< string, HBAccChemType >::const_iterator iter( name2acc_chem_type_.find( name ) );
320  return iter != name2acc_chem_type_.end();
321 }
322 
323 //////////////////////////////////////////////////////////////////////////////
324 /// @brief give a HBSeqSep string name and return its enum type
325 HBSeqSep
327 {
328  setup_type_names();
329  map< string, HBSeqSep >::const_iterator iter( name2seq_sep_type_.find( name ) );
330  if ( iter == name2seq_sep_type_.end() ) {
331  utility_exit_with_message("unrecognized hydrogen bond sequence separation type '"+name+"'");
332  }
333  return iter->second;
334 }
335 
336 string
338 {
339  setup_type_names();
340  return seq_sep_type2name_[ type ];
341 }
342 
343 ///@brief
344 bool
345 HBondTypeManager::is_seq_sep_type( string const & name )
346 {
347  setup_type_names();
348  map< string, HBSeqSep >::const_iterator iter( name2seq_sep_type_.find( name ) );
349  return iter != name2seq_sep_type_.end();
350 }
351 
352 //////////////////////////////////////////////////////////////////////////////
353 /// @brief given a chemical::Hybridization string name return its enum type
354 /// In the perfect world this would live in the chemical/ChemicalTypeManager.hh,
355 /// but the chemical types are currently not managed!
358 {
359  setup_type_names();
360  map< string, Hybridization >::const_iterator iter( name2hybridization_type_.find( name ) );
361  if ( iter == name2hybridization_type_.end() ) {
362  utility_exit_with_message("unrecognized chemical hybridization type '"+name+"'");
363  }
364  return iter->second;
365 }
366 
367 string
369 {
370  setup_type_names();
371  return hybridization_type2name_[ type ];
372 }
373 
374 ///@brief
375 bool
377 {
378  setup_type_names();
379  map< string, Hybridization >::const_iterator iter( name2hybridization_type_.find( name ) );
380  return iter != name2hybridization_type_.end();
381 }
382 
383 //////////////////////////////////////////////////////////////////////////////
384 /// @brief give a HBGeoDimType string name and return its enum type
387 {
388  setup_type_names();
389  map< string, HBGeoDimType >::const_iterator iter( name2geo_dim_type_.find( name ) );
390  if ( iter == name2geo_dim_type_.end() ) {
391  utility_exit_with_message("unrecognized hydrogen bond geometric dimension type '"+name+"'");
392  }
393  return iter->second;
394 }
395 
396 string
398 {
399  setup_type_names();
400  return geo_dim_type2name_[ type ];
401 }
402 
403 ///@brief
404 bool
405 HBondTypeManager::is_geo_dim_type( string const & name )
406 {
407  setup_type_names();
408  map< string, HBGeoDimType >::const_iterator iter( name2geo_dim_type_.find( name ) );
409  return iter != name2geo_dim_type_.end();
410 }
411 
412 
413 
414 } // hbonds
415 } // scoring
416 } // core