Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cst_util.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 cst_util.hh
11 /// @brief set of functions for adding constraints used in relax
12 /// @author James Thompson
13 
14 #include <core/pose/Pose.hh>
15 #include <core/id/AtomID.hh>
16 #include <core/types.hh>
17 
19 
20 #include <core/scoring/Energies.hh>
22 
23 // AUTO-REMOVED #include <core/scoring/constraints/BoundConstraint.hh>
29 
32 
37 
38 #include <basic/Tracer.hh>
39 
40 #include <utility/vector1.hh>
41 
42 
43 static basic::Tracer tr("protocols.relax.cst_util");
44 
45 namespace protocols {
46 namespace relax {
47 
49  core::pose::Pose & pose,
51  core::Real coord_sdev
52 ) {
53 
54  if ( aln.size() == 0 ) {
55  tr.Debug << "Empty alignment => no constraints!\n";
56  tr.Debug.flush();
57  }
58  // add coordinate constraints over aligned residues
59  using core::Size;
60  using core::Real;
61  using core::id::AtomID;
63  using namespace core::scoring::constraints;
64  if ( pose.residue(pose.total_residue()).name() != "VRT" ) {
67  pose.residue(1).residue_type_set().name_map( "VRT" )
68  ),
69  static_cast< Size > (pose.total_residue() / 2)
70  );
71  }
72  Size nres = pose.total_residue();
73 
75 
77  for ( Size idx = 1; idx <= nres - 1; ++idx ) {
78  if ( map[idx] != 0 ) {
79  coord_sdevs.push_back(coord_sdev);
80  }
81  }
82 
84  pose, coord_sdevs
85  );
86 
87  //for ( Size idx = 1; idx <= nres - 1; ++idx ) {
88  // if ( map[idx] != 0 ) {
89  // using namespace core::conformation;
90  // Residue const & rsd( pose.residue(idx) );
91  // for ( Size ii = 1; ii <= rsd.last_backbone_atom(); ++ii ) {
92  // using namespace core::scoring::constraints;
93  // pose.add_constraint(
94  // new CoordinateConstraint(
95  // AtomID(ii,idx), AtomID(1,nres), rsd.xyz(ii),
96  // new HarmonicFunc(0.0,coord_sdev)
97  // )
98  // );
99  // } // ii
100  // } // if residue is aligned
101  //} // nres
102 } // coordinate_constraint_selection
103 
106  core::pose::Pose & pose,
107  utility::vector1< core::Real > const & coord_sdevs
108 ) {
109  using core::Size;
110  using core::Real;
111  using core::id::AtomID;
112  using namespace core::conformation;
113  using namespace core::scoring::constraints;
114 
115  ConstraintSetOP cst_set( new ConstraintSet );
116  for ( Size idx = 1; idx <= pose.total_residue(); ++idx ) {
117  if ( coord_sdevs.size() >= idx ) {
118  Residue const & rsd( pose.residue(idx) );
119  core::Real const coord_sdev( coord_sdevs[idx] );
120  if ( coord_sdev > 0 ) {
121  for ( Size ii = 1; ii <= rsd.last_backbone_atom(); ++ii ) {
122  cst_set->add_constraint(
124  AtomID(ii,idx), AtomID(1,pose.total_residue()), rsd.xyz(ii),
125  new HarmonicFunc(0.0,coord_sdev)
126  )
127  );
128  }
129  } // coord_sdev > 0
130  } // have a coord_sdev for idx
131  } // idx
132 
133  return cst_set;
134 } // generate_bb_coordinate_constraints
135 
137  core::pose::Pose & pose
138 ) {
139  using core::Size;
140  // remove virtual residues
141  for ( Size idx = 1; idx <= pose.total_residue(); ++idx ) {
142  if ( pose.residue_type(idx).name() == "VRT" ) {
143  pose.conformation().delete_residue_slow(idx);
144  }
145  }
146 }
147 
150  core::pose::Pose & pose,
151  core::scoring::ScoreType scoretype
152 ) {
153  using core::Size;
154  using core::Real;
155  using utility::vector1;
156  using namespace core::scoring;
157  vector1< Real > scores;
158  for ( Size jj = 1; jj <= pose.total_residue(); ++jj ) {
159  EnergyMap rsd_energies( pose.energies().residue_total_energies(jj) );
160  Real const per_residue_score( rsd_energies[ scoretype ] );
161  scores.push_back( per_residue_score );
162  }
163  return scores;
164 }
165 
167  core::pose::Pose & pose
168 ) {
169  using core::Size;
171  if ( pose.residue(pose.total_residue()).name() != "VRT" ) {
174  pose.residue(1).residue_type_set().name_map( "VRT" )
175  ),
176  static_cast< Size > (pose.total_residue() / 2)
177  );
178  }
179 }
180 
182  core::pose::Pose & pose,
183  core::Real const upper_dist_cutoff
184 ) {
185  using core::Size;
186  using core::Real;
187  using core::id::AtomID;
188  using namespace core::scoring::constraints;
189 
190  Real const cst_sdev ( 2.0 );
191  //Real const cst_width( 2.0 );
192 
193  for ( Size ii = 1, end_ii = pose.total_residue(); ii <= end_ii; ++ii ) {
194  for ( Size jj = ii+1, end_jj = pose.total_residue(); jj <= end_jj; ++jj ) {
195  const core::conformation::Residue& resi = pose.residue(ii);
196  const core::conformation::Residue& resj = pose.residue(jj);
197 
198  for ( Size atm_ii = resi.first_sidechain_atom(); atm_ii <= resi.natoms(); ++atm_ii ) {
199  for ( Size atm_jj = resj.first_sidechain_atom(); atm_jj <= resj.natoms(); ++atm_jj ) {
200  // determine whether Euclidean distance is below threshold
201  Real const distance(
202  resi.xyz(atm_ii).distance( resj.xyz(atm_jj) ));
203  if ( distance <= upper_dist_cutoff ) {
204  pose.add_constraint(
205  new AtomPairConstraint(
206  AtomID(atm_ii,ii), AtomID(atm_jj,jj),
207  new HarmonicFunc( distance, cst_sdev )
208  ) );
209  tr << "adding restraint from "
210  << "AtomID(" << atm_ii << "," << ii
211  << "AtomID(" << atm_jj << "," << jj
212  << ") with distance = " << distance << std::endl;
213  }
214  } // atm_jj
215  } // atm_ii
216  } // res jj
217  } // res ii
218  tr.flush_all_channels();
219 } // derive_sc_sc_restraints
220 
221 } // relax
222 } // protocols