Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HolesParams.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 core/scoring/packing/HolesParams.cc
11 /// @brief Packing Score Params
12 /// @author Will Sheffler
13 
14 #ifndef INCLUDED_core_scoring_packing_HolesParams_hh
15 #define INCLUDED_core_scoring_packing_HolesParams_hh
16 
17 #include <core/types.hh>
18 
19 // AUTO-REMOVED #include <basic/database/open.hh>
20 // AUTO-REMOVED #include <basic/options/option.hh>
21 
22 #include <utility/io/izstream.hh>
23 #include <utility/exit.hh>
24 
25 // option key includes
26 
27 // AUTO-REMOVED #include <basic/options/keys/holes.OptionKeys.gen.hh>
28 
29 #include <utility/vector1.hh>
30 #include <map>
31 
32 
33 namespace core {
34 namespace scoring {
35 namespace packing {
36 
37 
38 class HolesParams {
39 
40  typedef std::pair< core::Size, char > Key;
41 
42 public:
43 
45  : max_atom_types_(21), sep_ss_(21,true) {
46  }
47 
49  : max_atom_types_(21), sep_ss_(21,true) {
50  read_data_file( fname );
51  }
52 
53  void read_data_file( std::string fname ) {
54  using namespace std;
55  using namespace core;
56  using namespace utility;
57 
58  utility::io::izstream in;
59  in.close();
60  in.clear();
61  in.open( fname.c_str() );
62 
63  if( !in ) { utility_exit_with_message("HolesParams::read_data_file can't find file"); }
64 
65  string tmp;
66  char ss;
67  Size at;
68  for( Size i = 1; i <=24; ++i ) {
69  in >> tmp;
70  // std::cerr << "in: " << tmp << std::endl;
71  }
72  while( true ) {
73  // std::cerr << "LOOP START" << std::endl;
74  in >> at;
75  if( 999 == at ) break;
76  in >> ss;
77  // std::cerr << "atype / ss " << "'" << at << "' '" << ss << "'" << std::endl;
78  vector1<char> SS;
79  if( '*'==ss ) { SS.push_back('E'); SS.push_back('H'); SS.push_back('L'); sep_ss_[at] = false; }
80  else SS.push_back(ss);
81 
82  Key k(at,SS[1]);
83  in >> nb_weights_[k];
84  sa_weights_[k].resize(20,0.0);
85  for( Size i = 1; i <= 20; ++i ) in >> sa_weights_[k][i];
86  in >> intercepts_[k];
87 
88  // std::cerr << "nb: " << nb_weights_[k] << std::endl;
89  // for( Size i = 1; i <= 20; ++i ) std::cerr << sa_weights_[k][i] << " ";
90  // std::cerr << std::endl;
91  // std::cerr << "icpt: " << intercepts_[k] << std::endl;
92 
93  for( Size i = 2; i <= SS.size(); ++i ) {
94  nb_weights_[Key(at,SS[i])] = nb_weights_[k];
95  sa_weights_[Key(at,SS[i])] = sa_weights_[k];
96  intercepts_[Key(at,SS[i])] = intercepts_[k];
97  }
98 
99  }
100  in >> intercept_;
101  }
102 
103  core::Real nb_weight( core::Size const at, char const ss ) const { return nb_weights_.find(Key(at,ss))->second; }
104  core::Real sa_weight( core::Size const at, char const ss, core::Size sa ) const { return sa_weights_.find(Key(at,ss))->second[sa]; }
105  core::Real intercept( core::Size const at, char const ss ) const { return intercepts_.find(Key(at,ss))->second; }
106  core::Real intercept( ) const { return intercept_; }
107 
109  bool sep_ss( core::Size at ) const { return sep_ss_[at]; }
110 
111  bool have_params( core::Size const at, char const ss ) const {
112  return sa_weights_.find(Key(at,ss)) != sa_weights_.end();
113  }
114 
115  friend
116  std::ostream &
117  operator<< (std::ostream & out, HolesParams const & hp) {
118  using namespace core;
119  using namespace std;
120  for( Size at = 1; at <= hp.max_atom_types(); ++at ) {
121  if( hp.sep_ss(at) ) {
122  out<<at<<" E "<<hp.nb_weight(at,'E'); for(Size i=1;i<21;++i) out<<" "<<hp.sa_weight(at,'E',i); out<<" "<<hp.intercept(at,'E')<<endl;
123  out<<at<<" H "<<hp.nb_weight(at,'H'); for(Size i=1;i<21;++i) out<<" "<<hp.sa_weight(at,'H',i); out<<" "<<hp.intercept(at,'H')<<endl;
124  out<<at<<" L "<<hp.nb_weight(at,'L'); for(Size i=1;i<21;++i) out<<" "<<hp.sa_weight(at,'L',i); out<<" "<<hp.intercept(at,'L')<<endl;
125  } else {
126  out<<at<<" * "<<hp.nb_weight(at,'E'); for(Size i=1;i<21;++i) out<<" "<<hp.sa_weight(at,'E',i); out<<" "<<hp.intercept(at,'E')<<endl;
127  }
128  }
129  out << "999 " << hp.intercept() << endl;
130  return out;
131  }
132 
133 private:
134 
136  std::map<Key,utility::vector1<core::Real> > sa_weights_;
137  std::map<Key,core::Real> nb_weights_;
138  std::map<Key,core::Real> intercepts_;
141 
142 
143 };
144 
145 } // end packing
146 } // end scoring
147 } // end core
148 
149 #endif // INCLUDED_core_scoring_packing_HolesParams_HH