Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimplePDB.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/packstat/SimplePDB.cc
11 ///
12 /// @brief
13 /// @author will sheffler
14 
15 
16 // Unit header or inline function header
18 #include <basic/Tracer.hh>
20 
21 #include <set>
22 
24 #include <utility/vector1.hh>
25 
26 static basic::Tracer TR("protocols.packstat.SimplePDB");
27 
28 namespace core {
29 namespace scoring {
30 namespace packstat {
31 
32 Spheres
34  AtomRadiusMap const & arm
35 ) const {
36  using namespace std;
37  set<pair<string,string> > errors;
38  Spheres spheres;
39  for( SPAtomCIter i = atoms_.begin(); i != atoms_.end(); ++i ) {
40  SimplePDB_Atom const & atom( *i );
41  numeric::xyzVector<PackstatReal> xyz( atom.x, atom.y, atom.z );
42  PackstatReal radius = arm.get_radius( atom.type, atom.res );
43  if( radius > 0 ) {
44  spheres.push_back( Sphere( xyz, radius ) );
45  } else if( radius < 0 ) {
46  errors.insert( pair<string,string>(atom.type,atom.res) );
47  }
48  }
49  if( errors.size() ) {
50  TR << "ignoring unknown atom types:" << std::endl;
51  for(set<pair<string,string> >::iterator i = errors.begin(); i != errors.end(); ++i) {
52  TR << "(" << i->first << "," << i->second << "), ";
53  }
54  TR << std::endl;
55  // spheres.clear();
56  }
57  return spheres;
58 }
59 
60 
63 {
65  AtomRadiusMap arm;
66  pd->spheres = get_spheres(arm);
67  pd->centers = get_res_centers();
68  pd->labels = res_labels();
69  return pd;
70 }
71 
72 
75 {
76  Size MIN_RES_ATOM_COUNT = 1;
77  using namespace std;
78  using namespace numeric;
79  using namespace utility;
80  Size num_res = 0;
81  int last_res_num = -12345;
82  char last_chain = '*';
83  for( SPAtomCIter i = atoms_.begin(); i != atoms_.end(); ++i ) {
84  if( i->resnum != last_res_num || i->chain != last_chain ) {
85  num_res++;
86  last_res_num = i->resnum;
87  last_chain = i->chain;
88  }
89  }
91  res_labels_.clear();
92  xyzVector<PackstatReal> center(0,0,0);
93  last_res_num = -12345;
94  last_chain = '*';
95  Size res_atom_count = 0;
96  for( SPAtomCIter i = atoms_.begin(); i != atoms_.end(); ++i ) {
97  if( i->resnum != last_res_num || i->chain != last_chain ) {
98  if( num_res > 0 ) {
99  if( res_atom_count >= MIN_RES_ATOM_COUNT ){
100  centers.push_back(center/res_atom_count);
101  res_labels_.push_back(i->res);
102  }
103  res_atom_count = 0;
104  }
105  center = xyzVector<PackstatReal>(0,0,0);
106  last_res_num = i->resnum;
107  last_chain = i->chain;
108  }
109  center += xyzVector<PackstatReal>( i->x, i->y, i->z );
110  res_atom_count++;
111  }
112  if( res_atom_count >= MIN_RES_ATOM_COUNT ) centers.push_back( center/res_atom_count );
113  return centers;
114 }
115 
116 
117 
119  core::Size count = 0;
120  for( core::Size i = 1; i <= atoms_.size(); ++i ) {
121  if( atoms_[i].res == "HOH" ) {
122  count++;
123  }
124  }
125  return count;
126 }
127 
128 
129 
131  // std::cerr << "remove_surface_waters()" << std::endl;
132  using namespace core;
133  for( Size i = 1; i <= atoms_.size(); ++i ) {
134  atoms_[i].xyz.x(atoms_[i].x);
135  atoms_[i].xyz.y(atoms_[i].y);
136  atoms_[i].xyz.z(atoms_[i].z);
137  atoms_[i].radius = 2; // huge hack, but avoids needing AtomRadiusMap
138  }
139  int count = 0;
140  while( true ) {
141  // std::cerr << "REMOVE_SURFACE_WATERS " << count << std::endl;
142  count++;
143  compute_sasa_generic<SimplePDB_Atom>( atoms_, 3.0 );
144  vector1<SimplePDB_Atom> newatoms;
145  bool removed = false;
146  for( Size i = 1; i <= atoms_.size(); ++i ) {
147  // std::cerr << "ATOM " << atoms_[i].res << " " << atoms_[i].sasa << std::endl;
148  if( "HOH" != atoms_[i].res || atoms_[i].sasa == 0 ) { // if not water or buried
149  newatoms.push_back( atoms_[i] );
150  } else {
151  removed = true;
152  }
153  }
154  if( !removed ) break;
155  atoms_ = newatoms;
156  }
157 }
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 } // namespace packstat
175 } // namespace scoring
176 } // namespace core