Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // Copyright in the Rosetta software belongs to the developers and their institutions.
7 // For more information, see www.rosettacommons.org.
8 
9 /// @file ./src/protocols/fldsgn/topology/util.cc
10 /// @brief utilities for fldsgn/topology
11 /// @author Nobuyasu Koga ( nobuyasu@u.washington.edu )
12 
13 // unit header
18 
19 // Project Headers
20 #include <core/scoring/Energies.hh>
22 #include <core/pose/Pose.hh>
23 #include <core/pose/util.hh>
26 #include <core/id/AtomID_Map.hh>
28 #include <core/scoring/sasa.hh>
29 
30 // utility headers
31 // AUTO-REMOVED #include <utility/string_util.hh>
32 #include <utility/exit.hh>
33 
34 // C++ headers
35 #include <cassert>
36 #include <iostream>
37 #include <sstream>
38 // AUTO-REMOVED #include <boost/lexical_cast.hpp>
39 #include <basic/Tracer.hh>
40 #include <map>
41 
42 #include <utility/vector1.hh>
43 
44 //Auto Headers
45 #include <core/pose/util.tmpl.hh>
46 static basic::Tracer TR( "protocols.topology.util" );
47 
48 using namespace core;
51 
52 namespace protocols {
53 namespace fldsgn {
54 namespace topology {
55 
56 /// @brief convert StrandParingSet of dssp to fldsgn::topology::StrandPairingSet
59  core::pose::Pose const & pose,
61  core::Size minimum_pair_length )
62 {
63  using core::Size;
64  typedef protocols::fldsgn::topology::StrandPairing StrandParing;
65  typedef protocols::fldsgn::topology::StrandPairingOP StrandParingOP;
66 
67  core::scoring::dssp::Dssp dssp( pose );
68 
69  std::map< String, StrandPairingOP > newpairs;
70 
72  spairset = dssp.strand_pairing_set();
73 
74  for( Size ispair=1; ispair<=spairset.size(); ispair++ ) {
75 
77  sp = spairset.strand_pairing( ispair );
78  Size begin1 ( sp.begin1() );
79  Size end1 ( sp.end1() );
80 
81  for( Size iaa=begin1; iaa<=end1; ++iaa ) {
82 
83  Size istrand ( ssinfo->strand_id( iaa ) );
84  if( istrand == 0 ) continue;
85  Size ist_begin ( ssinfo->strand( istrand )->begin() );
86 
87  Size jaa ( sp.get_pair( iaa ) );
88  if ( jaa == 0 ) continue;
89  Size pleats ( sp.get_pleating( iaa ) );
90  Size jstrand ( ssinfo->strand_id( jaa ) );
91  if( jstrand == 0 ) continue;
92 
93  Size jst_begin ( ssinfo->strand( jstrand )->begin() );
94  Size jst_end ( ssinfo->strand( jstrand )->end() );
95  Size jst_length ( jst_end - jst_begin );
96 
97  if( istrand == jstrand ) continue;
98 
99  if( istrand !=0 && jstrand !=0 && jaa !=0 ){
100 
101  char orient;
102  Real rgstr_shift;
103 
104  if( sp.antiparallel() ){
105  orient = 'A';
106  rgstr_shift = Real(iaa) - Real(ist_begin) - (Real(jst_length) - (Real(jaa) - Real(jst_begin)));
107  }else{
108  orient = 'P';
109  rgstr_shift = Real(iaa) - Real(ist_begin) - (Real(jaa) - Real(jst_begin));
110  }
111 
112  std::ostringstream spairname;
113  spairname << istrand << "-" << jstrand << "." << orient ;
114  std::map<String, StrandPairingOP>::iterator it( newpairs.find( spairname.str() ) );
115  if ( it == newpairs.end() ){
116  StrandPairingOP strand_pair = new StrandPairing( istrand, jstrand, iaa, jaa, pleats, rgstr_shift, orient );
117  newpairs.insert( std::map<String, StrandPairingOP>::value_type( spairname.str(), strand_pair ) );
118  }else{
119  (*it).second->elongate( iaa, jaa, pleats, pleats );
120  }
121 
122  } // istrand !=0 && jstrand !=0 && jaa !=0
123  } // iaa
124  } // ispair
125 
126  StrandPairingSet spairset_new;
127  std::map<String, StrandPairingOP>::iterator it( newpairs.begin() );
128  while( it != newpairs.end() ){
129 
130  // skip if pair length < minimum_pair_length
131  if( (*it).second->size1() < minimum_pair_length || (*it).second->size2() < minimum_pair_length ) {
132  ++it;
133  continue;
134  }
135 
136  //
137  TR.Debug << "Defined strand pair : " << *((*it).second)
138  << ", 1st_strand begin: " << (*it).second->begin1() << ", end: " << (*it).second->end1()
139  << ", 2nd_strand begin: " << (*it).second->begin2() << ", end: " << (*it).second->end2() << std::endl;
140  spairset_new.push_back( (*it).second );
141  ++it;
142  }
143 
144  spairset_new.finalize();
145 
146  return spairset_new;
147 
148 } // clac_strand_pairings
149 
150 
151 /// @brief calc delta sasa, when a molecule is splited to 2parts.
154  core::pose::Pose const & pose,
156  Real const pore_radius )
157 {
158 
159  /// calc surface areas of total residues
160 
161  // define atom_map for main-chain and CB
163  core::pose::initialize_atomid_map( atom_map, pose, false );
164  for ( Size ir = 1; ir <= pose.total_residue(); ++ir ) {
165  for ( Size j = 1; j<=5; ++j ) {
166  core::id::AtomID atom( j, ir );
167  atom_map.set( atom, true );
168  }
169  }
170 
171  utility::vector1< Real > rsd_sasa;
173  core::scoring::calc_per_atom_sasa( pose, atom_sasa, rsd_sasa, pore_radius, false, atom_map );
174 
175  /// calc surface areas of A, B regions which are dicretized by intervals.
176  /// A is non-assigned regions by intervals and B is assigned regions by intervals
177 
178  core::id::AtomID_Map< bool > atom_map_A;
179  core::id::AtomID_Map< bool > atom_map_B;
180  utility::vector1< Real > rsd_sasa_A;
181  utility::vector1< Real > rsd_sasa_B;
182  core::pose::initialize_atomid_map( atom_map_A, pose, false );
183  core::pose::initialize_atomid_map( atom_map_B, pose, false );
184 
185  utility::vector1< bool > position_A( pose.total_residue(), true );
186  for( Size ii=1; ii<=intervals.size(); ii++ ) {
187  for( Size jj=intervals[ ii ].left; jj<=intervals[ ii ].right; ++jj ) {
188  position_A[ jj ] = false;
189  }
190  for ( Size j=1; j<=5; ++j ) {
191  core::id::AtomID atom1( j, intervals[ ii ].left );
192  atom_map_A.set( atom1, true );
193 
194  core::id::AtomID atom2( j, intervals[ ii ].right );
195  atom_map_A.set( atom2, true );
196 
197  core::id::AtomID atom3( j, intervals[ ii ].left-1 );
198  atom_map_B.set( atom3, true );
199 
200  core::id::AtomID atom4( j, intervals[ ii ].right+1 );
201  atom_map_B.set( atom4, true );
202  }
203  }
204 
205  for( Size jj=1; jj<=pose.total_residue(); jj++ ) {
206  if( position_A[ jj ] ) {
207  for ( Size j=1; j<=5; ++j ) {
208  core::id::AtomID atom( j, jj );
209  atom_map_A.set( atom, true );
210  }
211  } else {
212  for ( Size j=1; j<=5; ++j ) {
213  core::id::AtomID atom( j, jj );
214  atom_map_B.set( atom, true );
215  }
216  }
217  }
218 
219  core::scoring::calc_per_atom_sasa( pose, atom_sasa, rsd_sasa_A, pore_radius, false, atom_map_A );
220  core::scoring::calc_per_atom_sasa( pose, atom_sasa, rsd_sasa_B, pore_radius, false, atom_map_B );
221 
222  Real tot_all( 0.0 ), tot_A( 0.0 ), tot_B( 0.0 );
223  for( Size ii=2; ii<=pose.total_residue()-1; ii++ ) {
224  tot_all += rsd_sasa[ ii ];
225  if( position_A[ ii ] ) {
226  tot_A += rsd_sasa_A[ ii ];
227  } else {
228  tot_B += rsd_sasa_B[ ii ];
229  }
230  }
231 
232 // for( Size ii=1; ii<=pose.total_residue(); ii++ ) {
233 // if( position_A[ ii ] ) {
234 // std::cout << ii << " " << rsd_sasa[ ii ] << " " << rsd_sasa_A[ ii ] << " " << rsd_sasa_B[ ii ] << "*" <<std::endl;
235 // } else {
236 // std::cout << ii << " " << rsd_sasa[ ii ] << " " << rsd_sasa_A[ ii ] << " " << rsd_sasa_B[ ii ] << std::endl;
237 // }
238 // }
239 // std::cout << tot_all << " " << tot_A << " " << tot_B << std::endl;
240 
241  return tot_A + tot_B - tot_all;
242 
243 } // calc_delta_sasa
244 
245 
246 /// @brief check kink of helix, return number of loosen hydrogen
249  core::pose::Pose const & pose,
250  core::Size const begin,
251  core::Size const end )
252 {
255 
256  core::pose::Pose copy_pose( pose );
257  HBondSet const & hbond_set( static_cast< HBondSet const & > ( copy_pose.energies().data().get( HBOND_SET )) );
258  //hbond_set.show( copy_pose );
259 
260  Size num_broken_hbond( 0 );
261  for( Size ii=begin; ii<=end; ++ii ) {
262  if( ! hbond_set.acc_bbg_in_bb_bb_hbond( ii ) ) {
263  TR << "hbonds of " << ii << " is broken. " << std::endl;
264  num_broken_hbond++;
265  }
266  }
267 
268  return num_broken_hbond;
269 }
270 
271 
272 /// @brief check kink of helix, return number of loosen hydrogen
275  core::pose::Pose const & pose,
276  core::Size const begin,
277  core::Size const end )
278 {
282 
283  core::pose::Pose copy_pose( pose );
284  HBondSet const & hbond_set( static_cast< HBondSet const & > ( copy_pose.energies().data().get( HBOND_SET )) );
285 
287  for ( core::Size i=1; i<=(core::Size)hbond_set.nhbonds(); ++i ) {
288  Size don_pos = hbond_set.hbond((int)i).don_res();
289  Size acc_pos = hbond_set.hbond((int)i).acc_res();
290  if( don_pos >= begin && don_pos <= end &&
291  acc_pos >= begin && acc_pos <= end ) {
292  hbonds.push_back( hbond_set.hbond((int)i) );
293  }
294  }
295 
296  return hbonds;
297 
298 }
299 
300 
301 // /// @brief
302 // utility::vector1< Size >
303 // split_into_ss_chunk(
304 // core::pose::Pose const & pose,
305 // protocols::fldsgn::topology::SS_Info2_COP const ssinfo )
306 //{
307 //
308 // /// types of chunk
309 // /// 1. sheet with short loops ( <=6 residues )
310 // /// 2. -loop-helix-loop-helix-
311 // /// 3. long loop ( >6 residues ) between strand & helix, strand & strand, helix & helix
312 //
313 //
314 // for() {
315 //
316 // }
317 //
318 //
319 // return;
320 //
321 //}
322 
323 
324 } // namespace topology
325 } // namespace fldsgn
326 } // namespace protocols