Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MetalloPlacementEnergy.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 //
4 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file core/scoring/methods/MetalloPlacementEnergy.cc
10 /// @brief Low-res placement score for metal sites
11 /// @author Will Sheffler
12 
13 
14 // Unit headers
16 
17 // Package headers
19 //#include <core/scoring/ScoringManager.hh>
20 
21 // Project headers
22 #include <core/pose/Pose.hh>
23 #include <ObjexxFCL/FArray2D.hh>
24 
25 #include <numeric/model_quality/rms.hh>
28 
29 
30 
31 
32 // Utility headers
33 
34 #include <ObjexxFCL/format.hh>
35 
36 
37 namespace core {
38 namespace scoring {
39 namespace methods {
40 
41 /// c-tor THIS CLASS REQUIRES AN EnergyMethodCreator to function properly
43 {
44  //add_score_type( metal_placement );
45  collision_thresh2_ = 11.0*11.0;
46  cb_cb_dis_thresh2_ = 3.0*3.0;
47 }
48 
49 
50 
51 /// clone
54 {
55  return new MetalloPlacementEnergy( *this );
56 }
57 
58 
59 
60 /// all scoring happens here
61 void
63  pose::Pose & pose,
64  ScoreFunction const & /*scorefxn*/,
65  EnergyMap & totals
66 ) const
67 {
68  using namespace core::conformation::symmetry;
69  core::Size mmres,nsub;
70  {
71  assert( is_symmetric( pose ) );
72  SymmetricConformation & symm_conf ( dynamic_cast<SymmetricConformation & > ( pose.conformation()) );
73  mmres = symm_conf.Symmetry_Info().num_independent_residues();
74  nsub = symm_conf.Symmetry_Info().subunits();
75  }
76 // std::cerr << "MetalloPlacementEnergy.cc:74 (" << mmres << " " << nsub << ")" << std::endl;
77 
78 
79  totals[ metal_placement ] = 9e9;
80  using core::id::AtomID;
81 
82  FArray2D<numeric::Real> sf4crd1(3,4);
83  FArray2D<numeric::Real> sf4crd2(3,4);
84  core::Real const R(3.94858713768);
85  sf4crd1(1,1)= 0.000*R; sf4crd1(2,1)= 0.000*R; sf4crd1(3,1)= 1.000*R;
86  sf4crd1(1,2)= 0.943*R; sf4crd1(2,2)= 0.000*R; sf4crd1(3,2)=-0.333*R;
87  sf4crd1(1,3)=-0.471*R; sf4crd1(2,3)= 0.816*R; sf4crd1(3,3)=-0.333*R;
88  sf4crd1(1,4)=-0.471*R; sf4crd1(2,4)=-0.816*R; sf4crd1(3,4)=-0.333*R;
89  sf4crd2(1,1)= 0.943*R; sf4crd2(2,1)= 0.000*R; sf4crd2(3,1)=-0.333*R;
90  sf4crd2(1,2)= 0.000*R; sf4crd2(2,2)= 0.000*R; sf4crd2(3,2)= 1.000*R;
91  sf4crd2(1,3)=-0.471*R; sf4crd2(2,3)= 0.816*R; sf4crd2(3,3)=-0.333*R;
92  sf4crd2(1,4)=-0.471*R; sf4crd2(2,4)=-0.816*R; sf4crd2(3,4)=-0.333*R;
93 
94  for(Size i = 1; i <= mmres ; ++i ) {
95  if( pose.residue_type(i).nheavyatoms() < 5 ) continue;
96  for(Size j = i+1; j <= mmres*nsub; ++j ) {
97  if( pose.residue_type(j).nheavyatoms() < 5 ) continue;
98  if( i%mmres == j%mmres ) continue;
99  if( cb_cb_dis_thresh2_ < pose.xyz(AtomID(5,i)).distance_squared(pose.xyz(AtomID(5,j))) ) continue;
100  for(Size k = j+1; k <= mmres*nsub; ++k ) {
101  if( pose.residue_type(k).nheavyatoms() < 5 ) continue;
102  if( i%mmres == k%mmres ) continue;
103  if( j%mmres == k%mmres ) continue;
104  if( cb_cb_dis_thresh2_ < pose.xyz(AtomID(5,i)).distance_squared(pose.xyz(AtomID(5,k))) ) continue;
105  if( cb_cb_dis_thresh2_ < pose.xyz(AtomID(5,j)).distance_squared(pose.xyz(AtomID(5,k))) ) continue;
106  for(Size l = k+1; l <= mmres*nsub; ++l ) {
107  if( pose.residue_type(k).nheavyatoms() < 5 ) continue;
108  if( i%mmres == l%mmres ) continue;
109  if( j%mmres == l%mmres ) continue;
110  if( k%mmres == l%mmres ) continue;
111  if( cb_cb_dis_thresh2_ < pose.xyz(AtomID(5,i)).distance_squared(pose.xyz(AtomID(5,l))) ) continue;
112  if( cb_cb_dis_thresh2_ < pose.xyz(AtomID(5,j)).distance_squared(pose.xyz(AtomID(5,l))) ) continue;
113  if( cb_cb_dis_thresh2_ < pose.xyz(AtomID(5,k)).distance_squared(pose.xyz(AtomID(5,l))) ) continue;
114 std::cerr << "MetalloPlacementEnergy.cc:112 (" << i << " " << j << " " << k << " " << l << ")" << std::endl;
115 
116  // check for space for SF4
117  numeric::xyzVector<core::Real> const a = pose.xyz(AtomID(5,i));
118  numeric::xyzVector<core::Real> const b = pose.xyz(AtomID(5,j));
119  numeric::xyzVector<core::Real> const c = pose.xyz(AtomID(5,k));
120  numeric::xyzVector<core::Real> const d = pose.xyz(AtomID(5,l));
121  numeric::xyzVector<core::Real> const aa = pose.xyz(AtomID(2,i));
122  numeric::xyzVector<core::Real> const ba = pose.xyz(AtomID(2,j));
123  numeric::xyzVector<core::Real> const ca = pose.xyz(AtomID(2,k));
124  numeric::xyzVector<core::Real> const da = pose.xyz(AtomID(2,l));
125  numeric::xyzVector<core::Real> com = (a+b+c+d)/4.0;
126 
127  // check CA-CB pointing roughly right way
128  if( (com-a).dot(a-aa) < 0.0 || (com-b).dot(b-ba) < 0.0 || (com-c).dot(c-ca) < 0.0 || (com-d).dot(d-da) < 0.0 ) {
129  std::cerr << "MetalloPlacementEnergy.cc:127 ( fail dot prod )" << std::endl;
130  continue;
131  }
132 
133  // std::cout << "checking sf4 spot " << i << " " << j << " " << k << " " << l;
134 
135  bool collision = false;
136  for(Size ir = 1; ir <= mmres*nsub; ++ir) {
137  for(Size ia = 1; ia <= pose.residue_type(ir).nheavyatoms(); ++ia) {
138  if( com.distance_squared(pose.xyz(AtomID(ia,ir))) < collision_thresh2_ ) {
139  collision = true;
140  break;
141  }
142  }
143  if(collision) break;
144  }
145  if( collision ) {
146  std::cerr << "MetalloPlacementEnergy.cc:144 (" << "fail collision" << ")" << std::endl;
147  continue;
148  }
149 
150  FArray2D<core::Real> crd(3,4);
151  crd(1,1) = a.x(); crd(2,1) = a.y(); crd(3,1) = a.z();
152  crd(1,2) = b.x(); crd(2,2) = b.y(); crd(3,2) = b.z();
153  crd(1,3) = c.x(); crd(2,3) = c.y(); crd(3,3) = c.z();
154  crd(1,4) = d.x(); crd(2,4) = d.y(); crd(3,4) = d.z();
155 
156  core::Real rms1 = numeric::model_quality::rms_wrapper(4,sf4crd1,crd);
157  core::Real rms2 = numeric::model_quality::rms_wrapper(4,sf4crd2,crd);
158  core::Real score = numeric::min(rms1,rms2);
159 
160  com.z(0);
161  using numeric::min;
162  using numeric::max;
163  Size nt = min((i-1)%mmres,min((j-1)%mmres,min((k-1)%mmres,(l-1)%mmres)))+1;
164  Size ct = mmres - max((i-1)%mmres,max((j-1)%mmres,max((k-1)%mmres,(l-1)%mmres))) ;
165  score += com.length() / 2.0;
166  Real tailpen = -0.5*( max(0.0,4.0-nt) + max(0.0,4.0-ct) );
167  score += tailpen;
168 
169  if( score < totals[ metal_placement ] ) {
170  std::cerr << "metal_placement " << score << " " << tailpen << " " << com.length() / 2.0 << std::endl;
171  totals[ metal_placement ] = score;
172  }
173 
174  } // l
175  } // k
176  } // j
177  } // i
178 
179 // std::cerr << "MetalloPlacementEnergy.cc:177 (DONE)" << std::endl;
180 
181 }
182 
183 
184 
185 
186 }
187 }
188 }