Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RigidScore.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 noet:
3 // :noTabs=false:tabSize=4:indentSize=4:
4 
9 
10 #include <basic/options/keys/sicdock.OptionKeys.gen.hh>
11 #include <basic/options/keys/lh.OptionKeys.gen.hh>
12 #include <basic/options/option.hh>
13 #include <basic/options/option_macros.hh>
14 #include <numeric/constants.hh>
15 #include <numeric/xyz.functions.hh>
16 #include <numeric/xyz.io.hh>
17 #include <ObjexxFCL/format.hh>
18 #include <ObjexxFCL/string.functions.hh>
19 #include <utility/io/ozstream.hh>
20 #include <utility/string_util.hh>
21 #include <core/id/AtomID_Map.hh>
22 #include <core/scoring/sasa.hh>
23 #include <core/pose/util.hh>
28 #include <basic/Tracer.hh>
29 
30 namespace protocols {
31 namespace sic_dock {
32 
33 static basic::Tracer TR( "propocols.sic_dock.RigidScore" );
34 
35 using platform::Size;
36 using platform::Real;
37 using numeric::min;
38 using core::id::AtomID;
39 using std::cout;
40 using std::endl;
41 typedef platform::Real Real;
42 typedef platform::Size Size;
43 typedef core::pose::Pose Pose;
52 
53 inline Real dist_score( Real const & sqdist, Real const & start, Real const & stop ) {
54  if( sqdist > stop*stop ) {
55  return 0.0;
56  } else if( sqdist < start*start ) {
57  return 1.0;
58  } else {
59  Real dist = sqrt( sqdist );
60  return (stop-dist)/(stop-start);
61  //return sqr(1.0 - sqr( (dist - start) / (stop - start) ) );
62  }
63 }
64 
65 std::ostream & operator<< ( std::ostream & out, Vec3 v ){
66  out << v.a << " " << v.b << " " << v.c;
67  return out;
68 }
69 
71  Pose const & pose1,
72  Pose const & pose2,
73  Real clash_dis,
74  Real contact_dis
75 ):
76  hash_pose1_( pose1_has_most_CBs(pose1,pose2) ),
77  clash_dis_(clash_dis),
78  contact_dis_(contact_dis),
79  weights_( cb_weights_from_pose( hash_pose1_?pose2:pose1 ) ),
80  points_( get_CB_Vecs( hash_pose1_?pose2:pose1 ) ),
81  xyzhash_(
82  contact_dis,
83  hash_pose1_?pose1:pose2,
84  cb_weight_map_from_pose( hash_pose1_?pose1:pose2 )
85  )
86  // ,
87  // pose1_(pose1),
88  // pose2_(pose2)
89 {}
90 
95  Real const & clash_dis_in,
96  Real const & contact_dis_in
97  ):
98  clash_dis(clash_dis_in),
99  contact_dis(contact_dis_in),
100  score(0.0)
101  {}
102  inline
103  void
105  numeric::xyzVector<Real> const & /*v*/,
106  Real const & vm,
107  numeric::xyzVector<Real> const & /*c*/,
108  Real const & cm,
109  Real const & d2
110  ){
111  score += dist_score(d2, clash_dis, contact_dis ) * vm * cm;
112  }
113 };
114 
117  Stub const & x1,
118  Stub const & x2
119 ) const {
120  Stub const xhp(multstubs(invstub(hash_pose1_?x1:x2),hash_pose1_?x2:x1));
121  CBScoreVisitor hash_visitor(clash_dis_,contact_dis_);
122  Reals::const_iterator iwb = weights_.begin();
123  for(Vecs::const_iterator i = points_.begin(); i != points_.end(); ++i,++iwb) {
124  xyzhash_.visit(xhp.local2global(*i),*iwb,hash_visitor);
125  }
126  return hash_visitor.score;
127 }
128 
129 
131  Pose const & pose1,
132  Pose const & pose2,
133  Size max_loop_len,
134  Size lookup_radius
135 ):
136  loopsizes_( range(3,max_loop_len+1) ),
137  lookup_radius_( lookup_radius ),
138  pose1_(pose1),
139  pose2_(pose2)
140 {
141  if( ! basic::options::option[ basic::options::OptionKeys::lh::db_path ].user() ){
142  utility_exit_with_message("user must specify -lh:db_path for loop hash database");
143  }
144 
146  TR << "loading loophash data" << std::endl;
147  if(loopsizes_.size()) loop_hash_library_->load_mergeddb();
148  TR << "done loading loophash data" << std::endl;
149 
152 
153  TR << lowers1_.size() << " " << uppers1_.size() << " " << lowers2_.size() << " " << uppers2_.size() << std::endl;
154  // utility_exit_with_message("TEST LINK SCORE");
155 }
156 
157 
158 
161  Stub const & x1,
162  Stub const & x2
163 ) const {
164  using namespace basic::options::OptionKeys;
165  using namespace protocols::loophash;
166  using namespace numeric::geometry::hashing;
167  using namespace core::kinematics;
168 
169  Real lkscore = 0.0;
170  for(TermInfo::const_iterator c1 = lowers1_.begin(); c1 != lowers1_.end(); ++c1){
171  for(TermInfo::const_iterator n2 = uppers2_.begin(); n2 != uppers2_.end(); ++n2){
172  Stub const lower = vec3_to_stub(x1,c1->second);
173  Stub const upper = vec3_to_stub(x2,n2->second);
175  Real s = linker_count2score(n);
176  lkscore += s;
177  }}
178  for(TermInfo::const_iterator c2 = lowers2_.begin(); c2 != lowers2_.end(); ++c2){
179  for(TermInfo::const_iterator n1 = uppers1_.begin(); n1 != uppers1_.end(); ++n1){
180  Stub const lower = vec3_to_stub(x2,c2->second);
181  Stub const upper = vec3_to_stub(x1,n1->second);
183  Real s = linker_count2score(n);
184  lkscore += s;
185  }}
186 
187  if(lkscore > 3.0){
188  Size ndumped = 0;
189  for(TermInfo::const_iterator c1 = lowers1_.begin(); c1 != lowers1_.end(); ++c1){
190  for(TermInfo::const_iterator n2 = uppers2_.begin(); n2 != uppers2_.end(); ++n2){
191  Stub const lower = vec3_to_stub(x1,c1->second);
192  Stub const upper = vec3_to_stub(x2,n2->second);
194  }}
195  for(TermInfo::const_iterator c2 = lowers2_.begin(); c2 != lowers2_.end(); ++c2){
196  for(TermInfo::const_iterator n1 = uppers1_.begin(); n1 != uppers1_.end(); ++n1){
197  Stub const lower = vec3_to_stub(x2,c2->second);
198  Stub const upper = vec3_to_stub(x1,n1->second);
200  }}
201  if( ndumped > 0 ){
202  Pose tmp1(pose1_),tmp2(pose2_);
203  xform_pose(tmp1,x1);
204  xform_pose(tmp2,x2);
205  tmp1.dump_pdb("comp1.pdb");
206  tmp2.dump_pdb("comp2.pdb");
207  utility_exit_with_message("TEST LINKER");
208  }
209  }
210 
211  return 10.0*lkscore;
212 }
213 
214 // void
215 // LinkerScore::dump_linkers(
216 // Stub const & x1,
217 // Stub const & x2
218 // ) const {
219 // using namespace basic::options::OptionKeys;
220 // using namespace protocols::loophash;
221 // using namespace numeric::geometry::hashing;
222 // using namespace core::kinematics;
223 
224 // for(TermInfo::const_iterator c1 = lowers1_.begin(); c1 != lowers1_.end(); ++c1){
225 // for(TermInfo::const_iterator n2 = uppers2_.begin(); n2 != uppers2_.end(); ++n2){
226 // dump_linkers( vec3_to_stub(x1,*c1), vec3_to_stub(x2,*n2), loop_hash_library_, loopsizes_ ) );
227 // }}
228 // for(TermInfo::const_iterator c2 = lowers2_.begin(); c2 != lowers2_.end(); ++c2){
229 // for(TermInfo::const_iterator n1 = uppers1_.begin(); n1 != uppers1_.end(); ++n1){
230 // dump_linkers( vec3_to_stub(x2,*c2), vec3_to_stub(x1,*n1), loop_hash_library_, loopsizes_ ) );
231 // }}
232 // }
233 
234 
236  Scores scores,
237  Reals weights
238 ):
239  scores_(scores),
240  weights_(weights)
241 {
242  if(scores_.size() != weights_.size()) utility_exit_with_message("bad score/weight");
243 }
244 
245 void
247  RigidScoreCOP score,
248  Real weight
249 ){
250  scores_.push_back(score);
251  weights_.push_back(weight);
252 }
253 
256  Stub const & x1,
257  Stub const & x2
258 ) const {
259  Real score = 0.0;
260  Reals::const_iterator w = weights_.begin();
261  for(Scores::const_iterator s = scores_.begin(); s != scores_.end(); ++s,++w){
262  score += (*s)->score(x1,x2) * (*w);
263  }
264  return score;
265 }
266 
267 
268 
269 } // namespace sic_dock
270 } // namespace protocols