Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DownstreamAlgorithm.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/downstream/DownstreamAlgorithm.cc
12 /// @brief
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
24 // AUTO-REMOVED #include <protocols/match/upstream/ScaffoldBuildPoint.hh>
26 // AUTO-REMOVED #include <protocols/match/downstream/LigandConformer.hh>
27 
28 //Project header
30 
31 // Utility headers
32 #include <utility/pointer/ReferenceCount.hh>
33 #include <basic/Tracer.hh>
34 
35 // C++ headers
36 #include <list>
37 
38 #include <core/id/AtomID.hh>
39 #include <protocols/match/Hit.hh>
40 #include <utility/vector1.hh>
41 
42 
43 namespace protocols {
44 namespace match {
45 namespace downstream {
46 
47 static basic::Tracer TR( "protocols.match.downstream.DownstreamAlgorithm" );
48 
49 DownstreamAlgorithm::DownstreamAlgorithm( Size geom_cst_id ) : geom_cst_id_( geom_cst_id ) {}
51  utility::pointer::ReferenceCount(),
52  geom_cst_id_( other.geom_cst_id_ ),
53  bbgrid_( other.bbgrid_ ),
54  active_site_grid_( other.active_site_grid_ )
55 {}
56 
57 DownstreamAlgorithm const &
59 {
60  if ( this != & rhs ) {
62  bbgrid_ = rhs.bbgrid_;
64  }
65  return *this;
66 }
67 
68 
70 
71 /// @details By initializing local std::list< Hit > variables inside the loop
72 /// over all of the build points, and then splicing them into a central vector
73 /// of hit lists, I can avoid expensive list-copy operations while guaranteeing
74 /// OpenMP thread saftey.
75 std::list< Hit >
77  Matcher & matcher
78 )
79 {
80  return default_build_hits_at_all_positions( matcher );
81 }
82 
83 /// @details no-op
84 void
86 
87 
88 
89 /// @details Noop in base class.
90 void
92 {}
93 
94 /// @details Noop in base class.
95 void
97 {}
98 
101  return geom_cst_id_;
102 }
103 
104 void
106  BumpGridCOP bbgrid
107 )
108 {
109  bbgrid_ = bbgrid;
110 }
111 
112 void
114  ActiveSiteGridCOP active_site_grid
115 )
116 {
118 }
119 
120 void
122  DownstreamBuilderOP dsbuilder )
123 {
124  if (dsbuilder_) {
125  dsbuilder_.reset_to_null();
126  }
127  dsbuilder_ = dsbuilder;
128 }
129 
132 {
133  return dsbuilder_;
134 }
135 
136 bool
138  core::conformation::Residue const & us_res /*upstream*/,
139  core::conformation::Residue const & ds_res /*downstream*/,
140  utility::vector1< core::id::AtomID > const & ds_atoms,
141  utility::vector1< core::Size > const & catalytic_atoms
142 ) const
143 {
144  //TR << "RES name" << us_res.name() << "SIZE " << ds_atoms.size() << std::endl;
145  //TR << "CAT 1: " << us_res.atom_name( catalytic_atoms[1] ) <<
146  // "CAT 2: " << us_res.atom_name( catalytic_atoms[2] ) <<
147  // "CAT 3: " << ds_res.atom_name( catalytic_atoms[3] ) <<
148  // "CAT 4: " << ds_res.atom_name( catalytic_atoms[4] ) << std::endl;
149 
150  for ( Size atomid_ds = 1; atomid_ds <= ds_atoms.size(); ++atomid_ds ) {
151  ProbeRadius ds_rad = probe_radius_for_atom_type( ds_res.atom_type_index( ds_atoms[ atomid_ds ].atomno() ) );
152  if ( ! ( catalytic_atoms[3] == ds_atoms[ atomid_ds ].atomno() ||
153  catalytic_atoms[4] == ds_atoms[ atomid_ds ].atomno() ) ){
154  //TR << " x "<< ds_res.xyz( ds_atoms[ atomid_ds ].atomno() )[0] << " y " << ds_res.xyz( ds_atoms[ atomid_ds ].atomno() )[1] << " z " << ds_res.xyz( ds_atoms[ atomid_ds ].atomno() )[2] << std::endl;
155 
156  for (Size atomid_us = us_res.first_sidechain_atom(); atomid_us <= us_res.nheavyatoms(); ++atomid_us ) {
157  if ( ! ( catalytic_atoms[1] == atomid_us ||
158  catalytic_atoms[2] == atomid_us ) ){
159 
160  //TR << "RES ds: " << ds_res.atom_name( ds_atoms[ atomid_ds ].atomno() ) << " RES us: " << us_res.atom_name(atomid_us) << std::endl;
161  core::Real dist2( ds_res.xyz( ds_atoms[ atomid_ds ].atomno() ).distance_squared( us_res.xyz( atomid_us ) ) );
162  ProbeRadius us_rad = probe_radius_for_atom_type( us_res.atom_type_index( atomid_us ) );
163  core::Real dis = bbgrid().required_separation_distance( us_rad, ds_rad );
164  dis = dis*dis;
165  //TR << "griddis " << dis << " dist2 " << dist2 << std::endl;
166  if ( dist2 < dis ) {
167  //TR << "Colliding" << std::endl;
168  return true;
169  }
170  }
171  }
172  }
173  }
174  return false;
175 }
176 
177 std::list< Hit >
179  Matcher const & matcher
180 ) const
181 {
184  Size n_build_points = launch_points.size();
185 
186  std::list< Hit > all_hits;
187  utility::vector1< std::list< Hit > > hits( n_build_points );
188 
189  /// Generate conformations for the upstream and downstream partners for each of the
190  /// possible scaffold build points for this geometric constraint.
191  /// This loop will be parallelized. Everything down stream of this call is const,
192  /// in spite of the fact that the matcher is handed as a non-const reference.
193 #ifdef USE_OPENMP
194  #pragma omp parallel for schedule(dynamic,1)
195 #endif
196  for ( Size ii = 1; ii <= n_build_points; ++ii ) {
197  std::list< Hit > iihits = matcher.upstream_builder( geom_cst_id_ )->build( * launch_points[ ii ] );
198  hits[ ii ].splice( hits[ ii ].end(), iihits );
199  }
200 
201  for ( Size ii = 1; ii <= n_build_points; ++ii ) {
202  all_hits.splice( all_hits.end(), hits[ ii ] );
203  }
204 
205  return all_hits;
206 }
207 
208 
209 }
210 }
211 }