Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
surf_vol.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 
10 /// @file core/scoring/packing/surf_vol.cc
11 /// @brief Packing Score
12 /// @author Will Sheffler
13 
14 //Unit headers
16 
17 //Package headers
18 
19 // AUTO-REMOVED #include <core/pose/Pose.hh>
20 // AUTO-REMOVED #include <core/id/AtomID_Map.Pose.hh>
21 #include <basic/options/option.hh>
22 
23 #include <basic/prof.hh>
24 
25 //numeric headers
26 #include <numeric/numeric.functions.hh>
27 #include <numeric/xyzMatrix.hh>
28 // AUTO-REMOVED #include <numeric/xyz.functions.hh>
29 
30 //utility headers
31 #include <utility/vector1.hh>
32 #include <utility/exit.hh>
33 #ifdef __native_client__
34 #define WIN32
35 #endif
36 
37 #ifndef WIN32
38 #include <pstream.h>
39 #endif
40 
41 //C++ headers
42 #include <iostream>
43 #include <iomanip>
44 
45 // option key includes
46 
47 #include <basic/options/keys/holes.OptionKeys.gen.hh>
48 
50 #include <core/kinematics/Jump.hh>
53 
54 
55 
56 
57 
58 
59 namespace core {
60 namespace scoring {
61 namespace packing {
62 
63 
64 
65 Real
67  pose::Pose const & pose,
68  core::Real const probe_radius
69 ) {
70  using namespace core;
71 
72  Real tot_surf = 0;
73 
74 #ifndef WIN32
75  PROF_START( basic::DALPHABALL );
76  PoseBallsLite pb(pose);
77 
78  std::string cmd = basic::options::option[ basic::options::OptionKeys::holes::dalphaball ]();
79  redi::pstream proc( cmd + " totalsurf" );
80  // proc.precision(20);
81  proc << "NPOINTS" << std::endl << pb.nballs() << std::endl << "COORDS" << std::endl;
82  for( Size i = 1; i <= pb.nballs(); i++ ) {
83  Ball b(pb.ball(i));
84  proc << b.x() << " " << b.y() << " " << b.z() << " " << b.r() + probe_radius << " " << std::endl;
85  }
86  // no weights in surf_vol mode
87  proc << "END" << std::endl << redi::peof;
88 
89  proc >> tot_surf;
90  // std::string s;
91  // proc >> s; std::cerr << s << std::endl;
92  // proc >> s; std::cerr << s << std::endl;
93  // proc >> s; std::cerr << s << std::endl;
94  // proc >> s; std::cerr << s << std::endl;
95  // Size index;
96  // Real s,v;
97  // for( Size i = 1; i <= pb.nballs(); i++ ) {
98  // proc >> index >> s >> v;
99  // if( i != index ) {
100  // std::cerr << "DALPHABALL output indicies not matching! " << i << "!=" << index << std::endl;
101  // std::exit(-1);
102  // }
103  // tot_surf += s;
104  // }
105 
106  PROF_STOP( basic::DALPHABALL );
107 
108 #endif
109 
110  return tot_surf;
111 }
112 
113 
114 SurfVol
116  pose::Pose const & pose,
117  core::Real const probe_radius
118 ) {
119  using namespace core;
120 
121  SurfVol result;
122 
123 #ifndef WIN32
124 
125 
126  PoseBallsLite pb(pose);
127 
128  initialize_AtomID_Map<Real>(result.surf,pb);
129  initialize_AtomID_Map<Real>(result.vol ,pb);
130 
131  PROF_START( basic::DALPHABALL );
132 
133  std::string cmd = basic::options::option[ basic::options::OptionKeys::holes::dalphaball ]();
134  redi::pstream proc( cmd + " surf_vol" );
135  // proc.precision(20);
136  proc << "NPOINTS" << std::endl << pb.nballs() << std::endl << "COORDS" << std::endl;
137  for( Size i = 1; i <= pb.nballs(); i++ ) {
138  Ball b(pb.ball(i));
139  proc << b.x() << " " << b.y() << " " << b.z() << " " << b.r() + probe_radius << " " << std::endl;
140  }
141  // no weights in surf_vol mode
142  proc << "END" << std::endl << redi::peof;
143 
144  result.tot_surf = 0.0;
145  result.tot_vol = 0.0;
146  Size index;
147  Real s,v;
148  for( Size i = 1; i <= pb.nballs(); i++ ) {
149  proc >> index >> s >> v;
150  if( i != index ) {
151  std::cerr << "DALPHABALL output indicies not matching! " << i << "!=" << index << std::endl;
152  std::exit(-1);
153  }
154  result.surf[ pb.index_to_id(i) ] = s;
155  result.vol [ pb.index_to_id(i) ] = v;
156  result.tot_surf += s;
157  result.tot_vol += v;
158  }
159 
160  PROF_STOP( basic::DALPHABALL );
161 
162 #endif
163 
164  return result;
165 }
166 
167 
168 SurfVolDeriv
170  pose::Pose const & pose,
171  core::Real const probe_radius
172 ) {
173  using namespace core;
174 
175  SurfVolDeriv result;
176 
177 #ifndef WIN32
178 
179  PROF_START( basic::DALPHABALL );
180 
181  PoseBalls pb(pose);
182 
183  initialize_AtomID_Map<Real>(result.surf,pb);
184  initialize_AtomID_Map<Real>(result.vol ,pb);
185  initialize_AtomID_Map<numeric::xyzVector<Real> >(result.dsurf,pb);
186  initialize_AtomID_Map<numeric::xyzVector<Real> >(result.dvol ,pb);
187 
188  std::string cmd = basic::options::option[ basic::options::OptionKeys::holes::dalphaball ]();
189  redi::pstream proc( cmd + " surf_vol_deriv" );
190  proc.precision(20);
191  proc << "NPOINTS" << std::endl << pb.nballs() << std::endl << "COORDS" << std::endl;
192  for( Size i = 1; i <= pb.nballs(); i++ ) {
193  Ball b(pb.ball(i));
194  proc << b.x() << " " << b.y() << " " << b.z() << " " << b.r() + probe_radius << " " << std::endl;
195  }
196  // no weights in surf_vol mode
197  proc << "END" << std::endl << redi::peof;
198 
199  result.tot_surf = 0.0;
200  result.tot_vol = 0.0;
201  Size index;
202  Real s,v,dsx,dsy,dsz,dvx,dvy,dvz;
203  for( Size i = 1; i <= pb.nballs(); i++ ) {
204  proc >> index >> s >> v >> dsx >> dsy >> dsz >> dvx >> dvy >> dvz;
205  if( i != index ) {
206  std::cerr << "DALPHABALL output indicies not matching! " << i << "!=" << index << std::endl;
207  std::exit(-1);
208  }
209  result.surf[ pb.index_to_id(i) ] = s;
210  result.vol [ pb.index_to_id(i) ] = v;
211  result.dsurf[ pb.index_to_id(i) ] = numeric::xyzVector<Real>(dsx,dsy,dsz);
212  result.dvol [ pb.index_to_id(i) ] = numeric::xyzVector<Real>(dvx,dvy,dvz);
213  result.tot_surf += s;
214  result.tot_vol += v;
215  }
216 
217  PROF_STOP( basic::DALPHABALL );
218 
219 #endif
220 
221  return result;
222 }
223 
224 
225 }
226 }
227 }