Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
utility.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/flxbb/utility.cc
11 /// @brief
12 /// @author Nobuyasu Koga (nobuyasua@uw.edu)
13 
14 #ifndef INCLUDED_protocols_flxbb_utility_HH
15 #define INCLUDED_protocols_flxbb_utility_HH
16 
17 // Unit headers
19 
20 // Package headers
22 
23 // Project headers
24 #include <basic/options/option.hh>
25 #include <basic/options/keys/flxbb.OptionKeys.gen.hh>
26 
27 #include <core/pose/Pose.hh>
28 // AUTO-REMOVED #include <core/scoring/ScoreFunction.hh>
29 #include <core/scoring/SS_Info.hh>
32 
41 // AUTO-REMOVED #include <protocols/fldsgn/topology/HSSTriplet.hh> // REQUIRED FOR WINDOWS
42 
43 /// Numeric headers
44 #include <numeric/xyzVector.hh>
45 
46 // Utility headers
47 #include <basic/Tracer.hh>
48 
49 #include <utility/vector1.hh>
50 
51 static basic::Tracer TR("protocols.flxbb.FlxbbDesign.utility");
52 
53 namespace protocols {
54 namespace flxbb {
55 
56 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
57 
58 typedef core::Size Size;
59 typedef core::Real Real;
64 
66 constraints_sheet( Pose const & pose, BluePrintOP const & blueprint, Real const coef, Real const condist )
67 {
79 
80  // returned data
81  ConstraintOPs csts;
82 
83  // set constraint func
84  Real lb( 0.0 );
85  Real ub( condist );
86  Real sd( 1.0 );
87  String tag( "constraints_in_beta_sheet" );
88  ScalarWeightedFuncOP cstfunc = new ScalarWeightedFunc( coef, new BoundFunc( lb, ub, sd, tag ) );
89 
90  //flo sep '12 add more accurate constraints by also constraining proper angles along paired residues
91  core::scoring::constraints::FuncOP cacb_dihedral_func = new core::scoring::constraints::OffsetPeriodicBoundFunc(-0.9,0.9, sqrt(1.0/42.0), "dihed_cacb", 6.28, 0.0 );
92  core::scoring::constraints::FuncOP bb_dihedral_func = new core::scoring::constraints::OffsetPeriodicBoundFunc(-0.52,0.52, sqrt(1.0/42.0), "dihed_bb", 3.14, 0.0 );
93  core::scoring::constraints::FuncOP bb_angle_func = new core::scoring::constraints::BoundFunc(1.22,1.92, sqrt(1.0/42.0), "angle_bb");
94 
95  // set constraints to csts
96  Size nres( pose.total_residue() );
97  //flo sep '12 in case we have ligands in the pose, don't count them
98  for( core::Size i = nres; i != 0; i-- ){
99  if( pose.residue_type(i).is_ligand() ) nres--;
100  else break;
101  }
102  runtime_assert( nres == blueprint->total_residue() );
103 
104  TR << "Blueprint file is used for determining constrained residue pairs. " << std::endl;
105  TR << "Constrains between CA-CA atoms in sheet are applied for the following residues. " << std::endl;
106  TR << "dist=" << condist << ", coef=" << coef << std::endl;
107 
108  SS_Info2_OP ssinfo = new SS_Info2( pose, blueprint->secstruct() );
109  StrandPairingSet spairset( blueprint->strand_pairings(), ssinfo );
110  StrandPairings spairs = spairset.strand_pairings();
111  for ( utility::vector1< StrandPairingOP >::const_iterator it=spairs.begin(); it!=spairs.end(); ++it ) {
112 
113  StrandPairing & spair=**it;
114  for( Size iaa=spair.begin1(); iaa<=spair.end1(); iaa++ ) {
115  Size jaa( spair.residue_pair( iaa ) );
116  TR << iaa << ' ' << jaa << std::endl;
117  core::id::AtomID atom1( pose.residue_type( iaa ).atom_index( "CA" ), iaa );
118  core::id::AtomID atom2( pose.residue_type( jaa ).atom_index( "CA" ), jaa );
119  csts.push_back( new AtomPairConstraint( atom1, atom2, cstfunc ) );
120  //flo sep '12: constrain dihedral, might be more accurate
121  if( basic::options::option[ basic::options::OptionKeys::flxbb::constraints_sheet_include_cacb_pseudotorsion ].value() ){
122  core::id::AtomID resi_n( pose.residue_type( iaa ).atom_index( "N" ), iaa );
123  core::id::AtomID resi_c( pose.residue_type( iaa ).atom_index( "C" ), iaa );
124  core::id::AtomID resi_o( pose.residue_type( iaa ).atom_index( "O" ), iaa );
125  core::id::AtomID resj_n( pose.residue_type( jaa ).atom_index( "N" ), jaa );
126  core::id::AtomID resj_c( pose.residue_type( jaa ).atom_index( "C" ), jaa );
127  core::id::AtomID resj_o( pose.residue_type( jaa ).atom_index( "O" ), jaa );
128  csts.push_back( new core::scoring::constraints::DihedralConstraint( resi_o, resi_n, resi_c, resj_c, bb_dihedral_func ) );
129  csts.push_back( new core::scoring::constraints::DihedralConstraint( resj_o, resj_n, resj_c, resi_c, bb_dihedral_func ) );
130  if( spair.orient() == 'P' ){
131  csts.push_back( new core::scoring::constraints::AngleConstraint( resi_n, resi_c, resj_c, bb_angle_func ) );
132  csts.push_back( new core::scoring::constraints::AngleConstraint( resj_n, resj_c, resi_c, bb_angle_func ) );
133  }
134  else if( spair.orient() == 'A' ){
135  csts.push_back( new core::scoring::constraints::AngleConstraint( resi_n, resi_c, resj_n, bb_angle_func ) );
136  csts.push_back( new core::scoring::constraints::AngleConstraint( resj_n, resj_c, resi_n, bb_angle_func ) );
137  }
138  if( (pose.residue_type( iaa ).name3() == "GLY") || (pose.residue_type( jaa ).name3() == "GLY" ) ) continue; // don't bother restraining cacb dihedral with gly
139  core::id::AtomID resi_cb( pose.residue_type( iaa ).atom_index( "CB" ), iaa );
140  core::id::AtomID resj_cb( pose.residue_type( jaa ).atom_index( "CB" ), jaa );
141  csts.push_back( new core::scoring::constraints::DihedralConstraint( resi_cb, atom1, atom2, resj_cb, cacb_dihedral_func ) );
142  }
143  // flo sep '12 over
144  } // for( Size i=1 )
145 
146  } // StrandPairingOP
147 
148  return csts;
149 } // constraint_sheet
150 
151 
152 
153 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
155 constraints_NtoC( Pose const & pose, Real const coef, Real const condist )
156 {
162 
163  // returned data
164  ConstraintOPs csts;
165 
166  // set constraint func
167  Real lb( 0.0 );
168  Real ub( condist );
169  Real sd( 1.0 );
170  String tag( "constraint_between_N_&_C_terminal_Calpha" );
171  ScalarWeightedFuncOP cstfunc = new ScalarWeightedFunc( coef, new BoundFunc( lb, ub, sd, tag ) );
172 
173  Size nres( pose.total_residue() );
174  core::id::AtomID atom1( pose.residue_type( 1 ).atom_index( "CA" ), 1 );
175  core::id::AtomID atom2( pose.residue_type( nres ).atom_index( "CA" ), nres );
176  csts.push_back( new AtomPairConstraint( atom1, atom2, cstfunc ) );
177 
178  TR << "Constraints between N- and C- terminal: 1-" << nres << ", dist=" << condist << ", coef=" << coef << std::endl;
179 
180  return csts;
181 } // constraints_NtoC
182 
183 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
185 constraints_sheet( Pose const & pose, Real const coef, Real const condist )
186 {
194 
195  // returned data
196  ConstraintOPs csts;
197 
198  // set constraint func
199  Real lb( 0.0 );
200  Real ub( condist );
201  Real sd( 1.0 );
202  std::string tag( "constraints_in_beta_sheet" );
203  ScalarWeightedFuncOP cstfunc = new ScalarWeightedFunc( coef, new BoundFunc( lb, ub, sd, tag ) );
204 
205  // set secondary structure
206  Dssp dssp( pose );
207 
208  // set strands
209  Size nres( pose.total_residue() );
210  bool flag( false );
211  Size istrand ( 0 );
212  Strands strands( nres );
213 
214  for ( Size i=1; i<=nres; ++i ) {
215  char ss( dssp.get_dssp_secstruct( i ) );
216  if( ss =='E' && flag == false ){
217  istrand ++;
218  strands.SS_strand_end( 1, istrand ) = i;
219  flag = true;
220  }
221  if( ss !='E' && flag == true ){
222  strands.SS_strand_end( 2, istrand ) = i - 1;
223  flag = false;
224  }
225  }
226  strands.total_strands = istrand;
227 
228  TR << "# Constrains between CA-CA atoms in sheet are applied for the following residues " << std::endl;
229  TR << "dist=" << condist << ", coef=" << coef << std::endl;
230 
231  Real condist2 = condist*condist;
232  for( int i=1; i<=strands.total_strands-1; ++i ) {
233  for( int j=i+1; j<=strands.total_strands; ++j ) {
234 
235  for( int iresid=strands.SS_strand_end( 1, i ); iresid<=strands.SS_strand_end( 2, i ); iresid++ ){
236  for( int jresid=strands.SS_strand_end( 1, j ); jresid<=strands.SS_strand_end( 2, j ); jresid++ ){
237 
238  core::conformation::Residue const & ires( pose.residue( iresid ) );
239  core::conformation::Residue const & jres( pose.residue( jresid ) );
240  Size ica = ires.atom_index( "CA" );
241  Size jca = jres.atom_index( "CA" );
242  Real const dsq( ires.xyz( ica ).distance_squared( jres.xyz( jca ) ));
243  if( dsq<=condist2 ){
244  TR << iresid << ' ' << jresid << std::endl;
245  core::id::AtomID atom1( pose.residue_type( iresid ).atom_index( "CA" ), iresid );
246  core::id::AtomID atom2( pose.residue_type( jresid ).atom_index( "CA" ), jresid );
247  csts.push_back( new AtomPairConstraint( atom1, atom2, cstfunc ) );
248  }
249 
250  }// jresid
251  } // iresid
252 
253  } // j
254  } // i
255 
256  return csts;
257 
258 } // constraint_sheet
259 
260 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
261 // Looks for unknown amino acids in the pose and returns their indices
263 find_ligands( Pose const & pose )
264 {
265  utility::vector1<Size> retval;
266  // look at each amino acid to see if it is of unknown type
267  for( Size i = 1; i <= pose.total_residue(); i++ ) {
268  if ( ! pose.residue( i ).is_protein() ) {
269  TR << "Residue " << i << " (type=" << pose.residue(i).name3() << ") is probably a ligand" << std::endl;
270  retval.push_back( i );
271  }
272  }
273  // WARNING: This doesn't rearrange residue numbers to put the ligands at the end
274  // However, this behavior IS important for many functions
275  return retval;
276 }
277 
278 } //namespace flxbb
279 } //namespace protocols
280 
281 #endif