Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UpstreamDownstreamCollisionFilter.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 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file protocols/match/output/UpstreamDownstreamCollisionFilter.hh
12 /// @brief Implementation for class to filter matches where the upstream residues collide.
13 /// @author Alex Zanghellini (zanghell@u.washington.edu)
14 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com), porting to mini
15 
16 // Unit headers
18 
19 // Package headers
23 
24 // Project headers
26 #include <core/pose/Pose.hh>
28 // AUTO-REMOVED #include <core/scoring/ScoringManager.hh>
29 // AUTO-REMOVED #include <core/scoring/etable/EtableEnergy.hh>
30 // AUTO-REMOVED #include <core/scoring/methods/EnergyMethodOptions.hh>
31 
32 // Utility headers
33 #include <utility/pointer/ReferenceCount.hh>
34 
35 // C++ headers
36 #include <iostream>
37 
38 #include <core/id/AtomID.hh>
40 #include <protocols/match/Hit.hh>
41 #include <utility/vector1.hh>
42 
43 
44 namespace protocols {
45 namespace match {
46 namespace output {
47 
49  std::string filter_name,
50  UpstreamHitCacherOP coordinate_cacher
51 ) :
52  parent( filter_name, coordinate_cacher ),
53  max_overlap_dis_(0.0)
54 {
55  std::cout << "Created UpstreamDownstreamCollisionFilter" << std::endl;
56 }
57 
59 {}
60 
61 void
63 {
64  downstream_pose_ = new core::pose::Pose( downstream_pose );
65  Size count_atoms( 0 );
66  per_res_atom_ind_.resize( downstream_pose.total_residue() );
67  for ( Size ii = 1; ii <= downstream_pose.total_residue(); ++ii ) {
68  Size const ii_natoms = downstream_pose.residue( ii ).natoms();
69  per_res_atom_ind_[ ii ].resize( ii_natoms );
70  for ( Size jj = 1; jj <= ii_natoms; ++jj ) {
71  per_res_atom_ind_[ ii ][ jj ] = ++count_atoms;
72  }
73  }
74  downstream_atoms_.resize( count_atoms );
75  coords_.resize( count_atoms );
76  count_atoms = 0;
77  for ( Size ii = 1; ii <= downstream_pose.total_residue(); ++ii ) {
78  Size const ii_natoms = downstream_pose.residue( ii ).natoms();
79  for ( Size jj = 1; jj <= ii_natoms; ++jj ) {
80  downstream_atoms_[ ++count_atoms ] = core::id::AtomID( jj, ii );
81  }
82  }
83 }
84 
85 void
87 {
88  dsbuilders_.resize( n_geomcst );
89  us_ds_chemical_bond_.resize( n_geomcst );
90  std::fill( us_ds_chemical_bond_.begin(), us_ds_chemical_bond_.end(), false );
91 }
92 
93 void
95 {
96  us_ds_chemical_bond_[ geomcst_id ] = true;
97 }
98 
99 
100 void
102  Size geomcst_id,
104 )
105 {
106  runtime_assert( dsbuilders_.size() >= geomcst_id && geomcst_id > 0 );
107  dsbuilders_[ geomcst_id ] = builder;
108 }
109 
110 
111 
112 bool
114  match const & m
115 ) const
116 {
117  for ( Size ii = 1; ii <= m.size(); ++ii ) {
118  if ( ! dsbuilders_[ ii ] ) continue;
119  if ( passes_filter( match_dspos1( m, ii ) ) ) return true;
120  }
121  return false;
122 }
123 
124 bool
126  match_dspos1 const & m
127 ) const
128 {
129  if ( filter_by_lj() ) {
130  return passes_etable_filter( m );
131  } else {
132  return passes_hardsphere_filter( m );
133  }
134 }
135 
137 {
139  max_overlap_dis_ = 0;
140  for ( Size ii = 1; ii <= n_probe_radii; ++ii ) {
141  for ( Size jj = ii; jj <= n_probe_radii; ++jj ) {
142  if ( bump_grid()->required_separation_distance(
143  ProbeRadius( ii ), ProbeRadius( jj ) ) > max_overlap_dis_ ) {
144  max_overlap_dis_ = bump_grid()->required_separation_distance( ProbeRadius( ii ), ProbeRadius( jj ) );
145  }
146  }
147  }
148 
149 }
150 
152 {
153  using namespace core;
154  using namespace core::conformation;
155  using namespace core::pose;
156 
157  runtime_assert( dsbuilders_[ m.originating_geom_cst_for_dspos ] );
158  dsbuilders_[ m.originating_geom_cst_for_dspos ]->coordinates_from_hit(
160  for ( Size ii = 1; ii <= downstream_atoms_.size(); ++ii ) {
161  downstream_pose_->set_xyz( downstream_atoms_[ ii ], coords_[ ii ] );
162  }
163 
164  using namespace core::scoring;
165  EnergyMap emap;
166  for ( Size ii = 1; ii < m.upstream_hits.size(); ++ii ) {
167  if ( ii == m.originating_geom_cst_for_dspos ) continue; // don't collision check since we've presumably done so already
168  if ( us_ds_chemical_bond_[ ii ] ) continue;
169  for ( Size jj = 1; jj <= downstream_pose_->total_residue(); ++jj ) {
170  emap[ fa_atr ] = 0; emap[ fa_rep ] = 0; emap[ fa_sol ] = 0;
171  etable_energy()->residue_pair_energy(
172  *( cacher_->upstream_conformation_for_hit( ii, fake_hit( m.upstream_hits[ ii ] )) ),
173  downstream_pose_->residue( jj ),
174  *empty_pose(), *empty_sfxn(),
175  emap );
176  Real energy = wfa_atr() * emap[ fa_atr ] + wfa_rep() * emap[ fa_rep ] + wfa_sol() * emap[ fa_sol ];
177  if ( energy > lj_cutoff() ) return false;
178  }
179  }
180  return true;
181 
182 }
183 
185 {
186  runtime_assert( dsbuilders_[ m.originating_geom_cst_for_dspos ] );
187  dsbuilders_[ m.originating_geom_cst_for_dspos ]->coordinates_from_hit(
189 
190  for ( Size ii = 1; ii <= m.upstream_hits.size(); ++ii ) {
191  if ( ii == m.originating_geom_cst_for_dspos ) continue;
192  if ( us_ds_chemical_bond_[ ii ] ) continue;
193 
194  if( !passes_hardsphere_filter( ii, fake_hit( m.upstream_hits[ ii ] ), coords_ ) ) return false;
195  } //loop over all upstream hits
196  return true;
197 }
198 
199 bool
201  core::Size geomcst_up,
202  core::Size geomcst_down,
203  Hit const & upstream_hit,
204  Hit const & downstream_hit
205 ) const
206 {
207  dsbuilders_[ geomcst_down ]->coordinates_from_hit( downstream_hit, downstream_atoms_, coords_ );
208  return passes_hardsphere_filter( geomcst_up, upstream_hit, coords_ );
209 }
210 
211 }
212 }
213 }