Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
util.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 // (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 
13 #include <core/pose/util.hh>
14 #include <numeric/xyz.functions.hh>
15 #include <ObjexxFCL/FArray3D.hh>
16 
17 namespace protocols {
18 namespace sic_dock {
19 
20 using platform::Size;
21 using platform::Real;
22 using numeric::min;
23 using core::id::AtomID;
24 using std::cout;
25 using std::endl;
26 typedef platform::Real Real;
27 typedef platform::Size Size;
28 typedef core::pose::Pose Pose;
37 
38 
39 int neighbor_count(core::pose::Pose const &pose, int ires, double distance_threshold) {
40  core::conformation::Residue const resi( pose.residue( ires ) );
41  Size resi_neighbors( 0 );
42  for(Size jres = 1; jres <= pose.n_residue(); ++jres) {
43  core::conformation::Residue const resj( pose.residue( jres ) );
44  double const distance( resi.xyz( resi.nbr_atom() ).distance( resj.xyz( resj.nbr_atom() ) ) );
45  if( distance <= distance_threshold ){
46  ++resi_neighbors;
47  }
48  }
49  return resi_neighbors;
50 }
51 
52 Real
53 cb_weight(core::pose::Pose const &pose, Size ires, Real distance_threshold) {
54  Real wt = numeric::min(1.0,(double)neighbor_count(pose,ires,distance_threshold)/20.0);
55  if(pose.secstruct(ires)=='L') wt = wt / 3.0; //TODO make option somehow
56  return wt;
57 }
58 
59 double
61  protocols::sic_dock::SICFast const & sic,
63  numeric::xyzTransform<core::Real> & xa,
64  numeric::xyzTransform<core::Real> const & xb,
66  platform::Real & score
67 ){
68  Stub sa(xa.R,xa.t), sb(xb.R,xb.t);
69  double d = sic.slide_into_contact(sa,sb,ori);
70  sa.v += d*ori;
71  xa.t += d*ori;
72  if(score != -12345.0) score = sfxn.score( sa, sb );
73  return d;
74 }
75 
76 double
78  protocols::sic_dock::SICFast const & sic,
81  core::kinematics::Stub const & xb,
83  platform::Real & score
84 ){
85  double d = sic.slide_into_contact(xa,xb,ori);
86  xa.v += d*ori;
87  if(score != -12345.0) score = sfxn.score( xa, xb );
88  return d;
89 }
90 
93  core::pose::Pose const & pose
94 ){
96  core::pose::initialize_atomid_map(amap,pose,-1.0);
97  for(Size i = 1; i <= pose.n_residue(); ++i){
98  if(pose.residue(i).has("CB")) {
99  amap[AtomID(pose.residue(i).atom_index("CB"),i)] = cb_weight(pose,i);
100  }
101  }
102  return amap;
103 }
104 
107  core::pose::Pose const & pose
108 ){
110  for(Size i = 1; i <= pose.n_residue(); ++i){
111  if(pose.residue(i).has("CB")) {
112  wts.push_back( cb_weight(pose,i) );
113  }
114  }
115  return wts;
116 }
117 
120  core::pose::Pose const & pose
121 ){
122  platform::Size cbcount;
123  for(Size ir = 1; ir <= pose.n_residue(); ++ir) cbcount += pose.residue(ir).has("CB");
124  return cbcount;
125 }
126 
127 core::pose::Pose const &
129  core::pose::Pose const & pose1,
130  core::pose::Pose const & pose2
131 ){
132  bool most_is_one = count_CBs(pose1) > count_CBs(pose2);
133  return most_is_one? pose1: pose2;
134 }
135 
136 bool
138  core::pose::Pose const & pose1,
139  core::pose::Pose const & pose2
140 ){
141  return count_CBs(pose1) > count_CBs(pose2);
142 }
143 
146  core::pose::Pose const & pose
147 ){
149  for(Size ir = 1; ir <= pose.n_residue(); ++ir) {
150  if( pose.residue(ir).has("CB") ){
151  CBs.push_back( pose.residue(ir).xyz("CB") );
152  }
153  }
154  return CBs;
155 }
156 
157 void
158 xform_pose( core::pose::Pose & pose, core::kinematics::Stub const & s, Size sres, Size eres ) {
159  if(eres==0) eres = pose.n_residue();
160  for(Size ir = sres; ir <= eres; ++ir) {
161  for(Size ia = 1; ia <= pose.residue_type(ir).natoms(); ++ia) {
162  core::id::AtomID const aid(core::id::AtomID(ia,ir));
163  pose.set_xyz( aid, s.local2global(pose.xyz(aid)) );
164  }
165  }
166 }
167 
168 void
170  if(eres==0) eres = pose.n_residue();
171  for(Size ir = sres; ir <= eres; ++ir) {
172  for(Size ia = 1; ia <= pose.residue_type(ir).natoms(); ++ia) {
173  core::id::AtomID const aid(core::id::AtomID(ia,ir));
174  pose.set_xyz( aid, s.global2local(pose.xyz(aid)) );
175  }
176  }
177 }
178 
179 void xform_pose( core::pose::Pose & pose, numeric::xyzTransform<core::Real> const & s, Size sres, Size eres ) {
180  if(eres==0) eres = pose.n_residue();
181  for(Size ir = sres; ir <= eres; ++ir) {
182  for(Size ia = 1; ia <= pose.residue_type(ir).natoms(); ++ia) {
183  core::id::AtomID const aid(core::id::AtomID(ia,ir));
184  pose.set_xyz( aid, s*pose.xyz(aid) );
185  }
186  }
187 }
188 void xform_pose_rev( core::pose::Pose & pose, numeric::xyzTransform<core::Real> const & s ) {
189  for(Size ir = 1; ir <= pose.n_residue(); ++ir) {
190  for(Size ia = 1; ia <= pose.residue_type(ir).natoms(); ++ia) {
191  core::id::AtomID const aid(core::id::AtomID(ia,ir));
192  pose.set_xyz( aid, ~s * pose.xyz(aid) );
193  }
194  }
195 }
196 
197 
198 
201  for(platform::Size i = beg; i < end; ++i) v.push_back(i);
202  return v;
203 }
204 
205 int flood_fill3D(int i, int j, int k, ObjexxFCL::FArray3D<double> & grid, double t) {
206  if( grid(i,j,k) <= t ) return 0;
207  grid(i,j,k) = t;
208  int nmark = 1;
209  if(i>1 ) nmark += flood_fill3D(i-1,j ,k ,grid,t);
210  if(i<(int)grid.size1()) nmark += flood_fill3D(i+1,j ,k ,grid,t);
211  if(j>1 ) nmark += flood_fill3D(i ,j-1,k ,grid,t);
212  if(j<(int)grid.size2()) nmark += flood_fill3D(i ,j+1,k ,grid,t);
213  if(k>1 ) nmark += flood_fill3D(i ,j ,k-1,grid,t);
214  if(k<(int)grid.size3()) nmark += flood_fill3D(i ,j ,k+1,grid,t);
215  return nmark;
216 }
217 
218 
219 
220 // void
221 // termini_exposed(
222 // core::pose::Pose const & pose,
223 // bool & ntgood,
224 // bool & ctgood
225 // ){
226 // using basic::options::option;
227 // using namespace basic::options::OptionKeys;
228 // core::id::AtomID_Map<Real> atom_sasa;
229 // core::id::AtomID_Map<bool> atom_subset;
230 // utility::vector1<Real> rsd_sasa;
231 // core::pose::initialize_atomid_map(atom_subset, pose, false);
232 // for(int i = 2; i <= (int)pose.n_residue()-1; ++i) {
233 // for(int ia = 1; ia <= (int)pose.residue(i).nheavyatoms(); ++ia) {
234 // if(pose.residue(i).atom_is_backbone(ia))
235 // atom_subset[core::id::AtomID(ia,i)] = true;
236 // }
237 // }
238 // atom_subset[core::id::AtomID(1,1)] = true;
239 // atom_subset[core::id::AtomID(3,pose.n_residue())] = true;
240 // core::scoring::calc_per_atom_sasa( pose, atom_sasa,rsd_sasa, 4.0, false, atom_subset );
241 // Real nexpose = atom_sasa[core::id::AtomID(1, 1 )] / 12.56637 / 5.44 / 5.44;
242 // Real cexpose = atom_sasa[core::id::AtomID(3,pose.n_residue())] / 12.56637 / 5.44 / 5.44;
243 
244 // Vec nt = pose.residue( 1 ).xyz("N");
245 // Vec ct = pose.residue(pose.n_residue()).xyz("C");
246 // Real nang = angle_degrees(nt,Vec(0,0,0),Vec(nt.x(),nt.y(),0));
247 // Real cang = angle_degrees(ct,Vec(0,0,0),Vec(ct.x(),ct.y(),0));
248 // ntgood = nexpose > option[sicdock::term_min_expose]() && nang < option[sicdock::term_max_angle]();
249 // ctgood = cexpose > option[sicdock::term_min_expose]() && cang < option[sicdock::term_max_angle]();
250 // // platform::Real nnt=0.0,nct=0.0,gnt=0.0,gct=0.0;
251 // // for(int ir=1; ir<=pose.n_residue(); ++ir) {
252 // // for(int ia=1; ia<=5; ++ia) {
253 // // Vec x = pose.residue(ir).xyz(ia);
254 // // if(angle_degrees(x,Vec(0,0,0),nt) < 15.0 && ) {
255 // // nnt += 1.0;
256 // // if( nt.normalized().dot(x) < nt.length() )
257 // // gnt += 1.0;
258 // // }
259 // // if(angle_degrees(x,Vec(0,0,0),ct) < 15.0 ) {
260 // // nct += 1.0;
261 // // if( ct.normalized().dot(x) < ct.length() )
262 // // gct += 1.0;
263 // // }
264 // // }
265 // // }
266 // }
267 
268 
269 
270 } // sic_dock
271 } // protocols