Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Rose.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 
6 
8 
9 #include <basic/options/keys/sicdock.OptionKeys.gen.hh>
10 #include <basic/options/option.hh>
11 #include <basic/options/option_macros.hh>
12 #include <numeric/constants.hh>
13 #include <numeric/xyz.functions.hh>
14 #include <numeric/xyz.io.hh>
15 #include <ObjexxFCL/format.hh>
16 #include <ObjexxFCL/string.functions.hh>
17 #include <utility/io/ozstream.hh>
18 #include <utility/string_util.hh>
19 #include <core/id/AtomID_Map.hh>
20 #include <core/scoring/sasa.hh>
21 #include <core/pose/util.hh>
22 
23 namespace protocols {
24 namespace sic_dock {
25 
26 using platform::Size;
27 using platform::Real;
28 using std::string;
29 using utility::vector1;
30 using ObjexxFCL::fmt::I;
31 using ObjexxFCL::fmt::F;
32 using ObjexxFCL::fmt::RJ;
33 using numeric::min;
34 using numeric::max;
35 using std::cout;
36 using std::cerr;
37 using std::endl;
40 
41 Rose::Rose(PoseCOP pin ) : p(pin),h(new Hash(3.5,*p, BB )) {}
42 Rose::Rose(PoseCOP pin, sic_dock::PoseCoordPickMode const & coord_picker ) : p(pin),h(new Hash(3.5,*p,coord_picker)) {}
43 Rose::Rose(PoseCOP pin, core::id::AtomID_Map<Real> const & clash_atoms ) : p(pin),h(new Hash(3.5,*p,clash_atoms )) {}
44 
45 
46 
47 bool Rose::clashes(RCR o) const {
48  // Real const & thresh_2 = h->grid_size2(); // Unused variable causes warning.
49  RCR b( h->natom() > o.h->natom() ? *this : o );
50  RCR s( h->natom() <= o.h->natom() ? *this : o );
51  // XC s2b( b.h->translation() + ( (s.x-s.h->translation()) / b.x ) );
52  XC s2b( b.h->translation() + ( ~b.x * (s.x-s.h->translation()) ) );
53  for(Hash::const_iterator i = s.h->begin(); i != s.h->end(); ++i){
54  if( b.h->clash_raw( s2b * *i ) ) return true;
55  }
56  return false;
57 }
58 
60  Size count = 0;
61  // Real const & thresh_2 = h->grid_size2(); // Unused variable causes warning.
62  RCR b( h->natom() > o.h->natom() ? *this : o );
63  RCR s( h->natom() <= o.h->natom() ? *this : o );
64  // (~d)*n
65  // XC s2b( b.h->translation() + ( (s.x-s.h->translation()) / b.x ) );
66  XC s2b( b.h->translation() + ( ~b.x * (s.x-s.h->translation()) ) );
67  for(Hash::const_iterator i = s.h->begin(); i != s.h->end(); ++i){
68  count += b.h->nbcount_raw( s2b * *i );
69  }
70  return count;
71 }
72 
75  for(Size ir = 1; ir <= pose->n_residue(); ++ir) {
76  for(Size ia = 1; ia <= pose->residue_type(ir).natoms(); ++ia) {
77  core::id::AtomID const aid(core::id::AtomID(ia,ir));
78  pose->set_xyz( aid, x.xform(pose->xyz(aid)) );
79  }
80  }
81  return pose;
82 }
83 
84 void Rose::dump_pdb(std::ostream & out) const {
85  pose()->dump_pdb(out);
86 }
87 
88 void Rose::dump_pdb(std::string const & fname) const {
89  pose()->dump_pdb(fname);
90 }
91 
92 void Rose::dump_minimal_pdb(std::ostream & out, char chain){
93  for(Size ir = 1; ir <= p->n_residue(); ++ir){
94  V v;
95  v = x * p->xyz(AID(1,ir)); out<<"ATOM "<<I(5,3*ir-2)<<' '<<" N "<<' '<<"GLY"<<' '<<chain<<I(4,ir)<<" "<<F(8,3,v.x())<<F(8,3,v.y())<<F(8,3,v.z())<<F(6,2,1.0)<<F(6,2,1.0)<<endl;
96  v = x * p->xyz(AID(2,ir)); out<<"ATOM "<<I(5,3*ir-1)<<' '<<" CA "<<' '<<"GLY"<<' '<<chain<<I(4,ir)<<" "<<F(8,3,v.x())<<F(8,3,v.y())<<F(8,3,v.z())<<F(6,2,1.0)<<F(6,2,1.0)<<endl;
97  v = x * p->xyz(AID(3,ir)); out<<"ATOM "<<I(5,3*ir-0)<<' '<<" C "<<' '<<"GLY"<<' '<<chain<<I(4,ir)<<" "<<F(8,3,v.x())<<F(8,3,v.y())<<F(8,3,v.z())<<F(6,2,1.0)<<F(6,2,1.0)<<endl;
98  }
99 }
100 
101 
102 //////////////// debugging ///////////////////////
103 
104 bool Rose::clashes_naive(RCR o) const {
105  Real const thresh_2 = h->grid_size2();
106  for(Hash::const_iterator i = o.h->begin(); i != o.h->end(); ++i){
107  VC u( o.x.xform(*i-o.h->translation()) );
108  for(Hash::const_iterator j = h->begin(); j != h->end(); ++j){
109  VC v( x.xform(*j-h->translation()) );
110  if( u.distance_squared(v) < thresh_2 ) return true;
111  }
112  }
113  return false;
114 }
115 
117  Size count = 0;
118  Real const thresh_2 = h->grid_size2();
119  for(Hash::const_iterator i = o.h->begin(); i != o.h->end(); ++i){
120  VC u( o.x.xform(*i-o.h->translation()) );
121  for(Hash::const_iterator j = h->begin(); j != h->end(); ++j){
122  VC v( x.xform(*j-h->translation()) );
123  if( u.distance_squared(v) <= thresh_2 ) count++;
124  }
125  }
126  return count;
127 }
128 
129 } // namespace sic_dock
130 } // namespace protocols