Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RotamerDNAHBondFilter.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 protocols/dna/RotamerDNAHBondFilter.cc
11 /// @brief filters rotamers for contact to DNA in an -ex dependent manner
12 /// @author ashworth
13 
15 #include <protocols/dna/util.hh> // close_to_dna
16 
17 // Package Headers
22 #include <core/pose/Pose.hh>
30 
31 #ifdef WIN32
32 // required for VS2005 build
33 #include <core/graph/Graph.hh>
34 #endif
35 
36 #include <basic/Tracer.hh>
37 
39 #include <utility/vector1.hh>
40 
41 static basic::Tracer TR("protocols.dna.RotamerDNAHBondFilter");
42 
43 namespace protocols {
44 namespace dna {
45 
46 using namespace core;
47 
49  core::Real threshold, // = -0.5
50  bool base_only // = true
51 ) :
52  pack::rotamer_set::RotamerOperation(),
53  threshold_( threshold ),
54  base_only_( base_only ),
55  nfiltered_(0),
56  naccepted_(0),
57  hb_database_(scoring::hbonds::HBondDatabase::get_database()),
58  hbondoptions_(new scoring::hbonds::HBondOptions )
59 {}
60 
62 
63 
64 bool
67  pose::Pose const & pose,
68  scoring::ScoreFunction const & scorefxn,
69  pack::task::ResidueLevelTask const & rtask,
72 )
73 {
74  using namespace scoring;
75  using namespace hbonds;
76  using namespace conformation;
77 
78  bool filter(false);
79 
81  Reals const & ex_chi_steps( chi_set->ex_chi_steps );
82 
83  Size const nchi( ex_chi_steps.size() );
84  if ( ( nchi > 0 && rtask.operate_on_ex1() && ex_chi_steps[1] != 0. ) ||
85  ( nchi > 1 && rtask.operate_on_ex2() && ex_chi_steps[2] != 0. ) ||
86  ( nchi > 2 && rtask.operate_on_ex3() && ex_chi_steps[3] != 0. ) ||
87  ( nchi > 3 && rtask.operate_on_ex4() && ex_chi_steps[4] != 0. ) ) filter = true;
88 
89  if ( !filter ) return true;
90  ++nfiltered_;
91 
92  for ( Size pos(1); pos <= pose.total_residue(); ++pos ) {
93  Residue const & dnares( pose.residue( pos ) );
94  if ( !dnares.is_DNA() ) continue;
95  if ( !close_to_dna( *rotamer, dnares, 10*10, base_only_ ) ) continue;
96 
97  Real hbE_total(0.0);
98  for ( Size ratom_i( rotamer->first_sidechain_atom() ), ratom_end( rotamer->natoms() );
99  ratom_i <= ratom_end; ++ratom_i ) {
100  Atom const & ratom( rotamer->atom( ratom_i ) );
101  Size const datom_start( base_only_ ? dnares.first_sidechain_atom() : 1 );
102  for ( Size datom_i( datom_start ), datom_end( dnares.natoms() );
103  datom_i <= datom_end; ++datom_i ) {
104  Atom const & datom( dnares.atom( datom_i ) );
105 
106  // rotamer donor, dna acceptor
107  if ( rotamer->atom_type( ratom_i ).is_hydrogen() &&
108  rotamer->atom_type( rotamer->atom_base( ratom_i ) ).is_donor() &&
109  dnares.atom_type( datom_i ).is_acceptor() ) {
110  Real dis2( ratom.xyz().distance_squared( datom.xyz() ) );
111  if ( dis2 > MAX_R2 || dis2 < MIN_R2 ) continue;
112  HBEvalTuple hbtype(rotamer->atom_base(ratom_i), *rotamer, datom_i, dnares);
113  Real hbE;
115  ratom.xyz(), rotamer->xyz( rotamer->atom_base( ratom_i )), create_don_orientation_vector( *rotamer, ratom_i ),
116  datom.xyz(), datom.xyz() /*apl -- acceptor base coordinate goes here, but used only for derivatives */,
117  create_acc_orientation_vector( *hbondoptions_, dnares, datom_i ),
118  Vector(-1.0, -1.0, -1.0) /* acceptor_base2 atom goes here, this is now wrong*/,
119  hbE,
120  false /*evaluate_derivative*/, DUMMY_DERIVS );
121  hbE_total += hbE * scorefxn.get_weight( hbond_sc );
122  } else if (
123  // rotamer acceptor, dna donor
124  dnares.atom_type( datom_i ).is_hydrogen() &&
125  dnares.atom_type( dnares.atom_base( datom_i ) ).is_donor() &&
126  rotamer->atom_type( ratom_i ).is_acceptor() ) {
127  Real dis2( ratom.xyz().distance_squared( datom.xyz() ) );
128  if ( dis2 > MAX_R2 || dis2 < MIN_R2 ) continue;
129  HBEvalTuple hbtype( dnares.atom_base(datom_i), dnares, ratom_i, *rotamer );
130  Real hbE;
132  datom.xyz(), dnares.xyz( dnares.atom_base( datom_i ) ), create_don_orientation_vector( dnares, datom_i ),
133  ratom.xyz(), ratom.xyz() /* apl -- acceptor-base coordinate goes here, but used only for derivatives */,
134  create_acc_orientation_vector( *hbondoptions_, *rotamer, ratom_i ),
135  Vector(-1.0, -1.0, -1.0) /* apl -- acceptor_base2 atom goes here, this is now wrong */,
136  hbE,
137  false /*evaluate_derivative*/, DUMMY_DERIVS );
138  hbE_total += hbE * scorefxn.get_weight( hbond_sc );
139 
140  }
141  else continue;
142 
143  if ( hbE_total < threshold_ ) {
144 // TR << "rotamer type " << rotamer->name() << " passed hbE threshold" << std::endl;
145  ++naccepted_;
146  return true;
147  }
148  }
149  }
150  }
151  return false;
152 }
153 
154 void
156 {
157  TR << nfiltered_ << " rotamers were filtered, " << naccepted_ << " accepted." << std::endl;
158 }
159 
160 }
161 }
162